Skip to content

Fix for debug output on Big Endian

Phil Sutter netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9set_elem: Review debug outputsrc/set_elem.c+21 -100 replies
2/9expr: data_reg: Avoid extra whitespacesrc/expr/bitwise.c src/expr/cmp.c src/expr/data_reg.c +3 more+24 -100 replies
3/9expr: Pass byteorder to struct expr_ops::set callbackinclude/expr_ops.h src/expr.c src/expr/bitwise.c +38 more+77 -570 replies
4/9data_reg: Introduce struct nftnl_data_reg::byteorder fieldinclude/data_reg.h src/expr/bitwise.c src/expr/cmp.c +4 more+18 -120 replies
5/9data_reg: Introduce struct nftnl_data_reg::sizes arrayinclude/data_reg.h src/expr/bitwise.c src/expr/cmp.c +4 more+22 -120 replies
6/9Introduce nftnl_{expr,set_elem}_set_imm()include/libnftnl/expr.h include/libnftnl/set.h src/expr.c +2 more+38 -60 replies
7/9data_reg: Respect data byteorder when printingsrc/expr/data_reg.c+23 -60 replies
8/9data_reg: Support concatenated datasrc/expr/data_reg.c+38 -100 replies
9/9udata: Store u32 udata values in Big Endiansrc/udata.c+5 -22 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [libnftnl PATCH 0/9] Fix for debug output on Big Endian

This series aims at providing identical netlink debug output in nftables on Big and Little Endian systems. Particularly problematic are all data regs in host byte order, worsened by the potential for byte order swaps within a single data reg (concatenated set elements).

A bonus task is cropping data reg values to their actual size. Previously, every four-byte register containing data was printed which further reduces data expressiveness.

This series introduces data attribute setters for expressions and set elements which accept a byteorder value (plus an array of component sizes in the latter case) and changes the data reg printer to:

- Print only nftnl_data_reg::len bytes at max
- Print data byte-by-byte, not four byte chunks as u32 values interpreted in host byte order
- Print data in reverse if in host byte order on Little Endian

If nftnl_data_reg::sizes array has non-zero fields, data is assumed to be concatenated and bits in nftnl_data_reg::byteorder signal host byte order in components. Each component is then printed as per the above rules and separated by a dot (".").

Patches 3-8 implement the above. Since debug output changes significantly, use the occasion to:
- Print a colon (":") and flags value only if relevant (patch 1)
- Fix for missing object name in objmap elements (patch 1)
- Avoid ambiguity between data and flags value by prefixing with 'flags' (patch 1)
- Avoid trailing whitespace or space before tab (patch 2)

Finally, patch 8 tries to avoid userdata values in host byte order by storing u32 values in Big Endian. Since nftnl_udata_put_u32() is the only typed attribute setter (apart from the unproblematic strz one), this may be good enough for the purpose.

Phil Sutter (9):
set_elem: Review debug output
expr: data_reg: Avoid extra whitespace
expr: Pass byteorder to struct expr_ops::set callback
data_reg: Introduce struct nftnl_data_reg::byteorder field
data_reg: Introduce struct nftnl_data_reg::sizes array Introduce nftnl_{expr,set_elem}_set_imm()
data_reg: Respect data byteorder when printing
data_reg: Support concatenated data
udata: Store u32 udata values in Big Endian

 include/data_reg.h      |  5 +++-
 include/expr_ops.h      |  2 +-
 include/libnftnl/expr.h |  1 +
 include/libnftnl/set.h  |  1 +
 src/expr.c              | 22 +++++++++++---
 src/expr/bitwise.c      | 18 ++++++++----
 src/expr/byteorder.c    |  2 +-
 src/expr/cmp.c          |  8 ++++--
 src/expr/connlimit.c    |  2 +-
 src/expr/counter.c      |  2 +-
 src/expr/ct.c           |  2 +-
 src/expr/data_reg.c     | 64 ++++++++++++++++++++++++++++++++++++-----
 src/expr/dup.c          |  5 ++--
 src/expr/dynset.c       |  2 +-
 src/expr/exthdr.c       |  2 +-
 src/expr/fib.c          |  2 +-
 src/expr/flow_offload.c |  5 ++--
 src/expr/fwd.c          |  5 ++--
 src/expr/hash.c         |  2 +-
 src/expr/immediate.c    |  8 ++++--
 src/expr/inner.c        |  2 +-
 src/expr/last.c         |  5 ++--
 src/expr/limit.c        |  2 +-
 src/expr/log.c          |  5 ++--
 src/expr/lookup.c       |  2 +-
 src/expr/masq.c         |  2 +-
 src/expr/match.c        |  2 +-
 src/expr/meta.c         |  2 +-
 src/expr/nat.c          |  2 +-
 src/expr/numgen.c       |  2 +-
 src/expr/objref.c       |  5 ++--
 src/expr/osf.c          |  5 ++--
 src/expr/payload.c      |  2 +-
 src/expr/queue.c        |  5 ++--
 src/expr/quota.c        |  5 ++--
 src/expr/range.c        | 17 ++++++++---
 src/expr/redir.c        |  2 +-
 src/expr/reject.c       |  5 ++--
 src/expr/rt.c           |  2 +-
 src/expr/socket.c       |  2 +-
 src/expr/synproxy.c     |  5 ++--
 src/expr/target.c       |  2 +-
 src/expr/tproxy.c       |  2 +-
 src/expr/tunnel.c       |  5 ++--
 src/expr/xfrm.c         |  2 +-
 src/libnftnl.map        |  5 ++++
 src/set_elem.c          | 61 ++++++++++++++++++++++++++++-----------
 src/udata.c             |  7 +++--
 48 files changed, 233 insertions(+), 92 deletions(-)
Signature · 1 line
2.51.0