Pass output packets to bpf(4). This is helpful when debugging stack
authormpi <mpi@openbsd.org>
Sat, 23 May 2015 08:31:05 +0000 (08:31 +0000)
committermpi <mpi@openbsd.org>
Sat, 23 May 2015 08:31:05 +0000 (08:31 +0000)
issues.

ok reyk@

sys/net/if_vether.c

index 2dc92e0..5854e04 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vether.c,v 1.23 2015/03/14 03:38:51 jsg Exp $ */
+/* $OpenBSD: if_vether.c,v 1.24 2015/05/23 08:31:05 mpi Exp $ */
 
 /*
  * Copyright (c) 2009 Theo de Raadt
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
 
+#include "bpfilter.h"
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
 void   vetherattach(int);
 int    vetherioctl(struct ifnet *, u_long, caddr_t);
 void   vetherstart(struct ifnet *);
@@ -117,15 +122,17 @@ void
 vetherstart(struct ifnet *ifp)
 {
        struct mbuf             *m;
-       int                      s;
 
        for (;;) {
-               s = splnet();
                IFQ_DEQUEUE(&ifp->if_snd, m);
-               splx(s);
-
                if (m == NULL)
                        return;
+
+#if NBPFILTER > 0
+               if (ifp->if_bpf)
+                       bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
+#endif /* NBPFILTER > 0 */
+
                ifp->if_opackets++;
                m_freem(m);
        }