Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.1-rc5 82 lines 2.2 kB view raw
1/* 2 * IPV6 GSO/GRO offload support 3 * Linux INET6 implementation 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 8 * 2 of the License, or (at your option) any later version. 9 * 10 * TCPv6 GSO/GRO support 11 */ 12#include <linux/indirect_call_wrapper.h> 13#include <linux/skbuff.h> 14#include <net/protocol.h> 15#include <net/tcp.h> 16#include <net/ip6_checksum.h> 17#include "ip6_offload.h" 18 19INDIRECT_CALLABLE_SCOPE 20struct sk_buff *tcp6_gro_receive(struct list_head *head, struct sk_buff *skb) 21{ 22 /* Don't bother verifying checksum if we're going to flush anyway. */ 23 if (!NAPI_GRO_CB(skb)->flush && 24 skb_gro_checksum_validate(skb, IPPROTO_TCP, 25 ip6_gro_compute_pseudo)) { 26 NAPI_GRO_CB(skb)->flush = 1; 27 return NULL; 28 } 29 30 return tcp_gro_receive(head, skb); 31} 32 33INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff) 34{ 35 const struct ipv6hdr *iph = ipv6_hdr(skb); 36 struct tcphdr *th = tcp_hdr(skb); 37 38 th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr, 39 &iph->daddr, 0); 40 skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6; 41 42 return tcp_gro_complete(skb); 43} 44 45static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb, 46 netdev_features_t features) 47{ 48 struct tcphdr *th; 49 50 if (!(skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)) 51 return ERR_PTR(-EINVAL); 52 53 if (!pskb_may_pull(skb, sizeof(*th))) 54 return ERR_PTR(-EINVAL); 55 56 if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) { 57 const struct ipv6hdr *ipv6h = ipv6_hdr(skb); 58 struct tcphdr *th = tcp_hdr(skb); 59 60 /* Set up pseudo header, usually expect stack to have done 61 * this. 62 */ 63 64 th->check = 0; 65 skb->ip_summed = CHECKSUM_PARTIAL; 66 __tcp_v6_send_check(skb, &ipv6h->saddr, &ipv6h->daddr); 67 } 68 69 return tcp_gso_segment(skb, features); 70} 71static const struct net_offload tcpv6_offload = { 72 .callbacks = { 73 .gso_segment = tcp6_gso_segment, 74 .gro_receive = tcp6_gro_receive, 75 .gro_complete = tcp6_gro_complete, 76 }, 77}; 78 79int __init tcpv6_offload_init(void) 80{ 81 return inet6_add_offload(&tcpv6_offload, IPPROTO_TCP); 82}