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.
This commit is contained in:
Willy Tarreau 2023-01-12 18:42:49 +01:00
parent 7866e8e50d
commit ee378165fb
4 changed files with 11 additions and 21 deletions

View 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 */

View 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

View 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;
}

View 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));
}
}