Source-Changes-HG archive

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

[src/trunk]: src/sys Redefine bpf linkage through an always present op vector...



details:   https://anonhg.NetBSD.org/src/rev/9037fff53b4b
branches:  trunk
changeset: 750946:9037fff53b4b
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Jan 19 22:08:16 2010 +0000

description:
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client.  This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached.  However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff.  ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.

diffstat:

 sys/net/agr/if_agr.c                      |  15 ++++-----------
 sys/net/agr/if_agrsubr.c                  |   5 ++---
 sys/net80211/ieee80211.c                  |  13 ++++---------
 sys/net80211/ieee80211_input.c            |  27 +++++++--------------------
 sys/net80211/ieee80211_output.c           |   7 ++-----
 sys/netinet/ip_carp.c                     |  15 ++++-----------
 sys/netinet/ip_etherip.c                  |  11 +++--------
 sys/netinet6/ip6_etherip.c                |  11 +++--------
 sys/netisdn/i4b_ipr.c                     |  12 ++++++------
 sys/netisdn/i4b_isppp.c                   |  12 ++++++------
 sys/rump/librump/rumpkern/opt/bpfilter.h  |   3 ---
 sys/rump/librump/rumpnet/Makefile.rumpnet |   5 ++++-
 sys/rump/librump/rumpnet/rump_net.c       |   7 +++++--
 sys/rump/net/lib/libvirtif/if_virt.c      |  14 ++++----------
 14 files changed, 54 insertions(+), 103 deletions(-)

diffs (truncated from 624 to 300 lines):

diff -r 1ba99fcb8a57 -r 9037fff53b4b sys/net/agr/if_agr.c
--- a/sys/net/agr/if_agr.c      Tue Jan 19 22:08:11 2010 +0000
+++ b/sys/net/agr/if_agr.c      Tue Jan 19 22:08:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agr.c,v 1.24 2009/06/09 22:21:54 yamt Exp $ */
+/*     $NetBSD: if_agr.c,v 1.25 2010/01/19 22:08:16 pooka Exp $        */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,9 +27,8 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.24 2009/06/09 22:21:54 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.25 2010/01/19 22:08:16 pooka Exp $");
 
-#include "bpfilter.h"
 #include "opt_inet.h"
 
 #include <sys/param.h>
@@ -43,9 +42,7 @@
 #include <sys/proc.h>  /* XXX for curproc */
 #include <sys/kauth.h>
 
-#if NBPFILTER > 0
 #include <net/bpf.h>
-#endif
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_types.h>
@@ -147,11 +144,9 @@
        }
 #endif
 
-#if NBPFILTER > 0
        if (ifp->if_bpf) {
-               bpf_mtap(ifp->if_bpf, m);
+               bpf_ops->bpf_mtap(ifp->if_bpf, m);
        }
-#endif
 
        (*ifp->if_input)(ifp, m);
 }
@@ -437,11 +432,9 @@
                if (m == NULL) {
                        break;
                }
-#if NBPFILTER > 0
                if (ifp->if_bpf) {
-                       bpf_mtap(ifp->if_bpf, m);
+                       bpf_ops->bpf_mtap(ifp->if_bpf, m);
                }
