Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/net/lib/libsockin support bpf



details:   https://anonhg.NetBSD.org/src/rev/241ec91adbb7
branches:  trunk
changeset: 751162:241ec91adbb7
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Jan 26 17:41:20 2010 +0000

description:
support bpf

diffstat:

 sys/rump/net/lib/libsockin/sockin.c |  18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diffs (67 lines):

diff -r d25fb5b92f61 -r 241ec91adbb7 sys/rump/net/lib/libsockin/sockin.c
--- a/sys/rump/net/lib/libsockin/sockin.c       Tue Jan 26 16:59:27 2010 +0000
+++ b/sys/rump/net/lib/libsockin/sockin.c       Tue Jan 26 17:41:20 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sockin.c,v 1.20 2009/10/20 12:17:44 tron Exp $ */
+/*     $NetBSD: sockin.c,v 1.21 2010/01/26 17:41:20 pooka Exp $        */
 
 /*
  * Copyright (c) 2008, 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.20 2009/10/20 12:17:44 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.21 2010/01/26 17:41:20 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -42,6 +42,8 @@
 #include <sys/socketvar.h>
 #include <sys/time.h>
 
+#include <net/bpf.h>
+#include <net/if.h>
 #include <net/radix.h>
 
 #include <netinet/in.h>
@@ -116,6 +118,10 @@
 static bool rebuild;
 static int nsock;
 
+/* XXX: for the bpf hack */
+static struct ifnet sockin_if;
+int ifpromisc(struct ifnet *ifp, int pswitch) { return 0; }
+
 static int
 registersock(struct socket *so, int news)
 {
@@ -207,6 +213,9 @@
        }
        m->m_len = m->m_pkthdr.len = n;
 
+       if (sockin_if.if_bpf)
+               bpf_ops->bpf_mtap_af(sockin_if.if_bpf, AF_UNSPEC, m);
+
        mutex_enter(softnet_lock);
        if (so->so_proto->pr_type == SOCK_DGRAM) {
                if (!sbappendaddr(&so->so_rcv, rmsg.msg_name, m, NULL)) {
@@ -340,6 +349,8 @@
                printf("sockin_init: no threads => no worker thread\n");
        }
        mutex_init(&su_mtx, MUTEX_DEFAULT, IPL_NONE);
+       strlcpy(sockin_if.if_xname, "sockin0", sizeof(sockin_if.if_xname));
+       bpf_ops->bpf_attach(&sockin_if, DLT_NULL, 0, &sockin_if.if_bpf);
 }
 
 static int
@@ -413,6 +424,9 @@
                size_t tot;
                int s;
 
+               if (sockin_if.if_bpf)
+                       bpf_ops->bpf_mtap_af(sockin_if.if_bpf, AF_UNSPEC, m);
+
                memset(&mhdr, 0, sizeof(mhdr));
 
                iov_max = 0;



Home | Main Index | Thread Index | Old Index