Loading include/linux/if_bridge.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __use typedef int br_should_route_hook_t(struct sk_buff *skb); extern br_should_route_hook_t __rcu *br_should_route_hook; extern struct net_device *br_port_dev_get(struct net_device *dev, unsigned char *addr); #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING) int br_multicast_list_adjacent(struct net_device *dev, Loading net/bridge/br_if.c +31 −0 Original line number Diff line number Diff line Loading @@ -655,3 +655,34 @@ void br_port_flags_change(struct net_bridge_port *p, unsigned long mask) if (mask & BR_AUTO_MASK) nbp_update_port_count(br); } /* br_port_dev_get() * Using the given addr, identify the port to which it is reachable, * returing a reference to the net device associated with that port. * * NOTE: Return NULL if given dev is not a bridge or * the mac has no associated port */ struct net_device *br_port_dev_get(struct net_device *dev, unsigned char *addr) { struct net_bridge_fdb_entry *fdbe; struct net_bridge *br; struct net_device *netdev = NULL; /* Is this a bridge? */ if (!(dev->priv_flags & IFF_EBRIDGE)) return NULL; br = netdev_priv(dev); /* Lookup the fdb entry and get reference to the port dev */ rcu_read_lock(); fdbe = __br_fdb_get(br, addr, 0); if (fdbe && fdbe->dst) { netdev = fdbe->dst->dev; /* port device */ dev_hold(netdev); } rcu_read_unlock(); return netdev; } EXPORT_SYMBOL(br_port_dev_get); Loading
include/linux/if_bridge.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __use typedef int br_should_route_hook_t(struct sk_buff *skb); extern br_should_route_hook_t __rcu *br_should_route_hook; extern struct net_device *br_port_dev_get(struct net_device *dev, unsigned char *addr); #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING) int br_multicast_list_adjacent(struct net_device *dev, Loading
net/bridge/br_if.c +31 −0 Original line number Diff line number Diff line Loading @@ -655,3 +655,34 @@ void br_port_flags_change(struct net_bridge_port *p, unsigned long mask) if (mask & BR_AUTO_MASK) nbp_update_port_count(br); } /* br_port_dev_get() * Using the given addr, identify the port to which it is reachable, * returing a reference to the net device associated with that port. * * NOTE: Return NULL if given dev is not a bridge or * the mac has no associated port */ struct net_device *br_port_dev_get(struct net_device *dev, unsigned char *addr) { struct net_bridge_fdb_entry *fdbe; struct net_bridge *br; struct net_device *netdev = NULL; /* Is this a bridge? */ if (!(dev->priv_flags & IFF_EBRIDGE)) return NULL; br = netdev_priv(dev); /* Lookup the fdb entry and get reference to the port dev */ rcu_read_lock(); fdbe = __br_fdb_get(br, addr, 0); if (fdbe && fdbe->dst) { netdev = fdbe->dst->dev; /* port device */ dev_hold(netdev); } rcu_read_unlock(); return netdev; } EXPORT_SYMBOL(br_port_dev_get);