Skip to contentSkip to conversation

nsh: set mac len based on inner packet

PATCH In review Willem de Bruijn 3 participants 7 messages Jul 11, 2018 – Jul 13, 2018

Subsystems (4)
lore
Share & tools
lore

Willem de Bruijn

author maintainer
#0 lore raw

PATCH 1/1 nsh: set mac len based on inner packet

From: Willem de Bruijn <[email protected]>

When pulling the NSH header in nsh_gso_segment, set the mac length based on the encapsulated packet type.

skb_reset_mac_len computes an offset to the network header, which here still points to the outer packet:

Quoted 7 lines
    skb_reset_network_header(skb);
    [...]
    __skb_pull(skb, nsh_len);
    skb_reset_mac_header(skb);    // now mac hdr starts nsh_len == 8B after net hdr
    skb_reset_mac_len(skb);       // mac len = net hdr - mac hdr == (u16) -8 == 65528
    [..]
    skb_mac_gso_segment(skb, ..)
---
 net/nsh/nsh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/nsh/nsh.c +1 -1
index 9696ef96b719..1a30e165eeb4 100644
@@ -104,7 +104,7 @@ static struct sk_buff *nsh_gso_segment(struct sk_buff *skb,
 	__skb_pull(skb, nsh_len);
 
 	skb_reset_mac_header(skb);
-	skb_reset_mac_len(skb);
+	skb->mac_len = proto == htons(ETH_P_TEB) ? ETH_HLEN : 0;
 	skb->protocol = proto;
 
 	features &= NETIF_F_SG;
Signature · 1 line
2.18.0.203.gfac676dfb9-goog
author maintainer
#1 lore raw

PATCH 1/1 packet: reset network header if packet shorter than ll reserved space

From: Willem de Bruijn <[email protected]>

If variable length link layer headers result in a packet shorter than dev->hard_header_len, reset the network header offset. Else skb->mac_len may exceed skb->len after skb_mac_reset_len.

packet_sendmsg_spkt already has similar logic.

Fixes b84bbaf7a6c8 ("packet: in packet_snd start writing at link layer allocation")
---
 net/packet/af_packet.c | 2 ++
 1 file changed, 2 insertions(+)
net/packet/af_packet.c +2 -0
index 57634bc3da74..9b27d0cd766d 100644
@@ -2878,6 +2878,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 			goto out_free;
 	} else if (reserve) {
 		skb_reserve(skb, -reserve);
+		if (len < reserve)
+			skb_reset_network_header(skb);
 	}
 
 	/* Returns -EFAULT on error */
Signature · 1 line
2.18.0.203.gfac676dfb9-goog
maintainer
#2 lore raw

Re: [PATCH net] packet: reset network header if packet shorter than ll reserved space

From: Willem de Bruijn <[email protected]>
Date: Wed, 11 Jul 2018 12:00:45 -0400

Quoted 10 lines

From: Willem de Bruijn <[email protected]>

If variable length link layer headers result in a packet shorter than dev->hard_header_len, reset the network header offset. Else skb->mac_len may exceed skb->len after skb_mac_reset_len.

packet_sendmsg_spkt already has similar logic.

Fixes b84bbaf7a6c8 ("packet: in packet_snd start writing at link layer allocation")

Applied and queued up for -stable.

author maintainer
#3 lore raw

PATCH 1/1 selftests: in udpgso_bench do not test udp zerocopy

In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>

The udpgso benchmark compares various configurations of UDP and TCP. Including one that is not upstream, udp zerocopy. This is a leftover from the earlier RFC patchset.

The test is part of kselftests and run in continuous spinners. Remove the failing case to make the test start passing.

Fixes 3a687bef148d ("selftests: udp gso benchmark")
---
 tools/testing/selftests/net/udpgso_bench.sh | 3 ---
 1 file changed, 3 deletions(-)
tools/testing/selftests/net/udpgso_bench.sh +0 -3
index 792fa4d0285e..850767befa47 100755
@@ -35,9 +35,6 @@ run_udp() {
 
 	echo "udp gso"
 	run_in_netns ${args} -S
-
-	echo "udp gso zerocopy"
-	run_in_netns ${args} -S -z
 }
 
 run_tcp() {
Signature · 1 line
2.18.0.203.gfac676dfb9-goog
maintainer Applied
#4 lore raw

Re: [PATCH net] selftests: in udpgso_bench do not test udp zerocopy

From: Willem de Bruijn <[email protected]>
Date: Wed, 11 Jul 2018 12:00:46 -0400

Quoted 6 lines

From: Willem de Bruijn <[email protected]>

The udpgso benchmark compares various configurations of UDP and TCP. Including one that is not upstream, udp zerocopy. This is a leftover from the earlier RFC patchset.

Quoted 6 lines

The test is part of kselftests and run in continuous spinners. Remove the failing case to make the test start passing.

Fixes 3a687bef148d ("selftests: udp gso benchmark")

Applied.

Acked-by on v1 1/1
#5 lore raw
In reply to Willem de Bruijn
Quoted 16 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

When pulling the NSH header in nsh_gso_segment, set the mac length based on the encapsulated packet type.

skb_reset_mac_len computes an offset to the network header, which here still points to the outer packet:

Quoted 7 lines
    skb_reset_network_header(skb);
    [...]
    __skb_pull(skb, nsh_len);
    skb_reset_mac_header(skb);    // now mac hdr starts nsh_len == 8B after net hdr
    skb_reset_mac_len(skb);       // mac len = net hdr - mac hdr == (u16) -8 == 65528
    [..]
    skb_mac_gso_segment(skb, ..)  
Quoted 4 lines
maintainer
#6 lore raw
In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>
Date: Wed, 11 Jul 2018 12:00:44 -0400

Quoted 16 lines

From: Willem de Bruijn <[email protected]>

When pulling the NSH header in nsh_gso_segment, set the mac length based on the encapsulated packet type.

skb_reset_mac_len computes an offset to the network header, which here still points to the outer packet:

Quoted 7 lines
    skb_reset_network_header(skb);
    [...]
    __skb_pull(skb, nsh_len);
    skb_reset_mac_header(skb);    // now mac hdr starts nsh_len == 8B after net hdr
    skb_reset_mac_len(skb);       // mac len = net hdr - mac hdr == (u16) -8 == 65528
    [..]
    skb_mac_gso_segment(skb, ..)
Quoted 4 lines

Applied and queued up for -stable.