MINOR: listener: move the network namespace to the struct settings

The netns is common to all listeners/receivers and is used to bind the
listening socket so it must be in the receiver settings and not in the
listener. This removes some yet another set of unnecessary loops.
diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h
index 9d0db4e..8ea7621 100644
--- a/include/haproxy/listener-t.h
+++ b/include/haproxy/listener-t.h
@@ -187,6 +187,7 @@
 			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 */
 };
 
@@ -219,8 +220,6 @@
 
 	__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 */
 
diff --git a/src/cfgparse-tcp.c b/src/cfgparse-tcp.c
index 033a3bd..961a726 100644
--- a/src/cfgparse-tcp.c
+++ b/src/cfgparse-tcp.c
@@ -192,7 +192,6 @@
 /* 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]) {
@@ -201,16 +200,14 @@
 	}
 	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;
 }
diff --git a/src/cli.c b/src/cli.c
index d7ec79a..5a2c5c6 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1716,9 +1716,9 @@
 			}
 
 #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
 		}
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 7be6882..7bb31b2 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -581,7 +581,7 @@
 	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;
diff --git a/src/proto_udp.c b/src/proto_udp.c
index 5337ac4..92dad6a 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -200,7 +200,7 @@
 	 * 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";
diff --git a/src/session.c b/src/session.c
index 52d3a1f..c303585 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->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);
diff --git a/src/sock.c b/src/sock.c
index 5899d44..a9dd5f2 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -388,8 +388,8 @@
 	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) {
@@ -398,7 +398,7 @@
 		    (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;
diff --git a/src/tcp_sample.c b/src/tcp_sample.c
index 5f1aa1f..680987b 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->netns, conn->dst);
+	smp->data.u.sint = addr_is_local(li->bind_conf->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->netns, conn->src);
+	smp->data.u.sint = addr_is_local(li->bind_conf->settings.netns, conn->src);
 	return smp->data.u.sint >= 0;
 }