diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-07-26 18:20:01 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-07-26 18:20:01 +0200 |
commit | 8af961b85bbfd48f4304851bcd42f106fa447bb9 (patch) | |
tree | d3854ebeac5d047728d4dec72035d0ba0735f506 /udp.c | |
parent | 9663378d6d6dcd8275d60b826356cc4be0538231 (diff) | |
download | passt-8af961b85bbfd48f4304851bcd42f106fa447bb9.tar passt-8af961b85bbfd48f4304851bcd42f106fa447bb9.tar.gz passt-8af961b85bbfd48f4304851bcd42f106fa447bb9.tar.bz2 passt-8af961b85bbfd48f4304851bcd42f106fa447bb9.tar.lz passt-8af961b85bbfd48f4304851bcd42f106fa447bb9.tar.xz passt-8af961b85bbfd48f4304851bcd42f106fa447bb9.tar.zst passt-8af961b85bbfd48f4304851bcd42f106fa447bb9.zip |
tcp, udp: Map source address to gateway for any traffic from 127.0.0.0/8
...instead of just 127.0.0.1.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -728,15 +728,16 @@ void udp_sock_handler(struct ctx *c, union epoll_ref ref, uint32_t events, for (i = 0; i < n; i++) { struct udp4_l2_buf_t *b = &udp4_l2_buf[i]; size_t ip_len, iov_len; + in_addr_t s_addr; ip_len = udp4_l2_mh_sock[i].msg_len + sizeof(b->iph) + sizeof(b->uh); b->iph.tot_len = htons(ip_len); - if (ntohl(b->s_in.sin_addr.s_addr) == INADDR_LOOPBACK || - ntohl(b->s_in.sin_addr.s_addr) == INADDR_ANY || - b->s_in.sin_addr.s_addr == c->addr4_seen) { + s_addr = ntohl(b->s_in.sin_addr.s_addr); + if (s_addr >> IN_CLASSA_NSHIFT == IN_LOOPBACKNET || + s_addr == INADDR_ANY || s_addr == c->addr4_seen) { in_port_t src = htons(b->s_in.sin_port); b->iph.saddr = c->gw4; |