]> git.ipfire.org Git - thirdparty/nftables.git/commit
datatype: accept a numeric cgroupsv2 id on input master
authorAvinash Duduskar <avinash.duduskar@gmail.com>
Sat, 1 Aug 2026 07:27:47 +0000 (12:57 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 5 Aug 2026 21:07:59 +0000 (23:07 +0200)
commit49e418238ece947e92f87a35ef6cf50755485370
tree02c1c39590dd0873cc39bf634c120bd501fa39ea
parent799389708028e89f54fa004024ac4f14d112165b
datatype: accept a numeric cgroupsv2 id on input

nft prints non-existent cgroup names as the raw id using PRIu64, but
cgroupv2_type_parse() only stats /sys/fs/cgroup/<identifier>, so the
listing does not load back:

  # nft list set ip t s
  table ip t {
          set s {
                  type cgroupsv2
                  elements = { 50834 }
          }
  }
  # nft delete element ip t s { 50834 }
  Error: cgroupv2 path fails: No such file or directory

The element cannot be deleted by key once its cgroup is gone, only
flushed with the set, and a dump does not restore. The json dump has
the same problem, and the stale id has been visible in the wild since
2022 (see Link). tests/shell/testcases/packetpath/cgroupv2 already
works around this in cleanup().

Fall back to integer_type_parse() when the path does not resolve, as
boolean_type_parse() already does. The path lookup stays first, so a
cgroup named as a number still resolves as a path. Improving the
integer parser is left for a follow-up as discussed in v1.

Fixes: 38228087252c ("src: add cgroupsv2 support")
Link: https://lore.kernel.org/netfilter-devel/fabde324-383a-622c-7e69-32c9b2d06191@gmail.com/
Signed-off-by: Avinash Duduskar <avinash.duduskar@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/datatype.c
tests/shell/testcases/parsing/cgroupv2_stale_id [new file with mode: 0755]
tests/shell/testcases/parsing/dumps/cgroupv2_stale_id.nodump [new file with mode: 0644]