Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  Linux ethernet bridge
0004  *
0005  *  Authors:
0006  *  Lennert Buytenhek       <buytenh@gnu.org>
0007  */
0008 #ifndef _LINUX_IF_BRIDGE_H
0009 #define _LINUX_IF_BRIDGE_H
0010 
0011 
0012 #include <linux/netdevice.h>
0013 #include <uapi/linux/if_bridge.h>
0014 #include <linux/bitops.h>
0015 
0016 struct br_ip {
0017     union {
0018         __be32  ip4;
0019 #if IS_ENABLED(CONFIG_IPV6)
0020         struct in6_addr ip6;
0021 #endif
0022     } src;
0023     union {
0024         __be32  ip4;
0025 #if IS_ENABLED(CONFIG_IPV6)
0026         struct in6_addr ip6;
0027 #endif
0028         unsigned char   mac_addr[ETH_ALEN];
0029     } dst;
0030     __be16      proto;
0031     __u16           vid;
0032 };
0033 
0034 struct br_ip_list {
0035     struct list_head list;
0036     struct br_ip addr;
0037 };
0038 
0039 #define BR_HAIRPIN_MODE     BIT(0)
0040 #define BR_BPDU_GUARD       BIT(1)
0041 #define BR_ROOT_BLOCK       BIT(2)
0042 #define BR_MULTICAST_FAST_LEAVE BIT(3)
0043 #define BR_ADMIN_COST       BIT(4)
0044 #define BR_LEARNING     BIT(5)
0045 #define BR_FLOOD        BIT(6)
0046 #define BR_AUTO_MASK        (BR_FLOOD | BR_LEARNING)
0047 #define BR_PROMISC      BIT(7)
0048 #define BR_PROXYARP     BIT(8)
0049 #define BR_LEARNING_SYNC    BIT(9)
0050 #define BR_PROXYARP_WIFI    BIT(10)
0051 #define BR_MCAST_FLOOD      BIT(11)
0052 #define BR_MULTICAST_TO_UNICAST BIT(12)
0053 #define BR_VLAN_TUNNEL      BIT(13)
0054 #define BR_BCAST_FLOOD      BIT(14)
0055 #define BR_NEIGH_SUPPRESS   BIT(15)
0056 #define BR_ISOLATED     BIT(16)
0057 #define BR_MRP_AWARE        BIT(17)
0058 #define BR_MRP_LOST_CONT    BIT(18)
0059 #define BR_MRP_LOST_IN_CONT BIT(19)
0060 #define BR_TX_FWD_OFFLOAD   BIT(20)
0061 #define BR_PORT_LOCKED      BIT(21)
0062 
0063 #define BR_DEFAULT_AGEING_TIME  (300 * HZ)
0064 
0065 struct net_bridge;
0066 void brioctl_set(int (*hook)(struct net *net, struct net_bridge *br,
0067                  unsigned int cmd, struct ifreq *ifr,
0068                  void __user *uarg));
0069 int br_ioctl_call(struct net *net, struct net_bridge *br, unsigned int cmd,
0070           struct ifreq *ifr, void __user *uarg);
0071 
0072 #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING)
0073 int br_multicast_list_adjacent(struct net_device *dev,
0074                    struct list_head *br_ip_list);
0075 bool br_multicast_has_querier_anywhere(struct net_device *dev, int proto);
0076 bool br_multicast_has_querier_adjacent(struct net_device *dev, int proto);
0077 bool br_multicast_has_router_adjacent(struct net_device *dev, int proto);
0078 bool br_multicast_enabled(const struct net_device *dev);
0079 bool br_multicast_router(const struct net_device *dev);
0080 #else
0081 static inline int br_multicast_list_adjacent(struct net_device *dev,
0082                          struct list_head *br_ip_list)
0083 {
0084     return 0;
0085 }
0086 static inline bool br_multicast_has_querier_anywhere(struct net_device *dev,
0087                              int proto)
0088 {
0089     return false;
0090 }
0091 static inline bool br_multicast_has_querier_adjacent(struct net_device *dev,
0092                              int proto)
0093 {
0094     return false;
0095 }
0096 
0097 static inline bool br_multicast_has_router_adjacent(struct net_device *dev,
0098                             int proto)
0099 {
0100     return true;
0101 }
0102 
0103 static inline bool br_multicast_enabled(const struct net_device *dev)
0104 {
0105     return false;
0106 }
0107 static inline bool br_multicast_router(const struct net_device *dev)
0108 {
0109     return false;
0110 }
0111 #endif
0112 
0113 #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_VLAN_FILTERING)
0114 bool br_vlan_enabled(const struct net_device *dev);
0115 int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid);
0116 int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid);
0117 int br_vlan_get_proto(const struct net_device *dev, u16 *p_proto);
0118 int br_vlan_get_info(const struct net_device *dev, u16 vid,
0119              struct bridge_vlan_info *p_vinfo);
0120 int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid,
0121              struct bridge_vlan_info *p_vinfo);
0122 bool br_mst_enabled(const struct net_device *dev);
0123 int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids);
0124 int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state);
0125 #else
0126 static inline bool br_vlan_enabled(const struct net_device *dev)
0127 {
0128     return false;
0129 }
0130 
0131 static inline int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
0132 {
0133     return -EINVAL;
0134 }
0135 
0136 static inline int br_vlan_get_proto(const struct net_device *dev, u16 *p_proto)
0137 {
0138     return -EINVAL;
0139 }
0140 
0141 static inline int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid)
0142 {
0143     return -EINVAL;
0144 }
0145 
0146 static inline int br_vlan_get_info(const struct net_device *dev, u16 vid,
0147                    struct bridge_vlan_info *p_vinfo)
0148 {
0149     return -EINVAL;
0150 }
0151 
0152 static inline int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid,
0153                        struct bridge_vlan_info *p_vinfo)
0154 {
0155     return -EINVAL;
0156 }
0157 
0158 static inline bool br_mst_enabled(const struct net_device *dev)
0159 {
0160     return false;
0161 }
0162 
0163 static inline int br_mst_get_info(const struct net_device *dev, u16 msti,
0164                   unsigned long *vids)
0165 {
0166     return -EINVAL;
0167 }
0168 static inline int br_mst_get_state(const struct net_device *dev, u16 msti,
0169                    u8 *state)
0170 {
0171     return -EINVAL;
0172 }
0173 #endif
0174 
0175 #if IS_ENABLED(CONFIG_BRIDGE)
0176 struct net_device *br_fdb_find_port(const struct net_device *br_dev,
0177                     const unsigned char *addr,
0178                     __u16 vid);
0179 void br_fdb_clear_offload(const struct net_device *dev, u16 vid);
0180 bool br_port_flag_is_set(const struct net_device *dev, unsigned long flag);
0181 u8 br_port_get_stp_state(const struct net_device *dev);
0182 clock_t br_get_ageing_time(const struct net_device *br_dev);
0183 #else
0184 static inline struct net_device *
0185 br_fdb_find_port(const struct net_device *br_dev,
0186          const unsigned char *addr,
0187          __u16 vid)
0188 {
0189     return NULL;
0190 }
0191 
0192 static inline void br_fdb_clear_offload(const struct net_device *dev, u16 vid)
0193 {
0194 }
0195 
0196 static inline bool
0197 br_port_flag_is_set(const struct net_device *dev, unsigned long flag)
0198 {
0199     return false;
0200 }
0201 
0202 static inline u8 br_port_get_stp_state(const struct net_device *dev)
0203 {
0204     return BR_STATE_DISABLED;
0205 }
0206 
0207 static inline clock_t br_get_ageing_time(const struct net_device *br_dev)
0208 {
0209     return 0;
0210 }
0211 #endif
0212 
0213 #endif