mirror of
https://passt.top/passt
synced 2025-06-11 01:55:34 +02:00
Use IPV4_IS_LOOPBACK more widely
This macro checks if an IPv4 address is in the loopback network (127.0.0.0/8). There are two places where we open code an identical check, use the macro instead. There are also a number of places we specifically exclude the loopback address (127.0.0.1), but we should actually be excluding anything in the loopback network. Change those sites to use the macro as well. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
dd09cceaee
commit
dd3470d9a9
2 changed files with 5 additions and 5 deletions
2
udp.c
2
udp.c
|
@ -680,7 +680,7 @@ static void udp_sock_fill_data_v4(const struct ctx *c, int n,
|
|||
src = ntohl(b->s_in.sin_addr.s_addr);
|
||||
src_port = ntohs(b->s_in.sin_port);
|
||||
|
||||
if (src >> IN_CLASSA_NSHIFT == IN_LOOPBACKNET ||
|
||||
if (IPV4_IS_LOOPBACK(src) ||
|
||||
src == INADDR_ANY || src == ntohl(c->ip4.addr_seen)) {
|
||||
b->iph.saddr = c->ip4.gw;
|
||||
udp_tap_map[V4][src_port].ts = now->tv_sec;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue