Skip to content

Commit 2f30b43

Browse files
committed
ipfilter/ippool: Dump a copy of ippool hash data in "new" format
As with 7531c43, which dumped ippool table data in the "new" format, print hash data in the "new" format. MFC after: 1 week
1 parent f3ff6ab commit 2f30b43

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

sbin/ipf/libipf/printhash_live.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
2626
if ((hp->iph_flags & IPHASH_DELETE) != 0)
2727
PRINTF("# ");
2828

29-
if ((opts & OPT_DEBUG) == 0)
29+
if (opts & OPT_SAVEOUT)
30+
PRINTF("{\n");
31+
else if ((opts & OPT_DEBUG) == 0)
3032
PRINTF("\t{");
3133

3234
obj.ipfo_rev = IPFILTER_VERSION;
@@ -50,6 +52,8 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
5052
last = 1;
5153
if (bcmp(&zero, &entry, sizeof(zero)) == 0)
5254
break;
55+
if (opts & OPT_SAVEOUT)
56+
PRINTF("\t");
5357
(void) printhashnode(hp, &entry, bcopywrap, opts, fields);
5458
printed++;
5559
}
@@ -59,7 +63,7 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
5963
if (printed == 0)
6064
putchar(';');
6165

62-
if ((opts & OPT_DEBUG) == 0)
66+
if ((opts & OPT_DEBUG) == 0 || (opts & OPT_SAVEOUT))
6367
PRINTF(" };\n");
6468

6569
(void) ioctl(fd,SIOCIPFDELTOK, &iter.ili_key);

sbin/ipf/libipf/printhashdata.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ void
1212
printhashdata(iphtable_t *hp, int opts)
1313
{
1414

15-
if ((opts & OPT_DEBUG) == 0) {
15+
if (opts & OPT_SAVEOUT) {
16+
if ((hp->iph_flags & IPHASH_DELETE) == IPHASH_DELETE)
17+
PRINTF("# ");
18+
PRINTF("pool ");
19+
} else if ((opts & OPT_DEBUG) == 0) {
1620
if ((hp->iph_type & IPHASH_ANON) == IPHASH_ANON)
1721
PRINTF("# 'anonymous' table refs %d\n", hp->iph_ref);
1822
if ((hp->iph_flags & IPHASH_DELETE) == IPHASH_DELETE)
@@ -50,7 +54,16 @@ printhashdata(iphtable_t *hp, int opts)
5054

5155
printunit(hp->iph_unit);
5256

53-
if ((opts & OPT_DEBUG) == 0) {
57+
if ((opts & OPT_SAVEOUT)) {
58+
if ((hp->iph_type & ~IPHASH_ANON) == IPHASH_LOOKUP)
59+
PRINTF("/hash");
60+
PRINTF("(%s \"%s\"; size %lu;",
61+
ISDIGIT(*hp->iph_name) ? "number" : "name",
62+
hp->iph_name, (u_long)hp->iph_size);
63+
if (hp->iph_seed != 0)
64+
PRINTF(" seed %lu;", hp->iph_seed);
65+
PRINTF(")\n", hp->iph_seed);
66+
} else if ((opts & OPT_DEBUG) == 0) {
5467
if ((hp->iph_type & ~IPHASH_ANON) == IPHASH_LOOKUP)
5568
PRINTF(" type=hash");
5669
PRINTF(" %s=%s size=%lu",

0 commit comments

Comments
 (0)