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 v4 01/14] net: mctp: don't use source cb data when forwarding, ensure pkt_type is set
Date: Fri, 27 Jun 2025 16:52:17 +0800 [thread overview]
Message-ID: <20250627-dev-forwarding-v4-1-72bb3cabc97c@codeconstruct.com.au> (raw)
In-Reply-To: <20250627-dev-forwarding-v4-0-72bb3cabc97c@codeconstruct.com.au>
In the output path, only check the skb->cb data when we know it's from
a local socket; input packets will have source address information there
instead.
In order to detect when we're forwarding, set skb->pkt_type on
input/output.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
net/mctp/route.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/net/mctp/route.c b/net/mctp/route.c
index d9c8e5a5f9ce9aefbf16730c65a1f54caa5592b9..128ac46dda5eb882994960b8c0eb671007ad8583 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -392,6 +392,9 @@ static int mctp_route_input(struct mctp_route *route, struct sk_buff *skb)
*/
skb_orphan(skb);
+ if (skb->pkt_type == PACKET_OUTGOING)
+ skb->pkt_type = PACKET_LOOPBACK;
+
/* ensure we have enough data for a header and a type */
if (skb->len < sizeof(struct mctp_hdr) + 1)
goto out;
@@ -578,7 +581,13 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)
return -EMSGSIZE;
}
- if (cb->ifindex) {
+ /* If we're forwarding, we don't want to use the input path's cb,
+ * as it holds the *source* hardware addressing information.
+ *
+ * We will have a PACKET_HOST skb from the dev, or PACKET_OUTGOING
+ * from a socket; only use cb in the latter case.
+ */
+ if (skb->pkt_type == PACKET_OUTGOING && cb->ifindex) {
/* direct route; use the hwaddr we stashed in sendmsg */
if (cb->halen != skb->dev->addr_len) {
/* sanity check, sendmsg should have already caught this */
@@ -587,6 +596,7 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)
}
daddr = cb->haddr;
} else {
+ skb->pkt_type = PACKET_OUTGOING;
/* If lookup fails let the device handle daddr==NULL */
if (mctp_neigh_lookup(route->dev, hdr->dest, daddr_buf) == 0)
daddr = daddr_buf;
@@ -1032,6 +1042,7 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
tag = req_tag & MCTP_TAG_MASK;
}
+ skb->pkt_type = PACKET_OUTGOING;
skb->protocol = htons(ETH_P_MCTP);
skb->priority = 0;
skb_reset_transport_header(skb);
--
2.39.5
next prev parent reply other threads:[~2025-06-27 8:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 8:52 [PATCH net-next v4 00/14] net: mctp: Add support for gateway routing Jeremy Kerr
2025-06-27 8:52 ` Jeremy Kerr [this message]
2025-06-27 8:52 ` [PATCH net-next v4 02/14] net: mctp: test: make cloned_frag buffers more appropriately-sized Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 03/14] net: mctp: separate routing database from routing operations Jeremy Kerr
2025-07-01 13:14 ` Paolo Abeni
2025-07-02 5:26 ` Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 04/14] net: mctp: separate cb from direct-addressing routing Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 05/14] net: mctp: test: Add an addressed device constructor Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 06/14] net: mctp: test: Add extaddr routing output test Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 07/14] net: mctp: test: move functions into utils.[ch] Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 08/14] net: mctp: test: add sock test infrastructure Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 09/14] net: mctp: test: Add initial socket tests Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 10/14] net: mctp: pass net into route creation Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 11/14] net: mctp: remove routes by netid, not by device Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 12/14] net: mctp: allow NL parsing directly into a struct mctp_route Jeremy Kerr
2025-07-01 13:20 ` Paolo Abeni
2025-07-02 5:28 ` Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 13/14] net: mctp: add gateway routing support Jeremy Kerr
2025-06-27 8:52 ` [PATCH net-next v4 14/14] net: mctp: test: Add tests for gateway routes Jeremy Kerr
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=20250627-dev-forwarding-v4-1-72bb3cabc97c@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.