summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-01-12 02:25:28 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-01-12 02:25:28 +0000
commit725ec4414b6f893d9c5eb4c317e6f7c667863307 (patch)
treedf5084ee9e54ee2565b72013e53ce5c2f670300e /sys/net
parente43a0c70800a7c878edc13a8b8da60ae312a2d89 (diff)
move gif_encap from gif_output to gif_start.
the main win is the simplification of bpf in the ouput path. ok visa@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_gif.c57
1 files changed, 7 insertions, 50 deletions
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index d3c6a427302..f613e4da4d1 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gif.c,v 1.107 2018/01/09 15:24:24 bluhm Exp $ */
+/* $OpenBSD: if_gif.c,v 1.108 2018/01/12 02:25:27 dlg Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
@@ -175,55 +175,14 @@ gif_start(struct ifnet *ifp)
#if NBPFILTER > 0
if (ifp->if_bpf) {
- int offset;
- sa_family_t family;
- u_int8_t proto;
-
- /* must decapsulate outer header for bpf */
- switch (sc->gif_psrc->sa_family) {
- case AF_INET:
- offset = sizeof(struct ip);
- proto = mtod(m, struct ip *)->ip_p;
- break;
-#ifdef INET6
- case AF_INET6:
- offset = sizeof(struct ip6_hdr);
- proto = mtod(m, struct ip6_hdr *)->ip6_nxt;
- break;
-#endif
- default:
- proto = 0;
- break;
- }
- switch (proto) {
- case IPPROTO_IPV4:
- family = AF_INET;
- break;
- case IPPROTO_IPV6:
- family = AF_INET6;
- break;
- case IPPROTO_ETHERIP:
- family = AF_LINK;
- offset += sizeof(struct etherip_header);
- break;
- case IPPROTO_MPLS:
- family = AF_MPLS;
- break;
- default:
- offset = 0;
- family = sc->gif_psrc->sa_family;
- break;
- }
- m->m_data += offset;
- m->m_len -= offset;
- m->m_pkthdr.len -= offset;
- bpf_mtap_af(ifp->if_bpf, family, m, BPF_DIRECTION_OUT);
- m->m_data -= offset;
- m->m_len += offset;
- m->m_pkthdr.len += offset;
+ bpf_mtap_af(ifp->if_bpf, m->m_pkthdr.ph_family, m,
+ BPF_DIRECTION_OUT);
}
#endif
+ if (gif_encap(ifp, &m, m->m_pkthdr.ph_family) != 0)
+ continue;
+
/* XXX we should cache the outgoing route */
switch (sc->gif_psrc->sa_family) {
@@ -294,9 +253,7 @@ gif_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
goto end;
}
- error = gif_encap(ifp, &m, dst->sa_family);
- if (error)
- goto end;
+ m->m_pkthdr.ph_family = dst->sa_family;
error = if_enqueue(ifp, m);