Commit 1635c937 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

sims/net/switch: only look up mac address once per packet

parent 43825889
...@@ -409,8 +409,9 @@ static void switch_pkt(Port &port, size_t iport) { ...@@ -409,8 +409,9 @@ static void switch_pkt(Port &port, size_t iport) {
mac_table[src] = iport; mac_table[src] = iport;
} }
// L2 forwarding // L2 forwarding
if (mac_table.count(dst) > 0) { auto i = mac_table.find(dst);
size_t eport = mac_table.at(dst); if (i != mac_table.end()) {
size_t eport = i->second;
forward_pkt(pkt_data, pkt_len, eport); forward_pkt(pkt_data, pkt_len, eport);
} else { } else {
// Broadcast // Broadcast
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment