summaryrefslogtreecommitdiffstats
path: root/samples/bpf
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo@kernel.org>2022-05-25 11:44:27 +0200
committerAndrii Nakryiko <andrii@kernel.org>2022-06-02 16:26:54 -0700
commit200a89e3e88786b52bc1dd5f26a310c097f4c6a7 (patch)
treecf15ebcfc2eb9b415a9bebe91457edf130b63120 /samples/bpf
parent610cd93b44ce1e7323878ef5f7b23dc10c7d45b7 (diff)
downloadlinux-200a89e3e88786b52bc1dd5f26a310c097f4c6a7.tar.gz
linux-200a89e3e88786b52bc1dd5f26a310c097f4c6a7.tar.bz2
linux-200a89e3e88786b52bc1dd5f26a310c097f4c6a7.zip
sample: bpf: xdp_router_ipv4: Allow the kernel to send arp requests
Forward the packet to the kernel if the gw router mac address is missing in to trigger ARP discovery. Fixes: 85bf1f51691c ("samples: bpf: Convert xdp_router_ipv4 to XDP samples helper") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/60bde5496d108089080504f58199bcf1143ea938.1653471558.git.lorenzo@kernel.org
Diffstat (limited to 'samples/bpf')
-rw-r--r--samples/bpf/xdp_router_ipv4.bpf.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/samples/bpf/xdp_router_ipv4.bpf.c b/samples/bpf/xdp_router_ipv4.bpf.c
index 248119ca7938..0643330d1d2e 100644
--- a/samples/bpf/xdp_router_ipv4.bpf.c
+++ b/samples/bpf/xdp_router_ipv4.bpf.c
@@ -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;
+ }
}
}