linux/include/uapi/linux/if_bridge.h
<<
>>
Prefs
   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
  14#ifndef _UAPI_LINUX_IF_BRIDGE_H
  15#define _UAPI_LINUX_IF_BRIDGE_H
  16
  17#include <linux/types.h>
  18#include <linux/if_ether.h>
  19#include <linux/in6.h>
  20
  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 {
  94        __u8 mac_addr[ETH_ALEN];
  95        __u8 port_no;
  96        __u8 is_local;
  97        __u32 ageing_timer_value;
  98        __u8 port_hi;
  99        __u8 pad0;
 100        __u16 unused;
 101};
 102
 103/* Bridge Flags */
 104#define BRIDGE_FLAGS_MASTER     1       /* Bridge command to/from master */
 105#define BRIDGE_FLAGS_SELF       2       /* Bridge command to/from lowerdev */
 106
 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 */
 110
 111/* Bridge management nested attributes
 112 * [IFLA_AF_SPEC] = {
 113 *     [IFLA_BRIDGE_FLAGS]
 114 *     [IFLA_BRIDGE_MODE]
 115 *     [IFLA_BRIDGE_VLAN_INFO]
 116 * }
 117 */
 118enum {
 119        IFLA_BRIDGE_FLAGS,
 120        IFLA_BRIDGE_MODE,
 121        IFLA_BRIDGE_VLAN_INFO,
 122        IFLA_BRIDGE_VLAN_TUNNEL_INFO,
 123        IFLA_BRIDGE_MRP,
 124        __IFLA_BRIDGE_MAX,
 125};
 126#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
 127
 128#define BRIDGE_VLAN_INFO_MASTER (1<<0)  /* Operate on Bridge device as well */
 129#define BRIDGE_VLAN_INFO_PVID   (1<<1)  /* VLAN is PVID, ingress untagged */
 130#define BRIDGE_VLAN_INFO_UNTAGGED       (1<<2)  /* VLAN egresses untagged */
 131#define BRIDGE_VLAN_INFO_RANGE_BEGIN    (1<<3) /* VLAN is start of vlan range */
 132#define BRIDGE_VLAN_INFO_RANGE_END      (1<<4) /* VLAN is end of vlan range */
 133#define BRIDGE_VLAN_INFO_BRENTRY        (1<<5) /* Global bridge VLAN entry */
 134#define BRIDGE_VLAN_INFO_ONLY_OPTS      (1<<6) /* Skip create/delete/flags */
 135
 136struct bridge_vlan_info {
 137        __u16 flags;
 138        __u16 vid;
 139};
 140
 141enum {
 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,
 147};
 148
 149#define IFLA_BRIDGE_VLAN_TUNNEL_MAX (__IFLA_BRIDGE_VLAN_TUNNEL_MAX - 1)
 150
 151struct bridge_vlan_xstats {
 152        __u64 rx_bytes;
 153        __u64 rx_packets;
 154        __u64 tx_bytes;
 155        __u64 tx_packets;
 156        __u16 vid;
 157        __u16 flags;
 158        __u32 pad2;
 159};
 160
 161enum {
 162        IFLA_BRIDGE_MRP_UNSPEC,
 163        IFLA_BRIDGE_MRP_INSTANCE,
 164        IFLA_BRIDGE_MRP_PORT_STATE,
 165        IFLA_BRIDGE_MRP_PORT_ROLE,
 166        IFLA_BRIDGE_MRP_RING_STATE,
 167        IFLA_BRIDGE_MRP_RING_ROLE,
 168        IFLA_BRIDGE_MRP_START_TEST,
 169        __IFLA_BRIDGE_MRP_MAX,
 170};
 171
 172#define IFLA_BRIDGE_MRP_MAX (__IFLA_BRIDGE_MRP_MAX - 1)
 173
 174enum {
 175        IFLA_BRIDGE_MRP_INSTANCE_UNSPEC,
 176        IFLA_BRIDGE_MRP_INSTANCE_RING_ID,
 177        IFLA_BRIDGE_MRP_INSTANCE_P_IFINDEX,
 178        IFLA_BRIDGE_MRP_INSTANCE_S_IFINDEX,
 179        IFLA_BRIDGE_MRP_INSTANCE_PRIO,
 180        __IFLA_BRIDGE_MRP_INSTANCE_MAX,
 181};
 182
 183#define IFLA_BRIDGE_MRP_INSTANCE_MAX (__IFLA_BRIDGE_MRP_INSTANCE_MAX - 1)
 184
 185enum {
 186        IFLA_BRIDGE_MRP_PORT_STATE_UNSPEC,
 187        IFLA_BRIDGE_MRP_PORT_STATE_STATE,
 188        __IFLA_BRIDGE_MRP_PORT_STATE_MAX,
 189};
 190
 191#define IFLA_BRIDGE_MRP_PORT_STATE_MAX (__IFLA_BRIDGE_MRP_PORT_STATE_MAX - 1)
 192
 193enum {
 194        IFLA_BRIDGE_MRP_PORT_ROLE_UNSPEC,
 195        IFLA_BRIDGE_MRP_PORT_ROLE_ROLE,
 196        __IFLA_BRIDGE_MRP_PORT_ROLE_MAX,
 197};
 198
 199#define IFLA_BRIDGE_MRP_PORT_ROLE_MAX (__IFLA_BRIDGE_MRP_PORT_ROLE_MAX - 1)
 200
 201enum {
 202        IFLA_BRIDGE_MRP_RING_STATE_UNSPEC,
 203        IFLA_BRIDGE_MRP_RING_STATE_RING_ID,
 204        IFLA_BRIDGE_MRP_RING_STATE_STATE,
 205        __IFLA_BRIDGE_MRP_RING_STATE_MAX,
 206};
 207
 208#define IFLA_BRIDGE_MRP_RING_STATE_MAX (__IFLA_BRIDGE_MRP_RING_STATE_MAX - 1)
 209
 210enum {
 211        IFLA_BRIDGE_MRP_RING_ROLE_UNSPEC,
 212        IFLA_BRIDGE_MRP_RING_ROLE_RING_ID,
 213        IFLA_BRIDGE_MRP_RING_ROLE_ROLE,
 214        __IFLA_BRIDGE_MRP_RING_ROLE_MAX,
 215};
 216
 217#define IFLA_BRIDGE_MRP_RING_ROLE_MAX (__IFLA_BRIDGE_MRP_RING_ROLE_MAX - 1)
 218
 219enum {
 220        IFLA_BRIDGE_MRP_START_TEST_UNSPEC,
 221        IFLA_BRIDGE_MRP_START_TEST_RING_ID,
 222        IFLA_BRIDGE_MRP_START_TEST_INTERVAL,
 223        IFLA_BRIDGE_MRP_START_TEST_MAX_MISS,
 224        IFLA_BRIDGE_MRP_START_TEST_PERIOD,
 225        IFLA_BRIDGE_MRP_START_TEST_MONITOR,
 226        __IFLA_BRIDGE_MRP_START_TEST_MAX,
 227};
 228
 229#define IFLA_BRIDGE_MRP_START_TEST_MAX (__IFLA_BRIDGE_MRP_START_TEST_MAX - 1)
 230
 231struct br_mrp_instance {
 232        __u32 ring_id;
 233        __u32 p_ifindex;
 234        __u32 s_ifindex;
 235        __u16 prio;
 236};
 237
 238struct br_mrp_ring_state {
 239        __u32 ring_id;
 240        __u32 ring_state;
 241};
 242
 243struct br_mrp_ring_role {
 244        __u32 ring_id;
 245        __u32 ring_role;
 246};
 247
 248struct br_mrp_start_test {
 249        __u32 ring_id;
 250        __u32 interval;
 251        __u32 max_miss;
 252        __u32 period;
 253        __u32 monitor;
 254};
 255
 256struct bridge_stp_xstats {
 257        __u64 transition_blk;
 258        __u64 transition_fwd;
 259        __u64 rx_bpdu;
 260        __u64 tx_bpdu;
 261        __u64 rx_tcn;
 262        __u64 tx_tcn;
 263};
 264
 265/* Bridge vlan RTM header */
 266struct br_vlan_msg {
 267        __u8 family;
 268        __u8 reserved1;
 269        __u16 reserved2;
 270        __u32 ifindex;
 271};
 272
 273enum {
 274        BRIDGE_VLANDB_DUMP_UNSPEC,
 275        BRIDGE_VLANDB_DUMP_FLAGS,
 276        __BRIDGE_VLANDB_DUMP_MAX,
 277};
 278#define BRIDGE_VLANDB_DUMP_MAX (__BRIDGE_VLANDB_DUMP_MAX - 1)
 279
 280/* flags used in BRIDGE_VLANDB_DUMP_FLAGS attribute to affect dumps */
 281#define BRIDGE_VLANDB_DUMPF_STATS       (1 << 0) /* Include stats in the dump */
 282
 283/* Bridge vlan RTM attributes
 284 * [BRIDGE_VLANDB_ENTRY] = {
 285 *     [BRIDGE_VLANDB_ENTRY_INFO]
 286 *     ...
 287 * }
 288 */
 289enum {
 290        BRIDGE_VLANDB_UNSPEC,
 291        BRIDGE_VLANDB_ENTRY,
 292        __BRIDGE_VLANDB_MAX,
 293};
 294#define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1)
 295
 296enum {
 297        BRIDGE_VLANDB_ENTRY_UNSPEC,
 298        BRIDGE_VLANDB_ENTRY_INFO,
 299        BRIDGE_VLANDB_ENTRY_RANGE,
 300        BRIDGE_VLANDB_ENTRY_STATE,
 301        BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,
 302        BRIDGE_VLANDB_ENTRY_STATS,
 303        __BRIDGE_VLANDB_ENTRY_MAX,
 304};
 305#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
 306
 307/* [BRIDGE_VLANDB_ENTRY] = {
 308 *     [BRIDGE_VLANDB_ENTRY_TUNNEL_INFO] = {
 309 *         [BRIDGE_VLANDB_TINFO_ID]
 310 *         ...
 311 *     }
 312 * }
 313 */
 314enum {
 315        BRIDGE_VLANDB_TINFO_UNSPEC,
 316        BRIDGE_VLANDB_TINFO_ID,
 317        BRIDGE_VLANDB_TINFO_CMD,
 318        __BRIDGE_VLANDB_TINFO_MAX,
 319};
 320#define BRIDGE_VLANDB_TINFO_MAX (__BRIDGE_VLANDB_TINFO_MAX - 1)
 321
 322/* [BRIDGE_VLANDB_ENTRY] = {
 323 *     [BRIDGE_VLANDB_ENTRY_STATS] = {
 324 *         [BRIDGE_VLANDB_STATS_RX_BYTES]
 325 *         ...
 326 *     }
 327 *     ...
 328 * }
 329 */
 330enum {
 331        BRIDGE_VLANDB_STATS_UNSPEC,
 332        BRIDGE_VLANDB_STATS_RX_BYTES,
 333        BRIDGE_VLANDB_STATS_RX_PACKETS,
 334        BRIDGE_VLANDB_STATS_TX_BYTES,
 335        BRIDGE_VLANDB_STATS_TX_PACKETS,
 336        BRIDGE_VLANDB_STATS_PAD,
 337        __BRIDGE_VLANDB_STATS_MAX,
 338};
 339#define BRIDGE_VLANDB_STATS_MAX (__BRIDGE_VLANDB_STATS_MAX - 1)
 340
 341/* Bridge multicast database attributes
 342 * [MDBA_MDB] = {
 343 *     [MDBA_MDB_ENTRY] = {
 344 *         [MDBA_MDB_ENTRY_INFO] {
 345 *              struct br_mdb_entry
 346 *              [MDBA_MDB_EATTR attributes]
 347 *         }
 348 *     }
 349 * }
 350 * [MDBA_ROUTER] = {
 351 *    [MDBA_ROUTER_PORT] = {
 352 *        u32 ifindex
 353 *        [MDBA_ROUTER_PATTR attributes]
 354 *    }
 355 * }
 356 */
 357enum {
 358        MDBA_UNSPEC,
 359        MDBA_MDB,
 360        MDBA_ROUTER,
 361        __MDBA_MAX,
 362};
 363#define MDBA_MAX (__MDBA_MAX - 1)
 364
 365enum {
 366        MDBA_MDB_UNSPEC,
 367        MDBA_MDB_ENTRY,
 368        __MDBA_MDB_MAX,
 369};
 370#define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
 371
 372enum {
 373        MDBA_MDB_ENTRY_UNSPEC,
 374        MDBA_MDB_ENTRY_INFO,
 375        __MDBA_MDB_ENTRY_MAX,
 376};
 377#define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
 378
 379/* per mdb entry additional attributes */
 380enum {
 381        MDBA_MDB_EATTR_UNSPEC,
 382        MDBA_MDB_EATTR_TIMER,
 383        __MDBA_MDB_EATTR_MAX
 384};
 385#define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
 386
 387/* multicast router types */
 388enum {
 389        MDB_RTR_TYPE_DISABLED,
 390        MDB_RTR_TYPE_TEMP_QUERY,
 391        MDB_RTR_TYPE_PERM,
 392        MDB_RTR_TYPE_TEMP
 393};
 394
 395enum {
 396        MDBA_ROUTER_UNSPEC,
 397        MDBA_ROUTER_PORT,
 398        __MDBA_ROUTER_MAX,
 399};
 400#define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
 401
 402/* router port attributes */
 403enum {
 404        MDBA_ROUTER_PATTR_UNSPEC,
 405        MDBA_ROUTER_PATTR_TIMER,
 406        MDBA_ROUTER_PATTR_TYPE,
 407        __MDBA_ROUTER_PATTR_MAX
 408};
 409#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
 410
 411struct br_port_msg {
 412        __u8  family;
 413        __u32 ifindex;
 414};
 415
 416struct br_mdb_entry {
 417        __u32 ifindex;
 418#define MDB_TEMPORARY 0
 419#define MDB_PERMANENT 1
 420        __u8 state;
 421#define MDB_FLAGS_OFFLOAD       (1 << 0)
 422#define MDB_FLAGS_FAST_LEAVE    (1 << 1)
 423        __u8 flags;
 424        __u16 vid;
 425        struct {
 426                union {
 427                        __be32  ip4;
 428                        struct in6_addr ip6;
 429                } u;
 430                __be16          proto;
 431        } addr;
 432};
 433
 434enum {
 435        MDBA_SET_ENTRY_UNSPEC,
 436        MDBA_SET_ENTRY,
 437        __MDBA_SET_ENTRY_MAX,
 438};
 439#define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
 440
 441/* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
 442enum {
 443        BRIDGE_XSTATS_UNSPEC,
 444        BRIDGE_XSTATS_VLAN,
 445        BRIDGE_XSTATS_MCAST,
 446        BRIDGE_XSTATS_PAD,
 447        BRIDGE_XSTATS_STP,
 448        __BRIDGE_XSTATS_MAX
 449};
 450#define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
 451
 452enum {
 453        BR_MCAST_DIR_RX,
 454        BR_MCAST_DIR_TX,
 455        BR_MCAST_DIR_SIZE
 456};
 457
 458/* IGMP/MLD statistics */
 459struct br_mcast_stats {
 460        __u64 igmp_v1queries[BR_MCAST_DIR_SIZE];
 461        __u64 igmp_v2queries[BR_MCAST_DIR_SIZE];
 462        __u64 igmp_v3queries[BR_MCAST_DIR_SIZE];
 463        __u64 igmp_leaves[BR_MCAST_DIR_SIZE];
 464        __u64 igmp_v1reports[BR_MCAST_DIR_SIZE];
 465        __u64 igmp_v2reports[BR_MCAST_DIR_SIZE];
 466        __u64 igmp_v3reports[BR_MCAST_DIR_SIZE];
 467        __u64 igmp_parse_errors;
 468
 469        __u64 mld_v1queries[BR_MCAST_DIR_SIZE];
 470        __u64 mld_v2queries[BR_MCAST_DIR_SIZE];
 471        __u64 mld_leaves[BR_MCAST_DIR_SIZE];
 472        __u64 mld_v1reports[BR_MCAST_DIR_SIZE];
 473        __u64 mld_v2reports[BR_MCAST_DIR_SIZE];
 474        __u64 mld_parse_errors;
 475
 476        __u64 mcast_bytes[BR_MCAST_DIR_SIZE];
 477        __u64 mcast_packets[BR_MCAST_DIR_SIZE];
 478};
 479
 480/* bridge boolean options
 481 * BR_BOOLOPT_NO_LL_LEARN - disable learning from link-local packets
 482 *
 483 * IMPORTANT: if adding a new option do not forget to handle
 484 *            it in br_boolopt_toggle/get and bridge sysfs
 485 */
 486enum br_boolopt_id {
 487        BR_BOOLOPT_NO_LL_LEARN,
 488        BR_BOOLOPT_MAX
 489};
 490
 491/* struct br_boolopt_multi - change multiple bridge boolean options
 492 *
 493 * @optval: new option values (bit per option)
 494 * @optmask: options to change (bit per option)
 495 */
 496struct br_boolopt_multi {
 497        __u32 optval;
 498        __u32 optmask;
 499};
 500#endif /* _UAPI_LINUX_IF_BRIDGE_H */
 501