Unverified Commit 77bb487d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12926 gso: fix udp gso fraglist segmentation after pull from frag_list

parents a98e739b 649d20ec
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <net/udp.h>
#include <net/protocol.h>
#include <net/inet_common.h>
#include <net/ip6_checksum.h>

static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
	netdev_features_t features,
@@ -269,9 +270,27 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
	__sum16 check;
	__be16 newlen;

	if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST)
	if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) {
		 /* Detect modified geometry and pass those to skb_segment. */
		if (skb_pagelen(gso_skb) - sizeof(*uh) == skb_shinfo(gso_skb)->gso_size)
			return __udp_gso_segment_list(gso_skb, features, is_ipv6);

		 /* Setup csum, as fraglist skips this in udp4_gro_receive. */
		gso_skb->csum_start = skb_transport_header(gso_skb) - gso_skb->head;
		gso_skb->csum_offset = offsetof(struct udphdr, check);
		gso_skb->ip_summed = CHECKSUM_PARTIAL;

		uh = udp_hdr(gso_skb);
		if (is_ipv6)
			uh->check = ~udp_v6_check(gso_skb->len,
						  &ipv6_hdr(gso_skb)->saddr,
						  &ipv6_hdr(gso_skb)->daddr, 0);
		else
			uh->check = ~udp_v4_check(gso_skb->len,
						  ip_hdr(gso_skb)->saddr,
						  ip_hdr(gso_skb)->daddr, 0);
	}

	mss = skb_shinfo(gso_skb)->gso_size;
	if (gso_skb->len <= sizeof(*uh) + mss)
		return ERR_PTR(-EINVAL);