Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 861b6501 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

tcp: gro: add checksuming helpers



skb with CHECKSUM_NONE cant currently be handled by GRO, and
we notice this deep in GRO stack in tcp[46]_gro_receive()

But there are cases where GRO can be a benefit, even with a lack
of checksums.

This preliminary work is needed to add GRO support
to tunnels.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 64c6d08e
Loading
Loading
Loading
Loading
+16 −3
Original line number Original line Diff line number Diff line
@@ -2803,6 +2803,8 @@ void tcp4_proc_exit(void)
struct sk_buff **tcp4_gro_receive(struct sk_buff **head, struct sk_buff *skb)
struct sk_buff **tcp4_gro_receive(struct sk_buff **head, struct sk_buff *skb)
{
{
	const struct iphdr *iph = skb_gro_network_header(skb);
	const struct iphdr *iph = skb_gro_network_header(skb);
	__wsum wsum;
	__sum16 sum;


	switch (skb->ip_summed) {
	switch (skb->ip_summed) {
	case CHECKSUM_COMPLETE:
	case CHECKSUM_COMPLETE:
@@ -2811,11 +2813,22 @@ struct sk_buff **tcp4_gro_receive(struct sk_buff **head, struct sk_buff *skb)
			skb->ip_summed = CHECKSUM_UNNECESSARY;
			skb->ip_summed = CHECKSUM_UNNECESSARY;
			break;
			break;
		}
		}

flush:
		/* fall through */
	case CHECKSUM_NONE:
		NAPI_GRO_CB(skb)->flush = 1;
		NAPI_GRO_CB(skb)->flush = 1;
		return NULL;
		return NULL;

	case CHECKSUM_NONE:
		wsum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
					  skb_gro_len(skb), IPPROTO_TCP, 0);
		sum = csum_fold(skb_checksum(skb,
					     skb_gro_offset(skb),
					     skb_gro_len(skb),
					     wsum));
		if (sum)
			goto flush;

		skb->ip_summed = CHECKSUM_UNNECESSARY;
		break;
	}
	}


	return tcp_gro_receive(head, skb);
	return tcp_gro_receive(head, skb);
+17 −3
Original line number Original line Diff line number Diff line
@@ -763,6 +763,8 @@ static struct sk_buff **tcp6_gro_receive(struct sk_buff **head,
					 struct sk_buff *skb)
					 struct sk_buff *skb)
{
{
	const struct ipv6hdr *iph = skb_gro_network_header(skb);
	const struct ipv6hdr *iph = skb_gro_network_header(skb);
	__wsum wsum;
	__sum16 sum;


	switch (skb->ip_summed) {
	switch (skb->ip_summed) {
	case CHECKSUM_COMPLETE:
	case CHECKSUM_COMPLETE:
@@ -771,11 +773,23 @@ static struct sk_buff **tcp6_gro_receive(struct sk_buff **head,
			skb->ip_summed = CHECKSUM_UNNECESSARY;
			skb->ip_summed = CHECKSUM_UNNECESSARY;
			break;
			break;
		}
		}

flush:
		/* fall through */
	case CHECKSUM_NONE:
		NAPI_GRO_CB(skb)->flush = 1;
		NAPI_GRO_CB(skb)->flush = 1;
		return NULL;
		return NULL;

	case CHECKSUM_NONE:
		wsum = ~csum_unfold(csum_ipv6_magic(&iph->saddr, &iph->daddr,
						    skb_gro_len(skb),
						    IPPROTO_TCP, 0));
		sum = csum_fold(skb_checksum(skb,
					     skb_gro_offset(skb),
					     skb_gro_len(skb),
					     wsum));
		if (sum)
			goto flush;

		skb->ip_summed = CHECKSUM_UNNECESSARY;
		break;
	}
	}


	return tcp_gro_receive(head, skb);
	return tcp_gro_receive(head, skb);