aboutgitcodebugslistschat
path: root/util.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-01-05 15:26:22 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-01-13 01:07:03 +0100
commitf1ed8dbfa732dd0c94461373fbcaea86b9eb1734 (patch)
tree07e8c99e3ea41b53b06a9a18e1491ab1c3f7764c /util.h
parentc9e193b5ae0d785f9d77adf2ce196393a1ab205c (diff)
downloadpasst-f1ed8dbfa732dd0c94461373fbcaea86b9eb1734.tar
passt-f1ed8dbfa732dd0c94461373fbcaea86b9eb1734.tar.gz
passt-f1ed8dbfa732dd0c94461373fbcaea86b9eb1734.tar.bz2
passt-f1ed8dbfa732dd0c94461373fbcaea86b9eb1734.tar.lz
passt-f1ed8dbfa732dd0c94461373fbcaea86b9eb1734.tar.xz
passt-f1ed8dbfa732dd0c94461373fbcaea86b9eb1734.tar.zst
passt-f1ed8dbfa732dd0c94461373fbcaea86b9eb1734.zip
udp: Pre-populate msg_names with local address
udp_splice_namebuf is now used only for spliced sending, and so it is only ever populated with the localhost address, either IPv4 or IPv6. So, replace the awkward initialization in udp_sock_handler_splice() with statically initialized versions for IPv4 and IPv6. We then just need to update the port number in udp_sock_handler_splice(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.h')
-rw-r--r--util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/util.h b/util.h
index 02b55a9..3baec91 100644
--- a/util.h
+++ b/util.h
@@ -79,6 +79,13 @@
(IN_MULTICAST(ntohl((a)->s_addr)))
#define IN4_ARE_ADDR_EQUAL(a, b) \
(((struct in_addr *)(a))->s_addr == ((struct in_addr *)b)->s_addr)
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define IN4ADDR_LOOPBACK_INIT \
+ { .s_addr = INADDR_LOOPBACK }
+#else
+#define IN4ADDR_LOOPBACK_INIT \
+ { .s_addr = __bswap_constant_32(INADDR_LOOPBACK) }
+#endif
#define NS_FN_STACK_SIZE (RLIMIT_STACK_VAL * 1024 / 8)
int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags,