Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src Pull up following revision(s) (requested by rmind in tick...
details: https://anonhg.NetBSD.org/src/rev/a5f95478cac7
branches: netbsd-7
changeset: 799487:a5f95478cac7
user: snj <snj%NetBSD.org@localhost>
date: Fri Jul 17 04:37:22 2015 +0000
description:
Pull up following revision(s) (requested by rmind in ticket #880):
sys/net/npf/npf_if.c: revision 1.5
sys/net/npf/npf_mbuf.c: revision 1.14
usr.sbin/npf/npf.7: revision 1.3
usr.sbin/npf/npfctl/npf_var.c: revision 1.9
npfkern: eliminate INACTIVE_ID and use 0 for unregistered interfaces.
--
- npfvar_get_type1: check for NULL first.
- Minor fix for the npf(7) man page.
diffstat:
sys/net/npf/npf_if.c | 34 ++++++++++++++--------------------
sys/net/npf/npf_mbuf.c | 6 +++---
usr.sbin/npf/npf.7 | 6 +++---
usr.sbin/npf/npfctl/npf_var.c | 10 +++++-----
4 files changed, 25 insertions(+), 31 deletions(-)
diffs (202 lines):
diff -r 46b3bdfea069 -r a5f95478cac7 sys/net/npf/npf_if.c
--- a/sys/net/npf/npf_if.c Fri Jul 17 04:34:34 2015 +0000
+++ b/sys/net/npf/npf_if.c Fri Jul 17 04:37:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_if.c,v 1.4 2014/08/10 19:09:43 rmind Exp $ */
+/* $NetBSD: npf_if.c,v 1.4.2.1 2015/07/17 04:37:22 snj Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,14 +35,17 @@
* NPF uses its own interface IDs (npf-if-id). When NPF configuration is
* (re)loaded, each required interface name is registered and a matching
* network interface gets an ID assigned. If an interface is not present,
- * it gets an ID on attach. Any other interfaces get INACTIVE_ID.
+ * it gets an ID on attach.
+ *
+ * IDs start from 1. Zero is reserved to indicate "no interface" case or
+ * an interface of no interest (i.e. not registered).
*
* The IDs are mapped synchronously based on interface events which are
* monitored using pfil(9) hooks.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_if.c,v 1.4 2014/08/10 19:09:43 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_if.c,v 1.4.2.1 2015/07/17 04:37:22 snj Exp $");
#ifdef _KERNEL_OPT
#include "pf.h"
@@ -59,8 +62,6 @@
#include "npf_impl.h"
-#define INACTIVE_ID ((u_int)-1)
-
typedef struct {
char n_ifname[IFNAMSIZ];
} npf_ifmap_t;
@@ -68,12 +69,6 @@
static npf_ifmap_t npf_ifmap[NPF_MAX_IFMAP] __read_mostly;
static u_int npf_ifmap_cnt __read_mostly;
-/*
- * NOTE: IDs start from 1. Zero is reserved for "no interface" and
- * (unsigned)-1 for "inactive interface". Therefore, an interface
- * can have either INACTIVE_ID or non-zero ID.
- */
-
static u_int
npf_ifmap_new(void)
{
@@ -85,7 +80,7 @@
if (npf_ifmap_cnt == NPF_MAX_IFMAP) {
printf("npf_ifmap_new: out of slots; bump NPF_MAX_IFMAP\n");
- return INACTIVE_ID;
+ return 0;
}
return ++npf_ifmap_cnt;
}
@@ -101,7 +96,7 @@
if (nim->n_ifname[0] && strcmp(nim->n_ifname, ifname) == 0)
return i + 1;
}
- return INACTIVE_ID;
+ return 0;
}
u_int
@@ -112,11 +107,10 @@
u_int i;
npf_config_enter();
- if ((i = npf_ifmap_lookup(ifname)) != INACTIVE_ID) {
+ if ((i = npf_ifmap_lookup(ifname)) != 0) {
goto out;
}
- if ((i = npf_ifmap_new()) == INACTIVE_ID) {
- i = INACTIVE_ID;
+ if ((i = npf_ifmap_new()) == 0) {
goto out;
}
nim = &npf_ifmap[i - 1];
@@ -146,7 +140,7 @@
KERNEL_LOCK(1, NULL);
IFNET_FOREACH(ifp) {
- ifp->if_pf_kif = (void *)(uintptr_t)INACTIVE_ID;
+ ifp->if_pf_kif = (void *)(uintptr_t)0;
}
KERNEL_UNLOCK_ONE(NULL);
}
@@ -155,8 +149,7 @@
npf_ifmap_getid(const ifnet_t *ifp)
{
const u_int i = (uintptr_t)ifp->if_pf_kif;
-
- KASSERT(i == INACTIVE_ID || (i > 0 && i <= npf_ifmap_cnt));
+ KASSERT(i <= npf_ifmap_cnt);
return i;
}
@@ -184,7 +177,8 @@
void
npf_ifmap_detach(ifnet_t *ifp)
{
+ /* Diagnostic. */
npf_config_enter();
- ifp->if_pf_kif = (void *)(uintptr_t)INACTIVE_ID; /* diagnostic */
+ ifp->if_pf_kif = (void *)(uintptr_t)0;
npf_config_exit();
}
diff -r 46b3bdfea069 -r a5f95478cac7 sys/net/npf/npf_mbuf.c
--- a/sys/net/npf/npf_mbuf.c Fri Jul 17 04:34:34 2015 +0000
+++ b/sys/net/npf/npf_mbuf.c Fri Jul 17 04:37:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_mbuf.c,v 1.13 2014/08/10 19:09:43 rmind Exp $ */
+/* $NetBSD: npf_mbuf.c,v 1.13.2.1 2015/07/17 04:37:22 snj Exp $ */
/*-
* Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_mbuf.c,v 1.13 2014/08/10 19:09:43 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_mbuf.c,v 1.13.2.1 2015/07/17 04:37:22 snj Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@@ -57,7 +57,7 @@
nbuf->nb_mbuf0 = m;
nbuf->nb_ifp = ifp;
- nbuf->nb_ifid = ifid;
+ nbuf->nb_ifid = ifid;
nbuf_reset(nbuf);
}
diff -r 46b3bdfea069 -r a5f95478cac7 usr.sbin/npf/npf.7
--- a/usr.sbin/npf/npf.7 Fri Jul 17 04:34:34 2015 +0000
+++ b/usr.sbin/npf/npf.7 Fri Jul 17 04:37:22 2015 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: npf.7,v 1.2 2014/08/10 19:09:43 rmind Exp $
+.\" $NetBSD: npf.7,v 1.2.2.1 2015/07/17 04:37:22 snj Exp $
.\"
.\" Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd August 2, 2014
+.Dd July 13, 2015
.Dt NPF 7
.Os
.Sh NAME
@@ -69,7 +69,7 @@
Packet logging (extension).
.El
.Pp
-For a full set features and their description, see the NPF
+For a full set of features and their description, see the NPF
documentation and other manual pages.
.\" -----
.Sh SEE ALSO
diff -r 46b3bdfea069 -r a5f95478cac7 usr.sbin/npf/npfctl/npf_var.c
--- a/usr.sbin/npf/npfctl/npf_var.c Fri Jul 17 04:34:34 2015 +0000
+++ b/usr.sbin/npf/npfctl/npf_var.c Fri Jul 17 04:37:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_var.c,v 1.8 2013/11/19 00:28:41 rmind Exp $ */
+/* $NetBSD: npf_var.c,v 1.8.4.1 2015/07/17 04:37:22 snj Exp $ */
/*-
* Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_var.c,v 1.8 2013/11/19 00:28:41 rmind Exp $");
+__RCSID("$NetBSD: npf_var.c,v 1.8.4.1 2015/07/17 04:37:22 snj Exp $");
#include <stdlib.h>
#include <string.h>
@@ -239,14 +239,14 @@
{
npf_element_t *el;
+ if (vp == NULL)
+ return -1;
+
if (level >= var_num) {
yyerror("variable loop for '%s'", vp->v_key);
return -1;
}
- if (vp == NULL)
- return -1;
-
if (vp->v_count <= idx) {
yyerror("variable '%s' has only %zu elements, requested %zu",
vp->v_key, vp->v_count, idx);
Home |
Main Index |
Thread Index |
Old Index