mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 06:40:59 +01:00
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:
parent
7866e8e50d
commit
ee378165fb
@ -198,6 +198,8 @@ struct bind_conf {
|
|||||||
struct xprt_ops *xprt; /* transport-layer operations for all listeners */
|
struct xprt_ops *xprt; /* transport-layer operations for all listeners */
|
||||||
uint options; /* set of BC_O_* flags */
|
uint options; /* set of BC_O_* flags */
|
||||||
unsigned int analysers; /* bitmap of required protocol analysers */
|
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 level; /* stats access level (ACCESS_LVL_*) */
|
||||||
int severity_output; /* default severity output format in cli feedback messages */
|
int severity_output; /* default severity output format in cli feedback messages */
|
||||||
struct list listeners; /* list of listeners using this bind config */
|
struct list listeners; /* list of listeners using this bind config */
|
||||||
@ -247,8 +249,6 @@ struct listener {
|
|||||||
/* cache line boundary */
|
/* cache line boundary */
|
||||||
struct mt_list wait_queue; /* link element to make the listener wait for something (LI_LIMITED) */
|
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 */
|
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 */
|
char *name; /* listener's name */
|
||||||
|
|
||||||
/* cache line boundary */
|
/* cache line boundary */
|
||||||
|
|||||||
@ -94,7 +94,6 @@ static int bind_parse_tfo(char **args, int cur_arg, struct proxy *px, struct bin
|
|||||||
/* parse the "mss" bind keyword */
|
/* parse the "mss" bind keyword */
|
||||||
static int bind_parse_mss(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
|
static int bind_parse_mss(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
|
||||||
{
|
{
|
||||||
struct listener *l;
|
|
||||||
int mss;
|
int mss;
|
||||||
|
|
||||||
if (!*args[cur_arg + 1]) {
|
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;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry(l, &conf->listeners, by_bind) {
|
conf->maxseg = mss;
|
||||||
if (l->rx.addr.ss_family == AF_INET || l->rx.addr.ss_family == AF_INET6)
|
|
||||||
l->maxseg = mss;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
static int bind_parse_tcp_ut(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
|
||||||
{
|
{
|
||||||
const char *ptr = NULL;
|
const char *ptr = NULL;
|
||||||
struct listener *l;
|
|
||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
|
|
||||||
if (!*args[cur_arg + 1]) {
|
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;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry(l, &conf->listeners, by_bind) {
|
conf->tcp_ut = timeout;
|
||||||
if (l->rx.addr.ss_family == AF_INET || l->rx.addr.ss_family == AF_INET6)
|
|
||||||
l->tcp_ut = timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -620,10 +620,10 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TCP_MAXSEG)
|
#if defined(TCP_MAXSEG)
|
||||||
if (listener->maxseg > 0) {
|
if (listener->bind_conf->maxseg > 0) {
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG,
|
if (setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG,
|
||||||
&listener->maxseg, sizeof(listener->maxseg)) == -1) {
|
&listener->bind_conf->maxseg, sizeof(listener->bind_conf->maxseg)) == -1) {
|
||||||
chunk_appendf(msg, "%scannot set MSS to %d", msg->data ? ", " : "", listener->maxseg);
|
chunk_appendf(msg, "%scannot set MSS to %d", msg->data ? ", " : "", listener->bind_conf->maxseg);
|
||||||
err |= ERR_WARN;
|
err |= ERR_WARN;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -647,9 +647,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(TCP_USER_TIMEOUT)
|
#if defined(TCP_USER_TIMEOUT)
|
||||||
if (listener->tcp_ut) {
|
if (listener->bind_conf->tcp_ut) {
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT,
|
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 ? ", " : "");
|
chunk_appendf(msg, "%scannot set TCP User Timeout", msg->data ? ", " : "");
|
||||||
err |= ERR_WARN;
|
err |= ERR_WARN;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -227,12 +227,12 @@ int session_accept_fd(struct connection *cli_conn)
|
|||||||
HA_ATOMIC_OR(&fdtab[cfd].state, FD_LINGER_RISK);
|
HA_ATOMIC_OR(&fdtab[cfd].state, FD_LINGER_RISK);
|
||||||
|
|
||||||
#if defined(TCP_MAXSEG)
|
#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 */
|
/* we just want to reduce the current MSS by that value */
|
||||||
int mss;
|
int mss;
|
||||||
socklen_t mss_len = sizeof(mss);
|
socklen_t mss_len = sizeof(mss);
|
||||||
if (getsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, &mss_len) == 0) {
|
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));
|
setsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof(mss));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user