David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 1 | /* |
| 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 Perches | e216975 | 2013-08-01 16:17:47 -0700 | [diff] [blame] | 17 | #include <linux/if_ether.h> |
Gregory Fong | 66f1c44 | 2014-11-04 11:21:21 -0800 | [diff] [blame] | 18 | #include <linux/in6.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 19 | |
| 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 | |
| 54 | struct __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 | |
| 76 | struct __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 | |
| 92 | struct __fdb_entry { |
Joe Perches | e216975 | 2013-08-01 16:17:47 -0700 | [diff] [blame] | 93 | __u8 mac_addr[ETH_ALEN]; |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 94 | __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 Fastabend | 2469ffd | 2012-10-24 08:13:03 +0000 | [diff] [blame] | 102 | /* 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 Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 105 | |
John Fastabend | 2469ffd | 2012-10-24 08:13:03 +0000 | [diff] [blame] | 106 | #define BRIDGE_MODE_VEB 0 /* Default loopback mode */ |
| 107 | #define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */ |
Roopa Prabhu | fc0bdbb | 2014-12-08 14:04:19 -0800 | [diff] [blame] | 108 | #define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */ |
John Fastabend | 2469ffd | 2012-10-24 08:13:03 +0000 | [diff] [blame] | 109 | |
| 110 | /* Bridge management nested attributes |
| 111 | * [IFLA_AF_SPEC] = { |
| 112 | * [IFLA_BRIDGE_FLAGS] |
| 113 | * [IFLA_BRIDGE_MODE] |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 114 | * [IFLA_BRIDGE_VLAN_INFO] |
John Fastabend | 2469ffd | 2012-10-24 08:13:03 +0000 | [diff] [blame] | 115 | * } |
| 116 | */ |
| 117 | enum { |
| 118 | IFLA_BRIDGE_FLAGS, |
| 119 | IFLA_BRIDGE_MODE, |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 120 | IFLA_BRIDGE_VLAN_INFO, |
John Fastabend | 2469ffd | 2012-10-24 08:13:03 +0000 | [diff] [blame] | 121 | __IFLA_BRIDGE_MAX, |
| 122 | }; |
| 123 | #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1) |
Cong Wang | ee07c6e | 2012-12-07 00:04:48 +0000 | [diff] [blame] | 124 | |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 125 | #define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */ |
Vlad Yasevich | 552406c | 2013-02-13 12:00:15 +0000 | [diff] [blame] | 126 | #define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */ |
Vlad Yasevich | 35e03f3 | 2013-02-13 12:00:20 +0000 | [diff] [blame] | 127 | #define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */ |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 128 | #define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */ |
| 129 | #define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */ |
Nikolay Aleksandrov | 2594e90 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 130 | #define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */ |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 131 | |
| 132 | struct bridge_vlan_info { |
Cong Wang | 9f89ec8 | 2013-02-14 13:32:31 +0800 | [diff] [blame] | 133 | __u16 flags; |
| 134 | __u16 vid; |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 135 | }; |
| 136 | |
Cong Wang | ee07c6e | 2012-12-07 00:04:48 +0000 | [diff] [blame] | 137 | /* Bridge multicast database attributes |
| 138 | * [MDBA_MDB] = { |
| 139 | * [MDBA_MDB_ENTRY] = { |
Nikolay Aleksandrov | 2125715 | 2016-02-16 12:46:54 +0100 | [diff] [blame] | 140 | * [MDBA_MDB_ENTRY_INFO] { |
| 141 | * struct br_mdb_entry |
| 142 | * [MDBA_MDB_EATTR attributes] |
| 143 | * } |
Cong Wang | ee07c6e | 2012-12-07 00:04:48 +0000 | [diff] [blame] | 144 | * } |
| 145 | * } |
| 146 | * [MDBA_ROUTER] = { |
| 147 | * [MDBA_ROUTER_PORT] |
| 148 | * } |
| 149 | */ |
| 150 | enum { |
| 151 | MDBA_UNSPEC, |
| 152 | MDBA_MDB, |
| 153 | MDBA_ROUTER, |
| 154 | __MDBA_MAX, |
| 155 | }; |
| 156 | #define MDBA_MAX (__MDBA_MAX - 1) |
| 157 | |
| 158 | enum { |
| 159 | MDBA_MDB_UNSPEC, |
| 160 | MDBA_MDB_ENTRY, |
| 161 | __MDBA_MDB_MAX, |
| 162 | }; |
| 163 | #define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1) |
| 164 | |
| 165 | enum { |
| 166 | MDBA_MDB_ENTRY_UNSPEC, |
| 167 | MDBA_MDB_ENTRY_INFO, |
| 168 | __MDBA_MDB_ENTRY_MAX, |
| 169 | }; |
| 170 | #define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1) |
| 171 | |
Nikolay Aleksandrov | 2125715 | 2016-02-16 12:46:54 +0100 | [diff] [blame] | 172 | /* per mdb entry additional attributes */ |
| 173 | enum { |
| 174 | MDBA_MDB_EATTR_UNSPEC, |
| 175 | MDBA_MDB_EATTR_TIMER, |
| 176 | __MDBA_MDB_EATTR_MAX |
| 177 | }; |
| 178 | #define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1) |
| 179 | |
Nikolay Aleksandrov | 7f0aec7 | 2016-02-26 21:20:01 +0100 | [diff] [blame] | 180 | /* multicast router types */ |
| 181 | enum { |
| 182 | MDB_RTR_TYPE_DISABLED, |
| 183 | MDB_RTR_TYPE_TEMP_QUERY, |
| 184 | MDB_RTR_TYPE_PERM, |
Nikolay Aleksandrov | a55d824 | 2016-02-26 21:20:03 +0100 | [diff] [blame^] | 185 | MDB_RTR_TYPE_TEMP |
Nikolay Aleksandrov | 7f0aec7 | 2016-02-26 21:20:01 +0100 | [diff] [blame] | 186 | }; |
| 187 | |
Cong Wang | ee07c6e | 2012-12-07 00:04:48 +0000 | [diff] [blame] | 188 | enum { |
| 189 | MDBA_ROUTER_UNSPEC, |
| 190 | MDBA_ROUTER_PORT, |
| 191 | __MDBA_ROUTER_MAX, |
| 192 | }; |
| 193 | #define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1) |
| 194 | |
| 195 | struct br_port_msg { |
Cong Wang | cfd5675 | 2012-12-11 22:23:08 +0000 | [diff] [blame] | 196 | __u8 family; |
Cong Wang | ee07c6e | 2012-12-07 00:04:48 +0000 | [diff] [blame] | 197 | __u32 ifindex; |
| 198 | }; |
| 199 | |
| 200 | struct br_mdb_entry { |
| 201 | __u32 ifindex; |
Amerigo Wang | ccb1c31 | 2012-12-14 22:09:51 +0000 | [diff] [blame] | 202 | #define MDB_TEMPORARY 0 |
| 203 | #define MDB_PERMANENT 1 |
| 204 | __u8 state; |
Elad Raz | 157ede6 | 2016-02-03 09:57:04 +0100 | [diff] [blame] | 205 | #define MDB_FLAGS_OFFLOAD (1 << 0) |
| 206 | __u8 flags; |
Nikolay Aleksandrov | 74fe61f | 2015-07-10 08:02:08 -0700 | [diff] [blame] | 207 | __u16 vid; |
Cong Wang | ee07c6e | 2012-12-07 00:04:48 +0000 | [diff] [blame] | 208 | struct { |
| 209 | union { |
| 210 | __be32 ip4; |
| 211 | struct in6_addr ip6; |
| 212 | } u; |
| 213 | __be16 proto; |
| 214 | } addr; |
| 215 | }; |
| 216 | |
Cong Wang | cfd5675 | 2012-12-11 22:23:08 +0000 | [diff] [blame] | 217 | enum { |
| 218 | MDBA_SET_ENTRY_UNSPEC, |
| 219 | MDBA_SET_ENTRY, |
| 220 | __MDBA_SET_ENTRY_MAX, |
| 221 | }; |
| 222 | #define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1) |
| 223 | |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 224 | #endif /* _UAPI_LINUX_IF_BRIDGE_H */ |