Skip to contentSkip to conversation

netlink: specs: conntrack: minor spec fixes

PATCH Applied Jakub Kicinski 3 participants 11 messages Sep 10 – Sep 12

Subsystems (4)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

cover netlink: specs: conntrack: minor spec fixes

Clashiko raised a bunch of pre-existing issues on a recent series from Ilya. Let's fix those and whatever else pops out in AI review and looks relatively legitimate.

Jakub Kicinski (7):
netlink: specs: conntrack: timestamp is a nest, not a be64
netlink: specs: conntrack: fix the get reply attribute lists
netlink: specs: conntrack: fix SCTP conntrack state names
netlink: specs: conntrack: fix the nat-attrs attribute IDs
netlink: specs: conntrack: describe CTA_HELP_INFO
netlink: specs: conntrack: fix the per-CPU stats reply
netlink: specs: conntrack: tweak definition of obsolete attrs

 Documentation/netlink/specs/conntrack.yaml | 54 ++++++++++++++--------
 1 file changed, 36 insertions(+), 18 deletions(-)
Signature · 1 line
2.55.0
author maintainer
#1 lore raw

PATCH 1/7 netlink: specs: conntrack: timestamp is a nest, not a be64

ctnetlink_dump_timestamp() wraps CTA_TIMESTAMP_START
and CTA_TIMESTAMP_STOP in a nest, but the spec declares CTA_TIMESTAMP as a flat be64. ynl picks reply attributes out of the attribute set rather than the operation's attribute list, so the mistyped attribute stops the whole dump:

Error decoding 'timestamp' from 'conntrack-attrs' Traceback (most recent call last):
File "tools/net/ynl/pyynl/cli.py", line 314, in main
reply = ynl.dump(args.dump, attrs)
File "tools/net/ynl/pyynl/lib/ynl.py", line 1082, in _decode
decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
File "tools/net/ynl/pyynl/lib/ynl.py", line 291, in as_scalar
return format_.unpack(self.raw)[0]
struct.error: unpack requires a buffer of 8 bytes

The tstamp extension is only attached when CONFIG_NF_CONNTRACK_TIMESTAMP is enabled and nf_conntrack_timestamp is turned on, which is off by default and is why every dump does not hit this.

stop is omitted for live entries, so it stays optional like every other member here. The pad member mirrors counter-attrs, which covers the same nla_put_be64() padding.

---
 Documentation/netlink/specs/conntrack.yaml | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
Documentation/netlink/specs/conntrack.yaml +16 -2
index b1eb102ab843..2b7f16cc4133 100644
@@ -345,6 +345,20 @@ doc: >-
       -
         name: secctx-name
         type: string
+  -
+    name: timestamp-attrs
+    attributes:
+      -
+        name: start
+        type: u64
+        byte-order: big-endian
+      -
+        name: stop
+        type: u64
+        byte-order: big-endian
+      -
+        name: pad
+        type: pad
   -
     name: synproxy-attrs
     attributes:
@@ -458,8 +472,8 @@ doc: >-
         nested-attributes: secctx-attrs
       -
         name: timestamp
-        type: u64
-        byte-order: big-endian
+        type: nest
+        nested-attributes: timestamp-attrs
       -
         name: mark-mask
         type: u32
Signature · 1 line
2.55.0
author maintainer
#2 lore raw

PATCH 2/7 netlink: specs: conntrack: fix the get reply attribute lists

In reply to Jakub Kicinski

CTA_NAT_SRC and CTA_NAT_DST are input-only. The only references to either are cda[] reads in ctnetlink_setup_nat() and the rejection in ctnetlink_change_conntrack(); no path ever puts them into a message, so neither belongs in a reply. nat-dst was listed twice on top of that.

CTA_TIMESTAMP is the opposite case - both the do and the dump reach ctnetlink_fill_info() with extinfo set, so ctnetlink_dump_extinfo() -> ctnetlink_dump_timestamp() emits it, but the lists never named it.

---
 Documentation/netlink/specs/conntrack.yaml | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
Documentation/netlink/specs/conntrack.yaml +2 -6
index 2b7f16cc4133..174697ce125e 100644
@@ -596,20 +596,18 @@ doc: >-
             - status
             - protoinfo
             - help
-            - nat-src
-            - nat-dst
             - timeout
             - mark
             - counters-orig
             - counters-reply
             - use
             - id
-            - nat-dst
             - tuple-master
             - seq-adj-orig
             - seq-adj-reply
             - zone
             - secctx
+            - timestamp
             - labels
             - synproxy
       dump:
@@ -632,20 +630,18 @@ doc: >-
             - status
             - protoinfo
             - help
-            - nat-src
-            - nat-dst
             - timeout
             - mark
             - counters-orig
             - counters-reply
             - use
             - id
