if_bridge.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 _UAPI_LINUX_IF_BRIDGE_H
  14. #define _UAPI_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. struct bridge_vlan_info {
  121. __u16 flags;
  122. __u16 vid;
  123. };
  124. enum {
  125. IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC,
  126. IFLA_BRIDGE_VLAN_TUNNEL_ID,
  127. IFLA_BRIDGE_VLAN_TUNNEL_VID,
  128. IFLA_BRIDGE_VLAN_TUNNEL_FLAGS,
  129. __IFLA_BRIDGE_VLAN_TUNNEL_MAX,
  130. };
  131. #define IFLA_BRIDGE_VLAN_TUNNEL_MAX (__IFLA_BRIDGE_VLAN_TUNNEL_MAX - 1)
  132. struct bridge_vlan_xstats {
  133. __u64 rx_bytes;
  134. __u64 rx_packets;
  135. __u64 tx_bytes;
  136. __u64 tx_packets;
  137. __u16 vid;
  138. __u16 flags;
  139. __u32 pad2;
  140. };
  141. /* Bridge multicast database attributes
  142. * [MDBA_MDB] = {
  143. * [MDBA_MDB_ENTRY] = {
  144. * [MDBA_MDB_ENTRY_INFO] {
  145. * struct br_mdb_entry
  146. * [MDBA_MDB_EATTR attributes]
  147. * }
  148. * }
  149. * }
  150. * [MDBA_ROUTER] = {
  151. * [MDBA_ROUTER_PORT] = {
  152. * u32 ifindex
  153. * [MDBA_ROUTER_PATTR attributes]
  154. * }
  155. * }
  156. */
  157. enum {
  158. MDBA_UNSPEC,
  159. MDBA_MDB,
  160. MDBA_ROUTER,
  161. __MDBA_MAX,
  162. };
  163. #define MDBA_MAX (__MDBA_MAX - 1)
  164. enum {
  165. MDBA_MDB_UNSPEC,
  166. MDBA_MDB_ENTRY,
  167. __MDBA_MDB_MAX,
  168. };
  169. #define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
  170. enum {
  171. MDBA_MDB_ENTRY_UNSPEC,
  172. MDBA_MDB_ENTRY_INFO,
  173. __MDBA_MDB_ENTRY_MAX,
  174. };
  175. #define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
  176. /* per mdb entry additional attributes */
  177. enum {
  178. MDBA_MDB_EATTR_UNSPEC,
  179. MDBA_MDB_EATTR_TIMER,
  180. __MDBA_MDB_EATTR_MAX
  181. };
  182. #define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
  183. /* multicast router types */
  184. enum {
  185. MDB_RTR_TYPE_DISABLED,
  186. MDB_RTR_TYPE_TEMP_QUERY,
  187. MDB_RTR_TYPE_PERM,
  188. MDB_RTR_TYPE_TEMP
  189. };
  190. enum {
  191. MDBA_ROUTER_UNSPEC,
  192. MDBA_ROUTER_PORT,
  193. __MDBA_ROUTER_MAX,
  194. };
  195. #define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
  196. /* router port attributes */
  197. enum {
  198. MDBA_ROUTER_PATTR_UNSPEC,
  199. MDBA_ROUTER_PATTR_TIMER,
  200. MDBA_ROUTER_PATTR_TYPE,
  201. __MDBA_ROUTER_PATTR_MAX
  202. };
  203. #define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
  204. struct br_port_msg {
  205. __u8 family;
  206. __u32 ifindex;
  207. };
  208. struct br_mdb_entry {
  209. __u32 ifindex;
  210. #define MDB_TEMPORARY 0
  211. #define MDB_PERMANENT 1
  212. __u8 state;
  213. #define MDB_FLAGS_OFFLOAD (1 << 0)
  214. __u8 flags;
  215. __u16 vid;
  216. struct {
  217. union {
  218. __be32 ip4;
  219. struct in6_addr ip6;
  220. } u;
  221. __be16 proto;
  222. } addr;
  223. };
  224. enum {
  225. MDBA_SET_ENTRY_UNSPEC,
  226. MDBA_SET_ENTRY,
  227. __MDBA_SET_ENTRY_MAX,
  228. };
  229. #define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
  230. /* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
  231. enum {
  232. BRIDGE_XSTATS_UNSPEC,
  233. BRIDGE_XSTATS_VLAN,
  234. BRIDGE_XSTATS_MCAST,
  235. BRIDGE_XSTATS_PAD,
  236. __BRIDGE_XSTATS_MAX
  237. };
  238. #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
  239. enum {
  240. BR_MCAST_DIR_RX,
  241. BR_MCAST_DIR_TX,
  242. BR_MCAST_DIR_SIZE
  243. };
  244. /* IGMP/MLD statistics */
  245. struct br_mcast_stats {
  246. __u64 igmp_v1queries[BR_MCAST_DIR_SIZE];
  247. __u64 igmp_v2queries[BR_MCAST_DIR_SIZE];
  248. __u64 igmp_v3queries[BR_MCAST_DIR_SIZE];
  249. __u64 igmp_leaves[BR_MCAST_DIR_SIZE];
  250. __u64 igmp_v1reports[BR_MCAST_DIR_SIZE];
  251. __u64 igmp_v2reports[BR_MCAST_DIR_SIZE];
  252. __u64 igmp_v3reports[BR_MCAST_DIR_SIZE];
  253. __u64 igmp_parse_errors;
  254. __u64 mld_v1queries[BR_MCAST_DIR_SIZE];
  255. __u64 mld_v2queries[BR_MCAST_DIR_SIZE];
  256. __u64 mld_leaves[BR_MCAST_DIR_SIZE];
  257. __u64 mld_v1reports[BR_MCAST_DIR_SIZE];
  258. __u64 mld_v2reports[BR_MCAST_DIR_SIZE];
  259. __u64 mld_parse_errors;
  260. __u64 mcast_bytes[BR_MCAST_DIR_SIZE];
  261. __u64 mcast_packets[BR_MCAST_DIR_SIZE];
  262. };
  263. #endif /* _UAPI_LINUX_IF_BRIDGE_H */