* getsockopt(TCP_DEFER_ACCEPT) value change @ 2010-01-05 10:42 Daniel Lezcano 2010-01-05 13:40 ` Ilpo Järvinen 0 siblings, 1 reply; 8+ messages in thread From: Daniel Lezcano @ 2010-01-05 10:42 UTC (permalink / raw) To: Linux Netdev List Hi, 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; } ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: getsockopt(TCP_DEFER_ACCEPT) value change 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 2010-01-05 20:29 ` David Miller 0 siblings, 2 replies; 8+ messages in thread From: Ilpo Järvinen @ 2010-01-05 13:40 UTC (permalink / raw) To: Daniel Lezcano, Julian Anastasov, Eric Dumazet, David Miller Cc: Linux Netdev List 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? -- i. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: getsockopt(TCP_DEFER_ACCEPT) value change 2010-01-05 13:40 ` Ilpo Järvinen @ 2010-01-05 14:11 ` Eric Dumazet 2010-01-05 14:45 ` Eric Dumazet 2010-01-05 15:45 ` Daniel Lezcano 2010-01-05 20:29 ` David Miller 1 sibling, 2 replies; 8+ messages in thread From: Eric Dumazet @ 2010-01-05 14:11 UTC (permalink / raw) To: Ilpo Järvinen Cc: Daniel Lezcano, Julian Anastasov, David Miller, Linux Netdev List 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: getsockopt(TCP_DEFER_ACCEPT) value change 2010-01-05 14:11 ` Eric Dumazet @ 2010-01-05 14:45 ` Eric Dumazet 2010-01-05 15:45 ` Daniel Lezcano 1 sibling, 0 replies; 8+ messages in thread From: Eric Dumazet @ 2010-01-05 14:45 UTC (permalink / raw) To: Ilpo Järvinen Cc: Daniel Lezcano, Julian Anastasov, David Miller, Linux Netdev List Le 05/01/2010 15:11, Eric Dumazet a écrit : > 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. BTW, previous kernels were rounding too : 1 -> 3 2 -> 3 3 -> 3 4 -> 6 5 -> 6 6 -> 6 7 -> 12 8 -> 12 9 -> 12 10 -> 12 11 -> 12 12 -> 12 13 -> 24 14 -> 24 15 -> 24 16 -> 24 17 -> 24 18 -> 24 19 -> 24 New kernel (or other sysctl settings, I didnot check) : 1 -> 3 2 -> 3 3 -> 3 4 -> 9 5 -> 9 6 -> 9 7 -> 9 8 -> 9 9 -> 9 10 -> 21 11 -> 21 12 -> 21 13 -> 21 14 -> 21 15 -> 21 16 -> 21 17 -> 21 18 -> 21 19 -> 21 #include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> int main(int argc, char *argv[]) { int i, val1 = 12, val2; socklen_t len = sizeof(val2); int fd; fd = socket(PF_INET, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); return -1; } for (i = 1; i < 20 ; i++) { val1 = i; 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; } printf("%d -> %d\n", i, val2); } return 0; } ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: getsockopt(TCP_DEFER_ACCEPT) value change 2010-01-05 14:11 ` Eric Dumazet 2010-01-05 14:45 ` Eric Dumazet @ 2010-01-05 15:45 ` Daniel Lezcano 2010-01-05 16:14 ` Eric Dumazet 1 sibling, 1 reply; 8+ messages in thread From: Daniel Lezcano @ 2010-01-05 15:45 UTC (permalink / raw) To: Eric Dumazet Cc: Ilpo Järvinen, Julian Anastasov, David Miller, Linux Netdev List Eric Dumazet wrote: > 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. > It's not problem if the set / get values are not same, but I was asking because I am working with a test suite checking if a checkpoint / restart solution is correct. One of these tests, sets the TCP_DEFER_ACCEPT value to 12, checkpoints / restarts, and reads the value in order to check if it was correctly restored. The value 12 was chosen because it is not rounded, so we were able to safely do the test. But with the 2.6.32, the behaviour changed, so I preferred to report it in case that is something not expected. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: getsockopt(TCP_DEFER_ACCEPT) value change 2010-01-05 15:45 ` Daniel Lezcano @ 2010-01-05 16:14 ` Eric Dumazet 2010-01-05 16:57 ` Daniel Lezcano 0 siblings, 1 reply; 8+ messages in thread From: Eric Dumazet @ 2010-01-05 16:14 UTC (permalink / raw) To: Daniel Lezcano Cc: Ilpo Järvinen, Julian Anastasov, David Miller, Linux Netdev List Le 05/01/2010 16:45, Daniel Lezcano a écrit : > It's not problem if the set / get values are not same, but I was asking > because I am working with a test suite checking if a checkpoint / > restart solution is correct. One of these tests, sets the > TCP_DEFER_ACCEPT value to 12, checkpoints / restarts, and reads the > value in order to check if it was correctly restored. The value 12 was > chosen because it is not rounded, so we were able to safely do the test. > But with the 2.6.32, the behaviour changed, so I preferred to report it > in case that is something not expected. > > 12 happened to be rounded to 12 with previous kernels, but with recent kernels we have another conversion table : 1 -> 3 2 -> 3 3 -> 3 4 -> 9 5 -> 9 6 -> 9 7 -> 9 8 -> 9 9 -> 9 10 -> 21 ... 21 -> 21 22 -> 45 ... 45 -> 45 46 -> 93 ... 93 -> 93 94 -> 189 ... 189 -> 189 190 -> 309 ... ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: getsockopt(TCP_DEFER_ACCEPT) value change 2010-01-05 16:14 ` Eric Dumazet @ 2010-01-05 16:57 ` Daniel Lezcano 0 siblings, 0 replies; 8+ messages in thread From: Daniel Lezcano @ 2010-01-05 16:57 UTC (permalink / raw) To: Eric Dumazet Cc: Ilpo Järvinen, Julian Anastasov, David Miller, Linux Netdev List Eric Dumazet wrote: > Le 05/01/2010 16:45, Daniel Lezcano a écrit : > > >> It's not problem if the set / get values are not same, but I was asking >> because I am working with a test suite checking if a checkpoint / >> restart solution is correct. One of these tests, sets the >> TCP_DEFER_ACCEPT value to 12, checkpoints / restarts, and reads the >> value in order to check if it was correctly restored. The value 12 was >> chosen because it is not rounded, so we were able to safely do the test. >> But with the 2.6.32, the behaviour changed, so I preferred to report it >> in case that is something not expected. >> >> >> > > 12 happened to be rounded to 12 with previous kernels, > but with recent kernels we have another conversion table : > Thanks Eric, I will change the test program. -- Daniel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: getsockopt(TCP_DEFER_ACCEPT) value change 2010-01-05 13:40 ` Ilpo Järvinen 2010-01-05 14:11 ` Eric Dumazet @ 2010-01-05 20:29 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: David Miller @ 2010-01-05 20:29 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: daniel.lezcano, ja, eric.dumazet, netdev From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Tue, 5 Jan 2010 15:40:57 +0200 (EET) > In general, I wonder if there's something that mandates that a set/get > pair of value should be equal? There is no such requirement, we've been violating that premise since day one for socket receive and send queue buffer limit socket options. The kernel is always allowed to add fuzz or overhead adjustments to whatever the user gives it. If the user wants to know what the kernel actually ended up using, it get getsockopt() to find out. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-01-05 20:29 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).