Re: [PATCH bpf-next v3 2/2] bpf, xdp: restructure redirect actions
From: Jesper Dangaard Brouer <hidden>
Date: 2021-02-22 08:13:07
Also in:
bpf
On Sun, 21 Feb 2021 21:09:54 +0100 Björn Töpel [off-list ref] wrote:
From: Björn Töpel <redacted>
The XDP_REDIRECT implementations for maps and non-maps are fairly
similar, but obviously need to take different code paths depending on
if the target is using a map or not. Today, the redirect targets for
XDP either uses a map, or is based on ifindex.
Here, an explicit redirect type is added to bpf_redirect_info, instead
of the actual map. Redirect type, map item/ifindex, and the map_id (if
any) is passed to xdp_do_redirect().
In addition to making the code easier to follow, using an explicit
type in bpf_redirect_info has a slight positive performance impact by
avoiding a pointer indirection for the map type lookup, and instead
use the cacheline for bpf_redirect_info.
Since the actual map is not passed via bpf_redirect_info anymore, the
map lookup is only done in the BPF helper. This means that the
bpf_clear_redirect_map() function can be removed. The actual map item
is RCU protected.
The bpf_redirect_info flags member is not used by XDP, and not
read/written any more. The map member is only written to when
required/used, and not unconditionally.
v1->v2 : Removed warning when CONFIG_BPF_SYSCALL was not set. (lkp)
: Cleaned up case-clause in xdp_do_generic_redirect_map(). (Toke)
rfc->v1: Use map_id, and remove bpf_clear_redirect_map(). (Toke)
Acked-by: Toke Høiland-Jørgensen <redacted>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Björn Töpel <redacted>
---
include/linux/bpf.h | 1 +
include/linux/filter.h | 11 ++-
include/trace/events/xdp.h | 66 +++++++++------
kernel/bpf/cpumap.c | 1 -
kernel/bpf/devmap.c | 1 -
net/core/filter.c | 165 ++++++++++++++++---------------------
net/xdp/xskmap.c | 1 -
7 files changed, 122 insertions(+), 124 deletions(-)I like it! :-) Acked-by: Jesper Dangaard Brouer <redacted> -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer