Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Oct 2025 12:37:05 GMT
From:      Cy Schubert <cy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 96870b5accc9 - stable/13 - ipfilter/ippool: Dump a copy of ippool hash data in "new" format
Message-ID:  <202510091237.599Cb5Sf072593@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by cy:

URL: https://cgit.FreeBSD.org/src/commit/?id=96870b5accc9260c0f0098d88ea3f56573b1e417

commit 96870b5accc9260c0f0098d88ea3f56573b1e417
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2022-11-02 05:46:41 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2025-10-09 12:36:57 +0000

    ipfilter/ippool: Dump a copy of ippool hash data in "new" format
    
    As with 7531c434a593, which dumped ippool table data in the "new"
    format, print hash data in the "new" format.
    
    (cherry picked from commit 2f30b43fa269bc63086b0428f45c79e982abb02f)
---
 sbin/ipf/libipf/printhash_live.c |  8 ++++++--
 sbin/ipf/libipf/printhashdata.c  | 17 +++++++++++++++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/sbin/ipf/libipf/printhash_live.c b/sbin/ipf/libipf/printhash_live.c
index b8ee31b27597..427daa18316b 100644
--- a/sbin/ipf/libipf/printhash_live.c
+++ b/sbin/ipf/libipf/printhash_live.c
@@ -26,7 +26,9 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
 	if ((hp->iph_flags & IPHASH_DELETE) != 0)
 		PRINTF("# ");
 
-	if ((opts & OPT_DEBUG) == 0)
+	if (opts & OPT_SAVEOUT)
+		PRINTF("{\n");
+	else if ((opts & OPT_DEBUG) == 0)
 		PRINTF("\t{");
 
 	obj.ipfo_rev = IPFILTER_VERSION;
@@ -50,6 +52,8 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
 			last = 1;
 		if (bcmp(&zero, &entry, sizeof(zero)) == 0)
 			break;
+		if (opts & OPT_SAVEOUT)
+			PRINTF("\t");
 		(void) printhashnode(hp, &entry, bcopywrap, opts, fields);
 		printed++;
 	}
@@ -59,7 +63,7 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
 	if (printed == 0)
 		putchar(';');
 
-	if ((opts & OPT_DEBUG) == 0)
+	if ((opts & OPT_DEBUG) == 0 || (opts & OPT_SAVEOUT))
 		PRINTF(" };\n");
 
 	(void) ioctl(fd,SIOCIPFDELTOK, &iter.ili_key);
diff --git a/sbin/ipf/libipf/printhashdata.c b/sbin/ipf/libipf/printhashdata.c
index ba96a75a94d7..6fa62e67556d 100644
--- a/sbin/ipf/libipf/printhashdata.c
+++ b/sbin/ipf/libipf/printhashdata.c
@@ -12,7 +12,11 @@ void
 printhashdata(iphtable_t *hp, int opts)
 {
 
-	if ((opts & OPT_DEBUG) == 0) {
+	if (opts & OPT_SAVEOUT) {
+		if ((hp->iph_flags & IPHASH_DELETE) == IPHASH_DELETE)
+			PRINTF("# ");
+		PRINTF("pool ");
+	} else if ((opts & OPT_DEBUG) == 0) {
 		if ((hp->iph_type & IPHASH_ANON) == IPHASH_ANON)
 			PRINTF("# 'anonymous' table refs %d\n", hp->iph_ref);
 		if ((hp->iph_flags & IPHASH_DELETE) == IPHASH_DELETE)
@@ -50,7 +54,16 @@ printhashdata(iphtable_t *hp, int opts)
 
 	printunit(hp->iph_unit);
 
-	if ((opts & OPT_DEBUG) == 0) {
+	if ((opts & OPT_SAVEOUT)) {
+		if ((hp->iph_type & ~IPHASH_ANON) == IPHASH_LOOKUP)
+			PRINTF("/hash");
+		PRINTF("(%s \"%s\"; size %lu;",
+			ISDIGIT(*hp->iph_name) ? "number" : "name",
+			hp->iph_name, (u_long)hp->iph_size);
+		if (hp->iph_seed != 0)
+			PRINTF(" seed %lu;", hp->iph_seed);
+		PRINTF(")\n", hp->iph_seed);
+	} else if ((opts & OPT_DEBUG) == 0) {
 		if ((hp->iph_type & ~IPHASH_ANON) == IPHASH_LOOKUP)
 			PRINTF(" type=hash");
 		PRINTF(" %s=%s size=%lu",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510091237.599Cb5Sf072593>