Module Name: src Committed By: snj Date: Wed Jun 10 16:57:58 UTC 2015
Modified Files: src/sys/net/npf [netbsd-7]: npf_ctl.c src/usr.sbin/npf/npfctl [netbsd-7]: npf_bpf_comp.c npf_build.c Log Message: Pull up following revision(s) (requested by rmind in ticket #835): sys/net/npf/npf_ctl.c: revision 1.42 usr.sbin/npf/npfctl/npf_bpf_comp.c: revision 1.8 usr.sbin/npf/npfctl/npf_build.c: revision 1.40 - npfctl: fix the confusion in the parser (0/0 case with no other filter). - Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC. To generate a diff of this commit: cvs rdiff -u -r1.38.2.2 -r1.38.2.3 src/sys/net/npf/npf_ctl.c cvs rdiff -u -r1.7 -r1.7.2.1 src/usr.sbin/npf/npfctl/npf_bpf_comp.c cvs rdiff -u -r1.38.2.1 -r1.38.2.2 src/usr.sbin/npf/npfctl/npf_build.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/npf/npf_ctl.c diff -u src/sys/net/npf/npf_ctl.c:1.38.2.2 src/sys/net/npf/npf_ctl.c:1.38.2.3 --- src/sys/net/npf/npf_ctl.c:1.38.2.2 Sat Mar 21 17:49:03 2015 +++ src/sys/net/npf/npf_ctl.c Wed Jun 10 16:57:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_ctl.c,v 1.38.2.2 2015/03/21 17:49:03 snj Exp $ */ +/* $NetBSD: npf_ctl.c,v 1.38.2.3 2015/06/10 16:57:58 snj Exp $ */ /*- * Copyright (c) 2009-2014 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.38.2.2 2015/03/21 17:49:03 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.38.2.3 2015/06/10 16:57:58 snj Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -49,13 +49,9 @@ __KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v #include "npf_impl.h" #include "npf_conn.h" -#if defined(DEBUG) || defined(DIAGNOSTIC) #define NPF_ERR_DEBUG(e) \ prop_dictionary_set_cstring_nocopy((e), "source-file", __FILE__); \ prop_dictionary_set_uint32((e), "source-line", __LINE__); -#else -#define NPF_ERR_DEBUG(e) -#endif /* * npfctl_switch: enable or disable packet inspection. Index: src/usr.sbin/npf/npfctl/npf_bpf_comp.c diff -u src/usr.sbin/npf/npfctl/npf_bpf_comp.c:1.7 src/usr.sbin/npf/npfctl/npf_bpf_comp.c:1.7.2.1 --- src/usr.sbin/npf/npfctl/npf_bpf_comp.c:1.7 Sun Jun 29 00:05:24 2014 +++ src/usr.sbin/npf/npfctl/npf_bpf_comp.c Wed Jun 10 16:57:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_bpf_comp.c,v 1.7 2014/06/29 00:05:24 rmind Exp $ */ +/* $NetBSD: npf_bpf_comp.c,v 1.7.2.1 2015/06/10 16:57:58 snj Exp $ */ /*- * Copyright (c) 2010-2014 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: npf_bpf_comp.c,v 1.7 2014/06/29 00:05:24 rmind Exp $"); +__RCSID("$NetBSD: npf_bpf_comp.c,v 1.7.2.1 2015/06/10 16:57:58 snj Exp $"); #include <stdlib.h> #include <stdbool.h> @@ -189,6 +189,10 @@ npfctl_bpf_complete(npf_bpf_t *ctx) struct bpf_program *bp = &ctx->prog; const u_int retoff = bp->bf_len; + /* No instructions (optimised out). */ + if (!bp->bf_len) + return NULL; + /* Add the return fragment (success and failure paths). */ struct bpf_insn insns_ret[] = { BPF_STMT(BPF_RET+BPF_K, NPF_BPF_SUCCESS), Index: src/usr.sbin/npf/npfctl/npf_build.c diff -u src/usr.sbin/npf/npfctl/npf_build.c:1.38.2.1 src/usr.sbin/npf/npfctl/npf_build.c:1.38.2.2 --- src/usr.sbin/npf/npfctl/npf_build.c:1.38.2.1 Sat Mar 21 17:49:03 2015 +++ src/usr.sbin/npf/npfctl/npf_build.c Wed Jun 10 16:57:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: npf_build.c,v 1.38.2.1 2015/03/21 17:49:03 snj Exp $ */ +/* $NetBSD: npf_build.c,v 1.38.2.2 2015/06/10 16:57:58 snj Exp $ */ /*- * Copyright (c) 2011-2014 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: npf_build.c,v 1.38.2.1 2015/03/21 17:49:03 snj Exp $"); +__RCSID("$NetBSD: npf_build.c,v 1.38.2.2 2015/06/10 16:57:58 snj Exp $"); #include <sys/types.h> #include <sys/mman.h> @@ -368,6 +368,10 @@ npfctl_build_code(nl_rule_t *rl, sa_fami /* Complete BPF byte-code and pass to the rule. */ struct bpf_program *bf = npfctl_bpf_complete(bc); + if (bf == NULL) { + npfctl_bpf_destroy(bc); + return true; + } len = bf->bf_len * sizeof(struct bpf_insn); if (npf_rule_setcode(rl, NPF_CODE_BPF, bf->bf_insns, len) == -1) {