Skip to content

bpf: return proper error codes for lwt redirect

Yan Zhai bpf kernel-janitors linux-kselftest lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 23 repliesIn review
  2. v32 patches 7 repliesSuperseded

Changes in v4 from the cover letter

* minor change in commit message and changelogs
* tested by Jakub Sitnicki

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: fix skb_do_redirect return valuesinclude/linux/netdevice.h net/core/filter.c+9 -215 replies
2/2bpf: selftests: add lwt redirect regression test casestools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/progs/test_lwt_redirect.c tools/testing/selftests/bpf/test_lwt_redirect.sh+241 -08 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchJakub Sitnicki
1/2T-b R-b
2/2T-b R-b

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

Read the v4 thread

Cover letter [PATCH v4 bpf 0/2] bpf: return proper error codes for lwt redirect

lwt xmit hook does not expect positive return values in function ip_finish_output2 and ip6_finish_output2. However, BPF redirect programs can return positive values such like NET_XMIT_DROP, NET_RX_DROP, and etc as errors. Such return values can panic the kernel unexpectedly:

https://gist.github.com/zhaiyan920/8fbac245b261fe316a7ef04c9b1eba48

This patch fixes the return values from BPF redirect, so the error handling would be consistent at xmit hook. It also adds a few test cases to prevent future regressions.

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

changes since v3:
* minor change in commit message and changelogs
* tested by Jakub Sitnicki

changes since v2:
* subject name changed
* also covered redirect to ingress case
* added selftests

changes since v1:
* minor code style changes

Yan Zhai (2):
bpf: fix skb_do_redirect return values
bpf: selftests: add lwt redirect regression test cases

 include/linux/netdevice.h                     |   2 +
 net/core/filter.c                             |   9 +-
 tools/testing/selftests/bpf/Makefile          |   1 +
 .../selftests/bpf/progs/test_lwt_redirect.c   |  66 +++++++
 .../selftests/bpf/test_lwt_redirect.sh        | 174 ++++++++++++++++++
 5 files changed, 250 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_lwt_redirect.c
 create mode 100755 tools/testing/selftests/bpf/test_lwt_redirect.sh
Signature · 1 line
2.30.2