blob: a9e6244ce43803339584f3f6e43757005363e621 [file] [log] [blame]
David Howells607ca462012-10-13 10:46:48 +01001/*
2 * Linux ethernet bridge
3 *
4 * Authors:
5 * Lennert Buytenhek <buytenh@gnu.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef _UAPI_LINUX_IF_BRIDGE_H
14#define _UAPI_LINUX_IF_BRIDGE_H
15
16#include <linux/types.h>
Joe Perchese2169752013-08-01 16:17:47 -070017#include <linux/if_ether.h>
Gregory Fong66f1c442014-11-04 11:21:21 -080018#include <linux/in6.h>
David Howells607ca462012-10-13 10:46:48 +010019
20#define SYSFS_BRIDGE_ATTR "bridge"
21#define SYSFS_BRIDGE_FDB "brforward"
22#define SYSFS_BRIDGE_PORT_SUBDIR "brif"
23#define SYSFS_BRIDGE_PORT_ATTR "brport"
24#define SYSFS_BRIDGE_PORT_LINK "bridge"
25
26#define BRCTL_VERSION 1
27
28#define BRCTL_GET_VERSION 0
29#define BRCTL_GET_BRIDGES 1
30#define BRCTL_ADD_BRIDGE 2
31#define BRCTL_DEL_BRIDGE 3
32#define BRCTL_ADD_IF 4
33#define BRCTL_DEL_IF 5
34#define BRCTL_GET_BRIDGE_INFO 6
35#define BRCTL_GET_PORT_LIST 7
36#define BRCTL_SET_BRIDGE_FORWARD_DELAY 8
37#define BRCTL_SET_BRIDGE_HELLO_TIME 9
38#define BRCTL_SET_BRIDGE_MAX_AGE 10
39#define BRCTL_SET_AGEING_TIME 11
40#define BRCTL_SET_GC_INTERVAL 12
41#define BRCTL_GET_PORT_INFO 13
42#define BRCTL_SET_BRIDGE_STP_STATE 14
43#define BRCTL_SET_BRIDGE_PRIORITY 15
44#define BRCTL_SET_PORT_PRIORITY 16
45#define BRCTL_SET_PATH_COST 17
46#define BRCTL_GET_FDB_ENTRIES 18
47
48#define BR_STATE_DISABLED 0
49#define BR_STATE_LISTENING 1
50#define BR_STATE_LEARNING 2
51#define BR_STATE_FORWARDING 3
52#define BR_STATE_BLOCKING 4
53
54struct __bridge_info {
55 __u64 designated_root;
56 __u64 bridge_id;
57 __u32 root_path_cost;
58 __u32 max_age;
59 __u32 hello_time;
60 __u32 forward_delay;
61 __u32 bridge_max_age;
62 __u32 bridge_hello_time;
63 __u32 bridge_forward_delay;
64 __u8 topology_change;
65 __u8 topology_change_detected;
66 __u8 root_port;
67 __u8 stp_enabled;
68 __u32 ageing_time;
69 __u32 gc_interval;
70 __u32 hello_timer_value;
71 __u32 tcn_timer_value;
72 __u32 topology_change_timer_value;
73 __u32 gc_timer_value;
74};
75
76struct __port_info {
77 __u64 designated_root;
78 __u64 designated_bridge;
79 __u16 port_id;
80 __u16 designated_port;
81 __u32 path_cost;
82 __u32 designated_cost;
83 __u8 state;
84 __u8 top_change_ack;
85 __u8 config_pending;
86 __u8 unused0;
87 __u32 message_age_timer_value;
88 __u32 forward_delay_timer_value;
89 __u32 hold_timer_value;
90};
91
92struct __fdb_entry {
Joe Perchese2169752013-08-01 16:17:47 -070093 __u8 mac_addr[ETH_ALEN];
David Howells607ca462012-10-13 10:46:48 +010094 __u8 port_no;
95 __u8 is_local;
96 __u32 ageing_timer_value;
97 __u8 port_hi;
98 __u8 pad0;
99 __u16 unused;
100};
101
John Fastabend2469ffd2012-10-24 08:13:03 +0000102/* Bridge Flags */
103#define BRIDGE_FLAGS_MASTER 1 /* Bridge command to/from master */
104#define BRIDGE_FLAGS_SELF 2 /* Bridge command to/from lowerdev */
David Howells607ca462012-10-13 10:46:48 +0100105
John Fastabend2469ffd2012-10-24 08:13:03 +0000106#define BRIDGE_MODE_VEB 0 /* Default loopback mode */
107#define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */
Roopa Prabhufc0bdbb2014-12-08 14:04:19 -0800108#define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */
John Fastabend2469ffd2012-10-24 08:13:03 +0000109
110/* Bridge management nested attributes
111 * [IFLA_AF_SPEC] = {
112 * [IFLA_BRIDGE_FLAGS]
113 * [IFLA_BRIDGE_MODE]
Vlad Yasevich407af322013-02-13 12:00:12 +0000114 * [IFLA_BRIDGE_VLAN_INFO]
John Fastabend2469ffd2012-10-24 08:13:03 +0000115 * }
116 */
117enum {
118 IFLA_BRIDGE_FLAGS,
119 IFLA_BRIDGE_MODE,
Vlad Yasevich407af322013-02-13 12:00:12 +0000120 IFLA_BRIDGE_VLAN_INFO,
Roopa Prabhub3c7ef02017-01-31 22:59:53 -0800121 IFLA_BRIDGE_VLAN_TUNNEL_INFO,
John Fastabend2469ffd2012-10-24 08:13:03 +0000122 __IFLA_BRIDGE_MAX,
123};
124#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
Cong Wangee07c6e2012-12-07 00:04:48 +0000125
Vlad Yasevich407af322013-02-13 12:00:12 +0000126#define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */
Vlad Yasevich552406c2013-02-13 12:00:15 +0000127#define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */
Vlad Yasevich35e03f32013-02-13 12:00:20 +0000128#define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */
Roopa Prabhubdced7e2015-01-10 07:31:12 -0800129#define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */
130#define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */
Nikolay Aleksandrov2594e902015-09-25 19:00:11 +0200131#define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */
Vlad Yasevich407af322013-02-13 12:00:12 +0000132
133struct bridge_vlan_info {
Cong Wang9f89ec82013-02-14 13:32:31 +0800134 __u16 flags;
135 __u16 vid;
Vlad Yasevich407af322013-02-13 12:00:12 +0000136};
137
Roopa Prabhub3c7ef02017-01-31 22:59:53 -0800138enum {
139 IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC,
140 IFLA_BRIDGE_VLAN_TUNNEL_ID,
141 IFLA_BRIDGE_VLAN_TUNNEL_VID,
142 IFLA_BRIDGE_VLAN_TUNNEL_FLAGS,
143 __IFLA_BRIDGE_VLAN_TUNNEL_MAX,
144};
145
146#define IFLA_BRIDGE_VLAN_TUNNEL_MAX (__IFLA_BRIDGE_VLAN_TUNNEL_MAX - 1)
147
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200148struct bridge_vlan_xstats {
149 __u64 rx_bytes;
150 __u64 rx_packets;
151 __u64 tx_bytes;
152 __u64 tx_packets;
153 __u16 vid;
Nikolay Aleksandrov61ba1a22016-08-17 12:53:10 +0200154 __u16 flags;
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200155 __u32 pad2;
156};
157
Cong Wangee07c6e2012-12-07 00:04:48 +0000158/* Bridge multicast database attributes
159 * [MDBA_MDB] = {
160 * [MDBA_MDB_ENTRY] = {
Nikolay Aleksandrov21257152016-02-16 12:46:54 +0100161 * [MDBA_MDB_ENTRY_INFO] {
162 * struct br_mdb_entry
163 * [MDBA_MDB_EATTR attributes]
164 * }
Cong Wangee07c6e2012-12-07 00:04:48 +0000165 * }
166 * }
167 * [MDBA_ROUTER] = {
Nikolay Aleksandrov59f78f92016-02-26 21:20:04 +0100168 * [MDBA_ROUTER_PORT] = {
169 * u32 ifindex
170 * [MDBA_ROUTER_PATTR attributes]
171 * }
Cong Wangee07c6e2012-12-07 00:04:48 +0000172 * }
173 */
174enum {
175 MDBA_UNSPEC,
176 MDBA_MDB,
177 MDBA_ROUTER,
178 __MDBA_MAX,
179};
180#define MDBA_MAX (__MDBA_MAX - 1)
181
182enum {
183 MDBA_MDB_UNSPEC,
184 MDBA_MDB_ENTRY,
185 __MDBA_MDB_MAX,
186};
187#define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
188
189enum {
190 MDBA_MDB_ENTRY_UNSPEC,
191 MDBA_MDB_ENTRY_INFO,
192 __MDBA_MDB_ENTRY_MAX,
193};
194#define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
195
Nikolay Aleksandrov21257152016-02-16 12:46:54 +0100196/* per mdb entry additional attributes */
197enum {
198 MDBA_MDB_EATTR_UNSPEC,
199 MDBA_MDB_EATTR_TIMER,
200 __MDBA_MDB_EATTR_MAX
201};
202#define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
203
Nikolay Aleksandrov7f0aec72016-02-26 21:20:01 +0100204/* multicast router types */
205enum {
206 MDB_RTR_TYPE_DISABLED,
207 MDB_RTR_TYPE_TEMP_QUERY,
208 MDB_RTR_TYPE_PERM,
Nikolay Aleksandrova55d8242016-02-26 21:20:03 +0100209 MDB_RTR_TYPE_TEMP
Nikolay Aleksandrov7f0aec72016-02-26 21:20:01 +0100210};
211
Cong Wangee07c6e2012-12-07 00:04:48 +0000212enum {
213 MDBA_ROUTER_UNSPEC,
214 MDBA_ROUTER_PORT,
215 __MDBA_ROUTER_MAX,
216};
217#define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
218
Nikolay Aleksandrov59f78f92016-02-26 21:20:04 +0100219/* router port attributes */
220enum {
221 MDBA_ROUTER_PATTR_UNSPEC,
222 MDBA_ROUTER_PATTR_TIMER,
223 MDBA_ROUTER_PATTR_TYPE,
224 __MDBA_ROUTER_PATTR_MAX
225};
226#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
227
Cong Wangee07c6e2012-12-07 00:04:48 +0000228struct br_port_msg {
Cong Wangcfd56752012-12-11 22:23:08 +0000229 __u8 family;
Cong Wangee07c6e2012-12-07 00:04:48 +0000230 __u32 ifindex;
231};
232
233struct br_mdb_entry {
234 __u32 ifindex;
Amerigo Wangccb1c312012-12-14 22:09:51 +0000235#define MDB_TEMPORARY 0
236#define MDB_PERMANENT 1
237 __u8 state;
Elad Raz157ede62016-02-03 09:57:04 +0100238#define MDB_FLAGS_OFFLOAD (1 << 0)
239 __u8 flags;
Nikolay Aleksandrov74fe61f2015-07-10 08:02:08 -0700240 __u16 vid;
Cong Wangee07c6e2012-12-07 00:04:48 +0000241 struct {
242 union {
243 __be32 ip4;
244 struct in6_addr ip6;
245 } u;
246 __be16 proto;
247 } addr;
248};
249
Cong Wangcfd56752012-12-11 22:23:08 +0000250enum {
251 MDBA_SET_ENTRY_UNSPEC,
252 MDBA_SET_ENTRY,
253 __MDBA_SET_ENTRY_MAX,
254};
255#define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
256
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200257/* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
258enum {
259 BRIDGE_XSTATS_UNSPEC,
260 BRIDGE_XSTATS_VLAN,
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200261 BRIDGE_XSTATS_MCAST,
262 BRIDGE_XSTATS_PAD,
Nikolay Aleksandrova60c0902016-04-30 10:25:29 +0200263 __BRIDGE_XSTATS_MAX
264};
265#define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
266
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200267enum {
268 BR_MCAST_DIR_RX,
269 BR_MCAST_DIR_TX,
270 BR_MCAST_DIR_SIZE
271};
272
273/* IGMP/MLD statistics */
274struct br_mcast_stats {
Nikolay Aleksandrova65056e2016-07-06 12:12:21 -0700275 __u64 igmp_v1queries[BR_MCAST_DIR_SIZE];
276 __u64 igmp_v2queries[BR_MCAST_DIR_SIZE];
277 __u64 igmp_v3queries[BR_MCAST_DIR_SIZE];
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200278 __u64 igmp_leaves[BR_MCAST_DIR_SIZE];
279 __u64 igmp_v1reports[BR_MCAST_DIR_SIZE];
280 __u64 igmp_v2reports[BR_MCAST_DIR_SIZE];
281 __u64 igmp_v3reports[BR_MCAST_DIR_SIZE];
282 __u64 igmp_parse_errors;
283
Nikolay Aleksandrova65056e2016-07-06 12:12:21 -0700284 __u64 mld_v1queries[BR_MCAST_DIR_SIZE];
285 __u64 mld_v2queries[BR_MCAST_DIR_SIZE];
Nikolay Aleksandrov1080ab92016-06-28 16:57:06 +0200286 __u64 mld_leaves[BR_MCAST_DIR_SIZE];
287 __u64 mld_v1reports[BR_MCAST_DIR_SIZE];
288 __u64 mld_v2reports[BR_MCAST_DIR_SIZE];
289 __u64 mld_parse_errors;
290
291 __u64 mcast_bytes[BR_MCAST_DIR_SIZE];
292 __u64 mcast_packets[BR_MCAST_DIR_SIZE];
293};
David Howells607ca462012-10-13 10:46:48 +0100294#endif /* _UAPI_LINUX_IF_BRIDGE_H */