bugzilla-daemon at netfilter.org
2021-Feb-12 09:58 UTC
[Bug 1499] New: python3-nftables wrong return code when working with JSON
https://bugzilla.netfilter.org/show_bug.cgi?id=1499 Bug ID: 1499 Summary: python3-nftables wrong return code when working with JSON Product: nftables Version: unspecified Hardware: x86_64 OS: Debian GNU/Linux Status: NEW Severity: normal Priority: P5 Component: nft Assignee: pablo at netfilter.org Reporter: arturo at netfilter.org Original bug report in the Debian bug tracker: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=981857 I am using the python wrapper in a program and faced a problem. Trying to list a Table while the Ruleset is empty returns an error, no problem yet. Every subsequent call to json_cmd() on the same nftables.Nftables class instance returns -1 in return code. Here is a short script reproducing the error : ###### testNFTABLES.py ++ import nftables import json nft = nftables.Nftables() nft.set_json_output(True) flushRulesetCMD = '{ "nftables": [ { "flush": { "ruleset": null }} ]}' getTableCMD = '{ "nftables": [ { "list": { "table": { "family": "inet", "name": "FooTable" }}} ]}' addTableCMD = '{ "nftables": [ { "add": { "table": { "family": "inet", "name": "FooTable" }}} ]}' result = nft.json_cmd(json.loads(flushRulesetCMD)) print(result) result = nft.json_cmd(json.loads(getTableCMD)) print(result) # Resetting Nftables class instance makes it work # nft = nftables.Nftables() result = nft.json_cmd(json.loads(addTableCMD)) print(result) ###### testNFTABLES.py -- -- You are receiving this mail because: You are watching all bug changes. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.netfilter.org/pipermail/netfilter-buglog/attachments/20210212/841f4a8f/attachment.html>