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

Configure Feed

Select the types of activity you want to include in your feed.

net: mctp: separate cb from direct-addressing routing

Now that we have the dst->haddr populated by sendmsg (when extended
addressing is in use), we no longer need to stash the link-layer address
in the skb->cb.

Instead, only use skb->cb for incoming lladdr data.

While we're at it: remove cb->src, as was never used.

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

authored by

Jeremy Kerr and committed by
Paolo Abeni
3007f90e 269936db

+7 -18
+2 -2
include/net/mctp.h
··· 183 183 struct mctp_skb_cb { 184 184 unsigned int magic; 185 185 unsigned int net; 186 - int ifindex; /* extended/direct addressing if set */ 187 - mctp_eid_t src; 186 + /* fields below provide extended addressing for ingress to recvmsg() */ 187 + int ifindex; 188 188 unsigned char halen; 189 189 unsigned char haddr[MAX_ADDR_LEN]; 190 190 };
+5 -16
net/mctp/route.c
··· 561 561 562 562 static int mctp_dst_output(struct mctp_dst *dst, struct sk_buff *skb) 563 563 { 564 - struct mctp_skb_cb *cb = mctp_cb(skb); 565 564 struct mctp_hdr *hdr = mctp_hdr(skb); 566 565 char daddr_buf[MAX_ADDR_LEN]; 567 566 char *daddr = NULL; 568 567 int rc; 569 568 570 569 skb->protocol = htons(ETH_P_MCTP); 570 + skb->pkt_type = PACKET_OUTGOING; 571 571 572 572 if (skb->len > dst->mtu) { 573 573 kfree_skb(skb); 574 574 return -EMSGSIZE; 575 575 } 576 576 577 - /* If we're forwarding, we don't want to use the input path's cb, 578 - * as it holds the *source* hardware addressing information. 579 - * 580 - * We will have a PACKET_HOST skb from the dev, or PACKET_OUTGOING 581 - * from a socket; only use cb in the latter case. 582 - */ 583 - if (skb->pkt_type == PACKET_OUTGOING && cb->ifindex) { 584 - /* direct route; use the hwaddr we stashed in sendmsg */ 585 - if (cb->halen != skb->dev->addr_len) { 577 + /* direct route; use the hwaddr we stashed in sendmsg */ 578 + if (dst->halen) { 579 + if (dst->halen != skb->dev->addr_len) { 586 580 /* sanity check, sendmsg should have already caught this */ 587 581 kfree_skb(skb); 588 582 return -EMSGSIZE; 589 583 } 590 - daddr = cb->haddr; 584 + daddr = dst->haddr; 591 585 } else { 592 - skb->pkt_type = PACKET_OUTGOING; 593 586 /* If lookup fails let the device handle daddr==NULL */ 594 587 if (mctp_neigh_lookup(dst->dev, hdr->dest, daddr_buf) == 0) 595 588 daddr = daddr_buf; ··· 1002 1009 struct sk_buff *skb, mctp_eid_t daddr, u8 req_tag) 1003 1010 { 1004 1011 struct mctp_sock *msk = container_of(sk, struct mctp_sock, sk); 1005 - struct mctp_skb_cb *cb = mctp_cb(skb); 1006 1012 struct mctp_sk_key *key; 1007 1013 struct mctp_hdr *hdr; 1008 1014 unsigned long flags; ··· 1055 1063 skb_push(skb, sizeof(struct mctp_hdr)); 1056 1064 skb_reset_network_header(skb); 1057 1065 skb->dev = dst->dev->dev; 1058 - 1059 - /* cb->net will have been set on initial ingress */ 1060 - cb->src = saddr; 1061 1066 1062 1067 /* set up common header fields */ 1063 1068 hdr = mctp_hdr(skb);