]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: move maxseg and tcp_ut to bind_conf
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jan 2023 17:42:49 +0000 (18:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Feb 2023 17:00:20 +0000 (18:00 +0100)
These two arguments were only set and only used with tcpv4/tcpv6. Let's
just store them into the bind_conf instead of duplicating them for all
listeners since they're fixed per "bind" line.

include/haproxy/listener-t.h
src/cfgparse-tcp.c
src/proto_tcp.c
src/session.c

index 17f4683225d8d2df545b9bfc5f4bae3815f0477b..45083975c10c5d48314824d049cc3a07e01a0dc4 100644 (file)
@@ -198,6 +198,8 @@ struct bind_conf {
        struct xprt_ops *xprt;     /* transport-layer operations for all listeners */
        uint options;              /* set of BC_O_* flags */
        unsigned int analysers;    /* bitmap of required protocol analysers */
+       int maxseg;                /* for TCP, advertised MSS */
+       int tcp_ut;                /* for TCP, user timeout */
        int level;                 /* stats access level (ACCESS_LVL_*) */
        int severity_output;       /* default severity output format in cli feedback messages */
        struct list listeners;     /* list of listeners using this bind config */
@@ -247,8 +249,6 @@ struct listener {
        /* cache line boundary */
        struct mt_list wait_queue;      /* link element to make the listener wait for something (LI_LIMITED)  */
        unsigned int thr_idx;           /* thread indexes for queue distribution : (t2<<16)+t1 */
-       int maxseg;                     /* for TCP, advertised MSS */
-       int tcp_ut;                     /* for TCP, user timeout */
        char *name;                     /* listener's name */
 
        /* cache line boundary */
index 13d433e059dabfe6dc796863e7db04525aa6dab4..c46a126c7a4ec25947f64bd3ebafd3c9c6e4ecb6 100644 (file)
@@ -94,7 +94,6 @@ static int bind_parse_tfo(char **args, int cur_arg, struct proxy *px, struct bin
 /* parse the "mss" bind keyword */
 static int bind_parse_mss(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
-       struct listener *l;
        int mss;
 
        if (!*args[cur_arg + 1]) {
@@ -108,11 +107,7 @@ static int bind_parse_mss(char **args, int cur_arg, struct proxy *px, struct bin
                return ERR_ALERT | ERR_FATAL;
        }
 
-       list_for_each_entry(l, &conf->listeners, by_bind) {
-               if (l->rx.addr.ss_family == AF_INET || l->rx.addr.ss_family == AF_INET6)
-                       l->maxseg = mss;
-       }
-
+       conf->maxseg = mss;
        return 0;
 }
 #endif
@@ -122,7 +117,6 @@ static int bind_parse_mss(char **args, int cur_arg, struct proxy *px, struct bin
 static int bind_parse_tcp_ut(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
        const char *ptr = NULL;
-       struct listener *l;
        unsigned int timeout;
 
        if (!*args[cur_arg + 1]) {
@@ -146,11 +140,7 @@ static int bind_parse_tcp_ut(char **args, int cur_arg, struct proxy *px, struct
                return ERR_ALERT | ERR_FATAL;
        }
 
-       list_for_each_entry(l, &conf->listeners, by_bind) {
-               if (l->rx.addr.ss_family == AF_INET || l->rx.addr.ss_family == AF_INET6)
-                       l->tcp_ut = timeout;
-       }
-
+       conf->tcp_ut = timeout;
        return 0;
 }
 #endif
index 0c86d6eb6e4257b716839e2dde3a23d82325ed7b..dca1f8d7a4c30469de8ed344beefcf03f74e85f8 100644 (file)
@@ -620,10 +620,10 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
        }
 
 #if defined(TCP_MAXSEG)
-       if (listener->maxseg > 0) {
+       if (listener->bind_conf->maxseg > 0) {
                if (setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG,
-                              &listener->maxseg, sizeof(listener->maxseg)) == -1) {
-                       chunk_appendf(msg, "%scannot set MSS to %d", msg->data ? ", " : "", listener->maxseg);
+                              &listener->bind_conf->maxseg, sizeof(listener->bind_conf->maxseg)) == -1) {
+                       chunk_appendf(msg, "%scannot set MSS to %d", msg->data ? ", " : "", listener->bind_conf->maxseg);
                        err |= ERR_WARN;
                }
        } else {
@@ -647,9 +647,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
        }
 #endif
 #if defined(TCP_USER_TIMEOUT)
-       if (listener->tcp_ut) {
+       if (listener->bind_conf->tcp_ut) {
                if (setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT,
-                              &listener->tcp_ut, sizeof(listener->tcp_ut)) == -1) {
+                              &listener->bind_conf->tcp_ut, sizeof(listener->bind_conf->tcp_ut)) == -1) {
                        chunk_appendf(msg, "%scannot set TCP User Timeout", msg->data ? ", " : "");
                        err |= ERR_WARN;
                }
index 5c868ae0981af9a1b4b8b4573c8bc407db4b39e0..2788c59c9811ebdecf6063ccf033431bb4e8ad80 100644 (file)
@@ -227,12 +227,12 @@ int session_accept_fd(struct connection *cli_conn)
                        HA_ATOMIC_OR(&fdtab[cfd].state, FD_LINGER_RISK);
 
 #if defined(TCP_MAXSEG)
-               if (l->maxseg < 0) {
+               if (l->bind_conf->maxseg < 0) {
                        /* we just want to reduce the current MSS by that value */
                        int mss;
                        socklen_t mss_len = sizeof(mss);
                        if (getsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, &mss_len) == 0) {
-                               mss += l->maxseg; /* remember, it's < 0 */
+                               mss += l->bind_conf->maxseg; /* remember, it's < 0 */
                                setsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof(mss));
                        }
                }