MINOR: listener: move maxseg and tcp_ut to bind_conf
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.
diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h
index 17f4683..4508397 100644
--- a/include/haproxy/listener-t.h
+++ b/include/haproxy/listener-t.h
@@ -198,6 +198,8 @@
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 @@
/* 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 */
diff --git a/src/cfgparse-tcp.c b/src/cfgparse-tcp.c
index 13d433e..c46a126 100644
--- a/src/cfgparse-tcp.c
+++ b/src/cfgparse-tcp.c
@@ -94,7 +94,6 @@
/* 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 @@
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_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 @@
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
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 0c86d6e..dca1f8d 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -620,10 +620,10 @@
}
#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 @@
}
#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;
}
diff --git a/src/session.c b/src/session.c
index 5c868ae..2788c59 100644
--- a/src/session.c
+++ b/src/session.c
@@ -227,12 +227,12 @@
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));
}
}