Source-Changes-HG archive

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

[src/trunk]: src/sys bpf_filter: add a custom argument which can be passed to...



details:   https://anonhg.NetBSD.org/src/rev/36a51cc5a22a
branches:  trunk
changeset: 789658:36a51cc5a22a
user:      rmind <rmind%NetBSD.org@localhost>
date:      Fri Aug 30 15:00:08 2013 +0000

description:
bpf_filter: add a custom argument which can be passed to coprocessor routine.

diffstat:

 sys/external/bsd/ipf/netinet/fil.c |   7 ++++---
 sys/net/bpf.c                      |   6 +++---
 sys/net/bpf.h                      |   7 ++++---
 sys/net/bpf_filter.c               |  12 ++++++------
 sys/net/if_ppp.c                   |  12 ++++++------
 sys/net/npf/npf_ruleset.c          |   8 ++++----
 6 files changed, 27 insertions(+), 25 deletions(-)

diffs (211 lines):

diff -r 7f6f4b524fd6 -r 36a51cc5a22a sys/external/bsd/ipf/netinet/fil.c
--- a/sys/external/bsd/ipf/netinet/fil.c        Fri Aug 30 12:59:19 2013 +0000
+++ b/sys/external/bsd/ipf/netinet/fil.c        Fri Aug 30 15:00:08 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fil.c,v 1.9 2013/08/29 14:25:40 rmind Exp $    */
+/*     $NetBSD: fil.c,v 1.10 2013/08/30 15:00:08 rmind Exp $   */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -138,7 +138,7 @@
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.9 2013/08/29 14:25:40 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.10 2013/08/30 15:00:08 rmind Exp $");
 #else
 static const char sccsid[] = "@(#)fil.c        1.36 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: fil.c,v 1.1.1.2 2012/07/22 13:45:07 darrenr Exp $";
@@ -2406,7 +2406,8 @@
                        mc = (u_char *)fin->fin_m;
                        wlen = fin->fin_dlen + fin->fin_hlen;
 #if defined(__NetBSD__)
-                       if (!bpf_filter(bpf_def_ctx, fr->fr_data, mc, wlen, 0))
+                       if (!bpf_filter(bpf_def_ctx, NULL,
+                           fr->fr_data, mc, wlen, 0))
                                continue;
 #else
                        if (!bpf_filter(fr->fr_data, mc, wlen, 0))
diff -r 7f6f4b524fd6 -r 36a51cc5a22a sys/net/bpf.c
--- a/sys/net/bpf.c     Fri Aug 30 12:59:19 2013 +0000
+++ b/sys/net/bpf.c     Fri Aug 30 15:00:08 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.174 2013/08/29 14:25:41 rmind Exp $  */
+/*     $NetBSD: bpf.c,v 1.175 2013/08/30 15:00:08 rmind Exp $  */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.174 2013/08/29 14:25:41 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.175 2013/08/30 15:00:08 rmind Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -1382,7 +1382,7 @@
                if (d->bd_jitcode != NULL)
                        slen = d->bd_jitcode(pkt, pktlen, buflen);
                else
