git: 9bfba304a8a3 - stable/13 - ipfilter: Support printing of IPv6 addresses in error message
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 19 Nov 2024 00:28:18 UTC
The branch stable/13 has been updated by cy:
URL: https://cgit.FreeBSD.org/src/commit/?id=9bfba304a8a36d3b2b8c8d2efa2caeb65955474e
commit 9bfba304a8a36d3b2b8c8d2efa2caeb65955474e
Author: Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2024-11-08 07:39:11 +0000
Commit: Cy Schubert <cy@FreeBSD.org>
CommitDate: 2024-11-19 00:27:07 +0000
ipfilter: Support printing of IPv6 addresses in error message
Replace inet_ntoa(3) with inet_ntop(3). This supporting the printing of
IPv6 IP addresses in addition to IPv4 IP addresses in error message.
(cherry picked from commit 3a2cb65b6e6dc1e71013db27ce143eb8670a1755)
---
sbin/ipf/libipf/load_poolnode.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/sbin/ipf/libipf/load_poolnode.c b/sbin/ipf/libipf/load_poolnode.c
index 0e41a3921b71..880a6cd1c681 100644
--- a/sbin/ipf/libipf/load_poolnode.c
+++ b/sbin/ipf/libipf/load_poolnode.c
@@ -53,11 +53,29 @@ load_poolnode(int role, char *name, ip_pool_node_t *node, int ttl,
if (err != 0) {
if ((opts & OPT_DONOTHING) == 0) {
char msg[255];
+ char ipaddr[80], mask_msg[10], mask[8];
- snprintf(msg, sizeof(msg), "%s pool(%s) node(%s/", what,
- name, inet_ntoa(pn.ipn_addr.adf_addr.in4));
- strlcat(msg, inet_ntoa(pn.ipn_mask.adf_addr.in4), sizeof(msg));
- strcat(msg, ")");
+ inet_ntop(pn.ipn_addr.adf_family,
+ pn.ipn_addr.adf_addr.vptr, ipaddr,
+ sizeof(ipaddr));
+
+#ifdef USE_INET6
+ if (pn.ipn_mask.adf_family == AF_INET) {
+#endif
+ inet_ntop(pn.ipn_mask.adf_family,
+ pn.ipn_mask.adf_addr.vptr, mask,
+ sizeof(mask));
+ mask_msg[0]='/';
+ mask_msg[1]='\0';
+ strlcat(mask_msg, mask, sizeof(mask_msg));
+#ifdef USE_INET6
+ } else {
+ mask_msg[0]='\0';
+ }
+#endif
+
+ snprintf(msg, sizeof(msg), "%s pool(%s) node(%s%s)",
+ what, name, ipaddr, mask_msg);
return (ipf_perror_fd(pool_fd(), iocfunc, msg));
}
}