ipfilter/ippool: Dump a copy of ippool hash data in "new" format

As with 7531c434a5, which dumped ippool table data in the "new"
format, print hash data in the "new" format.

MFC after:	1 week
This commit is contained in:
Cy Schubert committed 2025-10-02 12:03:35 -07:00
1 parent f3ff6abb9d
commit 2f30b43fa2
2 files changed
+21 -4

No files matched your search

+6 -2
View File
@@ -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);
+15 -2
View File
@@ -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",