if_bridge.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * Linux ethernet bridge
  4. *
  5. * Authors:
  6. * Lennert Buytenhek <buytenh@gnu.org>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #ifndef _LINUX_IF_BRIDGE_H
  14. #define _LINUX_IF_BRIDGE_H
  15. #include <linux/types.h>
  16. #include <linux/if_ether.h>
  17. #include <linux/in6.h>
  18. #define SYSFS_BRIDGE_ATTR "bridge"
  19. #define SYSFS_BRIDGE_FDB "brforward"
  20. #define SYSFS_BRIDGE_PORT_SUBDIR "brif"
  21. #define SYSFS_BRIDGE_PORT_ATTR "brport"
  22. #define SYSFS_BRIDGE_PORT_LINK "bridge"
  23. #define BRCTL_VERSION 1
  24. #define BRCTL_GET_VERSION 0
  25. #define BRCTL_GET_BRIDGES 1
  26. #define BRCTL_ADD_BRIDGE 2
  27. #define BRCTL_DEL_BRIDGE 3
  28. #define BRCTL_ADD_IF 4
  29. #define BRCTL_DEL_IF 5
  30. #define BRCTL_GET_BRIDGE_INFO 6
  31. #define BRCTL_GET_PORT_LIST 7
  32. #define BRCTL_SET_BRIDGE_FORWARD_DELAY 8
  33. #define BRCTL_SET_BRIDGE_HELLO_TIME 9
  34. #define BRCTL_SET_BRIDGE_MAX_AGE 10
  35. #define BRCTL_SET_AGEING_TIME 11
  36. #define BRCTL_SET_GC_INTERVAL 12
  37. #define BRCTL_GET_PORT_INFO 13
  38. #define BRCTL_SET_BRIDGE_STP_STATE 14
  39. #define BRCTL_SET_BRIDGE_PRIORITY 15
  40. #define BRCTL_SET_PORT_PRIORITY 16
  41. #define BRCTL_SET_PATH_COST 17
  42. #define BRCTL_GET_FDB_ENTRIES 18
  43. #define BR_STATE_DISABLED 0
  44. #define BR_STATE_LISTENING 1
  45. #define BR_STATE_LEARNING 2
  46. #define BR_STATE_FORWARDING 3
  47. #define BR_STATE_BLOCKING 4
  48. struct __bridge_info {
  49. __u64 designated_root;
  50. __u64 bridge_id;
  51. __u32 root_path_cost;
  52. __u32 max_age;
  53. __u32 hello_time;
  54. __u32 forward_delay;
  55. __u32 bridge_max_age;
  56. __u32 bridge_hello_time;
  57. __u32 bridge_forward_delay;
  58. __u8 topology_change;
  59. __u8 topology_change_detected;
  60. __u8 root_port;
  61. __u8 stp_enabled;
  62. __u32 ageing_time;
  63. __u32 gc_interval;
  64. __u32 hello_timer_value;
  65. __u32 tcn_timer_value;
  66. __u32 topology_change_timer_value;
  67. __u32 gc_timer_value;
  68. };
  69. struct __port_info {
  70. __u64 designated_root;
  71. __u64 designated_bridge;
  72. __u16 port_id;
  73. __u16 designated_port;
  74. __u32 path_cost;
  75. __u32 designated_cost;
  76. __u8 state;
  77. __u8 top_change_ack;
  78. __u8 config_pending;
  79. __u8 unused0;
  80. __u32 message_age_timer_value;
  81. __u32 forward_delay_timer_value;
  82. __u32 hold_timer_value;
  83. };
  84. struct __fdb_entry {
  85. __u8 mac_addr[ETH_ALEN];
  86. __u8 port_no;
  87. __u8 is_local;
  88. __u32 ageing_timer_value;
  89. __u8 port_hi;
  90. __u8 pad0;
  91. __u16 unused;
  92. };
  93. /* Bridge Flags */
  94. #define BRIDGE_FLAGS_MASTER 1 /* Bridge command to/from master */
  95. #define BRIDGE_FLAGS_SELF 2 /* Bridge command to/from lowerdev */
  96. #define BRIDGE_MODE_VEB 0 /* Default loopback mode */
  97. #define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */
  98. #define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */
  99. /* Bridge management nested attributes
  100. * [IFLA_AF_SPEC] = {
  101. * [IFLA_BRIDGE_FLAGS]
  102. * [IFLA_BRIDGE_MODE]
  103. * [IFLA_BRIDGE_VLAN_INFO]
  104. * }
  105. */
  106. enum {
  107. IFLA_BRIDGE_FLAGS,
  108. IFLA_BRIDGE_MODE,
  109. IFLA_BRIDGE_VLAN_INFO,
  110. IFLA_BRIDGE_VLAN_TUNNEL_INFO,
  111. __IFLA_BRIDGE_MAX,
  112. };
  113. #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
  114. #define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */
  115. #define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */
  116. #define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */
  117. #define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */
  118. #define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */
  119. #define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */
  120. #define BRIDGE_VLAN_INFO_ONLY_OPTS (1<<6) /* Skip create/delete/flags */
  121. struct bridge_vlan_info {
  122. __u16 flags;
  123. __u16 vid;
  124. };
  125. enum {
  126. IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC,
  127. IFLA_BRIDGE_VLAN_TUNNEL_ID,
  128. IFLA_BRIDGE_VLAN_TUNNEL_VID,
  129. IFLA_BRIDGE_VLAN_TUNNEL_FLAGS,
  130. __IFLA_BRIDGE_VLAN_TUNNEL_MAX,
  131. };
  132. #define IFLA_BRIDGE_VLAN_TUNNEL_MAX (__IFLA_BRIDGE_VLAN_TUNNEL_MAX - 1)
  133. struct bridge_vlan_xstats {
  134. __u64 rx_bytes;
  135. __u64 rx_packets;
  136. __u64 tx_bytes;
  137. __u64 tx_packets;
  138. __u16 vid;
  139. __u16 flags;
  140. __u32 pad2;
  141. };
  142. struct bridge_stp_xstats {
  143. __u64 transition_blk;
  144. __u64 transition_fwd;
  145. __u64 rx_bpdu;
  146. __u64 tx_bpdu;
  147. __u64 rx_tcn;
  148. __u64 tx_tcn;
  149. };
  150. /* Bridge vlan RTM header */
  151. struct br_vlan_msg {
  152. __u8 family;
  153. __u8 reserved1;
  154. __u16 reserved2;
  155. __u32 ifindex;
  156. };
  157. enum {
  158. BRIDGE_VLANDB_DUMP_UNSPEC,
  159. BRIDGE_VLANDB_DUMP_FLAGS,
  160. __BRIDGE_VLANDB_DUMP_MAX,
  161. };
  162. #define BRIDGE_VLANDB_DUMP_MAX (__BRIDGE_VLANDB_DUMP_MAX - 1)
  163. /* flags used in BRIDGE_VLANDB_DUMP_FLAGS attribute to affect dumps */
  164. #define BRIDGE_VLANDB_DUMPF_STATS (1 << 0) /* Include stats in the dump */
  165. /* Bridge vlan RTM attributes
  166. * [BRIDGE_VLANDB_ENTRY] = {
  167. * [BRIDGE_VLANDB_ENTRY_INFO]
  168. * ...
  169. * }
  170. */
  171. enum {
  172. BRIDGE_VLANDB_UNSPEC,
  173. BRIDGE_VLANDB_ENTRY,
  174. __BRIDGE_VLANDB_MAX,
  175. };
  176. #define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1)
  177. enum {
  178. BRIDGE_VLANDB_ENTRY_UNSPEC,
  179. BRIDGE_VLANDB_ENTRY_INFO,
  180. BRIDGE_VLANDB_ENTRY_RANGE,
  181. BRIDGE_VLANDB_ENTRY_STATE,
  182. BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,
  183. BRIDGE_VLANDB_ENTRY_STATS,
  184. __BRIDGE_VLANDB_ENTRY_MAX,
  185. };
  186. #define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
  187. /* [BRIDGE_VLANDB_ENTRY] = {
  188. * [BRIDGE_VLANDB_ENTRY_TUNNEL_INFO] = {
  189. * [BRIDGE_VLANDB_TINFO_ID]
  190. * ...
  191. * }
  192. * }
  193. */
  194. enum {
  195. BRIDGE_VLANDB_TINFO_UNSPEC,
  196. BRIDGE_VLANDB_TINFO_ID,
  197. BRIDGE_VLANDB_TINFO_CMD,
  198. __BRIDGE_VLANDB_TINFO_MAX,
  199. };
  200. #define BRIDGE_VLANDB_TINFO_MAX (__BRIDGE_VLANDB_TINFO_MAX - 1)
  201. /* [BRIDGE_VLANDB_ENTRY] = {
  202. * [BRIDGE_VLANDB_ENTRY_STATS] = {
  203. * [BRIDGE_VLANDB_STATS_RX_BYTES]
  204. * ...
  205. * }
  206. * ...
  207. * }
  208. */
  209. enum {
  210. BRIDGE_VLANDB_STATS_UNSPEC,
  211. BRIDGE_VLANDB_STATS_RX_BYTES,
  212. BRIDGE_VLANDB_STATS_RX_PACKETS,
  213. BRIDGE_VLANDB_STATS_TX_BYTES,
  214. BRIDGE_VLANDB_STATS_TX_PACKETS,
  215. BRIDGE_VLANDB_STATS_PAD,
  216. __BRIDGE_VLANDB_STATS_MAX,
  217. };
  218. #define BRIDGE_VLANDB_STATS_MAX (__BRIDGE_VLANDB_STATS_MAX - 1)
  219. /* Bridge multicast database attributes
  220. * [MDBA_MDB] = {
  221. * [MDBA_MDB_ENTRY] = {
  222. * [MDBA_MDB_ENTRY_INFO] {
  223. * struct br_mdb_entry
  224. * [MDBA_MDB_EATTR attributes]
  225. * }
  226. * }
  227. * }
  228. * [MDBA_ROUTER] = {
  229. * [MDBA_ROUTER_PORT] = {
  230. * u32 ifindex
  231. * [MDBA_ROUTER_PATTR attributes]
  232. * }
  233. * }
  234. */
  235. enum {
  236. MDBA_UNSPEC,
  237. MDBA_MDB,
  238. MDBA_ROUTER,
  239. __MDBA_MAX,
  240. };
  241. #define MDBA_MAX (__MDBA_MAX - 1)
  242. enum {
  243. MDBA_MDB_UNSPEC,
  244. MDBA_MDB_ENTRY,
  245. __MDBA_MDB_MAX,
  246. };
  247. #define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
  248. enum {
  249. MDBA_MDB_ENTRY_UNSPEC,
  250. MDBA_MDB_ENTRY_INFO,
  251. __MDBA_MDB_ENTRY_MAX,
  252. };
  253. #define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
  254. /* per mdb entry additional attributes */
  255. enum {
  256. MDBA_MDB_EATTR_UNSPEC,
  257. MDBA_MDB_EATTR_TIMER,
  258. __MDBA_MDB_EATTR_MAX
  259. };
  260. #define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
  261. /* multicast router types */
  262. enum {
  263. MDB_RTR_TYPE_DISABLED,
  264. MDB_RTR_TYPE_TEMP_QUERY,
  265. MDB_RTR_TYPE_PERM,
  266. MDB_RTR_TYPE_TEMP
  267. };
  268. enum {
  269. MDBA_ROUTER_UNSPEC,
  270. MDBA_ROUTER_PORT,
  271. __MDBA_ROUTER_MAX,
  272. };
  273. #define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
  274. /* router port attributes */
  275. enum {
  276. MDBA_ROUTER_PATTR_UNSPEC,
  277. MDBA_ROUTER_PATTR_TIMER,
  278. MDBA_ROUTER_PATTR_TYPE,
  279. __MDBA_ROUTER_PATTR_MAX
  280. };
  281. #define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
  282. struct br_port_msg {
  283. __u8 family;
  284. __u32 ifindex;
  285. };
  286. struct br_mdb_entry {
  287. __u32 ifindex;
  288. #define MDB_TEMPORARY 0
  289. #define MDB_PERMANENT 1
  290. __u8 state;
  291. #define MDB_FLAGS_OFFLOAD (1 << 0)
  292. #define MDB_FLAGS_FAST_LEAVE (1 << 1)
  293. __u8 flags;
  294. __u16 vid;
  295. struct {
  296. union {
  297. __be32 ip4;
  298. struct in6_addr ip6;
  299. } u;
  300. __be16 proto;
  301. } addr;
  302. };
  303. enum {
  304. MDBA_SET_ENTRY_UNSPEC,
  305. MDBA_SET_ENTRY,
  306. __MDBA_SET_ENTRY_MAX,
  307. };
  308. #define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
  309. /* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
  310. enum {
  311. BRIDGE_XSTATS_UNSPEC,
  312. BRIDGE_XSTATS_VLAN,
  313. BRIDGE_XSTATS_MCAST,
  314. BRIDGE_XSTATS_PAD,
  315. BRIDGE_XSTATS_STP,
  316. __BRIDGE_XSTATS_MAX
  317. };
  318. #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
  319. enum {
  320. BR_MCAST_DIR_RX,
  321. BR_MCAST_DIR_TX,
  322. BR_MCAST_DIR_SIZE
  323. };
  324. /* IGMP/MLD statistics */
  325. struct br_mcast_stats {
  326. __u64 igmp_v1queries[BR_MCAST_DIR_SIZE];
  327. __u64 igmp_v2queries[BR_MCAST_DIR_SIZE];
  328. __u64 igmp_v3queries[BR_MCAST_DIR_SIZE];
  329. __u64 igmp_leaves[BR_MCAST_DIR_SIZE];
  330. __u64 igmp_v1reports[BR_MCAST_DIR_SIZE];
  331. __u64 igmp_v2reports[BR_MCAST_DIR_SIZE];
  332. __u64 igmp_v3reports[BR_MCAST_DIR_SIZE];
  333. __u64 igmp_parse_errors;
  334. __u64 mld_v1queries[BR_MCAST_DIR_SIZE];
  335. __u64 mld_v2queries[BR_MCAST_DIR_SIZE];
  336. __u64 mld_leaves[BR_MCAST_DIR_SIZE];
  337. __u64 mld_v1reports[BR_MCAST_DIR_SIZE];
  338. __u64 mld_v2reports[BR_MCAST_DIR_SIZE];
  339. __u64 mld_parse_errors;
  340. __u64 mcast_bytes[BR_MCAST_DIR_SIZE];
  341. __u64 mcast_packets[BR_MCAST_DIR_SIZE];
  342. };
  343. /* bridge boolean options
  344. * BR_BOOLOPT_NO_LL_LEARN - disable learning from link-local packets
  345. *
  346. * IMPORTANT: if adding a new option do not forget to handle
  347. * it in br_boolopt_toggle/get and bridge sysfs
  348. */
  349. enum br_boolopt_id {
  350. BR_BOOLOPT_NO_LL_LEARN,
  351. BR_BOOLOPT_MAX
  352. };
  353. /* struct br_boolopt_multi - change multiple bridge boolean options
  354. *
  355. * @optval: new option values (bit per option)
  356. * @optmask: options to change (bit per option)
  357. */
  358. struct br_boolopt_multi {
  359. __u32 optval;
  360. __u32 optmask;
  361. };
  362. #endif /* _LINUX_IF_BRIDGE_H */