summaryrefslogtreecommitdiff
path: root/net/mctp/route.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@codeconstruct.com.au>2025-07-02 14:20:01 +0800
committerPaolo Abeni <pabeni@redhat.com>2025-07-08 12:39:23 +0200
commite0f3c79cc0bbf4925de1afde5abf148b7f7f4398 (patch)
tree26967884feed65ed999873b938e21b2075e3446d /net/mctp/route.c
parent05cc60ef27c9b7fb46972223e04ef3f797940154 (diff)
net: mctp: don't use source cb data when forwarding, ensure pkt_type is set
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> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-1-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/mctp/route.c')
-rw-r--r--net/mctp/route.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/net/mctp/route.c b/net/mctp/route.c
index d9c8e5a5f9ce..128ac46dda5e 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);