-            - nat-dst
             - tuple-master
             - seq-adj-orig
             - seq-adj-reply
             - zone
             - secctx
+            - timestamp
             - labels
             - synproxy
     -
Signature · 1 line
2.55.0
author maintainer
#3 lore raw

PATCH 3/7 netlink: specs: conntrack: fix SCTP conntrack state names

In reply to Jakub Kicinski

Correct the names of constants:

Value 1 is SCTP_CONNTRACK_CLOSED, not "cloned".
Value 6 is SCTP_CONNTRACK_SHUTDOWN_RECD, not "shutdown-received". Value 8 is SCTP_CONNTRACK_HEARTBEAT_SENT, there is no "shutdown-heartbeat" state.

Note that there's also a value of 9 (HEARTBEAT_ACKED) but sctp_nla_policy caps the attribute at HEARTBEAT_SENT and HEARTBEAT_ACKED is marked no longer used in the header.

---
 Documentation/netlink/specs/conntrack.yaml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/netlink/specs/conntrack.yaml +3 -3
index 174697ce125e..105b53d4b76a 100644
@@ -72,14 +72,14 @@ doc: >-
     type: enum
     entries:
       - none
-      - cloned
+      - closed
       - cookie-wait
       - cookie-echoed
       - established
       - shutdown-sent
-      - shutdown-received
+      - shutdown-recd
       - shutdown-ack-sent
-      - shutdown-heartbeat-sent
+      - heartbeat-sent
   -
     name: nf-ct-status
     type: flags
Signature · 1 line
2.55.0
author maintainer
#4 lore raw

PATCH 4/7 netlink: specs: conntrack: fix the nat-attrs attribute IDs

In reply to Jakub Kicinski

The enum for attr IDs says:

     CTA_NAT_V4_MINIP,
  #define CTA_NAT_MINIP CTA_NAT_V4_MINIP
     CTA_NAT_V4_MAXIP,
  #define CTA_NAT_MAXIP CTA_NAT_V4_MAXIP
     CTA_NAT_PROTO,
     CTA_NAT_V6_MINIP,
     CTA_NAT_V6_MAXIP,

Move nat-proto to the right place in the YAML spec to make sure the attr IDs match.

---
 Documentation/netlink/specs/conntrack.yaml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/netlink/specs/conntrack.yaml +4 -4
index 105b53d4b76a..0d1528507c4b 100644
@@ -314,16 +314,16 @@ doc: >-
         name: nat-v4-maxip
         type: u32
         byte-order: big-endian
+      -
+        name: nat-proto
+        type: nest
+        nested-attributes: nat-proto-attrs
       -
         name: nat-v6-minip
         type: binary
       -
         name: nat-v6-maxip
         type: binary
-      -
-        name: nat-proto
-        type: nest
-        nested-attributes: nat-proto-attrs
   -
     name: seqadj-attrs
     attributes:
Signature · 1 line
2.55.0
author maintainer
#5 lore raw

PATCH 5/7 netlink: specs: conntrack: describe CTA_HELP_INFO

In reply to Jakub Kicinski

nfnl_cthelper_to_nlattr() seems to output CTA_HELP_INFO but the spec doesn't have a definition for it, add one.

---
 Documentation/netlink/specs/conntrack.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/netlink/specs/conntrack.yaml +6 -0
index 0d1528507c4b..ec90d3d05841 100644
@@ -292,6 +292,12 @@ doc: >-
         name: help-name
         type: string
         doc: helper name
+      -
+        name: help-info
+        type: binary
+        doc: >-
+          Private data of a user space helper, only present for helpers
+          registered via nfnetlink_cthelper with a non-zero data length.
   -
     name: nat-proto-attrs
     attributes:
Signature · 1 line
2.55.0
author maintainer
#6 lore raw

PATCH 6/7 netlink: specs: conntrack: fix the per-CPU stats reply

In reply to Jakub Kicinski

ctnetlink_ct_stat_cpu_fill_info() emits CTA_STATS_INVALID but does not emit CTA_STATS_SEARCHED. Update the attr list, and remove the false annotation of invalid as obsolete.

---
 Documentation/netlink/specs/conntrack.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/netlink/specs/conntrack.yaml +2 -2
index ec90d3d05841..9ba93370275d 100644
@@ -530,7 +530,7 @@ doc: >-
         name: invalid
         type: u32
         byte-order: big-endian
-        doc: obsolete
+        doc: packets which could not be tracked
       -
         name: ignore
         type: u32
@@ -661,8 +661,8 @@ doc: >-
         reply:
           value: 0x104
           attributes:
-            - searched
             - found
+            - invalid
             - insert
             - insert-failed
             - drop
Signature · 1 line
2.55.0
author maintainer
#7 lore raw

PATCH 7/7 netlink: specs: conntrack: tweak definition of obsolete attrs

In reply to Jakub Kicinski