-#endif
                port = agr_select_tx_port(sc, m);
                if (port) {
                        int error;
diff -r 1ba99fcb8a57 -r 9037fff53b4b sys/net/agr/if_agrsubr.c
--- a/sys/net/agr/if_agrsubr.c  Tue Jan 19 22:08:11 2010 +0000
+++ b/sys/net/agr/if_agrsubr.c  Tue Jan 19 22:08:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agrsubr.c,v 1.8 2007/09/01 03:07:24 dyoung Exp $    */
+/*     $NetBSD: if_agrsubr.c,v 1.9 2010/01/19 22:08:17 pooka Exp $     */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,9 +27,8 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agrsubr.c,v 1.8 2007/09/01 03:07:24 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agrsubr.c,v 1.9 2010/01/19 22:08:17 pooka Exp $");
 
-#include "bpfilter.h"
 #include "opt_inet.h"
 
 #include <sys/param.h>
diff -r 1ba99fcb8a57 -r 9037fff53b4b sys/net80211/ieee80211.c
--- a/sys/net80211/ieee80211.c  Tue Jan 19 22:08:11 2010 +0000
+++ b/sys/net80211/ieee80211.c  Tue Jan 19 22:08:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211.c,v 1.49 2009/01/10 12:53:45 cegger Exp $    */
+/*     $NetBSD: ieee80211.c,v 1.50 2010/01/19 22:08:17 pooka Exp $     */
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211.c,v 1.22 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.49 2009/01/10 12:53:45 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.50 2010/01/19 22:08:17 pooka Exp $");
 #endif
 
 /*
@@ -44,7 +44,6 @@
  */
 
 #include "opt_inet.h"
-#include "bpfilter.h"
 
 #include <sys/param.h>
 #include <sys/systm.h> 
@@ -159,10 +158,8 @@
 #endif /* __NetBSD__ */
 
        ether_ifattach(ifp, ic->ic_myaddr);
-#if NBPFILTER > 0
-       bpfattach2(ifp, DLT_IEEE802_11,
+       bpf_ops->bpf_attach(ifp, DLT_IEEE802_11,
            sizeof(struct ieee80211_frame_addr4), &ic->ic_rawbpf);
-#endif
 
        ieee80211_crypto_attach(ic);
 
@@ -264,9 +261,7 @@
 
        IEEE80211_BEACON_LOCK_DESTROY(ic);
 
-#if NBPFILTER > 0
-       bpfdetach(ifp);
-#endif
+       bpf_ops->bpf_detach(ifp);
        ether_ifdetach(ifp);
 }
 
diff -r 1ba99fcb8a57 -r 9037fff53b4b sys/net80211/ieee80211_input.c
--- a/sys/net80211/ieee80211_input.c    Tue Jan 19 22:08:11 2010 +0000
+++ b/sys/net80211/ieee80211_input.c    Tue Jan 19 22:08:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211_input.c,v 1.68 2009/09/02 22:03:08 joerg Exp $       */
+/*     $NetBSD: ieee80211_input.c,v 1.69 2010/01/19 22:08:17 pooka Exp $       */
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,13 +36,12 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.81 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.68 2009/09/02 22:03:08 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.69 2010/01/19 22:08:17 pooka Exp $");
 #endif
 
 #include "opt_inet.h"
 
 #ifdef __NetBSD__
-#include "bpfilter.h"
 #endif /* __NetBSD__ */
 
 #include <sys/param.h>
@@ -68,9 +67,7 @@
 #include <net80211/ieee80211_netbsd.h>
 #include <net80211/ieee80211_var.h>
 
-#if NBPFILTER > 0
 #include <net/bpf.h>
-#endif
 
 #ifdef INET
 #include <netinet/in.h> 
@@ -455,11 +452,9 @@
                        goto out;
                }
 
-#if NBPFILTER > 0
                /* copy to listener after decrypt */
                if (ic->ic_rawbpf)
