Skip to content

AF_XDP selftests improvements & bpf_link

Maciej Fijalkowski bpf netdev 4 versions – Applied

Status from this message: Applied. Thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest17 patches 2 repliesApplied
  2. v417 patches 5 repliesSuperseded
  3. v317 patches 5 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v217 patches7 repliesSuperseded

Changes in v5 from the cover letter

- do not close potentially invalid bpf_link fd (Toke)
- fix misspelling in label (Toke)
- mask out XDP_FLAGS_UPDATE_IF_NOEXIST and XDP_FLAGS_REPLACE explicitly when creating bpf_link (Toke)

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/17selftests: xsk: don't call worker_pkt_dump() for stats testtools/testing/selftests/bpf/xdpxceiver.c+1 -10 replies
2/17selftests: xsk: remove struct ifaceconfigobjtools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+30 -440 replies
3/17selftests: xsk: remove unused functiontools/testing/selftests/bpf/xdpxceiver.c+0 -130 replies
4/17selftests: xsk: remove inline keyword from source filetools/testing/selftests/bpf/xdpxceiver.c+7 -100 replies
5/17selftests: xsk: simplify frame traversal in dumping threadtools/testing/selftests/bpf/xdpxceiver.c+21 -260 replies
6/17libbpf: xsk: use bpf_linktools/lib/bpf/xsk.c+213 -451 reply
7/17samples: bpf: do not unload prog within xdpsocksamples/bpf/xdpsock_user.c+14 -410 replies
8/17selftests: xsk: remove thread for netns switchtools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+14 -1190 replies
9/17selftests: xsk: split worker threadtools/testing/selftests/bpf/xdpxceiver.c+77 -790 replies
10/17selftests: xsk: remove Tx synchronization resourcestools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+7 -100 replies
11/17selftests: xsk: refactor teardown/bidi test cases and testapp_validatetools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+78 -530 replies
12/17selftests: xsk: remove sync_mutex_tx and atomic vartools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+7 -260 replies
13/17veth: implement ethtool's get_channels() callbackdrivers/net/veth.c+12 -00 replies
14/17selftests: xsk: implement bpf_link testtools/testing/selftests/bpf/test_xsk.sh tools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+139 -500 replies
15/17selftests: xsk: remove thread attributetools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+2 -90 replies
16/17selftests: xsk: Remove mutex and condition variabletools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+6 -300 replies
17/17selftests: xsk: Remove unused definestools/testing/selftests/bpf/xdpxceiver.c tools/testing/selftests/bpf/xdpxceiver.h+3 -60 replies

Reviews trailers per patch

1 of 17 patches has a Reviewed-by or Acked-by.

PatchToke Høiland-Jørgensen
1/17
2/17
3/17
4/17
5/17
6/17A-b
7/17
8/17
9/17
10/17
11/17
12/17
13/17
14/17
15/17
16/17
17/17

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 bpf-next 00/17] AF_XDP selftests improvements & bpf_link

Changes since v4 (all in patch 6):
- do not close potentially invalid bpf_link fd (Toke)
- fix misspelling in label (Toke)
- mask out XDP_FLAGS_UPDATE_IF_NOEXIST and XDP_FLAGS_REPLACE explicitly when creating bpf_link (Toke)

Changes since v3:
- do not unload netlink-based XDP prog when updating map elem failed and current socket was not the creator of XDP resources (Toke)
- pull out code paths based on prog_id value within __xsk_setup_xdp_prog so that teardown in case of error at any point is more clear

Changes since v2:
- fix c&p failure in veth's get_channels implementation (Magnus)
- provide a backward compatibilty if bpf_link is not supported (Andrii)
- check for a link type while looking up existing bpf_links (Andrii)

Changes since v1:
- selftests improvements and test case for bpf_link persistence itself
- do not unload netlink-based prog when --force flag is set (John)
- simplify return semantics in xsk_link_lookup (John)

v4: https://lore.kernel.org/bpf/[email protected]/
v3: https://lore.kernel.org/bpf/[email protected]/
v2: https://lore.kernel.org/bpf/[email protected]/
v1: https://lore.kernel.org/bpf/[email protected]/

--------------------------------------------------

This set is another approach towards addressing the below issue:

// load xdp prog and xskmap and add entry to xskmap at idx 10

$ sudo ./xdpsock -i ens801f0 -t -q 10

// add entry to xskmap at idx 11

$ sudo ./xdpsock -i ens801f0 -t -q 11

terminate one of the processes and another one is unable to work due to the fact that the XDP prog was unloaded from interface.

Previous attempt was, to put it mildly, a bit broken, as there was no synchronization between updates to additional map, as Bjorn pointed out. See https://lore.kernel.org/netdev/[email protected]/

In the meantime bpf_link was introduced and it seems that it can address the issue of refcounting the XDP prog on interface.

Although the bpf_link is the meat of the set, selftests improvements are a bigger part of it. Overall, we've been able to reduce the complexity of xsk selftests by removing a bunch of synchronization resources and simplifying logic and structs.

Last but not least, for multiqueue veth working with AF-XDP, ethtool's get_channels API needs to be implemented, so it's also included in that set.

Note also that in order to make it work, a commit from bpf tree:
veth: store queue_mapping independently of XDP prog presence
https://lore.kernel.org/bpf/[email protected]/

is needed.

Thanks,
Maciej

Björn Töpel (3):
selftests: xsk: remove thread attribute
selftests: xsk: Remove mutex and condition variable
selftests: xsk: Remove unused defines

Maciej Fijalkowski (14):
selftests: xsk: don't call worker_pkt_dump() for stats test
selftests: xsk: remove struct ifaceconfigobj
selftests: xsk: remove unused function
selftests: xsk: remove inline keyword from source file
selftests: xsk: simplify frame traversal in dumping thread
libbpf: xsk: use bpf_link
samples: bpf: do not unload prog within xdpsock
selftests: xsk: remove thread for netns switch
selftests: xsk: split worker thread
selftests: xsk: remove Tx synchronization resources
selftests: xsk: refactor teardown/bidi test cases and testapp_validate
selftests: xsk: remove sync_mutex_tx and atomic var
veth: implement ethtool's get_channels() callback
selftests: xsk: implement bpf_link test

 drivers/net/veth.c                       |  12 +
 samples/bpf/xdpsock_user.c               |  55 +-
 tools/lib/bpf/xsk.c                      | 258 +++++++--
 tools/testing/selftests/bpf/test_xsk.sh  |   3 +-
 tools/testing/selftests/bpf/xdpxceiver.c | 700 ++++++++++-------------
 tools/testing/selftests/bpf/xdpxceiver.h |  49 +-
 6 files changed, 573 insertions(+), 504 deletions(-)
Signature · 1 line
2.20.1