aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-19 13:05:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-19 13:05:34 -0400
commit1200b6809dfd9d73bc4c7db76d288c35fa4b2ebe (patch)
tree552e03de245cdbd0780ca1215914edc4a26540f7 /net/ipv4/tcp.c
parent6b5f04b6cf8ebab9a65d9c0026c650bb2538fd0f (diff)
parentfe30937b65354c7fec244caebbdaae68e28ca797 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Highlights: 1) Support more Realtek wireless chips, from Jes Sorenson. 2) New BPF types for per-cpu hash and arrap maps, from Alexei Starovoitov. 3) Make several TCP sysctls per-namespace, from Nikolay Borisov. 4) Allow the use of SO_REUSEPORT in order to do per-thread processing of incoming TCP/UDP connections. The muxing can be done using a BPF program which hashes the incoming packet. From Craig Gallek. 5) Add a multiplexer for TCP streams, to provide a messaged based interface. BPF programs can be used to determine the message boundaries. From Tom Herbert. 6) Add 802.1AE MACSEC support, from Sabrina Dubroca. 7) Avoid factorial complexity when taking down an inetdev interface with lots of configured addresses. We were doing things like traversing the entire address less for each address removed, and flushing the entire netfilter conntrack table for every address as well. 8) Add and use SKB bulk free infrastructure, from Jesper Brouer. 9) Allow offloading u32 classifiers to hardware, and implement for ixgbe, from John Fastabend. 10) Allow configuring IRQ coalescing parameters on a per-queue basis, from Kan Liang. 11) Extend ethtool so that larger link mode masks can be supported. From David Decotigny. 12) Introduce devlink, which can be used to configure port link types (ethernet vs Infiniband, etc.), port splitting, and switch device level attributes as a whole. From Jiri Pirko. 13) Hardware offload support for flower classifiers, from Amir Vadai. 14) Add "Local Checksum Offload". Basically, for a tunneled packet the checksum of the outer header is 'constant' (because with the checksum field filled into the inner protocol header, the payload of the outer frame checksums to 'zero'), and we can take advantage of that in various ways. From Edward Cree" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1548 commits) bonding: fix bond_get_stats() net: bcmgenet: fix dma api length mismatch net/mlx4_core: Fix backward compatibility on VFs phy: mdio-thunder: Fix some Kconfig typos lan78xx: add ndo_get_stats64 lan78xx: handle statistics counter rollover RDS: TCP: Remove unused constant RDS: TCP: Add sysctl tunables for sndbuf/rcvbuf on rds-tcp socket net: smc911x: convert pxa dma to dmaengine team: remove duplicate set of flag IFF_MULTICAST bonding: remove duplicate set of flag IFF_MULTICAST net: fix a comment typo ethernet: micrel: fix some error codes ip_tunnels, bpf: define IP_TUNNEL_OPTS_MAX and use it bpf, dst: add and use dst_tclassid helper bpf: make skb->tc_classid also readable net: mvneta: bm: clarify dependencies cls_bpf: reset class and reuse major in da ldmvsw: Checkpatch sunvnet.c and sunvnet_common.c ldmvsw: Add ldmvsw.c driver code ...
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4804645bdf02..08b8b960a8ed 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -282,8 +282,6 @@
282#include <asm/unaligned.h> 282#include <asm/unaligned.h>
283#include <net/busy_poll.h> 283#include <net/busy_poll.h>
284 284
285int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
286
287int sysctl_tcp_min_tso_segs __read_mostly = 2; 285int sysctl_tcp_min_tso_segs __read_mostly = 2;
288 286
289int sysctl_tcp_autocorking __read_mostly = 1; 287int sysctl_tcp_autocorking __read_mostly = 1;
@@ -406,7 +404,7 @@ void tcp_init_sock(struct sock *sk)
406 tp->mss_cache = TCP_MSS_DEFAULT; 404 tp->mss_cache = TCP_MSS_DEFAULT;
407 u64_stats_init(&tp->syncp); 405 u64_stats_init(&tp->syncp);
408 406
409 tp->reordering = sysctl_tcp_reordering; 407 tp->reordering = sock_net(sk)->ipv4.sysctl_tcp_reordering;
410 tcp_enable_early_retrans(tp); 408 tcp_enable_early_retrans(tp);
411 tcp_assign_congestion_control(sk); 409 tcp_assign_congestion_control(sk);
412 410
@@ -558,20 +556,7 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
558 return -EINVAL; 556 return -EINVAL;
559 557
560 slow = lock_sock_fast(sk); 558 slow = lock_sock_fast(sk);
561 if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) 559 answ = tcp_inq(sk);
562 answ = 0;
563 else if (sock_flag(sk, SOCK_URGINLINE) ||
564 !tp->urg_data ||
565 before(tp->urg_seq, tp->copied_seq) ||
566 !before(tp->urg_seq, tp->rcv_nxt)) {
567
568 answ = tp->rcv_nxt - tp->copied_seq;
569
570 /* Subtract 1, if FIN was received */
571 if (answ && sock_flag(sk, SOCK_DONE))
572 answ--;
573 } else
574 answ = tp->urg_seq - tp->copied_seq;
575 unlock_sock_fast(sk, slow); 560 unlock_sock_fast(sk, slow);
576 break; 561 break;
577 case SIOCATMARK: 562 case SIOCATMARK:
@@ -1466,8 +1451,10 @@ static struct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off)
1466 1451
1467 while ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) { 1452 while ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) {
1468 offset = seq - TCP_SKB_CB(skb)->seq; 1453 offset = seq - TCP_SKB_CB(skb)->seq;
1469 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN) 1454 if (unlikely(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {
1455 pr_err_once("%s: found a SYN, please report !\n", __func__);
1470 offset--; 1456 offset--;
1457 }
1471 if (offset < skb->len || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)) { 1458 if (offset < skb->len || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)) {
1472 *off = offset; 1459 *off = offset;
1473 return skb; 1460 return skb;
@@ -1657,8 +1644,10 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
1657 break; 1644 break;
1658 1645
1659 offset = *seq - TCP_SKB_CB(skb)->seq; 1646 offset = *seq - TCP_SKB_CB(skb)->seq;
1660 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN) 1647 if (unlikely(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {
1648 pr_err_once("%s: found a SYN, please report !\n", __func__);
1661 offset--; 1649 offset--;
1650 }
1662 if (offset < skb->len) 1651 if (offset < skb->len)
1663 goto found_ok_skb; 1652 goto found_ok_skb;
1664 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 1653 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
@@ -2326,6 +2315,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2326{ 2315{
2327 struct tcp_sock *tp = tcp_sk(sk); 2316 struct tcp_sock *tp = tcp_sk(sk);
2328 struct inet_connection_sock *icsk = inet_csk(sk); 2317 struct inet_connection_sock *icsk = inet_csk(sk);
2318 struct net *net = sock_net(sk);
2329 int val; 2319 int val;
2330 int err = 0; 2320 int err = 0;
2331 2321
@@ -2522,7 +2512,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2522 case TCP_LINGER2: 2512 case TCP_LINGER2:
2523 if (val < 0) 2513 if (val < 0)
2524 tp->linger2 = -1; 2514 tp->linger2 = -1;
2525 else if (val > sysctl_tcp_fin_timeout / HZ) 2515 else if (val > net->ipv4.sysctl_tcp_fin_timeout / HZ)
2526 tp->linger2 = 0; 2516 tp->linger2 = 0;
2527 else 2517 else
2528 tp->linger2 = val * HZ; 2518 tp->linger2 = val * HZ;
@@ -2639,6 +2629,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2639 const struct inet_connection_sock *icsk = inet_csk(sk); 2629 const struct inet_connection_sock *icsk = inet_csk(sk);
2640 u32 now = tcp_time_stamp; 2630 u32 now = tcp_time_stamp;
2641 unsigned int start; 2631 unsigned int start;
2632 int notsent_bytes;
2642 u64 rate64; 2633 u64 rate64;
2643 u32 rate; 2634 u32 rate;
2644 2635
@@ -2719,6 +2710,13 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2719 } while (u64_stats_fetch_retry_irq(&tp->syncp, start)); 2710 } while (u64_stats_fetch_retry_irq(&tp->syncp, start));
2720 info->tcpi_segs_out = tp->segs_out; 2711 info->tcpi_segs_out = tp->segs_out;
2721 info->tcpi_segs_in = tp->segs_in; 2712 info->tcpi_segs_in = tp->segs_in;
2713
2714 notsent_bytes = READ_ONCE(tp->write_seq) - READ_ONCE(tp->snd_nxt);
2715 info->tcpi_notsent_bytes = max(0, notsent_bytes);
2716
2717 info->tcpi_min_rtt = tcp_min_rtt(tp);
2718 info->tcpi_data_segs_in = tp->data_segs_in;
2719 info->tcpi_data_segs_out = tp->data_segs_out;
2722} 2720}
2723EXPORT_SYMBOL_GPL(tcp_get_info); 2721EXPORT_SYMBOL_GPL(tcp_get_info);
2724 2722
@@ -2727,6 +2725,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
2727{ 2725{
2728 struct inet_connection_sock *icsk = inet_csk(sk); 2726 struct inet_connection_sock *icsk = inet_csk(sk);
2729 struct tcp_sock *tp = tcp_sk(sk); 2727 struct tcp_sock *tp = tcp_sk(sk);
2728 struct net *net = sock_net(sk);
2730 int val, len; 2729 int val, len;
2731 2730
2732 if (get_user(len, optlen)) 2731 if (get_user(len, optlen))
@@ -2761,12 +2760,12 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
2761 val = keepalive_probes(tp); 2760 val = keepalive_probes(tp);
2762 break; 2761 break;
2763 case TCP_SYNCNT: 2762 case TCP_SYNCNT:
2764 val = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; 2763 val = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries;
2765 break; 2764 break;
2766 case TCP_LINGER2: 2765 case TCP_LINGER2:
2767 val = tp->linger2; 2766 val = tp->linger2;
2768 if (val >= 0) 2767 if (val >= 0)
2769 val = (val ? : sysctl_tcp_fin_timeout) / HZ; 2768 val = (val ? : net->ipv4.sysctl_tcp_fin_timeout) / HZ;
2770 break; 2769 break;
2771 case TCP_DEFER_ACCEPT: 2770 case TCP_DEFER_ACCEPT:
2772 val = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept, 2771 val = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept,