Skip to content

Commit

Permalink
sample: bpf: xdp_router_ipv4: Allow the kernel to send arp requests
Browse files Browse the repository at this point in the history
Forward the packet to the kernel if the gw router mac address is missing
in to trigger ARP discovery.

Fixes: 85bf1f5 ("samples: bpf: Convert xdp_router_ipv4 to XDP samples helper")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/60bde5496d108089080504f58199bcf1143ea938.1653471558.git.lorenzo@kernel.org
  • Loading branch information
LorenzoBianconi authored and anakryiko committed Jun 2, 2022
1 parent 610cd93 commit 200a89e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions samples/bpf/xdp_router_ipv4.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ int xdp_router_ipv4_prog(struct xdp_md *ctx)

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;
}
}
}

Expand Down

0 comments on commit 200a89e

Please sign in to comment.