diff options
author | Willy Tarreau <w@1wt.eu> | 2020-08-27 07:58:26 +0200 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2020-09-01 09:58:05 +0200 |
commit | 50c11c1ed8dfed4482eafc01a7cc075a87024794 (patch) | |
tree | 50e1bc0dbdf782683e85f0e64db550e5bc93f991 | |
parent | b29bf714e787dfb1382d9ce912253b67fa4f39c5 (diff) | |
download | haproxy-50c11c1ed8dfed4482eafc01a7cc075a87024794.tar.gz |
REORG: listeners: move the network interface to struct receiver
The interface is also an important discriminant for the address, so it
belongs to the receiver.
As a side note, the interface name is not freed upon exit.
-rw-r--r-- | include/haproxy/listener-t.h | 2 | ||||
-rw-r--r-- | src/cfgparse-tcp.c | 2 | ||||
-rw-r--r-- | src/cli.c | 4 | ||||
-rw-r--r-- | src/proto_tcp.c | 4 | ||||
-rw-r--r-- | src/proto_udp.c | 4 | ||||
-rw-r--r-- | src/sock.c | 6 |
6 files changed, 11 insertions, 11 deletions
diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index ae0a8b3ee..16e5bc082 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -191,6 +191,7 @@ struct bind_conf { struct receiver { int options; /* receiver options (RX_O_*) */ + char *interface; /* interface name or NULL */ const struct netns_entry *netns; /* network namespace of the receiving socket */ /* warning: this struct is huge, keep it at the bottom */ struct sockaddr_storage addr; /* the address the socket is bound to */ @@ -221,7 +222,6 @@ struct listener { unsigned int analysers; /* bitmap of required protocol analysers */ int maxseg; /* for TCP, advertised MSS */ int tcp_ut; /* for TCP, user timeout */ - char *interface; /* interface name or NULL */ char *name; /* listener's name */ __decl_thread(HA_SPINLOCK_T lock); diff --git a/src/cfgparse-tcp.c b/src/cfgparse-tcp.c index 724a54035..1b2f052f1 100644 --- a/src/cfgparse-tcp.c +++ b/src/cfgparse-tcp.c @@ -187,7 +187,7 @@ static int bind_parse_interface(char **args, int cur_arg, struct proxy *px, stru 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->interface = strdup(args[cur_arg + 1]); + l->rx.interface = strdup(args[cur_arg + 1]); } return 0; @@ -1710,8 +1710,8 @@ static int _getsocks(char **args, char *payload, struct appctx *appctx, void *pr if (fdtab[cur_fd].iocb == listener_accept) { const struct listener *l = fdtab[cur_fd].owner; - if (l->interface) { - if_name = l->interface; + if (l->rx.interface) { + if_name = l->rx.interface; if_nlen = strlen(if_name); } diff --git a/src/proto_tcp.c b/src/proto_tcp.c index b4a8217e5..d95ec5f7e 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -654,9 +654,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) #ifdef SO_BINDTODEVICE /* Note: this might fail if not CAP_NET_RAW */ - if (!ext && listener->interface) { + if (!ext && listener->rx.interface) { if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, - listener->interface, strlen(listener->interface) + 1) == -1) { + listener->rx.interface, strlen(listener->rx.interface) + 1) == -1) { msg = "cannot bind listener to device"; err |= ERR_WARN; } diff --git a/src/proto_udp.c b/src/proto_udp.c index 43306bebe..db058ccb9 100644 --- a/src/proto_udp.c +++ b/src/proto_udp.c @@ -257,9 +257,9 @@ int udp_bind_listener(struct listener *listener, char *errmsg, int errlen) #ifdef SO_BINDTODEVICE /* Note: this might fail if not CAP_NET_RAW */ - if (listener->interface) { + if (listener->rx.interface) { if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, - listener->interface, strlen(listener->interface) + 1) == -1) { + listener->rx.interface, strlen(listener->rx.interface) + 1) == -1) { msg = "cannot bind listener to device"; err |= ERR_WARN; } diff --git a/src/sock.c b/src/sock.c index c9b086832..12f4fc88d 100644 --- a/src/sock.c +++ b/src/sock.c @@ -385,8 +385,8 @@ int sock_find_compatible_fd(const struct listener *l) options |= SOCK_XFER_OPT_V6ONLY; } - if (l->interface) - if_namelen = strlen(l->interface); + if (l->rx.interface) + if_namelen = strlen(l->rx.interface); #ifdef USE_NS if (l->rx.netns) ns_namelen = l->rx.netns->name_len; @@ -396,7 +396,7 @@ int sock_find_compatible_fd(const struct listener *l) if ((options == xfer_sock->options) && (if_namelen == xfer_sock->if_namelen) && (ns_namelen == xfer_sock->ns_namelen) && - (!if_namelen || strcmp(l->interface, xfer_sock->iface) == 0) && + (!if_namelen || strcmp(l->rx.interface, xfer_sock->iface) == 0) && #ifdef USE_NS (!ns_namelen || strcmp(l->rx.netns->node.key, xfer_sock->namespace) == 0) && #endif |