skeletons
if (!ASSERT_LE(skeletons->nlinks+1, MAX_BPF_LINKS, "too many XDP programs attached"))
skeletons->links[skeletons->nlinks++] = link;
static int bonding_setup(struct skeletons *skeletons, int mode, int xmit_policy,
if (xdp_attach(skeletons, skeletons->xdp_dummy->progs.xdp_dummy_prog, "veth1_2"))
if (xdp_attach(skeletons, skeletons->xdp_dummy->progs.xdp_dummy_prog, "bond1"))
if (xdp_attach(skeletons, skeletons->xdp_tx->progs.xdp_tx, "bond2"))
static void bonding_cleanup(struct skeletons *skeletons)
while (skeletons->nlinks) {
skeletons->nlinks--;
bpf_link__destroy(skeletons->links[skeletons->nlinks]);
static void test_xdp_bonding_with_mode(struct skeletons *skeletons, int mode, int xmit_policy)
if (bonding_setup(skeletons, mode, xmit_policy, BOND_BOTH_AND_ATTACH))
bonding_cleanup(skeletons);
static void test_xdp_bonding_redirect_multi(struct skeletons *skeletons)
if (bonding_setup(skeletons, BOND_MODE_ROUNDROBIN, BOND_XMIT_POLICY_LAYER23,
int map_fd = bpf_map__fd(skeletons->xdp_redirect_multi_kern->maps.map_all);
if (xdp_attach(skeletons,
skeletons->xdp_redirect_multi_kern->progs.xdp_redirect_map_multi_prog,
bonding_cleanup(skeletons);
static void test_xdp_bonding_attach(struct skeletons *skeletons)
link = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog, veth);
link = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog, veth);
link2 = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog, bond);
link = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog, bond);
link2 = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog, veth);
link = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog, bond);
static void test_xdp_bonding_nested(struct skeletons *skeletons)
link = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog, bond);
static void test_xdp_bonding_features(struct skeletons *skeletons)
link = bpf_program__attach_xdp(skeletons->xdp_dummy->progs.xdp_dummy_prog,
static void test_xdp_bonding_xmit_policy_compat(struct skeletons *skeletons)
xdp_fd = bpf_program__fd(skeletons->xdp_dummy->progs.xdp_dummy_prog);
struct skeletons skeletons = {};
skeletons.xdp_dummy = xdp_dummy__open_and_load();
if (!ASSERT_OK_PTR(skeletons.xdp_dummy, "xdp_dummy__open_and_load"))
skeletons.xdp_tx = xdp_tx__open_and_load();
if (!ASSERT_OK_PTR(skeletons.xdp_tx, "xdp_tx__open_and_load"))
skeletons.xdp_redirect_multi_kern = xdp_redirect_multi_kern__open_and_load();
if (!ASSERT_OK_PTR(skeletons.xdp_redirect_multi_kern,
test_xdp_bonding_attach(&skeletons);
test_xdp_bonding_nested(&skeletons);
test_xdp_bonding_features(&skeletons);
&skeletons,
test_xdp_bonding_xmit_policy_compat(&skeletons);
test_xdp_bonding_redirect_multi(&skeletons);
xdp_dummy__destroy(skeletons.xdp_dummy);
xdp_tx__destroy(skeletons.xdp_tx);
xdp_redirect_multi_kern__destroy(skeletons.xdp_redirect_multi_kern);
static int xdp_attach(struct skeletons *skeletons, struct bpf_program *prog, char *iface)