]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tcp: don't try to set defaultmss when value is negative
authorWilliam Dauchy <w.dauchy@criteo.com>
Wed, 12 Feb 2020 14:53:04 +0000 (15:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Feb 2020 15:01:50 +0000 (16:01 +0100)
when `getsockopt` previously failed, we were trying to set defaultmss
with -2 value.

this is a followup of github issue #499

this should be backported to all versions >= v1.8

Fixes: 153659f1ae69a1 ("MINOR: tcp: When binding socket, attempt to
reuse one from the old proc.")
Signed-off-by: William Dauchy <w.dauchy@criteo.com>
src/proto_tcp.c

index 45d6a7c1995855f8ca678ae2fca76c25d5430e5a..7668ec29c37895b39961321a620897aee0070b7b 100644 (file)
@@ -906,9 +906,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
                        defaultmss = default_tcp6_maxseg;
 
                getsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &tmpmaxseg, &len);
-               if (tmpmaxseg != defaultmss && setsockopt(fd, IPPROTO_TCP,
-                                               TCP_MAXSEG, &defaultmss,
-                                               sizeof(defaultmss)) == -1) {
+               if (defaultmss > 0 &&
+                   tmpmaxseg != defaultmss &&
+                   setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &defaultmss, sizeof(defaultmss)) == -1) {
                        msg = "cannot set MSS";
                        err |= ERR_WARN;
                }