diff options
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 43 |
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 | ||
285 | int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT; | ||
286 | |||
287 | int sysctl_tcp_min_tso_segs __read_mostly = 2; | 285 | int sysctl_tcp_min_tso_segs __read_mostly = 2; |
288 | 286 | ||
289 | int sysctl_tcp_autocorking __read_mostly = 1; | 287 | int 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 | } |
2723 | EXPORT_SYMBOL_GPL(tcp_get_info); | 2721 | EXPORT_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, |