]> git.ipfire.org Git - thirdparty/nftables.git/commit
src: Optimize prefix matches on byte-boundaries
authorPhil Sutter <phil@nwl.cc>
Tue, 27 Oct 2020 16:33:15 +0000 (17:33 +0100)
committerPhil Sutter <phil@nwl.cc>
Wed, 4 Nov 2020 13:44:11 +0000 (14:44 +0100)
commit25338cdb6c77aa2f0977afbbb612571c9d325213
treee18d5b58d9718ebb9ee21cb06f189eb94bf7a22c
parent8a927c56d83ed0f78785011bd92a53edc25a0ca0
src: Optimize prefix matches on byte-boundaries

If a prefix expression's length is on a byte-boundary, it is sufficient
to just reduce the length passed to "cmp" expression. No need for
explicit bitwise modification of data on LHS. The relevant code is
already there, used for string prefix matches. There is one exception
though, namely zero-length prefixes: Kernel doesn't accept zero-length
"cmp" expressions, so keep them in the old code-path for now.

This patch depends upon the previous one to correctly parse odd-sized
payload matches but has to extend support for non-payload LHS as well.
In practice, this is needed for "ct" expressions as they allow matching
against IP address prefixes, too.

Signed-off-by: Phil Sutter <phil@nwl.cc>
src/netlink_delinearize.c
src/netlink_linearize.c
tests/py/ip/ct.t.payload
tests/py/ip/ip.t.payload
tests/py/ip/ip.t.payload.bridge
tests/py/ip/ip.t.payload.inet
tests/py/ip/ip.t.payload.netdev
tests/py/ip6/ip6.t.payload.inet
tests/py/ip6/ip6.t.payload.ip6