Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mctp: remove routes by netid, not by device

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>

authored by

Jeremy Kerr and committed by
Paolo Abeni
4a1de053 48e6aa60

+10 -4
+10 -4
net/mctp/route.c
··· 1085 1085 return rc; 1086 1086 } 1087 1087 1088 + static unsigned int mctp_route_netid(struct mctp_route *rt) 1089 + { 1090 + return rt->dev->net; 1091 + } 1092 + 1088 1093 /* route management */ 1089 1094 static int mctp_route_add(struct net *net, struct mctp_dev *mdev, 1090 1095 mctp_eid_t daddr_start, unsigned int daddr_extent, ··· 1142 1137 return 0; 1143 1138 } 1144 1139 1145 - static int mctp_route_remove(struct net *net, struct mctp_dev *mdev, 1140 + static int mctp_route_remove(struct net *net, unsigned int netid, 1146 1141 mctp_eid_t daddr_start, unsigned int daddr_extent, 1147 1142 unsigned char type) 1148 1143 { ··· 1159 1154 ASSERT_RTNL(); 1160 1155 1161 1156 list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { 1162 - if (rt->dev == mdev && 1157 + if (mctp_route_netid(rt) == netid && 1163 1158 rt->min == daddr_start && rt->max == daddr_end && 1164 1159 rt->type == type) { 1165 1160 list_del_rcu(&rt->list); ··· 1179 1174 1180 1175 int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr) 1181 1176 { 1182 - return mctp_route_remove(dev_net(mdev->dev), mdev, addr, 0, RTN_LOCAL); 1177 + return mctp_route_remove(dev_net(mdev->dev), mdev->net, 1178 + addr, 0, RTN_LOCAL); 1183 1179 } 1184 1180 1185 1181 /* removes all entries for a given device */ ··· 1400 1394 if (rtm->rtm_type != RTN_UNICAST) 1401 1395 return -EINVAL; 1402 1396 1403 - rc = mctp_route_remove(net, mdev, daddr_start, rtm->rtm_dst_len, 1397 + rc = mctp_route_remove(net, mdev->net, daddr_start, rtm->rtm_dst_len, 1404 1398 RTN_UNICAST); 1405 1399 return rc; 1406 1400 }