Skip to content

Commit 8c92436

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dsa: refuse cross-chip mirroring operations
In case of a tc mirred action from one switch to another, the behavior is not correct. We simply tell the source switch driver to program a mirroring entry towards mirror->to_local_port = to_dp->index, but it is not even guaranteed that the to_dp belongs to the same switch as dp. For proper cross-chip support, we would need to go through the cross-chip notifier layer in switch.c, program the entry on cascade ports, and introduce new, explicit API for cross-chip mirroring, given that intermediary switches should have introspection into the DSA tags passed through the cascade port (and not just program a port mirror on the entire cascade port). None of that exists today. Reject what is not implemented so that user space is not misled into thinking it works. Fixes: f50f212 ("net: dsa: Add plumbing for port mirroring") Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6be0630 commit 8c92436

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

net/dsa/user.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,16 +1392,21 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev,
13921392
if (!dsa_user_dev_check(act->dev))
13931393
return -EOPNOTSUPP;
13941394

1395+
to_dp = dsa_user_to_port(act->dev);
1396+
1397+
if (dp->ds != to_dp->ds) {
1398+
NL_SET_ERR_MSG_MOD(extack,
1399+
"Cross-chip mirroring not implemented");
1400+
return -EOPNOTSUPP;
1401+
}
1402+
13951403
mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
13961404
if (!mall_tc_entry)
13971405
return -ENOMEM;
13981406

13991407
mall_tc_entry->cookie = cls->cookie;
14001408
mall_tc_entry->type = DSA_PORT_MALL_MIRROR;
14011409
mirror = &mall_tc_entry->mirror;
1402-
1403-
to_dp = dsa_user_to_port(act->dev);
1404-
14051410
mirror->to_local_port = to_dp->index;
14061411
mirror->ingress = ingress;
14071412

0 commit comments

Comments
 (0)