Skip to content

nft: Implement forward compat for future binaries

Phil Sutter netfilter-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 1 replyIn review
  2. v18 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- Split the parser into a separate patch for easier backporting by distributions.
- Make the writer opt-in, allow users to force the parser fallback at run-time.
- Document the feature in man pages.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8nft: Make add_log() staticiptables/nft.c iptables/nft.h+3 -20 replies
2/8nft: ruleparse: Introduce nft_parse_rule_expr()iptables/nft-ruleparse.c iptables/nft-ruleparse.h+44 -330 replies
3/8nft: __add_{match,target}() can't failiptables/nft.c iptables/nft.h+12 -180 replies
4/8nft: Introduce UDATA_TYPE_COMPAT_EXTiptables/nft.c iptables/nft.h+15 -80 replies
5/8nft-ruleparse: Fallback to compat expressions in userdataconfigure.ac iptables/Makefile.am iptables/nft-compat.c +2 more+204 -00 replies
6/8nft: Pass nft_handle into add_{action,match}()iptables/nft-arp.c iptables/nft-bridge.c iptables/nft-ipv4.c +3 more+17 -130 replies
7/8nft: Embed compat extensions in rule userdataiptables/arptables-nft.8 iptables/ebtables-nft.8 iptables/iptables-restore.8.in +13 more+240 -170 replies
8/8tests: iptables-test: Add nft-compat variantiptables-test.py+12 -20 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [iptables PATCH v2 0/8] nft: Implement forward compat for future binaries

Changes since v1:
- Split the parser into a separate patch for easier backporting by distributions.
- Make the writer opt-in, allow users to force the parser fallback at run-time.
- Document the feature in man pages.

Time to abandon earlier attempts at providing compatibility for old binaries, choose the next best option which is not relying upon any kernel changes.

Basically, all extensions replaced by native bytecode are appended to rule userdata so when nftnl rule parsing code fails, it may retry omitting all these expressions and restoring an extension from userdata instead.

The idea behind this is that extensions are stable which relieves native bytecode from being the same. With this series in place, one may (re-)start converting extensions into native nftables bytecode again.

Appending rule userdata upon creation is inactive by default and enabled via --compat option or XTABLES_COMPAT env variable. The parser will fall back to userdata automatically if present and parsing fails.

Patches 1-3 are preparation. Patches 4 and 5 implement the parser side, patches 6 and 7 implement the writer and patch 8 finally extends iptables-test.py to cover the new code.

Phil Sutter (8):
nft: Make add_log() static
nft: ruleparse: Introduce nft_parse_rule_expr()
nft: __add_{match,target}() can't fail
nft: Introduce UDATA_TYPE_COMPAT_EXT
nft-ruleparse: Fallback to compat expressions in userdata
nft: Pass nft_handle into add_{action,match}()
nft: Embed compat extensions in rule userdata
tests: iptables-test: Add nft-compat variant

 configure.ac                   |   9 ++
 iptables-test.py               |  14 ++-
 iptables/Makefile.am           |   1 +
 iptables/arptables-nft.8       |  12 ++
 iptables/ebtables-nft.8        |  12 ++
 iptables/iptables-restore.8.in |  12 ++
 iptables/iptables.8.in         |  12 ++
 iptables/nft-arp.c             |   2 +-
 iptables/nft-bridge.c          |   9 +-
 iptables/nft-compat.c          | 222 +++++++++++++++++++++++++++++++++
 iptables/nft-compat.h          |  54 ++++++++
 iptables/nft-ipv4.c            |   2 +-
 iptables/nft-ipv6.c            |   2 +-
 iptables/nft-ruleparse.c       |  90 ++++++++-----
 iptables/nft-ruleparse.h       |   4 +
 iptables/nft.c                 | 111 ++++++++++-------
 iptables/nft.h                 |  24 +++-
 iptables/xshared.c             |   7 ++
 iptables/xshared.h             |   1 +
 iptables/xtables-arp.c         |   1 +
 iptables/xtables-eb.c          |   4 +
 iptables/xtables-nft.8         |  11 ++
 iptables/xtables-restore.c     |  15 ++-
 iptables/xtables.c             |   3 +
 24 files changed, 544 insertions(+), 90 deletions(-)
 create mode 100644 iptables/nft-compat.c
 create mode 100644 iptables/nft-compat.h
Signature · 1 line
2.43.0