/* Copyright (C) 2017 Cavium, Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation.
*/
/* Check for exact match, this would give a faster lookup */ if (direct_entry && direct_entry->mac &&
direct_entry->arp.mac) {
src_mac = &direct_entry->mac;
dest_mac = &direct_entry->arp.mac;
forward_to = direct_entry->ifindex;
} else { struct trie_value *prefix_value; union key_4 key4;
/* Look up in the trie for lpm */
key4.b32[0] = 32;
key4.b8[4] = iph->daddr & 0xff;
key4.b8[5] = (iph->daddr >> 8) & 0xff;
key4.b8[6] = (iph->daddr >> 16) & 0xff;
key4.b8[7] = (iph->daddr >> 24) & 0xff;
prefix_value = bpf_map_lookup_elem(&lpm_map, &key4); if (!prefix_value) goto drop;
forward_to = prefix_value->ifindex;
src_mac = &prefix_value->value; if (!src_mac) goto drop;
dest_mac = bpf_map_lookup_elem(&arp_table, &iph->daddr); if (!dest_mac) { if (!prefix_value->gw) goto drop;
dest_mac = bpf_map_lookup_elem(&arp_table,
&prefix_value->gw); if (!dest_mac) { /* Forward the packet to the kernel in * order to trigger ARP discovery for * the default gw.
*/ if (rec)
NO_TEAR_INC(rec->xdp_pass); return XDP_PASS;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.