git: 88fdbc9a0680 - stable/12 - ipfilter: Reliably print the interface name
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 10 Mar 2022 00:33:41 UTC
The branch stable/12 has been updated by cy:
URL: https://cgit.FreeBSD.org/src/commit/?id=88fdbc9a0680bb656bc9d7bff8fb2203990380fb
commit 88fdbc9a0680bb656bc9d7bff8fb2203990380fb
Author: Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2022-03-03 06:43:48 +0000
Commit: Cy Schubert <cy@FreeBSD.org>
CommitDate: 2022-03-10 00:33:20 +0000
ipfilter: Reliably print the interface name
When printing the interface name from the ipstate_t struct the interface
name in is_ifp may not always be avaiable when reading it from kmem
(tested on FreeBSD and NetBSD). However the is_ifname (the interface
name character string) is almost always available -- it is not available
when the source of the packet is a process running on the firewall
itself. Rather than print both interface name strings, print only the
one.
(cherry picked from commit 93c1048a1360c3a0f1a6a9248916ef06c52b4504)
---
sbin/ipf/libipf/printstate.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/sbin/ipf/libipf/printstate.c b/sbin/ipf/libipf/printstate.c
index 8832a723e9f1..1f135231ff58 100644
--- a/sbin/ipf/libipf/printstate.c
+++ b/sbin/ipf/libipf/printstate.c
@@ -184,23 +184,19 @@ printstate(ipstate_t *sp, int opts, u_long now)
PRINTF("\tis_flx %#x %#x %#x %#x\n", sp->is_flx[0][0],
sp->is_flx[0][1], sp->is_flx[1][0], sp->is_flx[1][1]);
}
- PRINTF("\tinterfaces: in %s[%s", getifname(sp->is_ifp[0]),
- sp->is_ifname[0]);
+ PRINTF("\tinterfaces: in %s", FORMAT_IF(sp->is_ifname[0]));
if (opts & OPT_DEBUG)
PRINTF("/%p", sp->is_ifp[0]);
- putchar(']');
- PRINTF(",%s[%s", getifname(sp->is_ifp[1]), sp->is_ifname[1]);
+ PRINTF(",%s", FORMAT_IF(sp->is_ifname[1]));
if (opts & OPT_DEBUG)
PRINTF("/%p", sp->is_ifp[1]);
- putchar(']');
- PRINTF(" out %s[%s", getifname(sp->is_ifp[2]), sp->is_ifname[2]);
+ PRINTF(" out %s", FORMAT_IF(sp->is_ifname[2]));
if (opts & OPT_DEBUG)
PRINTF("/%p", sp->is_ifp[2]);
- putchar(']');
- PRINTF(",%s[%s", getifname(sp->is_ifp[3]), sp->is_ifname[3]);
+ PRINTF(",%s", FORMAT_IF(sp->is_ifname[3]));
if (opts & OPT_DEBUG)
PRINTF("/%p", sp->is_ifp[3]);
- PRINTF("]\n");
+ PRINTF("\n");
PRINTF("\tSync status: ");
if (sp->is_sync != NULL) {