diff options
author | 2016-09-19 14:43:22 +0000 | |
---|---|---|
committer | 2016-09-19 14:43:22 +0000 | |
commit | ff87026bcf8f1b15cef69e97726b023d53a75052 (patch) | |
tree | a1d1da566664a79e7cf85a4bc14078be2354570e | |
parent | put the spkac section in the right place; (diff) | |
download | wireguard-openbsd-ff87026bcf8f1b15cef69e97726b023d53a75052.tar.xz wireguard-openbsd-ff87026bcf8f1b15cef69e97726b023d53a75052.zip |
Replace duplicated VLAN injection code with the standard vlan_inject()
function.
ok goda@
-rw-r--r-- | sys/net/switchofp.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/sys/net/switchofp.c b/sys/net/switchofp.c index f0d9b1c1c7b..6c8a74dda23 100644 --- a/sys/net/switchofp.c +++ b/sys/net/switchofp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: switchofp.c,v 1.5 2016/09/18 11:04:42 rzalamena Exp $ */ +/* $OpenBSD: switchofp.c,v 1.6 2016/09/19 14:43:22 rzalamena Exp $ */ /* * Copyright (c) 2016 Kazuya GODA <goda@openbsd.org> @@ -42,6 +42,7 @@ #include <netinet/if_ether.h> #include <net/if_bridge.h> #include <net/if_switch.h> +#include <net/if_vlan_var.h> #include <net/ofp.h> /* @@ -2838,28 +2839,13 @@ swofp_flow_lookup(struct swofp_flow_table *swft, struct mbuf * swofp_expand_8021q_tag(struct mbuf *m) { - struct ether_vlan_header evh; - if ((m->m_flags & M_VLANTAG) == 0) return (m); - m_copydata(m, 0, ETHER_HDR_LEN, (caddr_t)&evh); - - evh.evl_proto = evh.evl_encap_proto; /* H/W tagging supports only 802.1Q */ - evh.evl_encap_proto = htons(ETHERTYPE_VLAN); - evh.evl_tag = htons(EVL_VLANOFTAG(m->m_pkthdr.ether_vtag) | - EVL_PRIOFTAG(m->m_pkthdr.ether_vtag)); - - m_adj(m, ETHER_HDR_LEN); - M_PREPEND(m, sizeof(evh), M_DONTWAIT); - if (m == NULL) - return (NULL); - - m_copyback(m, 0, sizeof(evh), &evh, M_NOWAIT); - m->m_flags &= ~M_VLANTAG; - - return (m); + return (vlan_inject(m, ETHERTYPE_VLAN, + EVL_VLANOFTAG(m->m_pkthdr.ether_vtag) | + EVL_PRIOFTAG(m->m_pkthdr.ether_vtag))); } struct mbuf * |