]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: mctp: remove routes by netid, not by device
authorJeremy Kerr <jk@codeconstruct.com.au>
Wed, 2 Jul 2025 06:20:11 +0000 (14:20 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 8 Jul 2025 10:39:24 +0000 (12:39 +0200)
In upcoming changes, a route may not have a device associated. Since the
route is matched on the (network, eid) tuple, pass the netid itself into
mctp_route_remove.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Link: https://patch.msgid.link/20250702-dev-forwarding-v5-11-1468191da8a4@codeconstruct.com.au
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/mctp/route.c

index 66395f782759b6a2131342fda099fe5d7cdc4c38..f96265acf16f4ecedad7a3edf2367cfc7f56be7f 100644 (file)
@@ -1085,6 +1085,11 @@ out_release:
        return rc;
 }
 
+static unsigned int mctp_route_netid(struct mctp_route *rt)
+{
+       return rt->dev->net;
+}
+
 /* route management */
 static int mctp_route_add(struct net *net, struct mctp_dev *mdev,
                          mctp_eid_t daddr_start, unsigned int daddr_extent,
@@ -1137,7 +1142,7 @@ static int mctp_route_add(struct net *net, struct mctp_dev *mdev,
        return 0;
 }
 
-static int mctp_route_remove(struct net *net, struct mctp_dev *mdev,
+static int mctp_route_remove(struct net *net, unsigned int netid,
                             mctp_eid_t daddr_start, unsigned int daddr_extent,
                             unsigned char type)
 {
@@ -1154,7 +1159,7 @@ static int mctp_route_remove(struct net *net, struct mctp_dev *mdev,
        ASSERT_RTNL();
 
        list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) {
-               if (rt->dev == mdev &&
+               if (mctp_route_netid(rt) == netid &&
                    rt->min == daddr_start && rt->max == daddr_end &&
                    rt->type == type) {
                        list_del_rcu(&rt->list);
@@ -1174,7 +1179,8 @@ int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr)
 
 int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr)
 {
-       return mctp_route_remove(dev_net(mdev->dev), mdev, addr, 0, RTN_LOCAL);
+       return mctp_route_remove(dev_net(mdev->dev), mdev->net,
+                                addr, 0, RTN_LOCAL);
 }
 
 /* removes all entries for a given device */
@@ -1394,7 +1400,7 @@ static int mctp_delroute(struct sk_buff *skb, struct nlmsghdr *nlh,
        if (rtm->rtm_type != RTN_UNICAST)
                return -EINVAL;
 
-       rc = mctp_route_remove(net, mdev, daddr_start, rtm->rtm_dst_len,
+       rc = mctp_route_remove(net, mdev->net, daddr_start, rtm->rtm_dst_len,
                               RTN_UNICAST);
        return rc;
 }