Module Name: src
Committed By: christos
Date: Sun Jan 29 00:18:15 UTC 2017
Modified Files:
src/usr.sbin/npf/npfctl: npf_show.c
Log Message:
Always print the rule id associated with a rule.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/npf/npfctl/npf_show.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/npf/npfctl/npf_show.c
diff -u src/usr.sbin/npf/npfctl/npf_show.c:1.22 src/usr.sbin/npf/npfctl/npf_show.c:1.23
--- src/usr.sbin/npf/npfctl/npf_show.c:1.22 Thu Dec 29 15:48:50 2016
+++ src/usr.sbin/npf/npfctl/npf_show.c Sat Jan 28 19:18:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_show.c,v 1.22 2016/12/29 20:48:50 rmind Exp $ */
+/* $NetBSD: npf_show.c,v 1.23 2017/01/29 00:18:15 christos Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_show.c,v 1.22 2016/12/29 20:48:50 rmind Exp $");
+__RCSID("$NetBSD: npf_show.c,v 1.23 2017/01/29 00:18:15 christos Exp $");
#include <sys/socket.h>
#define __FAVOR_BSD
@@ -338,6 +338,13 @@ scan_marks(npf_conf_info_t *ctx, const s
}
static void
+npfctl_print_id(npf_conf_info_t *ctx, nl_rule_t *rl)
+{
+ uint64_t id = id = npf_rule_getid(rl);
+ fprintf(ctx->fp, "# id=\"%" PRIu64 "\" ", id);
+}
+
+static void
npfctl_print_filter(npf_conf_info_t *ctx, nl_rule_t *rl)
{
const void *marks;
@@ -399,8 +406,7 @@ npfctl_print_rule(npf_conf_info_t *ctx,
if ((attr & NPF_DYNAMIC_GROUP) == NPF_RULE_GROUP) {
/* Group; done. */
- fputs("\n", ctx->fp);
- return;
+ goto out;
}
/* Print filter criteria. */
@@ -411,12 +417,8 @@ npfctl_print_rule(npf_conf_info_t *ctx,
fprintf(ctx->fp, "apply \"%s\" ", rproc);
}
- /* If dynamic rule - print its ID. */
- if ((attr & NPF_DYNAMIC_GROUP) == NPF_RULE_DYNAMIC) {
- uint64_t id = npf_rule_getid(rl);
- fprintf(ctx->fp, "# id = \"%" PRIx64 "\" ", id);
- }
-
+out:
+ npfctl_print_id(ctx, rl);
fputs("\n", ctx->fp);
}
@@ -465,6 +467,7 @@ npfctl_print_nat(npf_conf_info_t *ctx, n
ifname, (flags & NPF_NAT_STATIC) ? "static" : "dynamic",
seg1, arrow, seg2);
npfctl_print_filter(ctx, rl);
+ npfctl_print_id(ctx, rl);
fputs("\n", ctx->fp);
free(seg);
}