public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 4/5] util: Add AF_UNSPEC support to sockaddr_ntop()
Date: Tue, 16 Jul 2024 15:29:35 +1000	[thread overview]
Message-ID: <20240716052936.1204164-5-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240716052936.1204164-1-david@gibson.dropbear.id.au>

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 <david@gibson.dropbear.id.au>
---
 util.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/util.c b/util.c
index 9a73fbb9..428847d2 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("<unspecified>");
+		break;
+
 	case AF_INET: {
 		const struct sockaddr_in *sa4 = sa;
 
-- 
@@ -622,6 +622,10 @@ const char *sockaddr_ntop(const void *sa, char *dst, socklen_t size)
 	} while (0)
 
 	switch (family) {
+	case AF_UNSPEC:
+		IPRINTF("<unspecified>");
+		break;
+
 	case AF_INET: {
 		const struct sockaddr_in *sa4 = sa;
 
-- 
2.45.2


  parent reply	other threads:[~2024-07-16  5:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16  5:29 [PATCH 0/5] Handle error events on UDP sockets David Gibson
2024-07-16  5:29 ` [PATCH 1/5] conf: Don't configure port forwarding for a disabled protocol David Gibson
2024-07-16  5:29 ` [PATCH 2/5] udp: Make udp_sock_recv static David Gibson
2024-07-16  5:29 ` [PATCH 3/5] udp, tcp: Tweak handling of no_udp and no_tcp flags David Gibson
2024-07-16  5:29 ` David Gibson [this message]
2024-07-16  5:29 ` [PATCH 5/5] udp: Handle errors on UDP sockets David Gibson
2024-07-16  7:25   ` Stefano Brivio
2024-07-17  0:04     ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240716052936.1204164-5-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).