CTA_SECMARK, CTA_COUNTERS32_{PACKETS,BYTES} are all obsolete be32 attrs. Since they are obsolete we don't bother with the byte-order annotation, but let's be consistent about marking them as u32 with doc: obsolete.

The attrs were obsoleted by:
commit 584015727a3b ("netfilter: accounting rework: ct_extend + 64bit counters (v4)") commit 1cc63249adfa ("conntrack: export lsm context rather than internal secid via netlink")

---
 Documentation/netlink/specs/conntrack.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/netlink/specs/conntrack.yaml +3 -1
index 9ba93370275d..1d163130241a 100644
@@ -116,9 +116,11 @@ doc: >-
       -
         name: packets-old
         type: u32
+        doc: obsolete
       -
         name: bytes-old
         type: u32
+        doc: obsolete
       -
         name: pad
         type: pad
@@ -465,7 +467,7 @@ doc: >-
         nested-attributes: seqadj-attrs
       -
         name: secmark
-        type: binary
+        type: u32
         doc: obsolete
       -
         name: zone
Signature · 1 line
2.55.0
Reviewed-by on the v1 series
#8 lore raw
In reply to Jakub Kicinski

Hi Jakub,

Quoted 13 lines · Jakub Kicinski

Clashiko raised a bunch of pre-existing issues on a recent series from Ilya. Let's fix those and whatever else pops out in AI review and looks relatively legitimate.

Jakub Kicinski (7):
netlink: specs: conntrack: timestamp is a nest, not a be64
netlink: specs: conntrack: fix the get reply attribute lists
netlink: specs: conntrack: fix SCTP conntrack state names
netlink: specs: conntrack: fix the nat-attrs attribute IDs
netlink: specs: conntrack: describe CTA_HELP_INFO
netlink: specs: conntrack: fix the per-CPU stats reply
netlink: specs: conntrack: tweak definition of obsolete attrs

Quoted 6 lines
 Documentation/netlink/specs/conntrack.yaml | 54 ++++++++++++++--------
 1 file changed, 36 insertions(+), 18 deletions(-)
Signature · 1 line
2.55.0

All the changes look reasonable to me and the change matches the conntrack code. For the series

BTW, I'm still working on rt lwtunnel encap support. I noticed some sections in your change have documentation while others do not. Are there any mandatory requirements for documentation at this point?

Thanks
Hangbin

author maintainer
#9 lore raw
Quoted 3 lines · On Thu, 10 Sep 2026 14:40:26 +0800 Hangbin Liu wrote:

BTW, I'm still working on rt lwtunnel encap support. I noticed some sections in your change have documentation while others do not. Are there any mandatory requirements for documentation at this point?

For the new families where YNL actually code gens the uAPI and kernel code it's recommended to add the docs in the spec. For classic Netlink families it's up to the author.

#10 lore raw
In reply to Jakub Kicinski
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 13 lines · On Wed, 9 Sep 2026 17:38:44 -0700 you wrote:

Clashiko raised a bunch of pre-existing issues on a recent series from Ilya. Let's fix those and whatever else pops out in AI review and looks relatively legitimate.

Jakub Kicinski (7):
netlink: specs: conntrack: timestamp is a nest, not a be64
netlink: specs: conntrack: fix the get reply attribute lists
netlink: specs: conntrack: fix SCTP conntrack state names
netlink: specs: conntrack: fix the nat-attrs attribute IDs
netlink: specs: conntrack: describe CTA_HELP_INFO
netlink: specs: conntrack: fix the per-CPU stats reply
netlink: specs: conntrack: tweak definition of obsolete attrs

Quoted 1 line

[...]

Here is the summary with links:
- [net-next,1/7] netlink: specs: conntrack: timestamp is a nest, not a be64

    https://git.kernel.org/netdev/net-next/c/68fd293d99e4
  - [net-next,2/7] netlink: specs: conntrack: fix the get reply attribute lists
    https://git.kernel.org/netdev/net-next/c/19be13c9c1e9
  - [net-next,3/7] netlink: specs: conntrack: fix SCTP conntrack state names
    https://git.kernel.org/netdev/net-next/c/924c8a610d3a
  - [net-next,4/7] netlink: specs: conntrack: fix the nat-attrs attribute IDs
    https://git.kernel.org/netdev/net-next/c/58c7df883ada
  - [net-next,5/7] netlink: specs: conntrack: describe CTA_HELP_INFO
    https://git.kernel.org/netdev/net-next/c/6c98fd455ed5
  - [net-next,6/7] netlink: specs: conntrack: fix the per-CPU stats reply
    https://git.kernel.org/netdev/net-next/c/f869aa4ceaa2
  - [net-next,7/7] netlink: specs: conntrack: tweak definition of obsolete attrs
    https://git.kernel.org/netdev/net-next/c/55edd9e55711

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html