From 6bd8283bf962126da73612737a5730082b70b5f3 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 17 Jul 2024 10:36:03 +1000 Subject: [PATCH] util: Add AF_UNSPEC support to sockaddr_ntop() Allow sockaddr_ntop() to format AF_UNSPEC socket addresses. There do exist a few cases where we might legitimately have either an AF_UNSPEC or a real address, such as the origin address from MSG_ERRQUEUE. Even in cases where we shouldn't get an AF_UNSPEC address, formatting it is likely to make things easier to debug if we ever somehow do. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util.c b/util.c index 9a73fbb..428847d 100644 --- a/util.c +++ b/util.c @@ -622,6 +622,10 @@ const char *sockaddr_ntop(const void *sa, char *dst, socklen_t size) } while (0) switch (family) { + case AF_UNSPEC: + IPRINTF(""); + break; + case AF_INET: { const struct sockaddr_in *sa4 = sa;