Skip to content

Commit cf3ab8d

Browse files
pigfavordavem330
authored andcommitted
net: fix wrong network header length
When clatd starts with ebpf offloaing, and NETIF_F_GRO_FRAGLIST is enable, several skbs are gathered in skb_shinfo(skb)->frag_list. The first skb's ipv6 header will be changed to ipv4 after bpf_skb_proto_6_to_4, network_header\transport_header\mac_header have been updated as ipv4 acts, but other skbs in frag_list didnot update anything, just ipv6 packets. udp_queue_rcv_skb will call skb_segment_list to traverse other skbs in frag_list and make sure right udp payload is delivered to user space. Unfortunately, other skbs in frag_list who are still ipv6 packets are updated like the first skb and will have wrong transport header length. e.g.before bpf_skb_proto_6_to_4,the first skb and other skbs in frag_list has the same network_header(24)& transport_header(64), after bpf_skb_proto_6_to_4, ipv6 protocol has been changed to ipv4, the first skb's network_header is 44,transport_header is 64, other skbs in frag_list didnot change.After skb_segment_list, the other skbs in frag_list has different network_header(24) and transport_header(44), so there will be 20 bytes different from original,that is difference between ipv6 header and ipv4 header. Just change transport_header to be the same with original. Actually, there are two solutions to fix it, one is traversing all skbs and changing every skb header in bpf_skb_proto_6_to_4, the other is modifying frag_list skb's header in skb_segment_list. Considering efficiency, adopt the second one--- when the first skb and other skbs in frag_list has different network_header length, restore them to make sure right udp payload is delivered to user space. Signed-off-by: Lina Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 49e6123 commit cf3ab8d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/core/skbuff.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3897,7 +3897,7 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,
38973897
unsigned int delta_len = 0;
38983898
struct sk_buff *tail = NULL;
38993899
struct sk_buff *nskb, *tmp;
3900-
int err;
3900+
int len_diff, err;
39013901

39023902
skb_push(skb, -skb_network_offset(skb) + offset);
39033903

@@ -3937,9 +3937,11 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,
39373937
skb_push(nskb, -skb_network_offset(nskb) + offset);
39383938

39393939
skb_release_head_state(nskb);
3940+
len_diff = skb_network_header_len(nskb) - skb_network_header_len(skb);
39403941
__copy_skb_header(nskb, skb);
39413942

39423943
skb_headers_offset_update(nskb, skb_headroom(nskb) - skb_headroom(skb));
3944+
nskb->transport_header += len_diff;
39433945
skb_copy_from_linear_data_offset(skb, -tnl_hlen,
39443946
nskb->data - tnl_hlen,
39453947
offset + tnl_hlen);

0 commit comments

Comments
 (0)