108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger/* 208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * Linux ethernet bridge 308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * 408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * Authors: 508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * Lennert Buytenhek <buytenh@gnu.org> 608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * 708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * This program is free software; you can redistribute it and/or 808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * modify it under the terms of the GNU General Public License 908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * as published by the Free Software Foundation; either version 1008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * 2 of the License, or (at your option) any later version. 1108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger */ 1208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 1308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#ifndef _LINUX_IF_BRIDGE_H 1408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define _LINUX_IF_BRIDGE_H 1508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 1608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#include <linux/types.h> 176b2ed935ae4e6a0bafa5a314cc177470529cd629Stephen Hemminger#include <linux/if_ether.h> 18e9c4b7c38f4f6c01dc23588ec337ab091d52b51dStephen Hemminger#include <linux/in6.h> 1908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 2008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define SYSFS_BRIDGE_ATTR "bridge" 2108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define SYSFS_BRIDGE_FDB "brforward" 2208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define SYSFS_BRIDGE_PORT_SUBDIR "brif" 2308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define SYSFS_BRIDGE_PORT_ATTR "brport" 2408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define SYSFS_BRIDGE_PORT_LINK "bridge" 2508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 2608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_VERSION 1 2708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 2808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_GET_VERSION 0 2908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_GET_BRIDGES 1 3008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_ADD_BRIDGE 2 3108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_DEL_BRIDGE 3 3208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_ADD_IF 4 3308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_DEL_IF 5 3408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_GET_BRIDGE_INFO 6 3508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_GET_PORT_LIST 7 3608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_BRIDGE_FORWARD_DELAY 8 3708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_BRIDGE_HELLO_TIME 9 3808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_BRIDGE_MAX_AGE 10 3908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_AGEING_TIME 11 4008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_GC_INTERVAL 12 4108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_GET_PORT_INFO 13 4208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_BRIDGE_STP_STATE 14 4308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_BRIDGE_PRIORITY 15 4408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_PORT_PRIORITY 16 4508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_SET_PATH_COST 17 4608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRCTL_GET_FDB_ENTRIES 18 4708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 4808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BR_STATE_DISABLED 0 4908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BR_STATE_LISTENING 1 5008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BR_STATE_LEARNING 2 5108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BR_STATE_FORWARDING 3 5208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BR_STATE_BLOCKING 4 5308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 5408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerstruct __bridge_info { 5508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u64 designated_root; 5608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u64 bridge_id; 5708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 root_path_cost; 5808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 max_age; 5908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 hello_time; 6008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 forward_delay; 6108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 bridge_max_age; 6208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 bridge_hello_time; 6308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 bridge_forward_delay; 6408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 topology_change; 6508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 topology_change_detected; 6608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 root_port; 6708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 stp_enabled; 6808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 ageing_time; 6908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 gc_interval; 7008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 hello_timer_value; 7108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 tcn_timer_value; 7208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 topology_change_timer_value; 7308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 gc_timer_value; 7408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 7508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 7608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerstruct __port_info { 7708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u64 designated_root; 7808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u64 designated_bridge; 7908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u16 port_id; 8008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u16 designated_port; 8108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 path_cost; 8208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 designated_cost; 8308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 state; 8408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 top_change_ack; 8508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 config_pending; 8608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 unused0; 8708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 message_age_timer_value; 8808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 forward_delay_timer_value; 8908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 hold_timer_value; 9008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 9108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 9208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerstruct __fdb_entry { 936b2ed935ae4e6a0bafa5a314cc177470529cd629Stephen Hemminger __u8 mac_addr[ETH_ALEN]; 9408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 port_no; 9508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 is_local; 9608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 ageing_timer_value; 9708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 port_hi; 9808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u8 pad0; 9908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u16 unused; 10008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 10108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 10208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger/* Bridge Flags */ 10308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRIDGE_FLAGS_MASTER 1 /* Bridge command to/from master */ 10408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRIDGE_FLAGS_SELF 2 /* Bridge command to/from lowerdev */ 10508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 10608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRIDGE_MODE_VEB 0 /* Default loopback mode */ 10708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */ 108093f18fd7a880c1cd76d8ce78ca6cacd9bc7d054Stephen Hemminger#define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */ 10908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 11008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger/* Bridge management nested attributes 11108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [IFLA_AF_SPEC] = { 11208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [IFLA_BRIDGE_FLAGS] 11308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [IFLA_BRIDGE_MODE] 114609106d3af62256752f97cadca620ec84b6784daStephen Hemminger * [IFLA_BRIDGE_VLAN_INFO] 11508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * } 11608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger */ 11708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerenum { 11808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger IFLA_BRIDGE_FLAGS, 11908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger IFLA_BRIDGE_MODE, 120609106d3af62256752f97cadca620ec84b6784daStephen Hemminger IFLA_BRIDGE_VLAN_INFO, 12108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __IFLA_BRIDGE_MAX, 12208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 12308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1) 12408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 125609106d3af62256752f97cadca620ec84b6784daStephen Hemminger#define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */ 126609106d3af62256752f97cadca620ec84b6784daStephen Hemminger#define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */ 127609106d3af62256752f97cadca620ec84b6784daStephen Hemminger#define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */ 128f233410d207c2985dd8a34c18a8c140200134d31Stephen Hemminger#define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */ 129f233410d207c2985dd8a34c18a8c140200134d31Stephen Hemminger#define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */ 13023e905096c45b5be4020a3adb5c8d0a789d30cc4Stephen Hemminger#define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */ 131609106d3af62256752f97cadca620ec84b6784daStephen Hemminger 132609106d3af62256752f97cadca620ec84b6784daStephen Hemmingerstruct bridge_vlan_info { 133609106d3af62256752f97cadca620ec84b6784daStephen Hemminger __u16 flags; 134609106d3af62256752f97cadca620ec84b6784daStephen Hemminger __u16 vid; 135609106d3af62256752f97cadca620ec84b6784daStephen Hemminger}; 136609106d3af62256752f97cadca620ec84b6784daStephen Hemminger 13708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger/* Bridge multicast database attributes 13808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [MDBA_MDB] = { 13908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [MDBA_MDB_ENTRY] = { 14008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [MDBA_MDB_ENTRY_INFO] 14108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * } 14208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * } 14308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [MDBA_ROUTER] = { 14408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * [MDBA_ROUTER_PORT] 14508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger * } 14608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger */ 14708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerenum { 14808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_UNSPEC, 14908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_MDB, 15008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_ROUTER, 15108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __MDBA_MAX, 15208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 15308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define MDBA_MAX (__MDBA_MAX - 1) 15408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 15508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerenum { 15608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_MDB_UNSPEC, 15708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_MDB_ENTRY, 15808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __MDBA_MDB_MAX, 15908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 16008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1) 16108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 16208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerenum { 16308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_MDB_ENTRY_UNSPEC, 16408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_MDB_ENTRY_INFO, 16508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __MDBA_MDB_ENTRY_MAX, 16608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 16708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1) 16808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 16908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerenum { 17008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_ROUTER_UNSPEC, 17108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger MDBA_ROUTER_PORT, 17208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __MDBA_ROUTER_MAX, 17308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 17408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1) 17508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 17608342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerstruct br_port_msg { 1779dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wang __u8 family; 17808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 ifindex; 17908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 18008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 18108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemmingerstruct br_mdb_entry { 18208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __u32 ifindex; 18375e003c23ed347592d650616f4ba971448ff44c4Stephen Hemminger#define MDB_TEMPORARY 0 18475e003c23ed347592d650616f4ba971448ff44c4Stephen Hemminger#define MDB_PERMANENT 1 18575e003c23ed347592d650616f4ba971448ff44c4Stephen Hemminger __u8 state; 186a3563ede2d519047dcb00fec3f12ad234ccdff45Stephen Hemminger __u16 vid; 18708342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger struct { 18808342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger union { 18908342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __be32 ip4; 19008342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger struct in6_addr ip6; 19108342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger } u; 19208342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger __be16 proto; 19308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger } addr; 19408342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger}; 19508342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger 1969dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wangenum { 1979dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wang MDBA_SET_ENTRY_UNSPEC, 1989dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wang MDBA_SET_ENTRY, 1999dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wang __MDBA_SET_ENTRY_MAX, 2009dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wang}; 2019dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wang#define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1) 2029dca676721215f82327c9f4b6630a6a37bbd60a4Cong Wang 20308342500eeb9f2cefa49ded2b4a6183becdaf419Stephen Hemminger#endif /* _LINUX_IF_BRIDGE_H */ 204