From 50b5b71ebeee33b725d44ab4487d5d257f9ca4c0 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 2 Apr 2019 15:34:43 +0200 Subject: parser_json: Rewrite echo support Instead of guessing which object to update with retrieved handle, introduce a list containing struct cmd <-> json_t associations. Upon batch commit, allocated cmd objects are assigned a unique netlink sequence number. Monitor events contain that number as well, so they may be associated to the cmd object which triggered them. Using json_cmd_assoc list the event may in turn be associated to the input's JSON object which should receive the handle value. This also fixes incorrect behaviour if JSON input contained "insert" commands. Fixes: bb32d8db9a125 ("JSON: Add support for echo option") Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- py/nftables.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'py') diff --git a/py/nftables.py b/py/nftables.py index 6891cb1c..f0716357 100644 --- a/py/nftables.py +++ b/py/nftables.py @@ -106,6 +106,9 @@ class Nftables: self.nft_ctx_buffer_output(self.__ctx) self.nft_ctx_buffer_error(self.__ctx) + def __del__(self): + self.nft_ctx_free(self.__ctx) + def __get_output_flag(self, name): flag = self.output_flags[name] return self.nft_ctx_output_get_flags(self.__ctx) & flag -- cgit v1.2.3