On Tue, Jun 13, 2017 at 12:43:51AM +0200, Adam Wolk wrote: > On Mon, Jun 12, 2017 at 11:43:44PM +0200, Alexandr Nedvedicky wrote: > > Hello Adam, > > > > </snip> > > > > > It was a rainy evening here, so here's the updated pfctl diff. > > > > I'm sorry to hear about the rainy weather [1]. > > anyway, you might want to run regression test for pfctl. > > > > cd $SRC/src/regress/sbin/pfctl > > cat Makefile > > # follow instructions > > > > just for sure. > > Ran the tests both on the unmodified and changed pfctl using a stock > unmodified > GENERIC kernel. > > One test case fails pfcmd1. >
Yet another rainy day, so revisiting the diff. 1. Re-basing the diff on the recently committed change from the OP 2. Removed the redundant error reporting from: - pfctl_clear_tables - pfctl_show_tables 3. pfctl_show_ifaces back to using radix_perror for output consistency 4. regress test altered, we are passing in the -n which just results in the rules being parsed. The definition for the pfctlcmd testing group in the Makefile is: # pfcmd: test pfctl command line parsing after the change the test failed not because of command line parsing but from the attempt of trying to clear tables from a non existing anchor. with the -n flag we still test if the anchor command can be combined with -Fa but don't actually attempt to run the clearing code. This regress modification passes both with the pfctl before this change as well as the newly modified one. Feedback, OK's?
? openbsd-daily-pfctl-1.diff ? openbsd-daily-pfctl-2.diff ? openbsd-daily-pfctl-3.diff ? parse.c ? pfctl ? rain.diff Index: pfctl.h =================================================================== RCS file: /cvs/src/sbin/pfctl/pfctl.h,v retrieving revision 1.53 diff -u -p -r1.53 pfctl.h --- pfctl.h 19 Jan 2015 23:52:02 -0000 1.53 +++ pfctl.h 16 Jun 2017 21:05:38 -0000 @@ -75,12 +75,12 @@ int pfi_get_ifaces(const char *, struct int pfi_clr_istats(const char *, int *, int); void pfctl_print_title(char *); -int pfctl_clear_tables(const char *, int); -int pfctl_show_tables(const char *, int); +void pfctl_clear_tables(const char *, int); +void pfctl_show_tables(const char *, int); int pfctl_command_tables(int, char *[], char *, const char *, char *, const char *, int); void warn_namespace_collision(const char *); -int pfctl_show_ifaces(const char *, int); +void pfctl_show_ifaces(const char *, int); FILE *pfctl_fopen(const char *, const char *); /* Index: pfctl_table.c =================================================================== RCS file: /cvs/src/sbin/pfctl/pfctl_table.c,v retrieving revision 1.75 diff -u -p -r1.75 pfctl_table.c --- pfctl_table.c 13 Apr 2017 07:30:21 -0000 1.75 +++ pfctl_table.c 16 Jun 2017 21:05:38 -0000 @@ -102,16 +102,18 @@ static const char *istats_text[2][2][2] table.pfrt_flags &= ~PFR_TFLAG_PERSIST; \ } while(0) -int +void pfctl_clear_tables(const char *anchor, int opts) { - return pfctl_table(0, NULL, NULL, "-F", NULL, anchor, opts); + if (pfctl_table(0, NULL, NULL, "-F", NULL, anchor, opts) == -1) + exit(1); } -int +void pfctl_show_tables(const char *anchor, int opts) { - return pfctl_table(0, NULL, NULL, "-s", NULL, anchor, opts); + if (pfctl_table(0, NULL, NULL, "-s", NULL, anchor, opts) == -1) + exit(1); } int @@ -594,7 +596,7 @@ xprintf(int opts, const char *fmt, ...) /* interface stuff */ -int +void pfctl_show_ifaces(const char *filter, int opts) { struct pfr_buffer b; @@ -608,7 +610,7 @@ pfctl_show_ifaces(const char *filter, in b.pfrb_size = b.pfrb_msize; if (pfi_get_ifaces(filter, b.pfrb_caddr, &b.pfrb_size)) { radix_perror(); - return (1); + exit(1); } if (b.pfrb_size <= b.pfrb_msize) break; @@ -618,7 +620,6 @@ pfctl_show_ifaces(const char *filter, in pfctl_print_title("INTERFACES:"); PFRB_FOREACH(p, &b) print_iface(p, opts); - return (0); } void
? pfctl-regress-2.diff ? pfctl-regress.diff Index: pfcmd1.opts =================================================================== RCS file: /cvs/src/regress/sbin/pfctl/pfcmd1.opts,v retrieving revision 1.1 diff -u -p -r1.1 pfcmd1.opts --- pfcmd1.opts 3 Jul 2010 02:32:45 -0000 1.1 +++ pfcmd1.opts 16 Jun 2017 21:34:29 -0000 @@ -1 +1 @@ --a regress/does_not_exist -Fa +-n -a regress/does_not_exist -Fa