Skip to content

Commit

Permalink
xdp-bench: Introduce xdp_redirect_basic_load_bytes_prog
Browse files Browse the repository at this point in the history
This commit introduces xdp_redirect_basic_load_bytes_prog to xdp-bench.
This program uses the bpf_xdp_load_bytes and bpf_xdp_store_bytes helpers for packet data access.
In contrast, xdp_redirect_basic_prog uses direct packet access.

The program that will be attached is determined by the --load-mode flag.

Signed-off-by: Nimrod Oren <[email protected]>
  • Loading branch information
nimrod-oren committed Nov 6, 2024
1 parent 8946702 commit d04057c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions xdp-bench/xdp_redirect_basic.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static long (*bpf_xdp_store_bytes)(struct xdp_md *xdp_md, __u32 offset, void *bu
const volatile int ifindex_out;

SEC("xdp")
int xdp_redirect_basic_prog(struct xdp_md *ctx)
int xdp_redirect_prog(struct xdp_md *ctx)
{
void *data_end = (void *)(long)ctx->data_end;
void *data = (void *)(long)ctx->data;
Expand All @@ -47,7 +47,7 @@ int xdp_redirect_basic_prog(struct xdp_md *ctx)
}

SEC("xdp")
int xdp_redirect_basic_load_bytes_prog(struct xdp_md *ctx)
int xdp_redirect_load_bytes_prog(struct xdp_md *ctx)
{
__u32 key = bpf_get_smp_processor_id();
int err, offset = 0;
Expand Down
4 changes: 1 addition & 3 deletions xdp-bench/xdp_redirect_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ int do_redirect_basic(const void *cfg, __unused const char *pin_root_path)
skel->rodata->ifindex_out = opt->iface_out.ifindex;

opts.obj = skel->obj;
opts.prog_name = (opt->load_mode == BASIC_LOAD_BYTES)
? "xdp_redirect_basic_load_bytes_prog"
: "xdp_redirect_basic_prog";
opts.prog_name = (opt->load_mode == BASIC_LOAD_BYTES) ? "xdp_redirect_load_bytes_prog" : "xdp_redirect_prog";
xdp_prog = xdp_program__create(&opts);
if (!xdp_prog) {
ret = -errno;
Expand Down

0 comments on commit d04057c

Please sign in to comment.