[RFC PATCH net-next 4/6] net: dsa: refuse cross-chip mirroring operations

From: Vladimir Oltean
Date: Fri Sep 13 2024 - 11:31:12 EST


These are not implemented but are not rejected either. Do so now.

Signed-off-by: Vladimir Oltean <vladimir.oltean@xxxxxxx>
---
net/dsa/user.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/net/dsa/user.c b/net/dsa/user.c
index 42ff3415c808..c8ddbe22d647 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -1401,6 +1401,14 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev,
if (!dsa_user_dev_check(act->dev))
return -EOPNOTSUPP;

+ to_dp = dsa_user_to_port(act->dev);
+
+ if (dp->ds != to_dp->ds) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Cross-chip mirroring not implemented");
+ return -EOPNOTSUPP;
+ }
+
mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
if (!mall_tc_entry)
return -ENOMEM;
@@ -1408,9 +1416,6 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev,
mall_tc_entry->cookie = cls->cookie;
mall_tc_entry->type = DSA_PORT_MALL_MIRROR;
mirror = &mall_tc_entry->mirror;
-
- to_dp = dsa_user_to_port(act->dev);
-
mirror->to_local_port = to_dp->index;
mirror->ingress = ingress;

--
2.34.1