Skip to content

Commit 1cd354f

Browse files
gaoxingwangdavem330
authored andcommitted
net: ipv6: fix wrong start position when receive hop-by-hop fragment
In IPv6, ipv6_rcv_core will parse the hop-by-hop type extension header and increase skb->transport_header by one extension header length. But if there are more other extension headers like fragment header at this time, the skb->transport_header points to the second extension header, not the transport layer header or the first extension header. This will result in the start and nexthdrp variable not pointing to the same position in ipv6frag_thdr_trunced, and ipv6_skip_exthdr returning incorrect offset and frag_off.Sometimes,the length of the last sharded packet is smaller than the calculated incorrect offset, resulting in packet loss. We can use network header to offset and calculate the correct position to solve this problem. Fixes: 9d9e937 (ipv6/netfilter: Discard first fragment not including all headers) Signed-off-by: Gao Xingwang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 383eed2 commit 1cd354f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ipv6/reassembly.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
369369
* the source of the fragment, with the Pointer field set to zero.
370370
*/
371371
nexthdr = hdr->nexthdr;
372-
if (ipv6frag_thdr_truncated(skb, skb_transport_offset(skb), &nexthdr)) {
372+
if (ipv6frag_thdr_truncated(skb, skb_network_offset(skb) + sizeof(struct ipv6hdr), &nexthdr)) {
373373
__IP6_INC_STATS(net, __in6_dev_get_safely(skb->dev),
374374
IPSTATS_MIB_INHDRERRORS);
375375
icmpv6_param_prob(skb, ICMPV6_HDR_INCOMP, 0);

0 commit comments

Comments
 (0)