^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Linux ethernet bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Lennert Buytenhek <buytenh@gnu.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef _BR_PRIVATE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define _BR_PRIVATE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/if_bridge.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/netpoll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/u64_stats_sync.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <net/route.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <net/ip6_fib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/if_vlan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/rhashtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define BR_HASH_BITS 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define BR_HASH_SIZE (1 << BR_HASH_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define BR_HOLD_TIME (1*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define BR_PORT_BITS 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define BR_MAX_PORTS (1<<BR_PORT_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define BR_MULTICAST_DEFAULT_HASH_MAX 4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define BR_VERSION "2.3"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* Control of forwarding link local multicast */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define BR_GROUPFWD_DEFAULT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* Don't allow forwarding of control protocols like STP, MAC PAUSE and LACP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) BR_GROUPFWD_STP = BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) BR_GROUPFWD_MACPAUSE = BIT(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) BR_GROUPFWD_LACP = BIT(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define BR_GROUPFWD_RESTRICTED (BR_GROUPFWD_STP | BR_GROUPFWD_MACPAUSE | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) BR_GROUPFWD_LACP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* The Nearest Customer Bridge Group Address, 01-80-C2-00-00-[00,0B,0C,0D,0F] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define BR_GROUPFWD_8021AD 0xB801u
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Path to usermode spanning tree program */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define BR_STP_PROG "/sbin/bridge-stp"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define BR_FDB_NOTIFY_SETTABLE_BITS (FDB_NOTIFY_BIT | FDB_NOTIFY_INACTIVE_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) typedef struct bridge_id bridge_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) typedef struct mac_addr mac_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) typedef __u16 port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct bridge_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) unsigned char prio[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) unsigned char addr[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct mac_addr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) unsigned char addr[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* our own querier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct bridge_mcast_own_query {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u32 startup_sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* other querier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct bridge_mcast_other_query {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned long delay_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* selected querier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct bridge_mcast_querier {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct br_ip addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct net_bridge_port __rcu *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /* IGMP/MLD statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct bridge_mcast_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct br_mcast_stats mstats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct u64_stats_sync syncp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct br_vlan_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) u64 rx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) u64 rx_packets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) u64 tx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) u64 tx_packets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct u64_stats_sync syncp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct br_tunnel_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) __be64 tunnel_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct metadata_dst __rcu *tunnel_dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* private vlan flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) BR_VLFLAG_PER_PORT_STATS = BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) BR_VLFLAG_ADDED_BY_SWITCHDEV = BIT(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * struct net_bridge_vlan - per-vlan entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * @vnode: rhashtable member
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * @vid: VLAN id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * @flags: bridge vlan flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * @priv_flags: private (in-kernel) bridge vlan flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * @state: STP state (e.g. blocking, learning, forwarding)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * @stats: per-cpu VLAN statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * @br: if MASTER flag set, this points to a bridge struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * @port: if MASTER flag unset, this points to a port struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * @refcnt: if MASTER flag set, this is bumped for each port referencing it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * @brvlan: if MASTER flag unset, this points to the global per-VLAN context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * for this VLAN entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * @vlist: sorted list of VLAN entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * @rcu: used for entry destruction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * This structure is shared between the global per-VLAN entries contained in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * the bridge rhashtable and the local per-port per-VLAN entries contained in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * the port's rhashtable. The union entries should be interpreted depending on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * the entry flags that are set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct net_bridge_vlan {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct rhash_head vnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct rhash_head tnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u16 vid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) u16 priv_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) u8 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct br_vlan_stats __percpu *stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct net_bridge_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) refcount_t refcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct net_bridge_vlan *brvlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct br_tunnel_info tinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct list_head vlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * struct net_bridge_vlan_group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * @vlan_hash: VLAN entry rhashtable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * @vlan_list: sorted VLAN entry list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * @num_vlans: number of total VLAN entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * @pvid: PVID VLAN id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * @pvid_state: PVID's STP state (e.g. forwarding, learning, blocking)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * IMPORTANT: Be careful when checking if there're VLAN entries using list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * primitives because the bridge can have entries in its list which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * are just for global context but not for filtering, i.e. they have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * the master flag set but not the brentry flag. If you have to check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * if there're "real" entries in the bridge please test @num_vlans
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct net_bridge_vlan_group {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct rhashtable vlan_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct rhashtable tunnel_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct list_head vlan_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) u16 num_vlans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) u16 pvid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) u8 pvid_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* bridge fdb flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) BR_FDB_LOCAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) BR_FDB_STATIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) BR_FDB_STICKY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) BR_FDB_ADDED_BY_USER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) BR_FDB_ADDED_BY_EXT_LEARN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) BR_FDB_OFFLOADED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) BR_FDB_NOTIFY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) BR_FDB_NOTIFY_INACTIVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct net_bridge_fdb_key {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) mac_addr addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) u16 vlan_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct net_bridge_fdb_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct rhash_head rhnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct net_bridge_port *dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct net_bridge_fdb_key key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct hlist_node fdb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* write-heavy members should not affect lookups */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) unsigned long updated ____cacheline_aligned_in_smp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) unsigned long used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #define MDB_PG_FLAGS_PERMANENT BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #define MDB_PG_FLAGS_OFFLOAD BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #define MDB_PG_FLAGS_FAST_LEAVE BIT(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define MDB_PG_FLAGS_STAR_EXCL BIT(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #define MDB_PG_FLAGS_BLOCKED BIT(4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #define PG_SRC_ENT_LIMIT 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) #define BR_SGRP_F_DELETE BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) #define BR_SGRP_F_SEND BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #define BR_SGRP_F_INSTALLED BIT(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct net_bridge_mcast_gc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct hlist_node gc_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) void (*destroy)(struct net_bridge_mcast_gc *gc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct net_bridge_group_src {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct hlist_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct br_ip addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct net_bridge_port_group *pg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) u8 src_query_rexmit_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct net_bridge_mcast_gc mcast_gc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) struct net_bridge_port_group_sg_key {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct net_bridge_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct br_ip addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct net_bridge_port_group {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct net_bridge_port_group __rcu *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct net_bridge_port_group_sg_key key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) unsigned char eth_addr[ETH_ALEN] __aligned(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) unsigned char flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) unsigned char filter_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) unsigned char grp_query_rexmit_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) unsigned char rt_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct hlist_head src_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) unsigned int src_ents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct timer_list rexmit_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct hlist_node mglist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct rhash_head rhnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct net_bridge_mcast_gc mcast_gc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct net_bridge_mdb_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct rhash_head rhnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) struct net_bridge_port_group __rcu *ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct br_ip addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) bool host_joined;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct hlist_node mdb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct net_bridge_mcast_gc mcast_gc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) struct net_bridge_port {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) #ifdef CONFIG_BRIDGE_VLAN_FILTERING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct net_bridge_vlan_group __rcu *vlgrp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) struct net_bridge_port __rcu *backup_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) /* STP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u8 priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) u8 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) u16 port_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) unsigned char topology_change_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) unsigned char config_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) port_id port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) port_id designated_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) bridge_id designated_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) bridge_id designated_bridge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) u32 path_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) u32 designated_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) unsigned long designated_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) struct timer_list forward_delay_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) struct timer_list hold_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) struct timer_list message_age_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) struct kobject kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) struct bridge_mcast_own_query ip4_own_query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) struct bridge_mcast_own_query ip6_own_query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #endif /* IS_ENABLED(CONFIG_IPV6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) unsigned char multicast_router;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct bridge_mcast_stats __percpu *mcast_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) struct timer_list multicast_router_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct hlist_head mglist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct hlist_node rlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #ifdef CONFIG_SYSFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) char sysfs_name[IFNAMSIZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #ifdef CONFIG_NET_POLL_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) struct netpoll *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #ifdef CONFIG_NET_SWITCHDEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) int offload_fwd_mark;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) u16 group_fwd_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) u16 backup_redirected_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) struct bridge_stp_xstats stp_xstats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) #define kobj_to_brport(obj) container_of(obj, struct net_bridge_port, kobj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) #define br_auto_port(p) ((p)->flags & BR_AUTO_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) #define br_promisc_port(p) ((p)->flags & BR_PROMISC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) return rcu_dereference(dev->rx_handler_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return netif_is_bridge_port(dev) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) rtnl_dereference(dev->rx_handler_data) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) static inline struct net_bridge_port *br_port_get_rtnl_rcu(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) return netif_is_bridge_port(dev) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) rcu_dereference_rtnl(dev->rx_handler_data) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) enum net_bridge_opts {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) BROPT_VLAN_ENABLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) BROPT_VLAN_STATS_ENABLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) BROPT_NF_CALL_IPTABLES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) BROPT_NF_CALL_IP6TABLES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) BROPT_NF_CALL_ARPTABLES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) BROPT_GROUP_ADDR_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) BROPT_MULTICAST_ENABLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) BROPT_MULTICAST_QUERIER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) BROPT_MULTICAST_QUERY_USE_IFADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) BROPT_MULTICAST_STATS_ENABLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) BROPT_HAS_IPV6_ADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) BROPT_NEIGH_SUPPRESS_ENABLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) BROPT_MTU_SET_BY_USER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) BROPT_VLAN_STATS_PER_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) BROPT_NO_LL_LEARN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) BROPT_VLAN_BRIDGE_BINDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) struct net_bridge {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) spinlock_t hash_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct list_head port_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct pcpu_sw_netstats __percpu *stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) unsigned long options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /* These fields are accessed on each packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #ifdef CONFIG_BRIDGE_VLAN_FILTERING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) __be16 vlan_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) u16 default_pvid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) struct net_bridge_vlan_group __rcu *vlgrp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) struct rhashtable fdb_hash_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) struct rtable fake_rtable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) struct rt6_info fake_rt6_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) u16 group_fwd_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) u16 group_fwd_mask_required;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) /* STP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) bridge_id designated_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) bridge_id bridge_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) unsigned char topology_change;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) unsigned char topology_change_detected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) u16 root_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) unsigned long max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) unsigned long hello_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) unsigned long forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) unsigned long ageing_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) unsigned long bridge_max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) unsigned long bridge_hello_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) unsigned long bridge_forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) unsigned long bridge_ageing_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) u32 root_path_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) u8 group_addr[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) BR_NO_STP, /* no spanning tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) BR_KERNEL_STP, /* old STP in kernel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) BR_USER_STP, /* new RSTP in userspace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) } stp_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) u32 hash_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) u32 multicast_last_member_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) u32 multicast_startup_query_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) u8 multicast_igmp_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) u8 multicast_router;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) u8 multicast_mld_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) spinlock_t multicast_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) unsigned long multicast_last_member_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) unsigned long multicast_membership_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) unsigned long multicast_querier_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) unsigned long multicast_query_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) unsigned long multicast_query_response_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) unsigned long multicast_startup_query_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) struct rhashtable mdb_hash_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) struct rhashtable sg_port_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) struct hlist_head mcast_gc_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) struct hlist_head mdb_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct hlist_head router_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) struct timer_list multicast_router_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) struct bridge_mcast_other_query ip4_other_query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) struct bridge_mcast_own_query ip4_own_query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) struct bridge_mcast_querier ip4_querier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) struct bridge_mcast_stats __percpu *mcast_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct bridge_mcast_other_query ip6_other_query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) struct bridge_mcast_own_query ip6_own_query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct bridge_mcast_querier ip6_querier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) #endif /* IS_ENABLED(CONFIG_IPV6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) struct work_struct mcast_gc_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) struct timer_list hello_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) struct timer_list tcn_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) struct timer_list topology_change_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) struct delayed_work gc_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct kobject *ifobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) u32 auto_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) #ifdef CONFIG_NET_SWITCHDEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) int offload_fwd_mark;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) struct hlist_head fdb_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) #if IS_ENABLED(CONFIG_BRIDGE_MRP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) struct list_head mrp_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) struct br_input_skb_cb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) struct net_device *brdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) u16 frag_max_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) u8 igmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) u8 mrouters_only:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) u8 proxyarp_replied:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) u8 src_port_isolated:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) #ifdef CONFIG_BRIDGE_VLAN_FILTERING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) u8 vlan_filtered:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) #ifdef CONFIG_NETFILTER_FAMILY_BRIDGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) u8 br_netfilter_broute:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) #ifdef CONFIG_NET_SWITCHDEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) int offload_fwd_mark;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) #define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (BR_INPUT_SKB_CB(__skb)->mrouters_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) #define br_printk(level, br, format, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) printk(level "%s: " format, (br)->dev->name, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) #define br_err(__br, format, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) br_printk(KERN_ERR, __br, format, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) #define br_warn(__br, format, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) br_printk(KERN_WARNING, __br, format, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) #define br_notice(__br, format, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) br_printk(KERN_NOTICE, __br, format, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) #define br_info(__br, format, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) br_printk(KERN_INFO, __br, format, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) #define br_debug(br, format, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) pr_debug("%s: " format, (br)->dev->name, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) static inline int br_is_root_bridge(const struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) return !memcmp(&br->bridge_id, &br->designated_root, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) /* check if a VLAN entry is global */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) static inline bool br_vlan_is_master(const struct net_bridge_vlan *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) return v->flags & BRIDGE_VLAN_INFO_MASTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) /* check if a VLAN entry is used by the bridge */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) static inline bool br_vlan_is_brentry(const struct net_bridge_vlan *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) return v->flags & BRIDGE_VLAN_INFO_BRENTRY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) /* check if we should use the vlan entry, returns false if it's only context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) static inline bool br_vlan_should_use(const struct net_bridge_vlan *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) if (br_vlan_is_master(v)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (br_vlan_is_brentry(v))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) static inline bool nbp_state_should_learn(const struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) return p->state == BR_STATE_LEARNING || p->state == BR_STATE_FORWARDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) static inline bool br_vlan_valid_id(u16 vid, struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) bool ret = vid > 0 && vid < VLAN_VID_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) NL_SET_ERR_MSG_MOD(extack, "Vlan id is invalid");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) static inline bool br_vlan_valid_range(const struct bridge_vlan_info *cur,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) const struct bridge_vlan_info *last,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) /* pvid flag is not allowed in ranges */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) if (cur->flags & BRIDGE_VLAN_INFO_PVID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) NL_SET_ERR_MSG_MOD(extack, "Pvid isn't allowed in a range");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) /* when cur is the range end, check if:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) * - it has range start flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) * - range ids are invalid (end is equal to or before start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (last) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (cur->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) NL_SET_ERR_MSG_MOD(extack, "Found a new vlan range start while processing one");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) } else if (!(cur->flags & BRIDGE_VLAN_INFO_RANGE_END)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) NL_SET_ERR_MSG_MOD(extack, "Vlan range end flag is missing");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) } else if (cur->vid <= last->vid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) NL_SET_ERR_MSG_MOD(extack, "End vlan id is less than or equal to start vlan id");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) /* check for required range flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) if (!(cur->flags & (BRIDGE_VLAN_INFO_RANGE_BEGIN |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) BRIDGE_VLAN_INFO_RANGE_END))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) NL_SET_ERR_MSG_MOD(extack, "Both vlan range flags are missing");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) static inline int br_afspec_cmd_to_rtm(int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) case RTM_SETLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) return RTM_NEWVLAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) case RTM_DELLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) return RTM_DELVLAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) static inline int br_opt_get(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) enum net_bridge_opts opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) return test_bit(opt, &br->options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) int br_boolopt_toggle(struct net_bridge *br, enum br_boolopt_id opt, bool on,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) int br_boolopt_get(const struct net_bridge *br, enum br_boolopt_id opt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) int br_boolopt_multi_toggle(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) struct br_boolopt_multi *bm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) void br_boolopt_multi_get(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) struct br_boolopt_multi *bm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) void br_opt_toggle(struct net_bridge *br, enum net_bridge_opts opt, bool on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) /* br_device.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) void br_dev_setup(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) void br_dev_delete(struct net_device *dev, struct list_head *list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) #ifdef CONFIG_NET_POLL_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) netpoll_send_skb(p->np, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) int br_netpoll_enable(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) void br_netpoll_disable(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) static inline int br_netpoll_enable(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) static inline void br_netpoll_disable(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) /* br_fdb.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) int br_fdb_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) void br_fdb_fini(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) int br_fdb_hash_init(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) void br_fdb_hash_fini(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) void br_fdb_flush(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) void br_fdb_find_delete_local(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) const unsigned char *addr, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) void br_fdb_cleanup(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) void br_fdb_delete_by_port(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) const struct net_bridge_port *p, u16 vid, int do_all);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) struct net_bridge_fdb_entry *br_fdb_find_rcu(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) const unsigned char *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) __u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) int br_fdb_test_addr(struct net_device *dev, unsigned char *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) unsigned long off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) const unsigned char *addr, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) const unsigned char *addr, u16 vid, unsigned long flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) struct net_device *dev, const unsigned char *addr, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) const unsigned char *addr, u16 vid, u16 nlh_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) int br_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) struct net_device *dev, struct net_device *fdev, int *idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[], struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) const unsigned char *addr, u16 vid, u32 portid, u32 seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) const unsigned char *addr, u16 vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) bool swdev_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) const unsigned char *addr, u16 vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) bool swdev_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) const unsigned char *addr, u16 vid, bool offloaded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) /* br_forward.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) enum br_pkt_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) BR_PKT_UNICAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) BR_PKT_MULTICAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) BR_PKT_BROADCAST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) void br_forward(const struct net_bridge_port *to, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) bool local_rcv, bool local_orig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) void br_flood(struct net_bridge *br, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) enum br_pkt_type pkt_type, bool local_rcv, bool local_orig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) /* return true if both source port and dest port are isolated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) static inline bool br_skb_isolated(const struct net_bridge_port *to,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) const struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) return BR_INPUT_SKB_CB(skb)->src_port_isolated &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) (to->flags & BR_ISOLATED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) /* br_if.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) void br_port_carrier_check(struct net_bridge_port *p, bool *notified);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) int br_add_bridge(struct net *net, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) int br_del_bridge(struct net *net, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) int br_add_if(struct net_bridge *br, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) int br_del_if(struct net_bridge *br, struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) void br_mtu_auto_adjust(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) netdev_features_t br_features_recompute(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) netdev_features_t features);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) void br_port_flags_change(struct net_bridge_port *port, unsigned long mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) void br_manage_promisc(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) int nbp_backup_change(struct net_bridge_port *p, struct net_device *backup_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) /* br_input.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) rx_handler_func_t *br_get_rx_handler(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) static inline bool br_rx_handler_check_rcu(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) return rcu_dereference(dev->rx_handler) == br_get_rx_handler(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) static inline bool br_rx_handler_check_rtnl(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) return rcu_dereference_rtnl(dev->rx_handler) == br_get_rx_handler(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) static inline struct net_bridge_port *br_port_get_check_rcu(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) return br_rx_handler_check_rcu(dev) ? br_port_get_rcu(dev) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) static inline struct net_bridge_port *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) br_port_get_check_rtnl(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) return br_rx_handler_check_rtnl(dev) ? br_port_get_rtnl_rcu(dev) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) /* br_ioctl.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) void __user *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) /* br_multicast.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) int br_multicast_rcv(struct net_bridge *br, struct net_bridge_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) struct sk_buff *skb, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) struct sk_buff *skb, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) int br_multicast_add_port(struct net_bridge_port *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) void br_multicast_del_port(struct net_bridge_port *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) void br_multicast_enable_port(struct net_bridge_port *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) void br_multicast_disable_port(struct net_bridge_port *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) void br_multicast_init(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) void br_multicast_join_snoopers(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) void br_multicast_leave_snoopers(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) void br_multicast_open(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) void br_multicast_stop(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) void br_multicast_dev_del(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) struct sk_buff *skb, bool local_rcv, bool local_orig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) int br_multicast_set_router(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) int br_multicast_toggle(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) int br_multicast_set_querier(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) int br_multicast_set_igmp_version(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) int br_multicast_set_mld_version(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) struct net_bridge_mdb_entry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) br_mdb_ip_get(struct net_bridge *br, struct br_ip *dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) struct net_bridge_mdb_entry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) br_multicast_new_group(struct net_bridge *br, struct br_ip *group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) struct net_bridge_port_group *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) struct net_bridge_port_group __rcu *next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) unsigned char flags, const unsigned char *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) u8 filter_mode, u8 rt_protocol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) int br_mdb_hash_init(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) void br_mdb_hash_fini(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) void br_mdb_notify(struct net_device *dev, struct net_bridge_mdb_entry *mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) struct net_bridge_port_group *pg, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) struct net_bridge_port_group *pg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) struct net_bridge_port_group __rcu **pp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) void br_multicast_count(struct net_bridge *br, const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) const struct sk_buff *skb, u8 type, u8 dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) int br_multicast_init_stats(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) void br_multicast_uninit_stats(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) void br_multicast_get_stats(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) struct br_mcast_stats *dest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) void br_mdb_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) void br_mdb_uninit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) void br_multicast_host_join(struct net_bridge_mdb_entry *mp, bool notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) void br_multicast_host_leave(struct net_bridge_mdb_entry *mp, bool notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) void br_multicast_star_g_handle_mode(struct net_bridge_port_group *pg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) u8 filter_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) void br_multicast_sg_add_exclude_ports(struct net_bridge_mdb_entry *star_mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) struct net_bridge_port_group *sg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) #define mlock_dereference(X, br) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) static inline bool br_multicast_is_router(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) return br->multicast_router == 2 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) (br->multicast_router == 1 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) timer_pending(&br->multicast_router_timer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) __br_multicast_querier_exists(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) struct bridge_mcast_other_query *querier,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) const bool is_ipv6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) bool own_querier_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) if (br_opt_get(br, BROPT_MULTICAST_QUERIER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) if (is_ipv6 && !br_opt_get(br, BROPT_HAS_IPV6_ADDR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) own_querier_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) own_querier_enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) own_querier_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) return time_is_before_jiffies(querier->delay_time) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) (own_querier_enabled || timer_pending(&querier->timer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) static inline bool br_multicast_querier_exists(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) struct ethhdr *eth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) switch (eth->h_proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) case (htons(ETH_P_IP)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) return __br_multicast_querier_exists(br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) &br->ip4_other_query, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) case (htons(ETH_P_IPV6)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) return __br_multicast_querier_exists(br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) &br->ip6_other_query, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) static inline bool br_multicast_is_star_g(const struct br_ip *ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) switch (ip->proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) case htons(ETH_P_IP):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) return ipv4_is_zeronet(ip->src.ip4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) case htons(ETH_P_IPV6):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) return ipv6_addr_any(&ip->src.ip6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) static inline bool br_multicast_should_handle_mode(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) __be16 proto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) switch (proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) case htons(ETH_P_IP):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) return !!(br->multicast_igmp_version == 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) case htons(ETH_P_IPV6):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) return !!(br->multicast_mld_version == 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) static inline int br_multicast_igmp_type(const struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) return BR_INPUT_SKB_CB(skb)->igmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) static inline unsigned long br_multicast_lmqt(const struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) return br->multicast_last_member_interval *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) br->multicast_last_member_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) static inline unsigned long br_multicast_gmi(const struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) return br->multicast_membership_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) static inline int br_multicast_rcv(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) struct net_bridge_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) static inline struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) struct sk_buff *skb, u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) static inline int br_multicast_add_port(struct net_bridge_port *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) static inline void br_multicast_del_port(struct net_bridge_port *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) static inline void br_multicast_enable_port(struct net_bridge_port *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) static inline void br_multicast_disable_port(struct net_bridge_port *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) static inline void br_multicast_init(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) static inline void br_multicast_join_snoopers(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) static inline void br_multicast_leave_snoopers(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) static inline void br_multicast_open(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) static inline void br_multicast_stop(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) static inline void br_multicast_dev_del(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) static inline void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) bool local_rcv, bool local_orig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) static inline bool br_multicast_is_router(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) static inline bool br_multicast_querier_exists(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) struct ethhdr *eth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) static inline void br_mdb_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) static inline void br_mdb_uninit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) static inline int br_mdb_hash_init(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) static inline void br_mdb_hash_fini(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) static inline void br_multicast_count(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) const struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) u8 type, u8 dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) static inline int br_multicast_init_stats(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) static inline void br_multicast_uninit_stats(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) static inline int br_multicast_igmp_type(const struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) /* br_vlan.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) #ifdef CONFIG_BRIDGE_VLAN_FILTERING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) bool br_allowed_ingress(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) struct net_bridge_vlan_group *vg, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) u16 *vid, u8 *state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) bool br_allowed_egress(struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) const struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) struct sk_buff *br_handle_vlan(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) const struct net_bridge_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) bool *changed, struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) int br_vlan_delete(struct net_bridge *br, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) void br_vlan_flush(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) struct net_bridge_vlan *br_vlan_find(struct net_bridge_vlan_group *vg, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) void br_recalculate_fwd_mask(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) int __br_vlan_filter_toggle(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) int __br_vlan_set_proto(struct net_bridge *br, __be16 proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) int br_vlan_set_proto(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) int br_vlan_set_stats(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) int br_vlan_set_stats_per_port(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) int br_vlan_init(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) bool *changed, struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) void nbp_vlan_flush(struct net_bridge_port *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) int nbp_vlan_init(struct net_bridge_port *port, struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) int nbp_get_num_vlan_infos(struct net_bridge_port *p, u32 filter_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) void br_vlan_get_stats(const struct net_bridge_vlan *v,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) struct br_vlan_stats *stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) void br_vlan_port_event(struct net_bridge_port *p, unsigned long event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) int br_vlan_bridge_event(struct net_device *dev, unsigned long event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) void *ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) void br_vlan_rtnl_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) void br_vlan_rtnl_uninit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) void br_vlan_notify(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) u16 vid, u16 vid_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) const struct net_bridge_vlan *range_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) static inline struct net_bridge_vlan_group *br_vlan_group(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) const struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) return rtnl_dereference(br->vlgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) static inline struct net_bridge_vlan_group *nbp_vlan_group(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) const struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) return rtnl_dereference(p->vlgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) static inline struct net_bridge_vlan_group *br_vlan_group_rcu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) const struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) return rcu_dereference(br->vlgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) static inline struct net_bridge_vlan_group *nbp_vlan_group_rcu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) const struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) return rcu_dereference(p->vlgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) /* Since bridge now depends on 8021Q module, but the time bridge sees the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) * skb, the vlan tag will always be present if the frame was tagged.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) static inline int br_vlan_get_tag(const struct sk_buff *skb, u16 *vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) if (skb_vlan_tag_present(skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) *vid = skb_vlan_tag_get_id(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) *vid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) if (!vg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) smp_rmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) return vg->pvid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) static inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) return v->vid == pvid ? v->flags | BRIDGE_VLAN_INFO_PVID : v->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) static inline bool br_allowed_ingress(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) u16 *vid, u8 *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) static inline bool br_allowed_egress(struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) const struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) static inline bool br_should_learn(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) struct sk_buff *skb, u16 *vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) static inline struct sk_buff *br_handle_vlan(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) const struct net_bridge_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) static inline int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) bool *changed, struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) *changed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) static inline int br_vlan_delete(struct net_bridge *br, u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) static inline void br_vlan_flush(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) static inline void br_recalculate_fwd_mask(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) static inline int br_vlan_init(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) static inline int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) bool *changed, struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) *changed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) static inline int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) static inline void nbp_vlan_flush(struct net_bridge_port *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) static inline struct net_bridge_vlan *br_vlan_find(struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) static inline int nbp_vlan_init(struct net_bridge_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) static inline u16 br_vlan_get_tag(const struct sk_buff *skb, u16 *tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) static inline int __br_vlan_filter_toggle(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) unsigned long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) static inline int nbp_get_num_vlan_infos(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) u32 filter_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) static inline struct net_bridge_vlan_group *br_vlan_group(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) const struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) static inline struct net_bridge_vlan_group *nbp_vlan_group(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) const struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) static inline struct net_bridge_vlan_group *br_vlan_group_rcu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) const struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) static inline struct net_bridge_vlan_group *nbp_vlan_group_rcu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) const struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) static inline void br_vlan_get_stats(const struct net_bridge_vlan *v,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) struct br_vlan_stats *stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) static inline void br_vlan_port_event(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) unsigned long event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) static inline int br_vlan_bridge_event(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) static inline void br_vlan_rtnl_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) static inline void br_vlan_rtnl_uninit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) static inline void br_vlan_notify(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) u16 vid, u16 vid_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) static inline bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) const struct net_bridge_vlan *range_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) /* br_vlan_options.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) #ifdef CONFIG_BRIDGE_VLAN_FILTERING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) const struct net_bridge_vlan *range_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) size_t br_vlan_opts_nl_size(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) int br_vlan_process_options(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) struct net_bridge_vlan *range_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) struct net_bridge_vlan *range_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) struct nlattr **tb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) /* vlan state manipulation helpers using *_ONCE to annotate lock-free access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) static inline u8 br_vlan_get_state(const struct net_bridge_vlan *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) return READ_ONCE(v->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) static inline void br_vlan_set_state(struct net_bridge_vlan *v, u8 state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) WRITE_ONCE(v->state, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) static inline u8 br_vlan_get_pvid_state(const struct net_bridge_vlan_group *vg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) return READ_ONCE(vg->pvid_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) static inline void br_vlan_set_pvid_state(struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) u8 state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) WRITE_ONCE(vg->pvid_state, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) /* learn_allow is true at ingress and false at egress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) static inline bool br_vlan_state_allowed(u8 state, bool learn_allow)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) case BR_STATE_LEARNING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) return learn_allow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) case BR_STATE_FORWARDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) struct nf_br_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) int (*br_dev_xmit_hook)(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) extern const struct nf_br_ops __rcu *nf_br_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) /* br_netfilter.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) int br_nf_core_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) void br_nf_core_fini(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) void br_netfilter_rtable_init(struct net_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) static inline int br_nf_core_init(void) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) static inline void br_nf_core_fini(void) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) #define br_netfilter_rtable_init(x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) /* br_stp.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) void br_set_state(struct net_bridge_port *p, unsigned int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) void br_init_port(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) void br_become_designated_port(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) int br_set_forward_delay(struct net_bridge *br, unsigned long x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) int br_set_hello_time(struct net_bridge *br, unsigned long x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) int br_set_max_age(struct net_bridge *br, unsigned long x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) int __set_ageing_time(struct net_device *dev, unsigned long t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) /* br_stp_if.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) void br_stp_enable_bridge(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) void br_stp_disable_bridge(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) int br_stp_set_enabled(struct net_bridge *br, unsigned long val,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) void br_stp_enable_port(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) void br_stp_disable_port(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) bool br_stp_recalculate_bridge_id(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) int br_stp_set_path_cost(struct net_bridge_port *p, unsigned long path_cost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) ssize_t br_show_bridge_id(char *buf, const struct bridge_id *id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) /* br_stp_bpdu.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) struct stp_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) /* br_stp_timer.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) void br_stp_timer_init(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) void br_stp_port_timer_init(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) unsigned long br_timer_value(const struct timer_list *timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) /* br.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) #if IS_ENABLED(CONFIG_ATM_LANE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) extern int (*br_fdb_test_addr_hook)(struct net_device *dev, unsigned char *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) /* br_mrp.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) #if IS_ENABLED(CONFIG_BRIDGE_MRP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) struct nlattr *attr, int cmd, struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) int br_mrp_process(struct net_bridge_port *p, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) bool br_mrp_enabled(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) void br_mrp_port_del(struct net_bridge *br, struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) int br_mrp_fill_info(struct sk_buff *skb, struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) static inline int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) struct nlattr *attr, int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) static inline int br_mrp_process(struct net_bridge_port *p, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) static inline bool br_mrp_enabled(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) static inline void br_mrp_port_del(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) static inline int br_mrp_fill_info(struct sk_buff *skb, struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) /* br_netlink.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) extern struct rtnl_link_ops br_link_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) int br_netlink_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) void br_netlink_fini(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) void br_ifinfo_notify(int event, const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) const struct net_bridge_port *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) int br_setlink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) int br_dellink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) int br_getlink(struct sk_buff *skb, u32 pid, u32 seq, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) u32 filter_mask, int nlflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) int br_process_vlan_info(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) struct net_bridge_port *p, int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) struct bridge_vlan_info *vinfo_curr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) struct bridge_vlan_info **vinfo_last,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) bool *changed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) #ifdef CONFIG_SYSFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) /* br_sysfs_if.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) extern const struct sysfs_ops brport_sysfs_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) int br_sysfs_addif(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) int br_sysfs_renameif(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) /* br_sysfs_br.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) int br_sysfs_addbr(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) void br_sysfs_delbr(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) static inline int br_sysfs_addif(struct net_bridge_port *p) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) static inline int br_sysfs_renameif(struct net_bridge_port *p) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) static inline int br_sysfs_addbr(struct net_device *dev) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) static inline void br_sysfs_delbr(struct net_device *dev) { return; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) #endif /* CONFIG_SYSFS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) /* br_switchdev.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) #ifdef CONFIG_NET_SWITCHDEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) int nbp_switchdev_mark_set(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) void nbp_switchdev_frame_mark(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) const struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) int br_switchdev_set_port_flag(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) unsigned long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) unsigned long mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) void br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) struct netlink_ext_ack *extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) static inline void br_switchdev_frame_unmark(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) skb->offload_fwd_mark = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) static inline int nbp_switchdev_mark_set(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) static inline void nbp_switchdev_frame_mark(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) const struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) static inline int br_switchdev_set_port_flag(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) unsigned long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) unsigned long mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) static inline int br_switchdev_port_vlan_add(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) u16 vid, u16 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) static inline int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) static inline void br_switchdev_frame_unmark(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) #endif /* CONFIG_NET_SWITCHDEV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) /* br_arp_nd_proxy.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) void br_recalculate_neigh_suppress_enabled(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) u16 vid, struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) u16 vid, struct net_bridge_port *p, struct nd_msg *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb, struct nd_msg *m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) #endif