mode_t mode; /* 0 to leave unchanged */
} ux;
char *interface; /* interface name or NULL */
+ const struct netns_entry *netns; /* network namespace of the listener*/
} settings; /* all the settings needed for the listening socket */
};
__decl_thread(HA_SPINLOCK_T lock);
- const struct netns_entry *netns; /* network namespace of the listener*/
-
/* cache line boundary */
unsigned int thr_conn[MAX_THREADS]; /* number of connections per thread */
/* parse the "namespace" bind keyword */
static int bind_parse_namespace(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
{
- struct listener *l;
char *namespace = NULL;
if (!*args[cur_arg + 1]) {
}
namespace = args[cur_arg + 1];
- list_for_each_entry(l, &conf->listeners, by_bind) {
- l->netns = netns_store_lookup(namespace, strlen(namespace));
+ conf->settings.netns = netns_store_lookup(namespace, strlen(namespace));
- if (l->netns == NULL)
- l->netns = netns_store_insert(namespace);
+ if (conf->settings.netns == NULL)
+ conf->settings.netns = netns_store_insert(namespace);
- if (l->netns == NULL) {
- ha_alert("Cannot open namespace '%s'.\n", args[cur_arg + 1]);
- return ERR_ALERT | ERR_FATAL;
- }
+ if (conf->settings.netns == NULL) {
+ ha_alert("Cannot open namespace '%s'.\n", args[cur_arg + 1]);
+ return ERR_ALERT | ERR_FATAL;
}
return 0;
}
}
#ifdef USE_NS
- if (l->netns) {
- ns_name = l->netns->node.key;
- ns_nlen = l->netns->name_len;
+ if (l->bind_conf->settings.netns) {
+ ns_name = l->bind_conf->settings.netns->node.key;
+ ns_nlen = l->bind_conf->settings.netns->name_len;
}
#endif
}
ext = (fd >= 0);
if (!ext) {
- fd = my_socketat(listener->netns, listener->addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
+ fd = my_socketat(listener->bind_conf->settings.netns, listener->addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1) {
err |= ERR_RETRYABLE | ERR_ALERT;
* IPPROTO (sockaddr is not enough)
*/
- fd = my_socketat(listener->netns, listener->proto->sock_family, listener->proto->sock_type, listener->proto->sock_prot);
+ fd = my_socketat(listener->bind_conf->settings.netns, listener->proto->sock_family, listener->proto->sock_type, listener->proto->sock_prot);
if (fd == -1) {
err |= ERR_RETRYABLE | ERR_ALERT;
msg = "cannot create listening socket";
cli_conn->handle.fd = cfd;
*cli_conn->src = *addr;
cli_conn->flags |= CO_FL_ADDR_FROM_SET;
- cli_conn->proxy_netns = l->netns;
+ cli_conn->proxy_netns = l->bind_conf->settings.netns;
conn_prepare(cli_conn, l->proto, l->bind_conf->xprt);
conn_ctrl_init(cli_conn);
if (l->bind_conf->settings.interface)
if_namelen = strlen(l->bind_conf->settings.interface);
#ifdef USE_NS
- if (l->netns)
- ns_namelen = l->netns->name_len;
+ if (l->bind_conf->settings.netns)
+ ns_namelen = l->bind_conf->settings.netns->name_len;
#endif
while (xfer_sock) {
(ns_namelen == xfer_sock->ns_namelen) &&
(!if_namelen || strcmp(l->bind_conf->settings.interface, xfer_sock->iface) == 0) &&
#ifdef USE_NS
- (!ns_namelen || strcmp(l->netns->node.key, xfer_sock->namespace) == 0) &&
+ (!ns_namelen || strcmp(l->bind_conf->settings.netns->node.key, xfer_sock->namespace) == 0) &&
#endif
l->proto->addrcmp(&xfer_sock->addr, &l->addr) == 0)
break;
smp->data.type = SMP_T_BOOL;
smp->flags = 0;
- smp->data.u.sint = addr_is_local(li->netns, conn->dst);
+ smp->data.u.sint = addr_is_local(li->bind_conf->settings.netns, conn->dst);
return smp->data.u.sint >= 0;
}
smp->data.type = SMP_T_BOOL;
smp->flags = 0;
- smp->data.u.sint = addr_is_local(li->netns, conn->src);
+ smp->data.u.sint = addr_is_local(li->bind_conf->settings.netns, conn->src);
return smp->data.u.sint >= 0;
}