kernel: bump 5.10 to 5.10.27
[openwrt/staging/jow.git] / target / linux / generic / pending-5.10 / 762-net-bridge-switchdev-Refactor-br_switchdev_fdb_notif.patch
1 From 46fe6cecb296d850c1ee2b333e57093ac4b733f3 Mon Sep 17 00:00:00 2001
2 From: Tobias Waldekranz <tobias@waldekranz.com>
3 Date: Sat, 16 Jan 2021 02:25:09 +0100
4 Subject: [PATCH] net: bridge: switchdev: Refactor br_switchdev_fdb_notify
5
6 Instead of having to add more and more arguments to
7 br_switchdev_fdb_call_notifiers, get rid of it and build the info
8 struct directly in br_switchdev_fdb_notify.
9
10 Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
11 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
12 ---
13 net/bridge/br_switchdev.c | 41 +++++++++++----------------------------
14 1 file changed, 11 insertions(+), 30 deletions(-)
15
16 --- a/net/bridge/br_switchdev.c
17 +++ b/net/bridge/br_switchdev.c
18 @@ -102,25 +102,16 @@ int br_switchdev_set_port_flag(struct ne
19 return 0;
20 }
21
22 -static void
23 -br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
24 - u16 vid, struct net_device *dev,
25 - bool added_by_user, bool offloaded)
26 -{
27 - struct switchdev_notifier_fdb_info info;
28 - unsigned long notifier_type;
29 -
30 - info.addr = mac;
31 - info.vid = vid;
32 - info.added_by_user = added_by_user;
33 - info.offloaded = offloaded;
34 - notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_DEVICE : SWITCHDEV_FDB_DEL_TO_DEVICE;
35 - call_switchdev_notifiers(notifier_type, dev, &info.info, NULL);
36 -}
37 -
38 void
39 br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
40 {
41 + struct switchdev_notifier_fdb_info info = {
42 + .addr = fdb->key.addr.addr,
43 + .vid = fdb->key.vlan_id,
44 + .added_by_user = test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags),
45 + .offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
46 + };
47 +
48 if (!fdb->dst)
49 return;
50 if (test_bit(BR_FDB_LOCAL, &fdb->flags))
51 @@ -128,22 +119,12 @@ br_switchdev_fdb_notify(const struct net
52
53 switch (type) {
54 case RTM_DELNEIGH:
55 - br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr,
56 - fdb->key.vlan_id,
57 - fdb->dst->dev,
58 - test_bit(BR_FDB_ADDED_BY_USER,
59 - &fdb->flags),
60 - test_bit(BR_FDB_OFFLOADED,
61 - &fdb->flags));
62 + call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
63 + fdb->dst->dev, &info.info, NULL);
64 break;
65 case RTM_NEWNEIGH:
66 - br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
67 - fdb->key.vlan_id,
68 - fdb->dst->dev,
69 - test_bit(BR_FDB_ADDED_BY_USER,
70 - &fdb->flags),
71 - test_bit(BR_FDB_OFFLOADED,
72 - &fdb->flags));
73 + call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
74 + fdb->dst->dev, &info.info, NULL);
75 break;
76 }
77 }