From 546332786cee921213fc59db6207be23c2d70208 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 8 Dec 2023 01:31:34 +1100 Subject: treewide: Use IN4ADDR_LOOPBACK_INIT more widely We already define IN4ADDR_LOOPBACK_INIT to initialise a struct in_addr to the loopback address without delving into its internals. However there are some places we don't use it, and explicitly look at the internal structure of struct in_addr, which we generally want to avoid. Use the define more widely to avoid that. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- udp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index 1f8c306..489a843 100644 --- a/udp.c +++ b/udp.c @@ -429,7 +429,7 @@ int udp_splice_new(const struct ctx *c, int v6, in_port_t src, bool ns) struct sockaddr_in addr4 = { .sin_family = AF_INET, .sin_port = htons(src), - .sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) }, + .sin_addr = IN4ADDR_LOOPBACK_INIT, }; if (bind(s, (struct sockaddr *)&addr4, sizeof(addr4))) goto fail; @@ -1012,7 +1012,7 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, udp_tap_map[V4][uref.port].sock = s < 0 ? -1 : s; udp_splice_init[V4][port].sock = s < 0 ? -1 : s; } else { - struct in_addr loopback = { htonl(INADDR_LOOPBACK) }; + struct in_addr loopback = IN4ADDR_LOOPBACK_INIT; r4 = s = sock_l4(c, AF_INET, IPPROTO_UDP, &loopback, ifname, port, uref.u32); -- cgit v1.2.3