summaryrefslogtreecommitdiffstats
path: root/sys/net/switchofp.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2016-11-16 13:47:27 +0000
committerreyk <reyk@openbsd.org>2016-11-16 13:47:27 +0000
commit7a61d4b0b602572c95a5b96f09678a2dda2ae243 (patch)
tree1858659280d5980cd47a6532151d132af54348e2 /sys/net/switchofp.c
parentFix calculation of whether we need a region for drawing a cell (only if (diff)
downloadwireguard-openbsd-7a61d4b0b602572c95a5b96f09678a2dda2ae243.tar.xz
wireguard-openbsd-7a61d4b0b602572c95a5b96f09678a2dda2ae243.zip
Add new DLT_OPENFLOW link-type to allow using tcpdump to debug switch(4),
eg. tcpdump -y openflow -i switch0 Includes a minor bump for libpcap. Feedback and OK rzalamena@
Diffstat (limited to 'sys/net/switchofp.c')
-rw-r--r--sys/net/switchofp.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/net/switchofp.c b/sys/net/switchofp.c
index 4cbfcb10883..acb185c3432 100644
--- a/sys/net/switchofp.c
+++ b/sys/net/switchofp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: switchofp.c,v 1.30 2016/11/10 17:32:40 rzalamena Exp $ */
+/* $OpenBSD: switchofp.c,v 1.31 2016/11/16 13:47:27 reyk Exp $ */
/*
* Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
@@ -18,6 +18,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include "bpfilter.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
@@ -45,6 +47,10 @@
#include <net/if_vlan_var.h>
#include <net/ofp.h>
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
/*
* per-frame matching logs provide a helpful for isolating a problem or debuging
* on runtime but it has potentiality which degrade performance and overflow
@@ -978,6 +984,11 @@ swofp_create(struct switch_softc *sc)
sc->sc_capabilities |= SWITCH_CAP_OFP;
sc->switch_process_forward = swofp_forward_ofs;
+#if NBPFILTER > 0
+ bpfattach(&sc->sc_ofbpf, &sc->sc_if, DLT_OPENFLOW,
+ sizeof(struct ofp_header));
+#endif
+
DPRINTF(sc, "enable OpenFlow switch capability\n");
return (0);
@@ -4478,6 +4489,11 @@ swofp_input(struct switch_softc *sc, struct mbuf *m)
swofp_mtype_str(oh->oh_type), ntohl(oh->oh_xid),
ntohs(oh->oh_length));
+#if NBPFILTER > 0
+ if (sc->sc_ofbpf)
+ switch_mtap(sc->sc_ofbpf, m, BPF_DIRECTION_IN);
+#endif
+
handler = swofp_lookup_msg_handler(oh->oh_type);
if (handler)
(*handler)(sc, m);
@@ -4503,6 +4519,11 @@ swofp_output(struct switch_softc *sc, struct mbuf *m)
swofp_mtype_str(oh->oh_type), ntohl(oh->oh_xid),
ntohs(oh->oh_length));
+#if NBPFILTER > 0
+ if (sc->sc_ofbpf)
+ switch_mtap(sc->sc_ofbpf, m, BPF_DIRECTION_OUT);
+#endif
+
if (sc->sc_swdev->swdev_output(sc, m) != 0)
return (ENOBUFS);