* Tue Jun 30 2026 Phil Sutter <psutter@redhat.com> [1.0.9-8.el9]
- parser_json: fix map/set type confusion crash in map statement parser (Phil Sutter) [RHEL-190549]
- parser_json: bail out on malformed statement in set (Phil Sutter) [RHEL-190549]
- parser_json: allow statement stateful statement only in set elements (Phil Sutter) [RHEL-190549]
- parser_json: fix crash in json_parse_set_stmt_list (Phil Sutter) [RHEL-190549]
- cache: honor -c/--check for reset commands (Phil Sutter) [RHEL-190549]
- mnl: Fix ordering of hooks in 'list hooks' output (Phil Sutter) [RHEL-190549]
- segtree: Fix for variable-sized object may not be initialized (Phil Sutter) [RHEL-190549]
- cache: Filter for table when listing flowtables (Phil Sutter) [RHEL-190549]
- cache: Filter for table when listing sets or maps (Phil Sutter) [RHEL-190549]
- cache: Relax chain_cache_dump filter application (Phil Sutter) [RHEL-190549]
- cache: Respect family in all list commands (Phil Sutter) [RHEL-190549]
- json: complete multi-statement set element support (Phil Sutter) [RHEL-190549]
- mergesort: Align concatenation sort order with Big Endian (Phil Sutter) [RHEL-190549]
- optimize: expand expression list when merging into concatenation (Phil Sutter) [RHEL-190549]
- mergesort: Fix sorting of string values (Phil Sutter) [RHEL-190549]
- segtree: Fix range aggregation on Big Endian (Phil Sutter) [RHEL-190549]
- monitor: fix memleak in setelem cb (Phil Sutter) [RHEL-190549]
- tests: json_echo: Drop rule handle before multi-add (Phil Sutter) [RHEL-190549]
- rule: skip CMD_OBJ_SETELEMS with no elements after set flush (Phil Sutter) [RHEL-190549]
- doc: libnftables-json: Describe RULESET object (Phil Sutter) [RHEL-190549]
- doc: don't suggest to disable GSO (Phil Sutter) [RHEL-190549]
- tests: py: inet/osf.t: Fix element ordering in JSON equivalents (Phil Sutter) [RHEL-190549]
- tests: py: any/ct.t.json.output: Drop leftover entry (Phil Sutter) [RHEL-190549]
- optimize: Fix verdict expression comparison (Phil Sutter) [RHEL-190549]
- datatype: Fix boolean type on Big Endian (Phil Sutter) [RHEL-190549]
- datatype: clamp boolean value to 0 and 1 (Phil Sutter) [RHEL-190549]
- src: parser_json: fix format string bugs (Phil Sutter) [RHEL-190549]
- doc: fix tcpdump example (Phil Sutter) [RHEL-190549]
- fib: Fix for existence check on Big Endian (Phil Sutter) [RHEL-190549]
- monitor: Inform JSON printer when reporting an object delete event (Phil Sutter) [RHEL-190549]
- tests: monitor: Fix regex collecting expected echo output (Phil Sutter) [RHEL-190549]
- monitor: Quote device names in chain declarations, too (Phil Sutter) [RHEL-190549]
- mnl: continue on ENOBUFS errors when processing batch (Phil Sutter) [RHEL-190549]
- mnl: silence compiler warning (Phil Sutter) [RHEL-190549]
- fib: restore JSON output for relational expressions (Phil Sutter) [RHEL-190549]
- json: Do not reduce single-item arrays on output (Phil Sutter) [RHEL-190549]
- src: ensure chain policy evaluation when specified (Phil Sutter) [RHEL-190549]
- segtree: incorrect type when aggregating concatenated set ranges (Phil Sutter) [RHEL-190549]
- tests: py: Fix tests added for 'icmpv6 taddr' support (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entry from ip/snat.t.payload (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entries from ip6/{ct,meta}.t.json (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entry from ip/snat.t.json (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/vxlan.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entry from inet/tcp.t.json (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/gretap.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/gre.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/geneve.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entries since redundant test case removal (Phil Sutter) [RHEL-190549]
- src: netlink: netlink_delinearize_table() may return NULL (Phil Sutter) [RHEL-190549]
- doc: nft.8: Minor NAT STATEMENTS section review (Phil Sutter) [RHEL-190549]
- mnl: Call mnl_attr_nest_end() just once (Phil Sutter) [RHEL-190549]
- evaluate: validate set expression type before accessing flags (Phil Sutter) [RHEL-190549]
- rule: print chain and flowtable devices in quotes (Phil Sutter) [RHEL-190549]
- tests: shell: skip if kernel does not support flowtable counter (Phil Sutter) [RHEL-190549]
- tests: shell: adjust add-after-delete flowtable for older kernels (Phil Sutter) [RHEL-190549]
- tests/shell: cover long interface name in "0042chain_variable_0" test (Phil Sutter) [RHEL-190549]
- tests: py: re-enables nft-test.py to load the local nftables.py (Phil Sutter) [RHEL-190549]
- fib: allow to use it in set statements (Phil Sutter) [RHEL-190549]
- fib: allow to check if route exists in maps (Phil Sutter) [RHEL-190549]
- tests: py: fix json single-flag output for fib & synproxy (Phil Sutter) [RHEL-190549]
- parser_json: Introduce parse_flags_array() (Phil Sutter) [RHEL-190549]
- json: work around fuzzer-induced assert crashes (Phil Sutter) [RHEL-190549]
- json: Introduce json_add_array_new() (Phil Sutter) [RHEL-190549]
- json: Print single synproxy flags as non-array (Phil Sutter) [RHEL-190549]
- json: Print single fib flag as non-array (Phil Sutter) [RHEL-190549]
- json: fix use after free in table_flags_json() (Phil Sutter) [RHEL-190549]
- doc: extend description of fib expression (Phil Sutter) [RHEL-190549]
- json: reject too long interface names (Phil Sutter) [RHEL-190549]
- parser_bison: allow delete command with map via handle (Phil Sutter) [RHEL-190549]
- parser_bison: only reset by name is supported by now (Phil Sutter) [RHEL-190549]
- cache: assert name is non-nul when looking up (Phil Sutter) [RHEL-190549]
- rule: skip fuzzy lookup if object name is not available (Phil Sutter) [RHEL-190549]
- src: BASECHAIN flag no longer implies presence of priority expression (Phil Sutter) [RHEL-190549]
- netlink: Avoid crash upon missing NFTNL_OBJ_CT_TIMEOUT_ARRAY attribute (Phil Sutter) [RHEL-190549]
- tests: py: Properly fix JSON equivalents for netdev/reject.t (Phil Sutter) [RHEL-190549]
- tests: monitor: Fix for single flag array avoidance (Phil Sutter) [RHEL-190549]
- json: Support typeof in set and map types (Phil Sutter) [RHEL-190549]
- netlink: Do not allocate a bogus flowtable priority expr (Phil Sutter) [RHEL-190549]
- netlink: Fix for potential crash parsing a flowtable (Phil Sutter) [RHEL-190549]
- json: prevent null deref if chain->policy is not set (Phil Sutter) [RHEL-190549]
- netlink: Catch unknown types when deserializing objects (Phil Sutter) [RHEL-190549]
- netlink: Avoid potential NULL-ptr deref parsing set elem expressions (Phil Sutter) [RHEL-190549]
- json: Print single set flag as non-array (Phil Sutter) [RHEL-190549]
- doc: Fix typo in nat statement 'prefix' description (Phil Sutter) [RHEL-190549]
Resolves: RHEL-190549
190 lines
7.3 KiB
Diff
190 lines
7.3 KiB
Diff
From c6b5059905d5e1ba029027cecd8e62d7b70c1c51 Mon Sep 17 00:00:00 2001
|
|
From: Phil Sutter <psutter@redhat.com>
|
|
Date: Tue, 30 Jun 2026 14:31:50 +0200
|
|
Subject: [PATCH] monitor: Inform JSON printer when reporting an object delete
|
|
event
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-190549
|
|
Upstream Status: nftables commit 6c04d24d16f1d15f216f2b3c8e64c9062cd77487
|
|
Conflicts:
|
|
- Context change due to missing commit 73a8adfc2432e
|
|
("monitor: Recognize flowtable add/del events")
|
|
- Adjusted to missing commit 3a957f8f1ff1e
|
|
("tunnel: add tunnel object and statement json support")
|
|
|
|
commit 6c04d24d16f1d15f216f2b3c8e64c9062cd77487
|
|
Author: Phil Sutter <phil@nwl.cc>
|
|
Date: Fri Aug 29 01:07:05 2025 +0200
|
|
|
|
monitor: Inform JSON printer when reporting an object delete event
|
|
|
|
Since kernel commit a1050dd07168 ("netfilter: nf_tables: Reintroduce
|
|
shortened deletion notifications"), type-specific data is no longer
|
|
dumped when notifying for a deleted object. JSON output was not aware of
|
|
this and tried to print bogus data.
|
|
|
|
Fixes: 9e88aae28e9f4 ("monitor: Use libnftables JSON output")
|
|
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
|
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
---
|
|
include/json.h | 5 +++--
|
|
src/json.c | 16 ++++++++++------
|
|
src/monitor.c | 2 +-
|
|
tests/monitor/testcases/object.t | 10 +++++-----
|
|
4 files changed, 19 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/include/json.h b/include/json.h
|
|
index 39be892..23ca49e 100644
|
|
--- a/include/json.h
|
|
+++ b/include/json.h
|
|
@@ -112,7 +112,7 @@ void monitor_print_set_json(struct netlink_mon_handler *monh,
|
|
void monitor_print_element_json(struct netlink_mon_handler *monh,
|
|
const char *cmd, struct set *s);
|
|
void monitor_print_obj_json(struct netlink_mon_handler *monh,
|
|
- const char *cmd, struct obj *o);
|
|
+ const char *cmd, struct obj *o, bool delete);
|
|
void monitor_print_rule_json(struct netlink_mon_handler *monh,
|
|
const char *cmd, struct rule *r);
|
|
|
|
@@ -249,7 +249,8 @@ static inline void monitor_print_element_json(struct netlink_mon_handler *monh,
|
|
}
|
|
|
|
static inline void monitor_print_obj_json(struct netlink_mon_handler *monh,
|
|
- const char *cmd, struct obj *o)
|
|
+ const char *cmd, struct obj *o,
|
|
+ bool delete)
|
|
{
|
|
/* empty */
|
|
}
|
|
diff --git a/src/json.c b/src/json.c
|
|
index 57b7664..fc2e962 100644
|
|
--- a/src/json.c
|
|
+++ b/src/json.c
|
|
@@ -353,7 +353,7 @@ static json_t *timeout_policy_json(uint8_t l4, const uint32_t *timeout)
|
|
return root ? : json_null();
|
|
}
|
|
|
|
-static json_t *obj_print_json(const struct obj *obj)
|
|
+static json_t *obj_print_json(const struct obj *obj, bool delete)
|
|
{
|
|
const char *rate_unit = NULL, *burst_unit = NULL;
|
|
const char *type = obj_type_name(obj->type);
|
|
@@ -366,6 +366,9 @@ static json_t *obj_print_json(const struct obj *obj)
|
|
"table", obj->handle.table.name,
|
|
"handle", obj->handle.handle.id);
|
|
|
|
+ if (delete)
|
|
+ goto out;
|
|
+
|
|
if (obj->comment) {
|
|
tmp = nft_json_pack("{s:s}", "comment", obj->comment);
|
|
json_object_update(root, tmp);
|
|
@@ -469,6 +472,7 @@ static json_t *obj_print_json(const struct obj *obj)
|
|
break;
|
|
}
|
|
|
|
+out:
|
|
return nft_json_pack("{s:o}", type, root);
|
|
}
|
|
|
|
@@ -1699,7 +1703,7 @@ static json_t *table_print_json_full(struct netlink_ctx *ctx,
|
|
json_array_append_new(root, tmp);
|
|
|
|
list_for_each_entry(obj, &table->obj_cache.list, cache.list) {
|
|
- tmp = obj_print_json(obj);
|
|
+ tmp = obj_print_json(obj, false);
|
|
json_array_append_new(root, tmp);
|
|
}
|
|
list_for_each_entry(set, &table->set_cache.list, cache.list) {
|
|
@@ -1861,7 +1865,7 @@ static json_t *do_list_sets_json(struct netlink_ctx *ctx, struct cmd *cmd)
|
|
static json_t *do_list_obj_json(struct netlink_ctx *ctx,
|
|
struct cmd *cmd, uint32_t type)
|
|
{
|
|
- json_t *root = json_array();
|
|
+ json_t *root = json_array(), *tmp;
|
|
struct table *table;
|
|
struct obj *obj;
|
|
|
|
@@ -1880,7 +1884,7 @@ static json_t *do_list_obj_json(struct netlink_ctx *ctx,
|
|
strcmp(cmd->handle.obj.name, obj->handle.obj.name)))
|
|
continue;
|
|
|
|
- json_array_append_new(root, obj_print_json(obj));
|
|
+ json_array_append_new(root, obj_print_json(obj, false));
|
|
}
|
|
}
|
|
|
|
@@ -2066,9 +2070,9 @@ void monitor_print_element_json(struct netlink_mon_handler *monh,
|
|
}
|
|
|
|
void monitor_print_obj_json(struct netlink_mon_handler *monh,
|
|
- const char *cmd, struct obj *o)
|
|
+ const char *cmd, struct obj *o, bool delete)
|
|
{
|
|
- monitor_print_json(monh, cmd, obj_print_json(o));
|
|
+ monitor_print_json(monh, cmd, obj_print_json(o, delete));
|
|
}
|
|
|
|
void monitor_print_rule_json(struct netlink_mon_handler *monh,
|
|
diff --git a/src/monitor.c b/src/monitor.c
|
|
index bf59f2d..87ff2a3 100644
|
|
--- a/src/monitor.c
|
|
+++ b/src/monitor.c
|
|
@@ -529,7 +529,7 @@ static int netlink_events_obj_cb(const struct nlmsghdr *nlh, int type,
|
|
nft_mon_print(monh, "\n");
|
|
break;
|
|
case NFTNL_OUTPUT_JSON:
|
|
- monitor_print_obj_json(monh, cmd, obj);
|
|
+ monitor_print_obj_json(monh, cmd, obj, type == NFT_MSG_DELOBJ);
|
|
if (!nft_output_echo(&monh->ctx->nft->output))
|
|
nft_mon_print(monh, "\n");
|
|
break;
|
|
diff --git a/tests/monitor/testcases/object.t b/tests/monitor/testcases/object.t
|
|
index 53a9f8c..b60dc98 100644
|
|
--- a/tests/monitor/testcases/object.t
|
|
+++ b/tests/monitor/testcases/object.t
|
|
@@ -9,7 +9,7 @@ J {"add": {"counter": {"family": "ip", "name": "c", "table": "t", "handle": 0, "
|
|
|
|
I delete counter ip t c
|
|
O -
|
|
-J {"delete": {"counter": {"family": "ip", "name": "c", "table": "t", "handle": 0, "packets": 0, "bytes": 0}}}
|
|
+J {"delete": {"counter": {"family": "ip", "name": "c", "table": "t", "handle": 0}}}
|
|
|
|
# FIXME: input/output shouldn't be asynchronous here
|
|
I add quota ip t q 25 mbytes
|
|
@@ -18,7 +18,7 @@ J {"add": {"quota": {"family": "ip", "name": "q", "table": "t", "handle": 0, "by
|
|
|
|
I delete quota ip t q
|
|
O -
|
|
-J {"delete": {"quota": {"family": "ip", "name": "q", "table": "t", "handle": 0, "bytes": 26214400, "used": 0, "inv": false}}}
|
|
+J {"delete": {"quota": {"family": "ip", "name": "q", "table": "t", "handle": 0}}}
|
|
|
|
# FIXME: input/output shouldn't be asynchronous here
|
|
I add limit ip t l rate 1/second
|
|
@@ -27,7 +27,7 @@ J {"add": {"limit": {"family": "ip", "name": "l", "table": "t", "handle": 0, "ra
|
|
|
|
I delete limit ip t l
|
|
O -
|
|
-J {"delete": {"limit": {"family": "ip", "name": "l", "table": "t", "handle": 0, "rate": 1, "per": "second", "burst": 5}}}
|
|
+J {"delete": {"limit": {"family": "ip", "name": "l", "table": "t", "handle": 0}}}
|
|
|
|
I add ct helper ip t cth { type "sip" protocol tcp; l3proto ip; }
|
|
O -
|
|
@@ -35,7 +35,7 @@ J {"add": {"ct helper": {"family": "ip", "name": "cth", "table": "t", "handle":
|
|
|
|
I delete ct helper ip t cth
|
|
O -
|
|
-J {"delete": {"ct helper": {"family": "ip", "name": "cth", "table": "t", "handle": 0, "type": "sip", "protocol": "tcp", "l3proto": "ip"}}}
|
|
+J {"delete": {"ct helper": {"family": "ip", "name": "cth", "table": "t", "handle": 0}}}
|
|
|
|
I add ct timeout ip t ctt { protocol udp; l3proto ip; policy = { unreplied : 15s, replied : 12s }; }
|
|
O -
|
|
@@ -43,4 +43,4 @@ J {"add": {"ct timeout": {"family": "ip", "name": "ctt", "table": "t", "handle":
|
|
|
|
I delete ct timeout ip t ctt
|
|
O -
|
|
-J {"delete": {"ct timeout": {"family": "ip", "name": "ctt", "table": "t", "handle": 0, "protocol": "udp", "l3proto": "ip", "policy": {"unreplied": 15, "replied": 12}}}}
|
|
+J {"delete": {"ct timeout": {"family": "ip", "name": "ctt", "table": "t", "handle": 0}}}
|