Skip to content

Commit

Permalink
xdp-bench: Enable the xdp_frags flag for all kernel programs
Browse files Browse the repository at this point in the history
We always set the frags support bit: nothing the XDP programs do
is incompatible with multibuf, and it's perfectly fine to load a
program with frags support on an interface with a small MTU. We don't
risk setting any flags the kernel will balk at, either, since libxdp
will do the feature probing for us and skip the flag if the kernel
doesn't support it.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
  • Loading branch information
tohojo committed Jun 8, 2023
1 parent fcb9822 commit d0bb739
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions xdp-bench/xdp_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ static int do_basic(const struct basic_opts *opt, enum xdp_action action)
goto end_destroy;
}

/* We always set the frags support bit: nothing the program does is
* incompatible with multibuf, and it's perfectly fine to load a program
* with frags support on an interface with a small MTU. We don't risk
* setting any flags the kernel will balk at, either, since libxdp will
* do the feature probing for us and skip the flag if the kernel doesn't
* support it.
*
* The function below returns EOPNOTSUPP it libbpf is too old to support
* setting the flags, but we just ignore that, since in such a case the
* best we can do is just attempt to run without the frags support.
*/
xdp_program__set_xdp_frags_support(xdp_prog, true);

ret = xdp_program__attach(xdp_prog, opt->iface_in.ifindex, opt->mode, 0);
if (ret < 0) {
pr_warn("Failed to attach XDP program: %s\n", strerror(-ret));
Expand Down
13 changes: 13 additions & 0 deletions xdp-bench/xdp_redirect_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ int do_redirect_basic(const void *cfg, __unused const char *pin_root_path)
goto end_destroy;
}

/* We always set the frags support bit: nothing the program does is
* incompatible with multibuf, and it's perfectly fine to load a program
* with frags support on an interface with a small MTU. We don't risk
* setting any flags the kernel will balk at, either, since libxdp will
* do the feature probing for us and skip the flag if the kernel doesn't
* support it.
*
* The function below returns EOPNOTSUPP it libbpf is too old to support
* setting the flags, but we just ignore that, since in such a case the
* best we can do is just attempt to run without the frags support.
*/
xdp_program__set_xdp_frags_support(xdp_prog, true);

ret = xdp_program__attach(xdp_prog, opt->iface_in.ifindex, opt->mode, 0);
if (ret < 0) {
pr_warn("Failed to attach XDP program: %s\n", strerror(-ret));
Expand Down
13 changes: 13 additions & 0 deletions xdp-bench/xdp_redirect_cpumap.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ int do_redirect_cpumap(const void *cfg, __unused const char *pin_root_path)
goto end_destroy;
}

/* We always set the frags support bit: nothing the program does is
* incompatible with multibuf, and it's perfectly fine to load a program
* with frags support on an interface with a small MTU. We don't risk
* setting any flags the kernel will balk at, either, since libxdp will
* do the feature probing for us and skip the flag if the kernel doesn't
* support it.
*
* The function below returns EOPNOTSUPP it libbpf is too old to support
* setting the flags, but we just ignore that, since in such a case the
* best we can do is just attempt to run without the frags support.
*/
xdp_program__set_xdp_frags_support(xdp_prog, true);

ret = xdp_program__attach(xdp_prog, opt->iface_in.ifindex, opt->mode, 0);
if (ret < 0) {
pr_warn("Failed to attach XDP program: %s\n",
Expand Down
13 changes: 13 additions & 0 deletions xdp-bench/xdp_redirect_devmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ int do_redirect_devmap(const void *cfg, __unused const char *pin_root_path)
goto end_destroy;
}

/* We always set the frags support bit: nothing the program does is
* incompatible with multibuf, and it's perfectly fine to load a program
* with frags support on an interface with a small MTU. We don't risk
* setting any flags the kernel will balk at, either, since libxdp will
* do the feature probing for us and skip the flag if the kernel doesn't
* support it.
*
* The function below returns EOPNOTSUPP it libbpf is too old to support
* setting the flags, but we just ignore that, since in such a case the
* best we can do is just attempt to run without the frags support.
*/
xdp_program__set_xdp_frags_support(xdp_prog, true);

ret = xdp_program__attach(xdp_prog, opt->iface_in.ifindex, opt->mode, 0);
if (ret < 0) {
/* First try with struct bpf_devmap_val as value for generic
Expand Down

0 comments on commit d0bb739

Please sign in to comment.