All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Subject: Fw: [Bug 108191] New: tcp option TCP_USER_TIMEOUT working incorrect within tcp keepalive.
Date: Fri, 20 Nov 2015 08:22:55 -0800	[thread overview]
Message-ID: <20151120082255.61842a04@xeon-e3> (raw)



Begin forwarded message:

Date: Fri, 20 Nov 2015 11:03:58 +0000
From: "bugzilla-daemon@bugzilla.kernel.org" <bugzilla-daemon@bugzilla.kernel.org>
To: "shemminger@linux-foundation.org" <shemminger@linux-foundation.org>
Subject: [Bug 108191] New: tcp option TCP_USER_TIMEOUT working incorrect within tcp keepalive.


https://bugzilla.kernel.org/show_bug.cgi?id=108191

            Bug ID: 108191
           Summary: tcp option TCP_USER_TIMEOUT working incorrect within
                    tcp keepalive.
           Product: Networking
           Version: 2.5
    Kernel Version: 4.3
          Hardware: All
                OS: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: IPV4
          Assignee: shemminger@linux-foundation.org
          Reporter: jj.net@163.com
        Regression: No

The TCP_USER_TIMEOUT semantic means when you send an packet,
how long time no received the ACK should disconnect the connection.

In tcp retransmits case, 
retransmits_timed_out checkout this timeout, it walks well.

but in keepalive case.
the code below may have bugs:

....
    elapsed = keepalive_time_elapsed(tp);

    if (elapsed >= keepalive_time_when(tp)) {
        /* If the TCP_USER_TIMEOUT option is enabled, use that
         * to determine when to timeout instead.
         */
        if ((icsk->icsk_user_timeout != 0 &&
            elapsed >= icsk->icsk_user_timeout &&
            icsk->icsk_probes_out > 0) ||
            (icsk->icsk_user_timeout == 0 &&
            icsk->icsk_probes_out >= keepalive_probes(tp))) {
            tcp_send_active_reset(sk, GFP_ATOMIC);
            tcp_write_err(sk);
            goto out;
        }
.....
elapsed >= icsk->icsk_user_timeout should be
elapsed-keepalive_time_when(tp) >= icsk->icsk_user_timeout 

here is the timeline:

idle   .......   keepalive1         ......       keepalive2 ...
keepalive_probes
<- katime_when ->          <- keepalive_intvl  ->
                 <-  TCP_USER_TIMEOUT ->  // user expected timeout
<---------------elapsed---------------->
                 <-elapsed-katime_when->


/* test code */
int v;
v=1;setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &v, 4);
v=30;setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &v, 4);
v=5;setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &v, 4);
v=3;setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &v, 4);
v=20*1000; setsockopt(fd, SOL_TCP, TCP_USER_TIMEOUT, &v, 4); 
connect(fd, addr, sizeof(addr);
// when connect
// drop the recv data
// iptables -t filter -A INPUT --protocol tcp --dport 8888 -j DROP
pause();

we can see 30s later, tcp start keepalive, and close connection
without do the  first retransmits (because 30+5 > 20)
but we want waiting 20 second.

-- 
You are receiving this mail because:
You are the assignee for the bug.

                 reply	other threads:[~2015-11-20 16:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151120082255.61842a04@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.