MINOR: listener: prefer to retrieve the socket's settings via the receiver
Some socket settings used to be retrieved via the listener and the
bind_conf. Now instead we use the receiver and its settings whenever
appropriate. This will simplify the removal of the dependency on the
listener.
diff --git a/src/cli.c b/src/cli.c
index 0d826aa..4cf4cc1 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1710,15 +1710,15 @@
if (fdtab[cur_fd].iocb == listener_accept) {
const struct listener *l = fdtab[cur_fd].owner;
- if (l->bind_conf->settings.interface) {
- if_name = l->bind_conf->settings.interface;
+ if (l->rx.settings->interface) {
+ if_name = l->rx.settings->interface;
if_nlen = strlen(if_name);
}
#ifdef USE_NS
- if (l->bind_conf->settings.netns) {
- ns_name = l->bind_conf->settings.netns->node.key;
- ns_nlen = l->bind_conf->settings.netns->name_len;
+ if (l->rx.settings->netns) {
+ ns_name = l->rx.settings->netns->node.key;
+ ns_nlen = l->rx.settings->netns->name_len;
}
#endif
}
diff --git a/src/listener.c b/src/listener.c
index 75115f4..4026ea2 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -235,7 +235,7 @@
HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock);
if (listener->state == LI_LISTEN) {
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
- !(proc_mask(listener->bind_conf->settings.bind_proc) & pid_bit)) {
+ !(proc_mask(listener->rx.settings->bind_proc) & pid_bit)) {
/* we don't want to enable this listener and don't
* want any fd event to reach it.
*/
@@ -342,7 +342,7 @@
goto end;
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
- !(proc_mask(l->bind_conf->settings.bind_proc) & pid_bit))
+ !(proc_mask(l->rx.settings->bind_proc) & pid_bit))
goto end;
if (l->state == LI_ASSIGNED) {
@@ -383,11 +383,11 @@
goto end;
}
- if (!(thread_mask(l->bind_conf->settings.bind_thread) & tid_bit)) {
+ if (!(thread_mask(l->rx.settings->bind_thread) & tid_bit)) {
/* we're not allowed to touch this listener's FD, let's requeue
* the listener into one of its owning thread's queue instead.
*/
- int first_thread = my_flsl(thread_mask(l->bind_conf->settings.bind_thread) & all_threads_mask) - 1;
+ int first_thread = my_flsl(thread_mask(l->rx.settings->bind_thread) & all_threads_mask) - 1;
work_list_add(&local_listener_queue[first_thread], &l->wait_queue);
goto end;
}
@@ -875,7 +875,7 @@
next_actconn = 0;
#if defined(USE_THREAD)
- mask = thread_mask(l->bind_conf->settings.bind_thread) & all_threads_mask;
+ mask = thread_mask(l->rx.settings->bind_thread) & all_threads_mask;
if (atleast2(mask) && (global.tune.options & GTUNE_LISTENER_MQ) && !stopping) {
struct accept_queue_ring *ring;
unsigned int t, t0, t1, t2;
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index 4030c33..90300cc 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -126,7 +126,7 @@
listener->state = LI_LISTEN;
fd_insert(fd, listener, listener->rx.proto->accept,
- thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
+ thread_mask(listener->rx.settings->bind_thread) & all_threads_mask);
return err;
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 79b68b4..62f8611 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -581,7 +581,7 @@
ext = (fd >= 0);
if (!ext) {
- fd = my_socketat(listener->bind_conf->settings.netns, listener->rx.addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
+ fd = my_socketat(listener->rx.settings->netns, listener->rx.addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1) {
err |= ERR_RETRYABLE | ERR_ALERT;
@@ -649,10 +649,10 @@
#ifdef SO_BINDTODEVICE
/* Note: this might fail if not CAP_NET_RAW */
- if (!ext && listener->bind_conf->settings.interface) {
+ if (!ext && listener->rx.settings->interface) {
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,
- listener->bind_conf->settings.interface,
- strlen(listener->bind_conf->settings.interface) + 1) == -1) {
+ listener->rx.settings->interface,
+ strlen(listener->rx.settings->interface) + 1) == -1) {
msg = "cannot bind listener to device";
err |= ERR_WARN;
}
@@ -769,7 +769,7 @@
listener->state = LI_LISTEN;
fd_insert(fd, listener, listener->rx.proto->accept,
- thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
+ thread_mask(listener->rx.settings->bind_thread) & all_threads_mask);
/* for now, all regularly bound TCP listeners are exportable */
if (!(listener->options & LI_O_INHERITED))
diff --git a/src/proto_udp.c b/src/proto_udp.c
index 5cd7b73..9325ba8 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -200,7 +200,7 @@
* IPPROTO (sockaddr is not enough)
*/
- fd = my_socketat(listener->bind_conf->settings.netns,
+ fd = my_socketat(listener->rx.settings->netns,
listener->rx.proto->sock_family,
listener->rx.proto->sock_type,
listener->rx.proto->sock_prot);
@@ -255,10 +255,10 @@
#ifdef SO_BINDTODEVICE
/* Note: this might fail if not CAP_NET_RAW */
- if (listener->bind_conf->settings.interface) {
+ if (listener->rx.settings->interface) {
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,
- listener->bind_conf->settings.interface,
- strlen(listener->bind_conf->settings.interface) + 1) == -1) {
+ listener->rx.settings->interface,
+ strlen(listener->rx.settings->interface) + 1) == -1) {
msg = "cannot bind listener to device";
err |= ERR_WARN;
}
@@ -283,7 +283,7 @@
if (listener->bind_conf->frontend->mode == PR_MODE_SYSLOG)
fd_insert(fd, listener, syslog_fd_handler,
- thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
+ thread_mask(listener->rx.settings->bind_thread) & all_threads_mask);
else {
err |= ERR_FATAL | ERR_ALERT;
msg = "UDP is not yet supported on this proxy mode";
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index a63f183..55d02be 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -223,9 +223,9 @@
* where it works. We also don't change permissions on abstract sockets.
*/
if (!ext && path[0] &&
- (((listener->bind_conf->settings.ux.uid != -1 || listener->bind_conf->settings.ux.gid != -1) &&
- (chown(tempname, listener->bind_conf->settings.ux.uid, listener->bind_conf->settings.ux.gid) == -1)) ||
- (listener->bind_conf->settings.ux.mode != 0 && chmod(tempname, listener->bind_conf->settings.ux.mode) == -1))) {
+ (((listener->rx.settings->ux.uid != -1 || listener->rx.settings->ux.gid != -1) &&
+ (chown(tempname, listener->rx.settings->ux.uid, listener->rx.settings->ux.gid) == -1)) ||
+ (listener->rx.settings->ux.mode != 0 && chmod(tempname, listener->rx.settings->ux.mode) == -1))) {
err |= ERR_FATAL | ERR_ALERT;
msg = "cannot change UNIX socket ownership";
goto err_unlink_temp;
@@ -262,7 +262,7 @@
listener->state = LI_LISTEN;
fd_insert(fd, listener, listener->rx.proto->accept,
- thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask);
+ thread_mask(listener->rx.settings->bind_thread) & all_threads_mask);
/* for now, all regularly bound UNIX listeners are exportable */
if (!(listener->options & LI_O_INHERITED))
diff --git a/src/session.c b/src/session.c
index 58eacd4..c5af3c4 100644
--- a/src/session.c
+++ b/src/session.c
@@ -153,7 +153,7 @@
cli_conn->handle.fd = cfd;
*cli_conn->src = *addr;
cli_conn->flags |= CO_FL_ADDR_FROM_SET;
- cli_conn->proxy_netns = l->bind_conf->settings.netns;
+ cli_conn->proxy_netns = l->rx.settings->netns;
conn_prepare(cli_conn, l->rx.proto, l->bind_conf->xprt);
conn_ctrl_init(cli_conn);
diff --git a/src/sock.c b/src/sock.c
index 3e7ba70..2ff615b 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -382,20 +382,20 @@
options |= SOCK_XFER_OPT_V6ONLY;
}
- if (l->bind_conf->settings.interface)
- if_namelen = strlen(l->bind_conf->settings.interface);
+ if (l->rx.settings->interface)
+ if_namelen = strlen(l->rx.settings->interface);
#ifdef USE_NS
- if (l->bind_conf->settings.netns)
- ns_namelen = l->bind_conf->settings.netns->name_len;
+ if (l->rx.settings->netns)
+ ns_namelen = l->rx.settings->netns->name_len;
#endif
while (xfer_sock) {
if ((options == xfer_sock->options) &&
(if_namelen == xfer_sock->if_namelen) &&
(ns_namelen == xfer_sock->ns_namelen) &&
- (!if_namelen || strcmp(l->bind_conf->settings.interface, xfer_sock->iface) == 0) &&
+ (!if_namelen || strcmp(l->rx.settings->interface, xfer_sock->iface) == 0) &&
#ifdef USE_NS
- (!ns_namelen || strcmp(l->bind_conf->settings.netns->node.key, xfer_sock->namespace) == 0) &&
+ (!ns_namelen || strcmp(l->rx.settings->netns->node.key, xfer_sock->namespace) == 0) &&
#endif
l->rx.proto->addrcmp(&xfer_sock->addr, &l->rx.addr) == 0)
break;
diff --git a/src/tcp_sample.c b/src/tcp_sample.c
index 680987b..91a5fb3 100644
--- a/src/tcp_sample.c
+++ b/src/tcp_sample.c
@@ -137,7 +137,7 @@
smp->data.type = SMP_T_BOOL;
smp->flags = 0;
- smp->data.u.sint = addr_is_local(li->bind_conf->settings.netns, conn->dst);
+ smp->data.u.sint = addr_is_local(li->rx.settings->netns, conn->dst);
return smp->data.u.sint >= 0;
}
@@ -157,7 +157,7 @@
smp->data.type = SMP_T_BOOL;
smp->flags = 0;
- smp->data.u.sint = addr_is_local(li->bind_conf->settings.netns, conn->src);
+ smp->data.u.sint = addr_is_local(li->rx.settings->netns, conn->src);
return smp->data.u.sint >= 0;
}