netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>,
	Julian Anastasov <ja@ssi.bg>, David Miller <davem@davemloft.net>,
	Linux Netdev List <netdev@vger.kernel.org>
Subject: Re: getsockopt(TCP_DEFER_ACCEPT) value change
Date: Tue, 05 Jan 2010 15:11:51 +0100	[thread overview]
Message-ID: <4B4348A7.4090509@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1001051526520.7024@wel-95.cs.helsinki.fi>

Le 05/01/2010 14:40, Ilpo Järvinen a écrit :
> On Tue, 5 Jan 2010, Daniel Lezcano wrote:
> 
>> I noticed a change in the value returned by the getsockopt for the
>> TCP_DEFER_ACCEPT option with a 2.6.32 kernel. The value retrieved with the
>> getsockopt is different from the one specified with the setsockopt. Is it an
>> expected behaviour ?
>>
>> I saw there were  changes around the TCP_DEFER_ACCEPT option with the number
>> of attempts converted to a number of seconds.
>>
>> The following program is working fine with a 2.6.31 but fails with a 2.6.32
>> kernel.
>>
>> Thanks
>>  -- Daniel
>>
>> #include <stdio.h>
>> #include <sys/socket.h>
>> #include <netinet/in.h>
>> #include <netinet/tcp.h>
>>
>> int main(int argc, char *argv[])
>> {
>>    int val1 = 12, val2;
>>    socklen_t len = sizeof(val2);
>>    int fd;
>>      fd = socket(PF_INET, SOCK_STREAM, 0);
>>    if (fd < 0) {
>>        perror("socket");
>>        return -1;
>>    }
>>      if (setsockopt(fd, SOL_TCP, TCP_DEFER_ACCEPT, &val1, sizeof(val1))) {
>>        perror("setsockopt");
>>        return -1;
>>    }
>>      if (getsockopt(fd, SOL_TCP, TCP_DEFER_ACCEPT, &val2, &len)) {
>>        perror("getsockopt");
>>        return -1;
>>    }
>>
>>    if (val1 != val2) {
>>        fprintf(stderr, "error %d != %d\n", val1, val2);
>>        return -1;
>>    }
>>
>>    return 0;
>> }
> 
> Added Cc.
> 
> I don't think this change was intentional. ...However, is this difference 
> particularly significant besides failing such a test program? The actual 
> value now returned by the getsockopt is more accurate than what the
> userspace initially provided.
> 
> In general, I wonder if there's something that mandates that a set/get 
> pair of value should be equal?
> 

Nothing... really... we can round the value, and we indeed round it in 2.6.32

defer value is given in second by user, and converted to number of retransmits by kernel.

Program assumption is wrong.


  reply	other threads:[~2010-01-05 14:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-05 10:42 getsockopt(TCP_DEFER_ACCEPT) value change Daniel Lezcano
2010-01-05 13:40 ` Ilpo Järvinen
2010-01-05 14:11   ` Eric Dumazet [this message]
2010-01-05 14:45     ` Eric Dumazet
2010-01-05 15:45     ` Daniel Lezcano
2010-01-05 16:14       ` Eric Dumazet
2010-01-05 16:57         ` Daniel Lezcano
2010-01-05 20:29   ` David Miller

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=4B4348A7.4090509@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=daniel.lezcano@free.fr \
    --cc=davem@davemloft.net \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=ja@ssi.bg \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).