-                       bpf_mtap(ic->ic_rawbpf, m);
-#endif
+                       bpf_ops->bpf_mtap(ic->ic_rawbpf, m);
 
                /*
                 * Finally, strip the 802.11 header.
@@ -572,10 +567,8 @@
                        wh = mtod(m, struct ieee80211_frame *);
                        wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
                }
-#if NBPFILTER > 0
                if (ic->ic_rawbpf)
-                       bpf_mtap(ic->ic_rawbpf, m);
-#endif
+                       bpf_ops->bpf_mtap(ic->ic_rawbpf, m);
                (*ic->ic_recv_mgmt)(ic, m, ni, subtype, rssi, rstamp);
                m_freem(m);
                return type;
@@ -603,10 +596,8 @@
        ifp->if_ierrors++;
 out:
        if (m != NULL) {
-#if NBPFILTER > 0
                if (ic->ic_rawbpf)
-                       bpf_mtap(ic->ic_rawbpf, m);
-#endif
+                       bpf_ops->bpf_mtap(ic->ic_rawbpf, m);
                m_freem(m);
        }
        return type;
@@ -766,14 +757,12 @@
                }
        }
        if (m != NULL) {
-#if NBPFILTER > 0
                /*
                 * XXX If we forward packet into transmitter of the AP,
                 * we don't need to duplicate for DLT_EN10MB.
                 */
                if (ifp->if_bpf)
-                       bpf_mtap(ifp->if_bpf, m);
-#endif
+                       bpf_ops->bpf_mtap(ifp->if_bpf, m);
 
                if (ni->ni_vlan != 0) {
                        /* attach vlan tag */
@@ -785,10 +774,8 @@
        return;
   out:
        if (m != NULL) {
-#if NBPFILTER > 0
                if (ic->ic_rawbpf)
-                       bpf_mtap(ic->ic_rawbpf, m);
-#endif
+                       bpf_ops->bpf_mtap(ic->ic_rawbpf, m);
                m_freem(m);
        }
 }
diff -r 1ba99fcb8a57 -r 9037fff53b4b sys/net80211/ieee80211_output.c
--- a/sys/net80211/ieee80211_output.c   Tue Jan 19 22:08:11 2010 +0000
+++ b/sys/net80211/ieee80211_output.c   Tue Jan 19 22:08:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211_output.c,v 1.48 2008/06/19 23:13:10 dyoung Exp $     */
+/*     $NetBSD: ieee80211_output.c,v 1.49 2010/01/19 22:08:17 pooka Exp $      */
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,13 +36,12 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.48 2008/06/19 23:13:10 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.49 2010/01/19 22:08:17 pooka Exp $");
 #endif
 
 #include "opt_inet.h"
 
 #ifdef __NetBSD__
-#include "bpfilter.h"
 #endif /* __NetBSD__ */
 
 #include <sys/param.h>
@@ -65,9 +64,7 @@
 #include <net80211/ieee80211_netbsd.h>
 #include <net80211/ieee80211_var.h>
 
-#if NBPFILTER > 0
 #include <net/bpf.h>
-#endif
 
 #ifdef INET
 #include <netinet/in.h>
diff -r 1ba99fcb8a57 -r 9037fff53b4b sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c     Tue Jan 19 22:08:11 2010 +0000
+++ b/sys/netinet/ip_carp.c     Tue Jan 19 22:08:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_carp.c,v 1.39 2009/09/16 15:23:05 pooka Exp $       */
+/*     $NetBSD: ip_carp.c,v 1.40 2010/01/19 22:08:17 pooka Exp $       */
 /*     $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $   */
 
 /*
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.39 2009/09/16 15:23:05 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.40 2010/01/19 22:08:17 pooka Exp $");
 
 /*
  * TODO:
@@ -92,10 +92,7 @@
 #include <netinet6/scope6_var.h>
 #endif
 
-#include "bpfilter.h"
-#if NBPFILTER > 0
 #include <net/bpf.h>
-#endif
 
 #include <sys/sha1.h>
 
@@ -803,9 +800,7 @@
        ifp->if_broadcastaddr = etherbroadcastaddr;
        carp_set_enaddr(sc);
        LIST_INIT(&sc->sc_ac.ec_multiaddrs);
-#if NBPFILTER > 0
-       bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
-#endif
+       bpf_ops->bpf_attach(ifp, DLT_EN10MB, ETHER_HDR_LEN, &ifp->if_bpf);
        return (0);
 }
 
@@ -1371,10 +1366,8 @@
 



Home | Main Index | Thread Index | Old Index