aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_ipv4.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-07 01:11:46 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-07 17:39:05 -0400
commit28850dc7c71da9d0c0e39246e9ff6913f41f8d0a (patch)
tree1ff43aef62041c487d4175af44e73da90bb70ce9 /net/ipv4/tcp_ipv4.c
parent5ee98591577aa63dbb9e78a0d142abc86b9063d0 (diff)
net: tcp: move GRO/GSO functions to tcp_offload
Would be good to make things explicit and move those functions to a new file called tcp_offload.c, thus make this similar to tcpv6_offload.c. While moving all related functions into tcp_offload.c, we can also make some of them static, since they are only used there. Also, add an explicit registration function. Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r--net/ipv4/tcp_ipv4.c66
1 files changed, 1 insertions, 65 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index d20ede0c9593..289039b4d8de 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -545,8 +545,7 @@ out:
545 sock_put(sk); 545 sock_put(sk);
546} 546}
547 547
548static void __tcp_v4_send_check(struct sk_buff *skb, 548void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr)
549 __be32 saddr, __be32 daddr)
550{ 549{
551 struct tcphdr *th = tcp_hdr(skb); 550 struct tcphdr *th = tcp_hdr(skb);
552 551
@@ -571,23 +570,6 @@ void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
571} 570}
572EXPORT_SYMBOL(tcp_v4_send_check); 571EXPORT_SYMBOL(tcp_v4_send_check);
573 572
574int tcp_v4_gso_send_check(struct sk_buff *skb)
575{
576 const struct iphdr *iph;
577 struct tcphdr *th;
578
579 if (!pskb_may_pull(skb, sizeof(*th)))
580 return -EINVAL;
581
582 iph = ip_hdr(skb);
583 th = tcp_hdr(skb);
584
585 th->check = 0;
586 skb->ip_summed = CHECKSUM_PARTIAL;
587 __tcp_v4_send_check(skb, iph->saddr, iph->daddr);
588 return 0;
589}
590
591/* 573/*
592 * This routine will send an RST to the other tcp. 574 * This routine will send an RST to the other tcp.
593 * 575 *
@@ -2795,52 +2777,6 @@ void tcp4_proc_exit(void)
2795} 2777}
2796#endif /* CONFIG_PROC_FS */ 2778#endif /* CONFIG_PROC_FS */
2797 2779
2798struct sk_buff **tcp4_gro_receive(struct sk_buff **head, struct sk_buff *skb)
2799{
2800 const struct iphdr *iph = skb_gro_network_header(skb);
2801 __wsum wsum;
2802 __sum16 sum;
2803
2804 switch (skb->ip_summed) {
2805 case CHECKSUM_COMPLETE:
2806 if (!tcp_v4_check(skb_gro_len(skb), iph->saddr, iph->daddr,
2807 skb->csum)) {
2808 skb->ip_summed = CHECKSUM_UNNECESSARY;
2809 break;
2810 }
2811flush:
2812 NAPI_GRO_CB(skb)->flush = 1;
2813 return NULL;
2814
2815 case CHECKSUM_NONE:
2816 wsum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
2817 skb_gro_len(skb), IPPROTO_TCP, 0);
2818 sum = csum_fold(skb_checksum(skb,
2819 skb_gro_offset(skb),
2820 skb_gro_len(skb),
2821 wsum));
2822 if (sum)
2823 goto flush;
2824
2825 skb->ip_summed = CHECKSUM_UNNECESSARY;
2826 break;
2827 }
2828
2829 return tcp_gro_receive(head, skb);
2830}
2831
2832int tcp4_gro_complete(struct sk_buff *skb)
2833{
2834 const struct iphdr *iph = ip_hdr(skb);
2835 struct tcphdr *th = tcp_hdr(skb);
2836
2837 th->check = ~tcp_v4_check(skb->len - skb_transport_offset(skb),
2838 iph->saddr, iph->daddr, 0);
2839 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
2840
2841 return tcp_gro_complete(skb);
2842}
2843
2844struct proto tcp_prot = { 2780struct proto tcp_prot = {
2845 .name = "TCP", 2781 .name = "TCP",
2846 .owner = THIS_MODULE, 2782 .owner = THIS_MODULE,