MCPcopy Create free account
hub / github.com/NetSys/bess / ProcessBatch

Method ProcessBatch

core/modules/vlan_pop.cc:35–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33#include "../utils/ether.h"
34
35void VLANPop::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {
36 using bess::utils::be16_t;
37 using bess::utils::Ethernet;
38
39 int cnt = batch->cnt();
40
41 for (int i = 0; i < cnt; i++) {
42 bess::Packet *pkt = batch->pkts()[i];
43 char *old_head = pkt->head_data<char *>();
44
45 __m128i eth = _mm_loadu_si128(reinterpret_cast<__m128i *>(old_head));
46 be16_t tpid(be16_t::swap(_mm_extract_epi16(eth, 6)));
47
48 bool tagged = (tpid == be16_t(Ethernet::Type::kVlan)) ||
49 (tpid == be16_t(Ethernet::Type::kQinQ));
50
51 if (tagged && pkt->adj(4)) {
52 eth = _mm_slli_si128(eth, 4);
53 _mm_storeu_si128(reinterpret_cast<__m128i *>(old_head), eth);
54 }
55 }
56
57 RunNextModule(ctx, batch);
58}
59
60ADD_MODULE(VLANPop, "vlan_pop", "removes 802.1Q/802.11ad VLAN tag")

Callers

nothing calls this directly

Calls 3

adjMethod · 0.80
cntMethod · 0.45
pktsMethod · 0.45

Tested by

no test coverage detected