mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 15:59:33 +07:00
2594e9064a
This patch changes the bridge vlan implementation to use rhashtables instead of bitmaps. The main motivation behind this change is that we need extensible per-vlan structures (both per-port and global) so more advanced features can be introduced and the vlan support can be extended. I've tried to break this up but the moment net_port_vlans is changed and the whole API goes away, thus this is a larger patch. A few short goals of this patch are: - Extensible per-vlan structs stored in rhashtables and a sorted list - Keep user-visible behaviour (compressed vlans etc) - Keep fastpath ingress/egress logic the same (optimizations to come later) Here's a brief list of some of the new features we'd like to introduce: - per-vlan counters - vlan ingress/egress mapping - per-vlan igmp configuration - vlan priorities - avoid fdb entries replication (e.g. local fdb scaling issues) The structure is kept single for both global and per-port entries so to avoid code duplication where possible and also because we'll soon introduce "port0 / aka bridge as port" which should simplify things further (thanks to Vlad for the suggestion!). Now we have per-vlan global rhashtable (bridge-wide) and per-vlan port rhashtable, if an entry is added to a port it'll get a pointer to its global context so it can be quickly accessed later. There's also a sorted vlan list which is used for stable walks and some user-visible behaviour such as the vlan ranges, also for error paths. VLANs are stored in a "vlan group" which currently contains the rhashtable, sorted vlan list and the number of "real" vlan entries. A good side-effect of this change is that it resembles how hw keeps per-vlan data. One important note after this change is that if a VLAN is being looked up in the bridge's rhashtable for filtering purposes (or to check if it's an existing usable entry, not just a global context) then the new helper br_vlan_should_use() needs to be used if the vlan is found. In case the lookup is done only with a port's vlan group, then this check can be skipped. Things tested so far: - basic vlan ingress/egress - pvids - untagged vlans - undef CONFIG_BRIDGE_VLAN_FILTERING - adding/deleting vlans in different scenarios (with/without global ctx, while transmitting traffic, in ranges etc) - loading/removing the module while having/adding/deleting vlans - extracting bridge vlan information (user ABI), compressed requests - adding/deleting fdbs on vlans - bridge mac change, promisc mode - default pvid change - kmemleak ON during the whole time Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
204 lines
4.5 KiB
C
204 lines
4.5 KiB
C
/*
|
|
* Linux ethernet bridge
|
|
*
|
|
* Authors:
|
|
* Lennert Buytenhek <buytenh@gnu.org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#ifndef _UAPI_LINUX_IF_BRIDGE_H
|
|
#define _UAPI_LINUX_IF_BRIDGE_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/if_ether.h>
|
|
#include <linux/in6.h>
|
|
|
|
#define SYSFS_BRIDGE_ATTR "bridge"
|
|
#define SYSFS_BRIDGE_FDB "brforward"
|
|
#define SYSFS_BRIDGE_PORT_SUBDIR "brif"
|
|
#define SYSFS_BRIDGE_PORT_ATTR "brport"
|
|
#define SYSFS_BRIDGE_PORT_LINK "bridge"
|
|
|
|
#define BRCTL_VERSION 1
|
|
|
|
#define BRCTL_GET_VERSION 0
|
|
#define BRCTL_GET_BRIDGES 1
|
|
#define BRCTL_ADD_BRIDGE 2
|
|
#define BRCTL_DEL_BRIDGE 3
|
|
#define BRCTL_ADD_IF 4
|
|
#define BRCTL_DEL_IF 5
|
|
#define BRCTL_GET_BRIDGE_INFO 6
|
|
#define BRCTL_GET_PORT_LIST 7
|
|
#define BRCTL_SET_BRIDGE_FORWARD_DELAY 8
|
|
#define BRCTL_SET_BRIDGE_HELLO_TIME 9
|
|
#define BRCTL_SET_BRIDGE_MAX_AGE 10
|
|
#define BRCTL_SET_AGEING_TIME 11
|
|
#define BRCTL_SET_GC_INTERVAL 12
|
|
#define BRCTL_GET_PORT_INFO 13
|
|
#define BRCTL_SET_BRIDGE_STP_STATE 14
|
|
#define BRCTL_SET_BRIDGE_PRIORITY 15
|
|
#define BRCTL_SET_PORT_PRIORITY 16
|
|
#define BRCTL_SET_PATH_COST 17
|
|
#define BRCTL_GET_FDB_ENTRIES 18
|
|
|
|
#define BR_STATE_DISABLED 0
|
|
#define BR_STATE_LISTENING 1
|
|
#define BR_STATE_LEARNING 2
|
|
#define BR_STATE_FORWARDING 3
|
|
#define BR_STATE_BLOCKING 4
|
|
|
|
struct __bridge_info {
|
|
__u64 designated_root;
|
|
__u64 bridge_id;
|
|
__u32 root_path_cost;
|
|
__u32 max_age;
|
|
__u32 hello_time;
|
|
__u32 forward_delay;
|
|
__u32 bridge_max_age;
|
|
__u32 bridge_hello_time;
|
|
__u32 bridge_forward_delay;
|
|
__u8 topology_change;
|
|
__u8 topology_change_detected;
|
|
__u8 root_port;
|
|
__u8 stp_enabled;
|
|
__u32 ageing_time;
|
|
__u32 gc_interval;
|
|
__u32 hello_timer_value;
|
|
__u32 tcn_timer_value;
|
|
__u32 topology_change_timer_value;
|
|
__u32 gc_timer_value;
|
|
};
|
|
|
|
struct __port_info {
|
|
__u64 designated_root;
|
|
__u64 designated_bridge;
|
|
__u16 port_id;
|
|
__u16 designated_port;
|
|
__u32 path_cost;
|
|
__u32 designated_cost;
|
|
__u8 state;
|
|
__u8 top_change_ack;
|
|
__u8 config_pending;
|
|
__u8 unused0;
|
|
__u32 message_age_timer_value;
|
|
__u32 forward_delay_timer_value;
|
|
__u32 hold_timer_value;
|
|
};
|
|
|
|
struct __fdb_entry {
|
|
__u8 mac_addr[ETH_ALEN];
|
|
__u8 port_no;
|
|
__u8 is_local;
|
|
__u32 ageing_timer_value;
|
|
__u8 port_hi;
|
|
__u8 pad0;
|
|
__u16 unused;
|
|
};
|
|
|
|
/* Bridge Flags */
|
|
#define BRIDGE_FLAGS_MASTER 1 /* Bridge command to/from master */
|
|
#define BRIDGE_FLAGS_SELF 2 /* Bridge command to/from lowerdev */
|
|
|
|
#define BRIDGE_MODE_VEB 0 /* Default loopback mode */
|
|
#define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */
|
|
#define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */
|
|
|
|
/* Bridge management nested attributes
|
|
* [IFLA_AF_SPEC] = {
|
|
* [IFLA_BRIDGE_FLAGS]
|
|
* [IFLA_BRIDGE_MODE]
|
|
* [IFLA_BRIDGE_VLAN_INFO]
|
|
* }
|
|
*/
|
|
enum {
|
|
IFLA_BRIDGE_FLAGS,
|
|
IFLA_BRIDGE_MODE,
|
|
IFLA_BRIDGE_VLAN_INFO,
|
|
__IFLA_BRIDGE_MAX,
|
|
};
|
|
#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
|
|
|
|
#define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */
|
|
#define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */
|
|
#define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */
|
|
#define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */
|
|
#define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */
|
|
#define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */
|
|
|
|
struct bridge_vlan_info {
|
|
__u16 flags;
|
|
__u16 vid;
|
|
};
|
|
|
|
/* Bridge multicast database attributes
|
|
* [MDBA_MDB] = {
|
|
* [MDBA_MDB_ENTRY] = {
|
|
* [MDBA_MDB_ENTRY_INFO]
|
|
* }
|
|
* }
|
|
* [MDBA_ROUTER] = {
|
|
* [MDBA_ROUTER_PORT]
|
|
* }
|
|
*/
|
|
enum {
|
|
MDBA_UNSPEC,
|
|
MDBA_MDB,
|
|
MDBA_ROUTER,
|
|
__MDBA_MAX,
|
|
};
|
|
#define MDBA_MAX (__MDBA_MAX - 1)
|
|
|
|
enum {
|
|
MDBA_MDB_UNSPEC,
|
|
MDBA_MDB_ENTRY,
|
|
__MDBA_MDB_MAX,
|
|
};
|
|
#define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
|
|
|
|
enum {
|
|
MDBA_MDB_ENTRY_UNSPEC,
|
|
MDBA_MDB_ENTRY_INFO,
|
|
__MDBA_MDB_ENTRY_MAX,
|
|
};
|
|
#define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
|
|
|
|
enum {
|
|
MDBA_ROUTER_UNSPEC,
|
|
MDBA_ROUTER_PORT,
|
|
__MDBA_ROUTER_MAX,
|
|
};
|
|
#define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
|
|
|
|
struct br_port_msg {
|
|
__u8 family;
|
|
__u32 ifindex;
|
|
};
|
|
|
|
struct br_mdb_entry {
|
|
__u32 ifindex;
|
|
#define MDB_TEMPORARY 0
|
|
#define MDB_PERMANENT 1
|
|
__u8 state;
|
|
__u16 vid;
|
|
struct {
|
|
union {
|
|
__be32 ip4;
|
|
struct in6_addr ip6;
|
|
} u;
|
|
__be16 proto;
|
|
} addr;
|
|
};
|
|
|
|
enum {
|
|
MDBA_SET_ENTRY_UNSPEC,
|
|
MDBA_SET_ENTRY,
|
|
__MDBA_SET_ENTRY_MAX,
|
|
};
|
|
#define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
|
|
|
|
#endif /* _UAPI_LINUX_IF_BRIDGE_H */
|