The branch main has been updated by cy:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2f30b43fa269bc63086b0428f45c79e982abb02f

commit 2f30b43fa269bc63086b0428f45c79e982abb02f
Author:     Cy Schubert <[email protected]>
AuthorDate: 2022-11-02 05:46:41 +0000
Commit:     Cy Schubert <[email protected]>
CommitDate: 2025-10-02 19:03:35 +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.
    
    MFC after:      1 week
---
 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",

Reply via email to