net: bridge: switchdev: send FDB notifications for host addresses
authorTobias Waldekranz <tobias@waldekranz.com>
Tue, 29 Jun 2021 14:06:45 +0000 (17:06 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 Jun 2021 17:46:23 +0000 (10:46 -0700)
Treat addresses added to the bridge itself in the same way as regular
ports and send out a notification so that drivers may sync it down to
the hardware FDB.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_fdb.c
net/bridge/br_private.h
net/bridge/br_switchdev.c

index dc3ecf2..bad7e84 100644 (file)
@@ -607,7 +607,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
                        /* fastpath: update of existing entry */
                        if (unlikely(source != READ_ONCE(fdb->dst) &&
                                     !test_bit(BR_FDB_STICKY, &fdb->flags))) {
-                               br_switchdev_fdb_notify(fdb, RTM_DELNEIGH);
+                               br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
                                WRITE_ONCE(fdb->dst, source);
                                fdb_modified = true;
                                /* Take over HW learned entry */
@@ -800,7 +800,7 @@ static void fdb_notify(struct net_bridge *br,
        int err = -ENOBUFS;
 
        if (swdev_notify)
-               br_switchdev_fdb_notify(fdb, type);
+               br_switchdev_fdb_notify(br, fdb, type);
 
        skb = nlmsg_new(fdb_nlmsg_size(), GFP_ATOMIC);
        if (skb == NULL)
index a684d0c..2b48b20 100644 (file)
@@ -1654,8 +1654,8 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
                               unsigned long flags,
                               unsigned long mask,
                               struct netlink_ext_ack *extack);
-void br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb,
-                            int type);
+void br_switchdev_fdb_notify(struct net_bridge *br,
+                            const struct net_bridge_fdb_entry *fdb, int type);
 int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
                               struct netlink_ext_ack *extack);
 int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid);
@@ -1702,7 +1702,8 @@ static inline int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid)
 }
 
 static inline void
-br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
+br_switchdev_fdb_notify(struct net_bridge *br,
+                       const struct net_bridge_fdb_entry *fdb, int type)
 {
 }
 
index 192293f..d3adee0 100644 (file)
@@ -108,9 +108,11 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
 }
 
 void
-br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
+br_switchdev_fdb_notify(struct net_bridge *br,
+                       const struct net_bridge_fdb_entry *fdb, int type)
 {
        const struct net_bridge_port *dst = READ_ONCE(fdb->dst);
+       struct net_device *dev = dst ? dst->dev : br->dev;
        struct switchdev_notifier_fdb_info info = {
                .addr = fdb->key.addr.addr,
                .vid = fdb->key.vlan_id,
@@ -119,17 +121,14 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
                .offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
        };
 
-       if (!dst)
-               return;
-
        switch (type) {
        case RTM_DELNEIGH:
                call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
-                                        dst->dev, &info.info, NULL);
+                                        dev, &info.info, NULL);
                break;
        case RTM_NEWNEIGH:
                call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
-                                        dst->dev, &info.info, NULL);
+                                        dev, &info.info, NULL);
                break;
        }
 }