All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Matt Johnston <matt@codeconstruct.com.au>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,  Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next v5 11/14] net: mctp: remove routes by netid, not by device
Date: Wed, 02 Jul 2025 14:20:11 +0800	[thread overview]
Message-ID: <20250702-dev-forwarding-v5-11-1468191da8a4@codeconstruct.com.au> (raw)
In-Reply-To: <20250702-dev-forwarding-v5-0-1468191da8a4@codeconstruct.com.au>

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>
---
 net/mctp/route.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/mctp/route.c b/net/mctp/route.c
index 66395f782759b6a2131342fda099fe5d7cdc4c38..f96265acf16f4ecedad7a3edf2367cfc7f56be7f 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -1085,6 +1085,11 @@ int mctp_local_output(struct sock *sk, struct mctp_dst *dst,
 	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;
 }

-- 
2.39.5


  parent reply	other threads:[~2025-07-02  6:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02  6:20 [PATCH net-next v5 00/14] net: mctp: Add support for gateway routing Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 01/14] net: mctp: don't use source cb data when forwarding, ensure pkt_type is set Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 02/14] net: mctp: test: make cloned_frag buffers more appropriately-sized Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 03/14] net: mctp: separate routing database from routing operations Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 04/14] net: mctp: separate cb from direct-addressing routing Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 05/14] net: mctp: test: Add an addressed device constructor Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 06/14] net: mctp: test: Add extaddr routing output test Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 07/14] net: mctp: test: move functions into utils.[ch] Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 08/14] net: mctp: test: add sock test infrastructure Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 09/14] net: mctp: test: Add initial socket tests Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 10/14] net: mctp: pass net into route creation Jeremy Kerr
2025-07-02  6:20 ` Jeremy Kerr [this message]
2025-07-02  6:20 ` [PATCH net-next v5 12/14] net: mctp: allow NL parsing directly into a struct mctp_route Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 13/14] net: mctp: add gateway routing support Jeremy Kerr
2025-07-02  6:20 ` [PATCH net-next v5 14/14] net: mctp: test: Add tests for gateway routes Jeremy Kerr
2025-07-08 11:00 ` [PATCH net-next v5 00/14] net: mctp: Add support for gateway routing patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250702-dev-forwarding-v5-11-1468191da8a4@codeconstruct.com.au \
    --to=jk@codeconstruct.com.au \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=matt@codeconstruct.com.au \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.