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

Method ProcessBatch

core/modules/vxlan_decap.cc:58–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void VXLANDecap::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {
59 using bess::utils::be32_t;
60 using bess::utils::Ethernet;
61 using bess::utils::Ipv4;
62 using bess::utils::Udp;
63 using bess::utils::Vxlan;
64
65 int cnt = batch->cnt();
66
67 for (int i = 0; i < cnt; i++) {
68 bess::Packet *pkt = batch->pkts()[i];
69 Ethernet *eth = pkt->head_data<Ethernet *>();
70 Ipv4 *ip = reinterpret_cast<Ipv4 *>(eth + 1);
71 size_t ip_bytes = ip->header_length << 2;
72 Udp *udp =
73 reinterpret_cast<Udp *>(reinterpret_cast<uint8_t *>(ip) + ip_bytes);
74 Vxlan *vh = reinterpret_cast<Vxlan *>(udp + 1);
75
76 set_attr<be32_t>(this, ATTR_W_TUN_IP_SRC, pkt, ip->src);
77 set_attr<be32_t>(this, ATTR_W_TUN_IP_DST, pkt, ip->dst);
78 set_attr<be32_t>(this, ATTR_W_TUN_ID, pkt, vh->vx_vni >> 8);
79
80 pkt->adj(sizeof(*eth) + ip_bytes + sizeof(*udp) + sizeof(*vh));
81 }
82
83 RunNextModule(ctx, batch);
84}
85
86ADD_MODULE(VXLANDecap, "vxlan_decap",
87 "decapsulates the outer Ethetnet/IP/UDP/VXLAN headers")

Callers

nothing calls this directly

Calls 3

adjMethod · 0.80
cntMethod · 0.45
pktsMethod · 0.45

Tested by

no test coverage detected