Skip to content

Commit 816a3be

Browse files
pmachatadavem330
authored andcommitted
switchdev: Add fdb.added_by_user to switchdev notifications
The following patch enables sending notifications also for events on FDB entries that weren't added by the user. Give the drivers the information necessary to distinguish between the two origins of FDB entries. To maintain the current behavior, have switchdev-implementing drivers bail out on notifications about non-user-added FDB entries. In case of mlxsw driver, allow a call to mlxsw_sp_span_respin() so that SPAN over bridge catches up with the changed FDB. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Acked-by: Ivan Vecera <ivecera@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0e913f2 commit 816a3be

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,8 @@ static void mlxsw_sp_switchdev_event_work(struct work_struct *work)
22702270
switch (switchdev_work->event) {
22712271
case SWITCHDEV_FDB_ADD_TO_DEVICE:
22722272
fdb_info = &switchdev_work->fdb_info;
2273+
if (!fdb_info->added_by_user)
2274+
break;
22732275
err = mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, true);
22742276
if (err)
22752277
break;
@@ -2279,6 +2281,8 @@ static void mlxsw_sp_switchdev_event_work(struct work_struct *work)
22792281
break;
22802282
case SWITCHDEV_FDB_DEL_TO_DEVICE:
22812283
fdb_info = &switchdev_work->fdb_info;
2284+
if (!fdb_info->added_by_user)
2285+
break;
22822286
mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, false);
22832287
break;
22842288
case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */

drivers/net/ethernet/rocker/rocker_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,6 +2783,8 @@ static int rocker_switchdev_event(struct notifier_block *unused,
27832783
switch (event) {
27842784
case SWITCHDEV_FDB_ADD_TO_DEVICE: /* fall through */
27852785
case SWITCHDEV_FDB_DEL_TO_DEVICE:
2786+
if (!fdb_info->added_by_user)
2787+
break;
27862788
memcpy(&switchdev_work->fdb_info, ptr,
27872789
sizeof(switchdev_work->fdb_info));
27882790
switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC);

include/net/switchdev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct switchdev_notifier_fdb_info {
155155
struct switchdev_notifier_info info; /* must be first */
156156
const unsigned char *addr;
157157
u16 vid;
158+
bool added_by_user;
158159
};
159160

160161
static inline struct net_device *

net/bridge/br_switchdev.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
102102

103103
static void
104104
br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
105-
u16 vid, struct net_device *dev)
105+
u16 vid, struct net_device *dev,
106+
bool added_by_user)
106107
{
107108
struct switchdev_notifier_fdb_info info;
108109
unsigned long notifier_type;
109110

110111
info.addr = mac;
111112
info.vid = vid;
113+
info.added_by_user = added_by_user;
112114
notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_DEVICE : SWITCHDEV_FDB_DEL_TO_DEVICE;
113115
call_switchdev_notifiers(notifier_type, dev, &info.info);
114116
}
@@ -123,12 +125,14 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
123125
case RTM_DELNEIGH:
124126
br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr,
125127
fdb->key.vlan_id,
126-
fdb->dst->dev);
128+
fdb->dst->dev,
129+
fdb->added_by_user);
127130
break;
128131
case RTM_NEWNEIGH:
129132
br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
130133
fdb->key.vlan_id,
131-
fdb->dst->dev);
134+
fdb->dst->dev,
135+
fdb->added_by_user);
132136
break;
133137
}
134138
}

net/dsa/slave.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
14411441
unsigned long event, void *ptr)
14421442
{
14431443
struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
1444+
struct switchdev_notifier_fdb_info *fdb_info = ptr;
14441445
struct dsa_switchdev_event_work *switchdev_work;
14451446

14461447
if (!dsa_slave_dev_check(dev))
@@ -1458,8 +1459,10 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
14581459
switch (event) {
14591460
case SWITCHDEV_FDB_ADD_TO_DEVICE: /* fall through */
14601461
case SWITCHDEV_FDB_DEL_TO_DEVICE:
1462+
if (!fdb_info->added_by_user)
1463+
break;
14611464
if (dsa_slave_switchdev_fdb_work_init(switchdev_work,
1462-
ptr))
1465+
fdb_info))
14631466
goto err_fdb_work_init;
14641467
dev_hold(dev);
14651468
break;

0 commit comments

Comments
 (0)