~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ipv6/tcpv6_offload.c

Version: ~ [ linux-6.3-rc3 ] ~ [ linux-6.2.7 ] ~ [ linux-6.1.20 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.103 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.175 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.237 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.278 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.310 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp