Skip to content

net: flow_dissector: trigger BPF hook when called from eth_get_headlen

Stanislav Fomichev bpf intel-wired-lan netdev 5 versions – Applied

Status from this message: Applied, thanks everyone!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest9 patches 7 repliesApplied
  2. v56 patches 7 repliesSuperseded
  3. v3 RFC8 patches 22 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC9 patches19 repliesSuperseded
v1 RFC7 patches22 repliesSuperseded

Changes in v6 from the cover letter

* more suggestions by Alexei:
* eth_get_headlen now takes net dev, not net namespace
* test skb-less case via tun eth_get_headlen
* fix return errors in bpf_flow_load
* don't adjust nhoff/thoff by ETH_HLEN

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/9flow_dissector: switch kernel context to struct bpf_flow_dissectorinclude/linux/skbuff.h include/net/flow_dissector.h include/net/sch_generic.h +3 more+117 -590 replies
2/9bpf: when doing BPF_PROG_TEST_RUN for flow dissector use no-skb modenet/bpf/test_run.c+17 -300 replies
3/9net: plumb network namespace into __skb_flow_dissectinclude/linux/skbuff.h net/core/flow_dissector.c net/ethernet/eth.c+31 -202 replies
4/9flow_dissector: handle no-skb use caseinclude/linux/skbuff.h net/core/flow_dissector.c+25 -320 replies
5/9net: pass net_device argument to the eth_get_headlendrivers/net/ethernet/aquantia/atlantic/aq_ring.c drivers/net/ethernet/broadcom/bnxt/bnxt.c drivers/net/ethernet/hisilicon/hns/hns_enet.c +13 more+22 -170 replies
6/9selftests/bpf: add flow dissector bpf_skb_load_bytes helper testtools/testing/selftests/bpf/prog_tests/flow_dissector_load_bytes.c+48 -00 replies
7/9selftests/bpf: run flow dissector tests in skb-less modetools/testing/selftests/bpf/flow_dissector_load.c tools/testing/selftests/bpf/flow_dissector_load.h tools/testing/selftests/bpf/prog_tests/flow_dissector.c +1 more+165 -340 replies
8/9selftests/bpf: properly return error from bpf_flow_loadtools/testing/selftests/bpf/flow_dissector_load.h+4 -40 replies
9/9bpf/flow_dissector: don't adjust nhoff by ETH_HLEN in BPF_PROG_TEST_RUNnet/bpf/test_run.c tools/testing/selftests/bpf/prog_tests/flow_dissector.c+9 -170 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchSaeed MahameedEric DumazetWillem de Bruijn
SeriesA-b A-b
1/9
2/9
3/9R-b
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH bpf-next v6 0/9] net: flow_dissector: trigger BPF hook when called from eth_get_headlen

Currently, when eth_get_headlen calls flow dissector, it doesn't pass any skb. Because we use passed skb to lookup associated networking namespace to find whether we have a BPF program attached or not, we always use C-based flow dissector in this case.

The goal of this patch series is to add new networking namespace argument to the eth_get_headlen and make BPF flow dissector programs be able to work in the skb-less case.

The series goes like this:
* use new kernel context (struct bpf_flow_dissector) for flow dissector programs; this makes it easy to distinguish between skb and no-skb case and supports calling BPF flow dissector on a chunk of raw data
* convert BPF_PROG_TEST_RUN to use raw data
* plumb network namespace into __skb_flow_dissect from all callers
* handle no-skb case in __skb_flow_dissect
* update eth_get_headlen to include net namespace argument and convert all existing users
* add selftest to make sure bpf_skb_load_bytes is not allowed in the no-skb mode
* extend test_progs to exercise skb-less flow dissection as well
* stop adjusting nhoff/thoff by ETH_HLEN in BPF_PROG_TEST_RUN

v6:
* more suggestions by Alexei:
* eth_get_headlen now takes net dev, not net namespace
* test skb-less case via tun eth_get_headlen
* fix return errors in bpf_flow_load
* don't adjust nhoff/thoff by ETH_HLEN

v5:
* API changes have been submitted via bpf/stable tree

v4:
* prohibit access to vlan fields as well (otherwise, inconsistent between skb/skb-less cases)
* drop extra unneeded check for skb->vlan_present in bpf_flow.c

v3:
* new kernel xdp_buff-like context per Alexei suggestion
* drop skb_net helper
* properly clamp flow_keys->nhoff

v2:
* moved temporary skb from stack into percpu (avoids memset of ~200 bytes per packet)
* tightened down access to __sk_buff fields from flow dissector programs to avoid touching shinfo (whitelist only relevant fields)
* addressed suggestions from Willem

Stanislav Fomichev (9):
flow_dissector: switch kernel context to struct bpf_flow_dissector
bpf: when doing BPF_PROG_TEST_RUN for flow dissector use no-skb mode
net: plumb network namespace into __skb_flow_dissect
flow_dissector: handle no-skb use case
net: pass net_device argument to the eth_get_headlen selftests/bpf: add flow dissector bpf_skb_load_bytes helper test selftests/bpf: run flow dissector tests in skb-less mode selftests/bpf: properly return error from bpf_flow_load bpf/flow_dissector: don't adjust nhoff by ETH_HLEN in
BPF_PROG_TEST_RUN

 .../net/ethernet/aquantia/atlantic/aq_ring.c  |   3 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     |   2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c |   2 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |   2 +-
 drivers/net/ethernet/intel/fm10k/fm10k_main.c |   2 +-
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |   3 +-
 drivers/net/ethernet/intel/iavf/iavf_txrx.c   |   2 +-
 drivers/net/ethernet/intel/ice/ice_txrx.c     |   2 +-
 drivers/net/ethernet/intel/igb/igb_main.c     |   2 +-
 drivers/net/ethernet/intel/igc/igc_main.c     |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   2 +-
 .../net/ethernet/intel/ixgbevf/ixgbevf_main.c |   3 +-
 .../net/ethernet/mellanox/mlx5/core/en_tx.c   |   2 +-
 drivers/net/tun.c                             |   3 +-
 include/linux/etherdevice.h                   |   2 +-
 include/linux/skbuff.h                        |  28 +++--
 include/net/flow_dissector.h                  |   7 ++
 include/net/sch_generic.h                     |  11 +-
 net/bpf/test_run.c                            |  48 +++-----
 net/core/filter.c                             | 105 ++++++++++++----
 net/core/flow_dissector.c                     |  90 +++++++-------
 net/ethernet/eth.c                            |   8 +-
 .../selftests/bpf/flow_dissector_load.c       |   2 +-
 .../selftests/bpf/flow_dissector_load.h       |  24 +++-
 .../selftests/bpf/prog_tests/flow_dissector.c | 113 ++++++++++++++++--
 .../prog_tests/flow_dissector_load_bytes.c    |  48 ++++++++
 tools/testing/selftests/bpf/progs/bpf_flow.c  |  79 +++++++-----
 27 files changed, 411 insertions(+), 186 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/flow_dissector_load_bytes.c
Signature · 1 line
2.21.0.593.g511ec345e18-goog