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
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.
10 Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
11 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
13 net/bridge/br_switchdev.c | 41 +++++++++++----------------------------
14 1 file changed, 11 insertions(+), 30 deletions(-)
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
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)
27 - struct switchdev_notifier_fdb_info info;
28 - unsigned long notifier_type;
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);
39 br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
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),
50 if (test_bit(BR_FDB_LOCAL, &fdb->flags))
51 @@ -128,22 +119,12 @@ br_switchdev_fdb_notify(const struct net
55 - br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr,
58 - test_bit(BR_FDB_ADDED_BY_USER,
60 - test_bit(BR_FDB_OFFLOADED,
62 + call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
63 + fdb->dst->dev, &info.info, NULL);
66 - br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
69 - test_bit(BR_FDB_ADDED_BY_USER,
71 - test_bit(BR_FDB_OFFLOADED,
73 + call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
74 + fdb->dst->dev, &info.info, NULL);