blob: 4da04f77d9eea3d8359e93ae14953c1e75a6db31 [file] [log] [blame]
Greg Kroah-Hartmane2be04c2017-11-01 15:09:13 +01001/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
David Howells607ca462012-10-13 10:46:48 +01002/*
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
14#ifndef _UAPI_LINUX_IF_BRIDGE_H
15#define _UAPI_LINUX_IF_BRIDGE_H
16
17#include <linux/types.h>
Joe Perchese2169752013-08-01 16:17:47 -070018#include <linux/if_ether.h>
Gregory Fong66f1c442014-11-04 11:21:21 -080019#include <linux/in6.h>
David Howells607ca462012-10-13 10:46:48 +010020
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"
26
27#define BRCTL_VERSION 1
28
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
48
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
54
55struct __bridge_info {
56 __u64 designated_root;
57 __u64 bridge_id;
58 __u32 root_path_cost;
59 __u32 max_age;
60 __u32 hello_time;
61 __u32 forward_delay;
62 __u32 bridge_max_age;
63 __u32 bridge_hello_time;
64 __u32 bridge_forward_delay;
65 __u8 topology_change;
66 __u8 topology_change_detected;
67 __u8 root_port;
68 __u8 stp_enabled;
69 __u32 ageing_time;
70 __u32 gc_interval;
71 __u32 hello_timer_value;
72 __u32 tcn_timer_value;
73 __u32 topology_change_timer_value;
74 __u32 gc_timer_value;
75};
76
77struct __port_info {
78 __u64 designated_root;
79 __u64 designated_bridge;
80 __u16 port_id;
81 __u16 designated_port;
82 __u32 path_cost;
83 __u32 designated_cost;
84 __u8 state;
85 __u8 top_change_ack;
86 __u8 config_pending;
87 __u8 unused0;
88 __u32 message_age_timer_value;
89 __u32 forward_delay_timer_value;
90 __u32 hold_timer_value;
91};
92
93struct __fdb_entry {
Joe Perchese2169752013-08-01 16:17:47 -070094 __u8 mac_addr[ETH_ALEN];
David Howells607ca462012-10-13 10:46:48 +010095 __u8 port_no;
96 __u8 is_local;
97 __u32 ageing_timer_value;
98 __u8 port_hi;
99 __u8 pad0;
100 __u16 unused;
101};
102
John Fastabend2469ffd2012-10-24 08:13:03 +0000103/* Bridge Flags */
104#define BRIDGE_FLAGS_MASTER 1 /* Bridge command to/from master */
105#define BRIDGE_FLAGS_SELF 2 /* Bridge command to/from lowerdev */
David Howells607ca462012-10-13 10:46:48 +0100106
John Fastabend2469ffd2012-10-24 08:13:03 +0000107#define BRIDGE_MODE_VEB 0 /* Default loopback mode */
108#define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */
Roopa Prabhufc0bdbb2014-12-08 14:04:19 -0800109#define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */
John Fastabend2469ffd2012-10-24 08:13:03 +0000110
111/* Bridge management nested attributes
112 * [IFLA_AF_SPEC] = {
113 * [IFLA_BRIDGE_FLAGS]
114 * [IFLA_BRIDGE_MODE]
Vlad Yasevich407af322013-02-13 12:00:12 +0000115 * [IFLA_BRIDGE_VLAN_INFO]
John Fastabend2469ffd2012-10-24 08:13:03 +0000116 * }
117 */
118enum {
119 IFLA_BRIDGE_FLAGS,
120 IFLA_BRIDGE_MODE,
Vlad Yasevich407af322013-02-13 12:00:12 +0000121 IFLA_BRIDGE_VLAN_INFO,
Roopa Prabhub3c7ef02017-01-31 22:59:53 -0800122 IFLA_BRIDGE_VLAN_TUNNEL_INFO,
John Fastabend2469ffd2012-10-24 08:13:03 +0000123 __IFLA_BRIDGE_MAX,
124};
125#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
Cong Wangee07c6e2012-12-07 00:04:48 +0000126
Vlad Yasevich407af322013-02-13 12:00:12 +0000127#define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */
Vlad Yasevich552406c2013-02-13 12:00:15 +0000128#define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */
Vlad Yasevich35e03f32013-02-13 12:00:20 +0000129#define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */
Roopa Prabhubdced7e2015-01-10 07:31:12 -0800130#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 */
Nikolay Aleksandrov2594e9062015-09-25 19:00:11 +0200132#define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */
Vlad Yasevich407af322013-02-13 12:00:12 +0000133
134struct bridge_vlan_info {
Cong Wang9f89ec82013-02-14 13:32:31 +0800135 __u16 flags;
136 __u16 vid;
Vlad Yasevich407af322013-02-13 12:00:12 +0000137};
138
Roopa Prabhub3c7ef02017-01-31 22:59:53 -0800139enum {
140 IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC,
141 IFLA_BRIDGE_VLAN_TUNNEL_ID,
142 IFLA_BRIDGE_VLAN_TUNNEL_VID,
143 IFLA_BRIDGE_VLAN_TUNNEL_FLAGS,
144 __IFLA_BRIDGE_VLAN_TUNNEL_MAX,
145};
146
147#define IFLA_BRIDGE_VLAN_TUNNEL_MAX (__IFLA_BRIDGE_VLAN_TUNNEL_MAX - 1)
148
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200149struct bridge_vlan_xstats {
150 __u64 rx_bytes;
151 __u64 rx_packets;
152 __u64 tx_bytes;
153 __u64 tx_packets;
154 __u16 vid;
Nikolay Aleksandrov61ba1a22016-08-17 12:53:10 +0200155 __u16 flags;
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200156 __u32 pad2;
157};
158
Vivien Didelotde179962019-12-11 20:07:10 -0500159struct bridge_stp_xstats {
160 __u64 transition_blk;
161 __u64 transition_fwd;
162 __u64 rx_bpdu;
163 __u64 tx_bpdu;
164 __u64 rx_tcn;
165 __u64 tx_tcn;
166};
167
Nikolay Aleksandrov8dcea182020-01-14 19:56:09 +0200168/* Bridge vlan RTM header */
169struct br_vlan_msg {
170 __u8 family;
171 __u8 reserved1;
172 __u16 reserved2;
173 __u32 ifindex;
174};
175
176/* Bridge vlan RTM attributes
177 * [BRIDGE_VLANDB_ENTRY] = {
178 * [BRIDGE_VLANDB_ENTRY_INFO]
179 * ...
180 * }
181 */
182enum {
183 BRIDGE_VLANDB_UNSPEC,
184 BRIDGE_VLANDB_ENTRY,
185 __BRIDGE_VLANDB_MAX,
186};
187#define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1)
188
189enum {
190 BRIDGE_VLANDB_ENTRY_UNSPEC,
191 BRIDGE_VLANDB_ENTRY_INFO,
192 __BRIDGE_VLANDB_ENTRY_MAX,
193};
194#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
195
Cong Wangee07c6e2012-12-07 00:04:48 +0000196/* Bridge multicast database attributes
197 * [MDBA_MDB] = {
198 * [MDBA_MDB_ENTRY] = {
Nikolay Aleksandrov21257152016-02-16 12:46:54 +0100199 * [MDBA_MDB_ENTRY_INFO] {
200 * struct br_mdb_entry
201 * [MDBA_MDB_EATTR attributes]
202 * }
Cong Wangee07c6e2012-12-07 00:04:48 +0000203 * }
204 * }
205 * [MDBA_ROUTER] = {
Nikolay Aleksandrov59f78f92016-02-26 21:20:04 +0100206 * [MDBA_ROUTER_PORT] = {
207 * u32 ifindex
208 * [MDBA_ROUTER_PATTR attributes]
209 * }
Cong Wangee07c6e2012-12-07 00:04:48 +0000210 * }
211 */
212enum {
213 MDBA_UNSPEC,
214 MDBA_MDB,
215 MDBA_ROUTER,
216 __MDBA_MAX,
217};
218#define MDBA_MAX (__MDBA_MAX - 1)
219
220enum {
221 MDBA_MDB_UNSPEC,
222 MDBA_MDB_ENTRY,
223 __MDBA_MDB_MAX,
224};
225#define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
226
227enum {
228 MDBA_MDB_ENTRY_UNSPEC,
229 MDBA_MDB_ENTRY_INFO,
230 __MDBA_MDB_ENTRY_MAX,
231};
232#define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
233
Nikolay Aleksandrov21257152016-02-16 12:46:54 +0100234/* per mdb entry additional attributes */
235enum {
236 MDBA_MDB_EATTR_UNSPEC,
237 MDBA_MDB_EATTR_TIMER,
238 __MDBA_MDB_EATTR_MAX
239};
240#define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
241
Nikolay Aleksandrov7f0aec72016-02-26 21:20:01 +0100242/* multicast router types */
243enum {
244 MDB_RTR_TYPE_DISABLED,
245 MDB_RTR_TYPE_TEMP_QUERY,
246 MDB_RTR_TYPE_PERM,
Nikolay Aleksandrova55d8242016-02-26 21:20:03 +0100247 MDB_RTR_TYPE_TEMP
Nikolay Aleksandrov7f0aec72016-02-26 21:20:01 +0100248};
249
Cong Wangee07c6e2012-12-07 00:04:48 +0000250enum {
251 MDBA_ROUTER_UNSPEC,
252 MDBA_ROUTER_PORT,
253 __MDBA_ROUTER_MAX,
254};
255#define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
256
Nikolay Aleksandrov59f78f92016-02-26 21:20:04 +0100257/* router port attributes */
258enum {
259 MDBA_ROUTER_PATTR_UNSPEC,
260 MDBA_ROUTER_PATTR_TIMER,
261 MDBA_ROUTER_PATTR_TYPE,
262 __MDBA_ROUTER_PATTR_MAX
263};
264#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
265
Cong Wangee07c6e2012-12-07 00:04:48 +0000266struct br_port_msg {
Cong Wangcfd56752012-12-11 22:23:08 +0000267 __u8 family;
Cong Wangee07c6e2012-12-07 00:04:48 +0000268 __u32 ifindex;
269};
270
271struct br_mdb_entry {
272 __u32 ifindex;
Amerigo Wangccb1c312012-12-14 22:09:51 +0000273#define MDB_TEMPORARY 0
274#define MDB_PERMANENT 1
275 __u8 state;
Elad Raz157ede62016-02-03 09:57:04 +0100276#define MDB_FLAGS_OFFLOAD (1 << 0)
Nikolay Aleksandrov3247b272019-07-30 15:20:41 +0300277#define MDB_FLAGS_FAST_LEAVE (1 << 1)
Elad Raz157ede62016-02-03 09:57:04 +0100278 __u8 flags;
Nikolay Aleksandrov74fe61f2015-07-10 08:02:08 -0700279 __u16 vid;
Cong Wangee07c6e2012-12-07 00:04:48 +0000280 struct {
281 union {
282 __be32 ip4;
283 struct in6_addr ip6;
284 } u;
285 __be16 proto;
286 } addr;
287};
288
Cong Wangcfd56752012-12-11 22:23:08 +0000289enum {
290 MDBA_SET_ENTRY_UNSPEC,
291 MDBA_SET_ENTRY,
292 __MDBA_SET_ENTRY_MAX,
293};
294#define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
295
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200296/* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
297enum {
298 BRIDGE_XSTATS_UNSPEC,
299 BRIDGE_XSTATS_VLAN,
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200300 BRIDGE_XSTATS_MCAST,
301 BRIDGE_XSTATS_PAD,
Vivien Didelotde179962019-12-11 20:07:10 -0500302 BRIDGE_XSTATS_STP,
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200303 __BRIDGE_XSTATS_MAX
304};
305#define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
306
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200307enum {
308 BR_MCAST_DIR_RX,
309 BR_MCAST_DIR_TX,
310 BR_MCAST_DIR_SIZE
311};
312
313/* IGMP/MLD statistics */
314struct br_mcast_stats {
Nikolay Aleksandrova65056e2016-07-06 12:12:21 -0700315 __u64 igmp_v1queries[BR_MCAST_DIR_SIZE];
316 __u64 igmp_v2queries[BR_MCAST_DIR_SIZE];
317 __u64 igmp_v3queries[BR_MCAST_DIR_SIZE];
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200318 __u64 igmp_leaves[BR_MCAST_DIR_SIZE];
319 __u64 igmp_v1reports[BR_MCAST_DIR_SIZE];
320 __u64 igmp_v2reports[BR_MCAST_DIR_SIZE];
321 __u64 igmp_v3reports[BR_MCAST_DIR_SIZE];
322 __u64 igmp_parse_errors;
323
Nikolay Aleksandrova65056e2016-07-06 12:12:21 -0700324 __u64 mld_v1queries[BR_MCAST_DIR_SIZE];
325 __u64 mld_v2queries[BR_MCAST_DIR_SIZE];
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200326 __u64 mld_leaves[BR_MCAST_DIR_SIZE];
327 __u64 mld_v1reports[BR_MCAST_DIR_SIZE];
328 __u64 mld_v2reports[BR_MCAST_DIR_SIZE];
329 __u64 mld_parse_errors;
330
331 __u64 mcast_bytes[BR_MCAST_DIR_SIZE];
332 __u64 mcast_packets[BR_MCAST_DIR_SIZE];
333};
Nikolay Aleksandrova428afe2018-11-24 04:34:20 +0200334
335/* bridge boolean options
Nikolay Aleksandrov70e42722018-11-24 04:34:21 +0200336 * BR_BOOLOPT_NO_LL_LEARN - disable learning from link-local packets
337 *
Nikolay Aleksandrova428afe2018-11-24 04:34:20 +0200338 * IMPORTANT: if adding a new option do not forget to handle
339 * it in br_boolopt_toggle/get and bridge sysfs
340 */
341enum br_boolopt_id {
Nikolay Aleksandrov70e42722018-11-24 04:34:21 +0200342 BR_BOOLOPT_NO_LL_LEARN,
Nikolay Aleksandrova428afe2018-11-24 04:34:20 +0200343 BR_BOOLOPT_MAX
344};
345
346/* struct br_boolopt_multi - change multiple bridge boolean options
347 *
348 * @optval: new option values (bit per option)
349 * @optmask: options to change (bit per option)
350 */
351struct br_boolopt_multi {
352 __u32 optval;
353 __u32 optmask;
354};
David Howells607ca462012-10-13 10:46:48 +0100355#endif /* _UAPI_LINUX_IF_BRIDGE_H */