1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
3 * Linux ethernet bridge
6 * Lennert Buytenhek <buytenh@gnu.org>
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.
14 #ifndef _LINUX_IF_BRIDGE_H
15 #define _LINUX_IF_BRIDGE_H
17 #include <linux/types.h>
18 #include <linux/if_ether.h>
19 #include <linux/in6.h>
21 #define SYSFS_BRIDGE_ATTR "bridge"
22 #define SYSFS_BRIDGE_FDB "brforward"
23 #define SYSFS_BRIDGE_PORT_SUBDIR "brif"
24 #define SYSFS_BRIDGE_PORT_ATTR "brport"
25 #define SYSFS_BRIDGE_PORT_LINK "bridge"
27 #define BRCTL_VERSION 1
29 #define BRCTL_GET_VERSION 0
30 #define BRCTL_GET_BRIDGES 1
31 #define BRCTL_ADD_BRIDGE 2
32 #define BRCTL_DEL_BRIDGE 3
33 #define BRCTL_ADD_IF 4
34 #define BRCTL_DEL_IF 5
35 #define BRCTL_GET_BRIDGE_INFO 6
36 #define BRCTL_GET_PORT_LIST 7
37 #define BRCTL_SET_BRIDGE_FORWARD_DELAY 8
38 #define BRCTL_SET_BRIDGE_HELLO_TIME 9
39 #define BRCTL_SET_BRIDGE_MAX_AGE 10
40 #define BRCTL_SET_AGEING_TIME 11
41 #define BRCTL_SET_GC_INTERVAL 12
42 #define BRCTL_GET_PORT_INFO 13
43 #define BRCTL_SET_BRIDGE_STP_STATE 14
44 #define BRCTL_SET_BRIDGE_PRIORITY 15
45 #define BRCTL_SET_PORT_PRIORITY 16
46 #define BRCTL_SET_PATH_COST 17
47 #define BRCTL_GET_FDB_ENTRIES 18
49 #define BR_STATE_DISABLED 0
50 #define BR_STATE_LISTENING 1
51 #define BR_STATE_LEARNING 2
52 #define BR_STATE_FORWARDING 3
53 #define BR_STATE_BLOCKING 4
55 struct __bridge_info
{
56 __u64 designated_root
;
63 __u32 bridge_hello_time
;
64 __u32 bridge_forward_delay
;
66 __u8 topology_change_detected
;
71 __u32 hello_timer_value
;
72 __u32 tcn_timer_value
;
73 __u32 topology_change_timer_value
;
78 __u64 designated_root
;
79 __u64 designated_bridge
;
81 __u16 designated_port
;
83 __u32 designated_cost
;
88 __u32 message_age_timer_value
;
89 __u32 forward_delay_timer_value
;
90 __u32 hold_timer_value
;
94 __u8 mac_addr
[ETH_ALEN
];
97 __u32 ageing_timer_value
;
104 #define BRIDGE_FLAGS_MASTER 1 /* Bridge command to/from master */
105 #define BRIDGE_FLAGS_SELF 2 /* Bridge command to/from lowerdev */
107 #define BRIDGE_MODE_VEB 0 /* Default loopback mode */
108 #define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */
109 #define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */
111 /* Bridge management nested attributes
113 * [IFLA_BRIDGE_FLAGS]
115 * [IFLA_BRIDGE_VLAN_INFO]
121 IFLA_BRIDGE_VLAN_INFO
,
122 IFLA_BRIDGE_VLAN_TUNNEL_INFO
,
125 #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
127 #define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */
128 #define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */
129 #define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */
130 #define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */
131 #define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */
132 #define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */
133 #define BRIDGE_VLAN_INFO_ONLY_OPTS (1<<6) /* Skip create/delete/flags */
134 #define BRIDGE_VLAN_INFO_REMOVE_TUN (1<<7) /* Remove tunnel mapping */
136 struct bridge_vlan_info
{
142 IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC
,
143 IFLA_BRIDGE_VLAN_TUNNEL_ID
,
144 IFLA_BRIDGE_VLAN_TUNNEL_VID
,
145 IFLA_BRIDGE_VLAN_TUNNEL_FLAGS
,
146 __IFLA_BRIDGE_VLAN_TUNNEL_MAX
,
149 #define IFLA_BRIDGE_VLAN_TUNNEL_MAX (__IFLA_BRIDGE_VLAN_TUNNEL_MAX - 1)
151 struct bridge_vlan_xstats
{
161 struct bridge_stp_xstats
{
162 __u64 transition_blk
;
163 __u64 transition_fwd
;
170 /* Bridge vlan RTM header */
179 BRIDGE_VLANDB_DUMP_UNSPEC
,
180 BRIDGE_VLANDB_DUMP_FLAGS
,
181 __BRIDGE_VLANDB_DUMP_MAX
,
183 #define BRIDGE_VLANDB_DUMP_MAX (__BRIDGE_VLANDB_DUMP_MAX - 1)
185 /* flags used in BRIDGE_VLANDB_DUMP_FLAGS attribute to affect dumps */
186 #define BRIDGE_VLANDB_DUMPF_STATS (1 << 0) /* Include stats in the dump */
188 /* Bridge vlan RTM attributes
189 * [BRIDGE_VLANDB_ENTRY] = {
190 * [BRIDGE_VLANDB_ENTRY_INFO]
195 BRIDGE_VLANDB_UNSPEC
,
199 #define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1)
202 BRIDGE_VLANDB_ENTRY_UNSPEC
,
203 BRIDGE_VLANDB_ENTRY_INFO
,
204 BRIDGE_VLANDB_ENTRY_RANGE
,
205 BRIDGE_VLANDB_ENTRY_STATE
,
206 BRIDGE_VLANDB_ENTRY_TUNNEL_ID
,
207 BRIDGE_VLANDB_ENTRY_STATS
,
208 __BRIDGE_VLANDB_ENTRY_MAX
,
210 #define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
212 /* [BRIDGE_VLANDB_ENTRY] = {
213 * [BRIDGE_VLANDB_ENTRY_STATS] = {
214 * [BRIDGE_VLANDB_STATS_RX_BYTES]
221 BRIDGE_VLANDB_STATS_UNSPEC
,
222 BRIDGE_VLANDB_STATS_RX_BYTES
,
223 BRIDGE_VLANDB_STATS_RX_PACKETS
,
224 BRIDGE_VLANDB_STATS_TX_BYTES
,
225 BRIDGE_VLANDB_STATS_TX_PACKETS
,
226 BRIDGE_VLANDB_STATS_PAD
,
227 __BRIDGE_VLANDB_STATS_MAX
,
229 #define BRIDGE_VLANDB_STATS_MAX (__BRIDGE_VLANDB_STATS_MAX - 1)
231 /* Bridge multicast database attributes
233 * [MDBA_MDB_ENTRY] = {
234 * [MDBA_MDB_ENTRY_INFO] {
235 * struct br_mdb_entry
236 * [MDBA_MDB_EATTR attributes]
241 * [MDBA_ROUTER_PORT] = {
243 * [MDBA_ROUTER_PATTR attributes]
253 #define MDBA_MAX (__MDBA_MAX - 1)
260 #define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
263 MDBA_MDB_ENTRY_UNSPEC
,
265 __MDBA_MDB_ENTRY_MAX
,
267 #define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
269 /* per mdb entry additional attributes */
271 MDBA_MDB_EATTR_UNSPEC
,
272 MDBA_MDB_EATTR_TIMER
,
275 #define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
277 /* multicast router types */
279 MDB_RTR_TYPE_DISABLED
,
280 MDB_RTR_TYPE_TEMP_QUERY
,
290 #define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
292 /* router port attributes */
294 MDBA_ROUTER_PATTR_UNSPEC
,
295 MDBA_ROUTER_PATTR_TIMER
,
296 MDBA_ROUTER_PATTR_TYPE
,
297 __MDBA_ROUTER_PATTR_MAX
299 #define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
306 struct br_mdb_entry
{
308 #define MDB_TEMPORARY 0
309 #define MDB_PERMANENT 1
311 #define MDB_FLAGS_OFFLOAD (1 << 0)
312 #define MDB_FLAGS_FAST_LEAVE (1 << 1)
325 MDBA_SET_ENTRY_UNSPEC
,
327 __MDBA_SET_ENTRY_MAX
,
329 #define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
331 /* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
333 BRIDGE_XSTATS_UNSPEC
,
340 #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
348 /* IGMP/MLD statistics */
349 struct br_mcast_stats
{
350 __u64 igmp_v1queries
[BR_MCAST_DIR_SIZE
];
351 __u64 igmp_v2queries
[BR_MCAST_DIR_SIZE
];
352 __u64 igmp_v3queries
[BR_MCAST_DIR_SIZE
];
353 __u64 igmp_leaves
[BR_MCAST_DIR_SIZE
];
354 __u64 igmp_v1reports
[BR_MCAST_DIR_SIZE
];
355 __u64 igmp_v2reports
[BR_MCAST_DIR_SIZE
];
356 __u64 igmp_v3reports
[BR_MCAST_DIR_SIZE
];
357 __u64 igmp_parse_errors
;
359 __u64 mld_v1queries
[BR_MCAST_DIR_SIZE
];
360 __u64 mld_v2queries
[BR_MCAST_DIR_SIZE
];
361 __u64 mld_leaves
[BR_MCAST_DIR_SIZE
];
362 __u64 mld_v1reports
[BR_MCAST_DIR_SIZE
];
363 __u64 mld_v2reports
[BR_MCAST_DIR_SIZE
];
364 __u64 mld_parse_errors
;
366 __u64 mcast_bytes
[BR_MCAST_DIR_SIZE
];
367 __u64 mcast_packets
[BR_MCAST_DIR_SIZE
];
370 /* bridge boolean options
371 * BR_BOOLOPT_NO_LL_LEARN - disable learning from link-local packets
373 * IMPORTANT: if adding a new option do not forget to handle
374 * it in br_boolopt_toggle/get and bridge sysfs
377 BR_BOOLOPT_NO_LL_LEARN
,
381 /* struct br_boolopt_multi - change multiple bridge boolean options
383 * @optval: new option values (bit per option)
384 * @optmask: options to change (bit per option)
386 struct br_boolopt_multi
{
390 #endif /* _LINUX_IF_BRIDGE_H */