ret = bpf_xdp_attach(interface, bpf_program__fd(xdp), flags, NULL); if (!ASSERT_OK(ret, "attach xdp_vlan_change")) goto cleanup;
tc_hook.ifindex = interface;
ret = bpf_tc_hook_create(&tc_hook); if (!ASSERT_OK(ret, "bpf_tc_hook_create")) goto detach_xdp;
/* Now we'll use BPF programs to pop/push the VLAN tags */
tc_opts.prog_fd = bpf_program__fd(tc);
ret = bpf_tc_attach(&tc_hook, &tc_opts); if (!ASSERT_OK(ret, "bpf_tc_attach")) goto detach_xdp;
close_netns(nstoken);
nstoken = NULL;
/* Now the namespaces can reach each-other, test with pings */
SYS(detach_tc, "ip netns exec %s ping -i 0.2 -W 2 -c 2 %s > /dev/null", ns1, NS2_IP_ADDR);
SYS(detach_tc, "ip netns exec %s ping -i 0.2 -W 2 -c 2 %s > /dev/null", ns2, NS1_IP_ADDR);
/* First test: Remove VLAN by setting VLAN ID 0, using "xdp_vlan_change" * egress use TC to add back VLAN tag 4011
*/ void test_xdp_vlan_change(void)
{ struct test_xdp_vlan *skel;
skel = test_xdp_vlan__open_and_load(); if (!ASSERT_OK_PTR(skel, "xdp_vlan__open_and_load")) return;
if (test__start_subtest("0"))
xdp_vlan(skel->progs.xdp_vlan_change, skel->progs.tc_vlan_push, 0);
if (test__start_subtest("DRV_MODE"))
xdp_vlan(skel->progs.xdp_vlan_change, skel->progs.tc_vlan_push,
XDP_FLAGS_DRV_MODE);
if (test__start_subtest("SKB_MODE"))
xdp_vlan(skel->progs.xdp_vlan_change, skel->progs.tc_vlan_push,
XDP_FLAGS_SKB_MODE);
test_xdp_vlan__destroy(skel);
}
/* Second test: XDP prog fully remove vlan header * * Catch kernel bug for generic-XDP, that doesn't allow us to * remove a VLAN header, because skb->protocol still contain VLAN * ETH_P_8021Q indication, and this cause overwriting of our changes.
*/ void test_xdp_vlan_remove(void)
{ struct test_xdp_vlan *skel;
skel = test_xdp_vlan__open_and_load(); if (!ASSERT_OK_PTR(skel, "xdp_vlan__open_and_load")) return;
if (test__start_subtest("0"))
xdp_vlan(skel->progs.xdp_vlan_remove_outer2, skel->progs.tc_vlan_push, 0);
if (test__start_subtest("DRV_MODE"))
xdp_vlan(skel->progs.xdp_vlan_remove_outer2, skel->progs.tc_vlan_push,
XDP_FLAGS_DRV_MODE);
if (test__start_subtest("SKB_MODE"))
xdp_vlan(skel->progs.xdp_vlan_remove_outer2, skel->progs.tc_vlan_push,
XDP_FLAGS_SKB_MODE);
test_xdp_vlan__destroy(skel);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.