-                       slen = bpf_filter(bpf_def_ctx, d->bd_filter,
+                       slen = bpf_filter(bpf_def_ctx, NULL, d->bd_filter,
                            pkt, pktlen, buflen);
 
                if (!slen) {
diff -r 7f6f4b524fd6 -r 36a51cc5a22a sys/net/bpf.h
--- a/sys/net/bpf.h     Fri Aug 30 12:59:19 2013 +0000
+++ b/sys/net/bpf.h     Fri Aug 30 15:00:08 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.h,v 1.60 2013/08/29 14:25:41 rmind Exp $   */
+/*     $NetBSD: bpf.h,v 1.61 2013/08/30 15:00:08 rmind Exp $   */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -382,14 +382,15 @@
 
 struct bpf_ctx;
 typedef struct bpf_ctx bpf_ctx_t;
-typedef uint32_t (*bpf_copfunc_t)(const struct mbuf *, uint32_t, uint32_t *);
+typedef uint32_t (*bpf_copfunc_t)(const struct mbuf *, void *,
+    uint32_t, uint32_t *);
 extern bpf_ctx_t *bpf_def_ctx;
 
 bpf_ctx_t *bpf_create(void);
 void   bpf_destroy(bpf_ctx_t *);
 
 int    bpf_set_cop(bpf_ctx_t *, const bpf_copfunc_t *, size_t);
-u_int  bpf_filter(bpf_ctx_t *, const struct bpf_insn *,
+u_int  bpf_filter(bpf_ctx_t *, void *, const struct bpf_insn *,
            const u_char *, u_int, u_int);
 int    bpf_validate(const struct bpf_insn *, int);
 
diff -r 7f6f4b524fd6 -r 36a51cc5a22a sys/net/bpf_filter.c
--- a/sys/net/bpf_filter.c      Fri Aug 30 12:59:19 2013 +0000
+++ b/sys/net/bpf_filter.c      Fri Aug 30 15:00:08 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf_filter.c,v 1.56 2013/08/29 14:25:41 rmind Exp $    */
+/*     $NetBSD: bpf_filter.c,v 1.57 2013/08/30 15:00:08 rmind Exp $    */
 
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf_filter.c,v 1.56 2013/08/29 14:25:41 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf_filter.c,v 1.57 2013/08/30 15:00:08 rmind Exp $");
 
 #if 0
 #if !(defined(lint) || defined(KERNEL))
@@ -180,8 +180,8 @@
  */
 #ifdef _KERNEL
 u_int
-bpf_filter(bpf_ctx_t *bc, const struct bpf_insn *pc, const u_char *p,
-    u_int wirelen, u_int buflen)
+bpf_filter(bpf_ctx_t *bc, void *arg, const struct bpf_insn *pc,
+    const u_char *p, u_int wirelen, u_int buflen)
 #else
 u_int
 bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen,
@@ -515,7 +515,7 @@
 #ifdef _KERNEL
                        if (pc->k < bc->nfuncs) {
                                const bpf_copfunc_t fn = bc->copfuncs[pc->k];
-                               A = fn((const struct mbuf *)p, A, mem);
+                               A = fn((const struct mbuf *)p, arg, A, mem);
                                continue;
                        }
 #endif
@@ -525,7 +525,7 @@
 #ifdef _KERNEL
                        if (X < bc->nfuncs) {
                                const bpf_copfunc_t fn = bc->copfuncs[X];
-                               A = fn((const struct mbuf *)p, A, mem);
+                               A = fn((const struct mbuf *)p, arg, A, mem);
                                continue;
                        }
 #endif
diff -r 7f6f4b524fd6 -r 36a51cc5a22a sys/net/if_ppp.c
--- a/sys/net/if_ppp.c  Fri Aug 30 12:59:19 2013 +0000
+++ b/sys/net/if_ppp.c  Fri Aug 30 15:00:08 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ppp.c,v 1.139 2013/08/29 14:25:41 rmind Exp $       */
+/*     $NetBSD: if_ppp.c,v 1.140 2013/08/30 15:00:08 rmind Exp $       */
 /*     Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp       */
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.139 2013/08/29 14:25:41 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.140 2013/08/30 15:00:08 rmind Exp $");
 
 #include "ppp.h"
 
@@ -946,7 +946,7 @@
         * but only if it is a data packet.
         */
        if (sc->sc_pass_filt_out.bf_insns != 0
-           && bpf_filter(bpf_def_ctx, sc->sc_pass_filt_out.bf_insns,
+           && bpf_filter(bpf_def_ctx, NULL, sc->sc_pass_filt_out.bf_insns,
                          (u_char *)m0, len, 0) == 0) {
            error = 0;          /* drop this packet */
            goto bad;
@@ -956,7 +956,7 @@
         * Update the time we sent the most recent packet.
         */
        if (sc->sc_active_filt_out.bf_insns == 0
-           || bpf_filter(bpf_def_ctx, sc->sc_active_filt_out.bf_insns,
+           || bpf_filter(bpf_def_ctx, NULL, sc->sc_active_filt_out.bf_insns,
                          (u_char *)m0, len, 0))
            sc->sc_last_sent = time_second;
 #else
@@ -1584,14 +1584,14 @@
         * if it counts as link activity.
         */
        if (sc->sc_pass_filt_in.bf_insns != 0
-           && bpf_filter(bpf_def_ctx, sc->sc_pass_filt_in.bf_insns,
+           && bpf_filter(bpf_def_ctx, NULL, sc->sc_pass_filt_in.bf_insns,
                          (u_char *)m, ilen, 0) == 0) {
            /* drop this packet */
            m_freem(m);
            return;
        }
        if (sc->sc_active_filt_in.bf_insns == 0
-           || bpf_filter(bpf_def_ctx, sc->sc_active_filt_in.bf_insns,
+           || bpf_filter(bpf_def_ctx, NULL, sc->sc_active_filt_in.bf_insns,
                          (u_char *)m, ilen, 0))
            sc->sc_last_recv = time_second;
 #else
diff -r 7f6f4b524fd6 -r 36a51cc5a22a sys/net/npf/npf_ruleset.c
--- a/sys/net/npf/npf_ruleset.c Fri Aug 30 12:59:19 2013 +0000
+++ b/sys/net/npf/npf_ruleset.c Fri Aug 30 15:00:08 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_ruleset.c,v 1.21 2013/08/29 14:25:41 rmind Exp $   */
+/*     $NetBSD: npf_ruleset.c,v 1.22 2013/08/30 15:00:08 rmind Exp $   */
 
 /*-
  * Copyright (c) 2009-2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.21 2013/08/29 14:25:41 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.22 2013/08/30 15:00:08 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -681,8 +681,8 @@
        case NPF_CODE_BPF: {
                struct mbuf *m = nbuf_head_mbuf(nbuf);
                size_t pktlen = m_length(m);
-               return bpf_filter(bpf_def_ctx, code, (unsigned char *)m,
-                   pktlen, 0) != 0;
+               return bpf_filter(bpf_def_ctx, NULL, code,
+                   (unsigned char *)m, pktlen, 0) != 0;
        }
        default:
                KASSERT(false);



Home | Main Index | Thread Index | Old Index