Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/npf/npfctl npfctl: fix the from/to port mess up whe...



details:   https://anonhg.NetBSD.org/src/rev/d630c1ece02c
branches:  trunk
changeset: 808825:d630c1ece02c
user:      rmind <rmind%NetBSD.org@localhost>
date:      Wed Jun 03 23:36:05 2015 +0000

description:
npfctl: fix the from/to port mess up when showing the rules.

diffstat:

 usr.sbin/npf/npfctl/npf_show.c |  17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diffs (59 lines):

diff -r a7430eeae9b6 -r d630c1ece02c usr.sbin/npf/npfctl/npf_show.c
--- a/usr.sbin/npf/npfctl/npf_show.c    Wed Jun 03 23:15:22 2015 +0000
+++ b/usr.sbin/npf/npfctl/npf_show.c    Wed Jun 03 23:36:05 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_show.c,v 1.18 2015/03/21 00:49:07 rmind Exp $      */
+/*     $NetBSD: npf_show.c,v 1.19 2015/06/03 23:36:05 rmind Exp $      */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_show.c,v 1.18 2015/03/21 00:49:07 rmind Exp $");
+__RCSID("$NetBSD: npf_show.c,v 1.19 2015/06/03 23:36:05 rmind Exp $");
 
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -214,14 +214,14 @@
        char *p;
 
        if (ctx->curmark == BM_SRC_PORTS && (ctx->flags & SEEN_SRC) == 0)
-               any_str = "to any ";
+               any_str = "from any ";
        if (ctx->curmark == BM_DST_PORTS && (ctx->flags & SEEN_DST) == 0)
-               any_str = "from any ";
+               any_str = "to any ";
 
        if (fport != tport) {
-               easprintf(&p, "%s%u:%u", any_str, fport, tport);
+               easprintf(&p, "%sport %u:%u", any_str, fport, tport);
        } else {
-               easprintf(&p, "%s%u", any_str, fport);
+               easprintf(&p, "%sport %u", any_str, fport);
        }
        return p;
 }
@@ -271,11 +271,11 @@
 
        { BM_SRC_CIDR,  "from %s",      ", ", SEEN_SRC, print_address,  6 },
        { BM_SRC_TABLE, "from <%s>",    NULL, SEEN_SRC, print_table,    1 },
-       { BM_SRC_PORTS, "port %s",      ", ", 0,        print_portrange,2 },
+       { BM_SRC_PORTS, "%s",           ", ", 0,        print_portrange,2 },
 
        { BM_DST_CIDR,  "to %s",        ", ", SEEN_DST, print_address,  6 },
        { BM_DST_TABLE, "to <%s>",      NULL, SEEN_DST, print_table,    1 },
-       { BM_DST_PORTS, "port %s",      ", ", 0,        print_portrange,2 },
+       { BM_DST_PORTS, "%s",           ", ", 0,        print_portrange,2 },
 };
 
 static const char * __attribute__((format_arg(2)))
@@ -351,6 +351,7 @@
                    "pcap-filter \"...\"" : "unrecognized-bytecode");
                return;
        }
+       ctx->flags = 0;
 
        /*
         * BPF filter criteria described by the byte-code marks.



Home | Main Index | Thread Index | Old Index