Linux Netfilter development
 help / color / mirror / Atom feed
* [libnftnl PATCH 0/9] Fix for debug output on Big Endian
@ 2025-10-23 16:05 Phil Sutter
  2025-10-23 16:05 ` [libnftnl PATCH 1/9] set_elem: Review debug output Phil Sutter
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Phil Sutter @ 2025-10-23 16:05 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-01-28 11:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 16:05 [libnftnl PATCH 0/9] Fix for debug output on Big Endian Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 1/9] set_elem: Review debug output Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 2/9] expr: data_reg: Avoid extra whitespace Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 3/9] expr: Pass byteorder to struct expr_ops::set callback Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 4/9] data_reg: Introduce struct nftnl_data_reg::byteorder field Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 5/9] data_reg: Introduce struct nftnl_data_reg::sizes array Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 6/9] Introduce nftnl_{expr,set_elem}_set_imm() Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 7/9] data_reg: Respect data byteorder when printing Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 8/9] data_reg: Support concatenated data Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 9/9] udata: Store u32 udata values in Big Endian Phil Sutter
2026-01-27 23:39   ` Pablo Neira Ayuso
2026-01-28 11:57     ` Phil Sutter
2026-01-27 22:04 ` [libnftnl PATCH 0/9] Fix for debug output on " Phil Sutter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox