MCTP fixes
Matt Johnston
maintainerPATCH 1/3 mctp: Fix check for dev_hard_header() result
In reply to Matt Johnstondev_hard_header() returns the length of the header, so we need to test for negative errors rather than non-zero.
--- net/mctp/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mctp/route.c +1 -1
@@ -512,7 +512,7 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb) rc =dev_hard_header (skb, skb->dev,ntohs (skb->protocol), daddr, skb->dev->dev_addr, skb->len); -if (rc) { +if (rc <0 ) {kfree_skb (skb);return -EHOSTUNREACH ; }
Signature · 1 line
2.32.0
Matt Johnston
maintainerPATCH 2/3 mctp i2c: correct mctp_i2c_header_create result
In reply to Matt Johnstonheader_ops.create should return the length of the header, instead mctp_i2c_head_create() returned 0.
This didn't cause any problem because the MCTP stack accepted 0 as success.
--- drivers/net/mctp/mctp-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mctp/mctp-i2c.c +1 -1
@@ -553,7 +553,7 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev, hdr->source_slave = ((llsrc <<1 ) &0xff ) |0x01 ; mhdr->ver =0x01 ; -return 0 ; +return sizeof (struct mctp_i2c_hdr ); }static int mctp_i2c_tx_thread (void *data)
Signature · 1 line
2.32.0
Matt Johnston
maintainercover MCTP fixes
Hi,
The following are fixes for the mctp core and mctp-i2c driver.
Thanks,
Matt
Matt Johnston (3):
mctp: Fix check for dev_hard_header() result mctp i2c: correct mctp_i2c_header_create result
mctp: Use output netdev to allocate skb headroom
drivers/net/mctp/mctp-i2c.c | 2 +- include/net/mctp.h | 2 -- net/mctp/af_mctp.c | 46 ++++++++++++++++++++++++++----------- net/mctp/route.c | 16 +++++++++---- 4 files changed, 46 insertions(+), 20 deletions(-)
Signature · 1 line
2.32.0
Matt Johnston
maintainerPATCH 3/3 mctp: Use output netdev to allocate skb headroom
Previously the skb was allocated with headroom MCTP_HEADER_MAXLEN, but that isn't sufficient if we are using devs that are not MCTP specific.
This also adds a check that the smctp_halen provided to sendmsg for extended addressing is the correct size for the netdev.
--- include/net/mctp.h | 2 -- net/mctp/af_mctp.c | 46 +++++++++++++++++++++++++++++++++------------- net/mctp/route.c | 14 +++++++++++--- 3 files changed, 44 insertions(+), 18 deletions(-)
include/net/mctp.h +0 -2
@@ -36,8 +36,6 @@ struct mctp_hdr {#define MCTP_HDR_TAG_SHIFT 0#define MCTP_HDR_TAG_MASK GENMASK(2, 0) -#define MCTP_HEADER_MAXLEN 4 -#define MCTP_INITIAL_DEFAULT_NET 1static inline bool mctp_address_unicast (mctp_eid_t eid)
net/mctp/af_mctp.c +33 -13
77 lines not on this page · raw message
net/mctp/route.c +11 -3
@@ -503,6 +503,11 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)if (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 */ +kfree_skb (skb); +return -EMSGSIZE ; + } daddr = cb->haddr; }else {/* If lookup fails let the device handle daddr==NULL */
@@ -756,7 +761,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb, {const unsigned int hlen =sizeof (struct mctp_hdr );struct mctp_hdr *hdr, *hdr2; -unsigned int pos, size; +unsigned int pos, size, headroom;struct sk_buff *skb2;int rc;u8 seq;
@@ -770,6 +775,9 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,return -EMSGSIZE ; } +/* keep same headroom as the original skb */ + headroom =skb_headroom (skb); +/* we've got the header */ skb_pull (skb, hlen);
@@ -777,7 +785,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,/* size of message payload */ size =min (mtu - hlen, skb->len - pos); - skb2 =alloc_skb (MCTP_HEADER_MAXLEN + hlen + size,GFP_KERNEL ); + skb2 =alloc_skb (headroom + hlen + size,GFP_KERNEL );if (!skb2) { rc = -ENOMEM ;break ;
@@ -793,7 +801,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb,skb_set_owner_w (skb2, skb->sk);/* establish packet */ -skb_reserve (skb2,MCTP_HEADER_MAXLEN ); +skb_reserve (skb2, headroom);skb_reset_network_header (skb2);skb_put (skb2, hlen + size); skb2->transport_header = skb2->network_header + hlen;
Signature · 1 line
2.32.0
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Quoted 8 lines · On Fri, 1 Apr 2022 10:48:41 +0800 you wrote:
Hi,
The following are fixes for the mctp core and mctp-i2c driver.
Thanks,
Matt[...]
Here is the summary with links:
- [net,1/3] mctp: Fix check for dev_hard_header() result
https://git.kernel.org/netdev/net/c/60be976ac451 - [net,2/3] mctp i2c: correct mctp_i2c_header_create result https://git.kernel.org/netdev/net/c/8ce40a2fd350 - [net,3/3] mctp: Use output netdev to allocate skb headroom https://git.kernel.org/netdev/net/c/4a9dda1c1da6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html