Skip to content

nft: exthdr fixes and improvements

Florian Westphal netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10evaluate: enforce ip6 proto with exthdr expressionsrc/evaluate.c tests/py/any/frag.t tests/py/any/frag.t.payload +2 more+189 -1770 replies
2/10netlink: split generic part of netlink_gen_payload_mask into helpersrc/netlink_linearize.c+23 -120 replies
3/10netlink: add and use netlink_gen_exthdr_masksrc/netlink_linearize.c+24 -30 replies
4/10payload: move payload_gen_dependency generic part to helpersrc/payload.c+38 -280 replies
5/10exthdr: generate dependencies for inet/bridge/netdev familyinclude/payload.h src/evaluate.c src/payload.c+31 -30 replies
6/10tests: add/fix inet+exthdr teststests/py/ip6/dst.t.payload.inet tests/py/ip6/frag.t.payload.inet tests/py/ip6/hbh.t.payload.inet +2 more+327 -00 replies
7/10exthdr: remove implicit dependenciessrc/netlink_delinearize.c+10 -30 replies
8/10exthdr: store offset for later useinclude/expression.h src/exthdr.c+3 -00 replies
9/10netlink_delinearize: prepare binop_postprocess for exthdr demuxsrc/netlink_delinearize.c+7 -80 replies
10/10netlink_delinearize: handle extension header templates with odd sizesinclude/exthdr.h src/exthdr.c src/netlink_delinearize.c+41 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH nft 00/10] nft: exthdr fixes and improvements

This adds following enhancements and fixes for the exthdr expression.

#1. Treat exthdr as if user asked for an ip6 protocol header field, i.e. add ipv6 dependency for bridge/netdev/inet family.

#2. Add scaling and masking to handle protocol headers that have non-byte divisible sizes.

Tested briefly with following dummy rules (nf_defrag_ipv6 module not loaded):

frag frag-off 0 counter packets 40 bytes 59840 frag frag-off 131 counter packets 0 bytes 0 frag frag-off 1448 counter packets 0 bytes 0 frag frag-off 181 counter packets 40 bytes 59840 frag frag-off > 0 counter packets 120 bytes 148160

Note that the offsets are *NOT* scaled, i.e. we match the raw values contained in the packet. To match offset of 1448 one thus needs to ask for 181.

This is same behaviour as ip hdrlength, where 5 matches a value of 20 bytes.

 include/expression.h             |    1
 include/exthdr.h                 |    2
 include/payload.h                |    2
 src/evaluate.c                   |   29 +++++++
 src/exthdr.c                     |   33 ++++++++
 src/netlink_delinearize.c        |   36 +++++----
 src/netlink_linearize.c          |   62 +++++++++++----
 src/payload.c                    |   75 ++++++++++++-------
 tests/py/ip6/dst.t.payload.inet  |   30 +++++++
 tests/py/ip6/frag.t              |   63 ++++++++++++++++
 tests/py/ip6/frag.t.payload.inet |  145 +++++++++++++++++++++++++++++++++++++
 tests/py/ip6/frag.t.payload.ip6  |  109 +++++++++++++++++++++++++++
 tests/py/ip6/hbh.t.payload.inet  |   30 +++++++
 tests/py/ip6/mh.t.payload.inet   |   64 ++++++++++++++++
 tests/py/ip6/rt.t.payload.inet   |   58 ++++++++++++++
 tests/py/any/frag.t                |   67 -----------------
 tests/py/any/frag.t.payload        |  109 ---------------------------
 17 files changed, 685 insertions(+), 230 deletions(-)

Note: frag-off match is broken at the moment, I passed a patch to netdev:

https://patchwork.ozlabs.org/patch/590568/