};
#endif
+/* Map has only one element as we don't handle any sort of
+ * routing for now. Key value set by user space is 0 and
+ * value is the peer interface. */
struct bpf_map_def SEC("maps") tx_peer = {
.type = BPF_MAP_TYPE_DEVMAP,
.key_size = sizeof(int),
.max_entries = 1,
};
+/* single entry to indicate if we have peer, key value
+ * set in user space is 0. It is only used to see if
+ * a interface has a peer we need to send the information to */
struct bpf_map_def SEC("maps") tx_peer_int = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
BPF_ANY);
}
+/**
+ * Setup peer interface in XDP system
+ *
+ * Ths function set up the peer interface in the XDP maps used by the
+ * bypass filter. The first map tx_peer has type device map and is
+ * used to store the peer. The second map tx_peer_int is used by the
+ * code to check if we have a peer defined for this interface.
+ *
+ * As the map are per device we just need maps with one single element.
+ * In both case, we use the key 0 to enter element so XDP kernel code
+ * is using the same key.
+ */
int EBPFSetPeerIface(const char *iface, const char *out_iface)
{
int mapfd = EBPFGetMapFDByName(iface, "tx_peer");