From 647a41379402cf0fae495f1be5d15d0ca8ed1e16 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sat, 28 Aug 2021 03:19:25 +0200 Subject: tcp, udp: Restore usage of gateway for guest to connect to local host This went lost in a recent rework: if the guest wants to connect directly to the host, it can use the address of the default gateway. Signed-off-by: Stefano Brivio --- udp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index 097e263..e3bb1e6 100644 --- a/udp.c +++ b/udp.c @@ -923,9 +923,9 @@ int udp_tap_handler(struct ctx *c, int af, void *addr, udp_tap_map[V4][src].ts = now->tv_sec; - if (s_in.sin_addr.s_addr == c->gw4 && - udp_tap_map[V4][dst].ts_local) { - if (udp_tap_map[V4][dst].loopback) + if (s_in.sin_addr.s_addr == c->gw4) { + if (!udp_tap_map[V4][dst].ts_local || + udp_tap_map[V4][dst].loopback) s_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK); else s_in.sin_addr.s_addr = c->addr4_seen; @@ -941,9 +941,9 @@ int udp_tap_handler(struct ctx *c, int af, void *addr, sa = (struct sockaddr *)&s_in6; sl = sizeof(s_in6); - if (!memcmp(addr, &c->gw6, sizeof(c->gw6)) && - udp_tap_map[V6][dst].ts_local) { - if (udp_tap_map[V6][dst].loopback) + if (!memcmp(addr, &c->gw6, sizeof(c->gw6))) { + if (!udp_tap_map[V6][dst].ts_local || + udp_tap_map[V6][dst].loopback) s_in6.sin6_addr = in6addr_loopback; else s_in6.sin6_addr = c->addr6_seen; -- cgit v1.2.3