Skip to content

Commit

Permalink
bpf: fib: delay smac selection until fib_do_redirect() has picked the…
Browse files Browse the repository at this point in the history
… oif

fib_do_redirect() potentially takes the `oif` from the fib_params. But
we currently don't consider this when selecting the smac.

Fix this by delaying the smac selection until we actually need it.

Fixes: 5fff05d ("bpf,fib: introduce fib_do_redirect function")
Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
  • Loading branch information
julianwiedmann committed Jun 16, 2023
1 parent 8a86a76 commit 2118930
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bpf/lib/fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ fib_do_redirect(struct __ctx_buff *ctx, const bool needs_l2_check,
{
struct bpf_redir_neigh nh_params;
struct bpf_redir_neigh *nh = NULL;
union macaddr smac = NATIVE_DEV_MAC_BY_IFINDEX(*oif);
union macaddr *dmac = 0;
int ret;

Expand Down Expand Up @@ -154,6 +153,8 @@ fib_do_redirect(struct __ctx_buff *ctx, const bool needs_l2_check,
else
return redirect_neigh(*oif, NULL, 0, 0);
} else {
union macaddr smac = NATIVE_DEV_MAC_BY_IFINDEX(*oif);

if (!dmac) {
*fib_ret = BPF_FIB_MAP_NO_NEIGH;
return DROP_NO_FIB;
Expand Down

0 comments on commit 2118930

Please sign in to comment.