diff options
author | Stefan Metzmacher <metze@samba.org> | 2019-01-23 19:41:36 +0100 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2020-03-21 13:59:42 +0100 |
commit | 7bced01e89a16e673794e83dc984967aaddb558c (patch) | |
tree | cc5790b14c4eaa3ab942688b3d29b60601a3990f /src | |
parent | eb5bd0bc2128cdea5f5ef0fc20fb0af28fb3f6c1 (diff) | |
download | socket_wrapper-7bced01e89a16e673794e83dc984967aaddb558c.tar.gz socket_wrapper-7bced01e89a16e673794e83dc984967aaddb558c.tar.xz socket_wrapper-7bced01e89a16e673794e83dc984967aaddb558c.zip |
swrap: add support for SOCKET_WRAPPER_IPV4_NETWORK=10.53.57.0
With this 10.53.57.XX/8 addresses are used instead of
127.0.0.XX/8. Note the broadcast address is 127.255.255.255
or 10.255.255.255 (and not 10.53.57.255!).
Some applications, e.g. Samba have some special behavior for
loopback addresses.
This allows more realistic tests and triggers the more common
code paths.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/socket_wrapper.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index d05182f..cee7c51 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -1193,13 +1193,18 @@ static void swrap_bind_symbol_all(void) *********************************************************/ /* - * For now we return 127.0.0.0 + * We return 127.0.0.0 (default) or 10.53.57.0. + * + * This can be controlled by: + * SOCKET_WRAPPER_IPV4_NETWORK=127.0.0.0 (default) + * or + * SOCKET_WRAPPER_IPV4_NETWORK=10.53.57.0 */ static in_addr_t swrap_ipv4_net(void) { static int initialized; static in_addr_t hv; - const char *net_str = "127.0.0.0"; + const char *net_str = NULL; struct in_addr nv; int ret; @@ -1208,6 +1213,11 @@ static in_addr_t swrap_ipv4_net(void) } initialized = 1; + net_str = getenv("SOCKET_WRAPPER_IPV4_NETWORK"); + if (net_str == NULL) { + net_str = "127.0.0.0"; + } + ret = inet_pton(AF_INET, net_str, &nv); if (ret <= 0) { SWRAP_LOG(SWRAP_LOG_ERROR, @@ -1237,7 +1247,7 @@ static in_addr_t swrap_ipv4_net(void) } /* - * This returns 127.255.255.255 + * This returns 127.255.255.255 or 10.255.255.255 */ static in_addr_t swrap_ipv4_bcast(void) { @@ -1250,7 +1260,7 @@ static in_addr_t swrap_ipv4_bcast(void) } /* - * This returns 127.0.0.${iface} + * This returns 127.0.0.${iface} or 10.53.57.${iface} */ static in_addr_t swrap_ipv4_iface(unsigned int iface) { @@ -1846,12 +1856,17 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i type = a_type; iface = socket_wrapper_default_iface(); } else if (b_type && addr == sw_bcast_addr) { - /* 127.255.255.255 only udp */ + /* + * 127.255.255.255 + * or + * 10.255.255.255 + * only udp + */ is_bcast = 1; type = b_type; iface = socket_wrapper_default_iface(); } else if ((addr & 0xFFFFFF00) == sw_net_addr) { - /* 127.0.0.X */ + /* 127.0.0.X or 10.53.57.X */ is_bcast = 0; type = u_type; iface = (addr & 0x000000FF); |