1 From 2e50fd9322047253c327550b4485cf8761035a8c Mon Sep 17 00:00:00 2001
2 From: Tobias Waldekranz <tobias@waldekranz.com>
3 Date: Sat, 16 Jan 2021 02:25:11 +0100
4 Subject: [PATCH] net: bridge: switchdev: Send FDB notifications for host
7 Treat addresses added to the bridge itself in the same way as regular
8 ports and send out a notification so that drivers may sync it down to
11 Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
13 net/bridge/br_fdb.c | 4 ++--
14 net/bridge/br_private.h | 7 ++++---
15 net/bridge/br_switchdev.c | 11 +++++------
16 3 files changed, 11 insertions(+), 11 deletions(-)
18 --- a/net/bridge/br_fdb.c
19 +++ b/net/bridge/br_fdb.c
20 @@ -602,7 +602,7 @@ void br_fdb_update(struct net_bridge *br
21 /* fastpath: update of existing entry */
22 if (unlikely(source != fdb->dst &&
23 !test_bit(BR_FDB_STICKY, &fdb->flags))) {
24 - br_switchdev_fdb_notify(fdb, RTM_DELNEIGH);
25 + br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
28 /* Take over HW learned entry */
29 @@ -735,7 +735,7 @@ static void fdb_notify(struct net_bridge
33 - br_switchdev_fdb_notify(fdb, type);
34 + br_switchdev_fdb_notify(br, fdb, type);
36 skb = nlmsg_new(fdb_nlmsg_size(), GFP_ATOMIC);
38 --- a/net/bridge/br_private.h
39 +++ b/net/bridge/br_private.h
40 @@ -1527,8 +1527,8 @@ bool nbp_switchdev_allowed_egress(const
41 int br_switchdev_set_port_flag(struct net_bridge_port *p,
44 -void br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb,
46 +void br_switchdev_fdb_notify(struct net_bridge *br,
47 + const struct net_bridge_fdb_entry *fdb, int type);
48 int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
49 struct netlink_ext_ack *extack);
50 int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid);
51 @@ -1574,7 +1574,8 @@ static inline int br_switchdev_port_vlan
55 -br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
56 +br_switchdev_fdb_notify(struct net_bridge *br,
57 + const struct net_bridge_fdb_entry *fdb, int type)
61 --- a/net/bridge/br_switchdev.c
62 +++ b/net/bridge/br_switchdev.c
63 @@ -103,7 +103,8 @@ int br_switchdev_set_port_flag(struct ne
67 -br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
68 +br_switchdev_fdb_notify(struct net_bridge *br,
69 + const struct net_bridge_fdb_entry *fdb, int type)
71 struct switchdev_notifier_fdb_info info = {
72 .addr = fdb->key.addr.addr,
73 @@ -112,20 +113,19 @@ br_switchdev_fdb_notify(const struct net
74 .local = test_bit(BR_FDB_LOCAL, &fdb->flags),
75 .offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
77 + struct net_device *dev = fdb->dst ? fdb->dst->dev : br->dev;
81 if (test_bit(BR_FDB_LOCAL, &fdb->flags))
86 call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
87 - fdb->dst->dev, &info.info, NULL);
88 + dev, &info.info, NULL);
91 call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
92 - fdb->dst->dev, &info.info, NULL);
93 + dev, &info.info, NULL);