kernel: bump 5.10 to 5.10.27
[openwrt/staging/jow.git] / target / linux / generic / pending-5.10 / 764-net-bridge-switchdev-Send-FDB-notifications-for-host.patch
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
5 addresses
6
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
9 the hardware FDB.
10
11 Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
12 ---
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(-)
17
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);
26 fdb->dst = source;
27 fdb_modified = true;
28 /* Take over HW learned entry */
29 @@ -735,7 +735,7 @@ static void fdb_notify(struct net_bridge
30 int err = -ENOBUFS;
31
32 if (swdev_notify)
33 - br_switchdev_fdb_notify(fdb, type);
34 + br_switchdev_fdb_notify(br, fdb, type);
35
36 skb = nlmsg_new(fdb_nlmsg_size(), GFP_ATOMIC);
37 if (skb == NULL)
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,
42 unsigned long flags,
43 unsigned long mask);
44 -void br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb,
45 - int type);
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
52 }
53
54 static inline void
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)
58 {
59 }
60
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
64 }
65
66 void
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)
70 {
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),
76 };
77 + struct net_device *dev = fdb->dst ? fdb->dst->dev : br->dev;
78
79 - if (!fdb->dst)
80 - return;
81 if (test_bit(BR_FDB_LOCAL, &fdb->flags))
82 return;
83
84 switch (type) {
85 case RTM_DELNEIGH:
86 call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
87 - fdb->dst->dev, &info.info, NULL);
88 + dev, &info.info, NULL);
89 break;
90 case RTM_NEWNEIGH:
91 call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
92 - fdb->dst->dev, &info.info, NULL);
93 + dev, &info.info, NULL);
94 break;
95 }
96 }