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 2/3] inany: Improve ASSERT message for bad socket family
Date: Thu, 10 Apr 2025 17:16:39 +1000 [thread overview]
Message-ID: <20250410071640.2310091-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20250410071640.2310091-1-david@gibson.dropbear.id.au>
inany_from_sockaddr() can only handle sockaddrs of family AF_INET or
AF_INET6 and asserts if given something else. I hit this assertion while
debugging something else, and wanted to see what the bad sockaddr family
was. Now that we have ASSERT_WITH_MSG() its easy to add this information.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
inany.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/inany.h b/inany.h
index 6a12c292..1c247e1e 100644
--- a/inany.h
+++ b/inany.h
@@ -252,7 +252,8 @@ static inline void inany_from_sockaddr(union inany_addr *aa, in_port_t *port,
*port = ntohs(sa->sa4.sin_port);
} else {
/* Not valid to call with other address families */
- ASSERT(0);
+ ASSERT_WITH_MSG(0, "Unexpected sockaddr family: %u",
+ sa->sa_family);
}
}
--
@@ -252,7 +252,8 @@ static inline void inany_from_sockaddr(union inany_addr *aa, in_port_t *port,
*port = ntohs(sa->sa4.sin_port);
} else {
/* Not valid to call with other address families */
- ASSERT(0);
+ ASSERT_WITH_MSG(0, "Unexpected sockaddr family: %u",
+ sa->sa_family);
}
}
--
2.49.0
next prev parent reply other threads:[~2025-04-10 7:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 7:16 [PATCH 0/3] Properly preseve local addresses for UDP flows David Gibson
2025-04-10 7:16 ` [PATCH 1/3] udp: Use PKTINFO cmsgs to get destination address for received datagrams David Gibson
2025-04-10 7:16 ` David Gibson [this message]
2025-04-10 7:16 ` [PATCH 3/3] udp, udp_flow: Track our specific address on socket interfaces David Gibson
2025-04-11 5:03 ` [PATCH 0/3] Properly preseve local addresses for UDP flows Stefano Brivio
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=20250410071640.2310091-3-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).