Re: [PATCH v5 bpf-next 3/3] selftests/bpf: Add selftest for bpf_xdp_flow_lookup kfunc

Lorenzo Bianconi
2024-06-29T20:11:58Z

[-- Attachment #1: Type: text/plain, Size: 2226 bytes --]

> On 6/14/24 5:40 PM, Lorenzo Bianconi wrote:
> [...]
> > +void test_xdp_flowtable(void)
> > +{
> > + struct xdp_flowtable *skel = NULL;
> > + struct nstoken *tok = NULL;
> > + int iifindex, stats_fd;
> > + __u32 value, key = 0;
> > + struct bpf_link *link;
> > +
> > + if (SYS_NOFAIL("nft -v")) {
> > + fprintf(stdout, "Missing required nft tool\n");
> > + test__skip();
> > + return;
>
> Bit unfortunate that upstream CI skips the test case at the moment:

yep, we are missing nft utility there.

>
> #542/2 xdp_devmap_attach/DEVMAP with frags programs in entries:OK
> #542/3 xdp_devmap_attach/Verifier check of DEVMAP programs:OK
> #542 xdp_devmap_attach:OK
> #543 xdp_do_redirect:OK
> #544 xdp_flowtable:SKIP
> [...]
>
> > +out:
> > + xdp_flowtable__destroy(skel);
> > + if (tok)
> > + close_netns(tok);
> > + SYS_NOFAIL("ip netns del " TX_NETNS_NAME);
> > + SYS_NOFAIL("ip netns del " RX_NETNS_NAME);
> > +}
> > diff --git a/tools/testing/selftests/bpf/progs/xdp_flowtable.c b/tools/testing/selftests/bpf/progs/xdp_flowtable.c
> > new file mode 100644
> > index 0000000000000..8297b30b0764b
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/xdp_flowtable.c
> > @@ -0,0 +1,146 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +#define BPF_NO_KFUNC_PROTOTYPES
> > +#include <vmlinux.h>
> > +#include <bpf/bpf_helpers.h>
> > +#include <bpf/bpf_endian.h>
> > +
> > +#define MAX_ERRNO 4095
>
> nit: unused?

ack, I will remove it in v6.

Regards,
Lorenzo

>
> > +#define ETH_P_IP 0x0800
> > +#define ETH_P_IPV6 0x86dd
> > +#define IP_MF 0x2000 /* "More Fragments" */
> > +#define IP_OFFSET 0x1fff /* "Fragment Offset" */
> > +#define AF_INET 2
> > +#define AF_INET6 10
> > +
> > +struct bpf_flowtable_opts___local {
> > + s32 error;
> > +};
> > +
> > +struct flow_offload_tuple_rhash *
> > +bpf_xdp_flow_lookup(struct xdp_md *, struct bpf_fib_lookup *,
> > + struct bpf_flowtable_opts___local *, u32) __ksym;
> > +
> > +struct {
> > + __uint(type, BPF_MAP_TYPE_ARRAY);
> > + __type(key, __u32);
> > + __type(value, __u32);
> > + __uint(max_entries, 1);
> > +} stats SEC(".maps");
> > +
> [...]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]