#981857 [Bug Report] [python3-nftables]

Package:
python3-nftables
Source:
nftables
Description:
nftables/libnftables python3 module
Submitter:
Rémi Cabandé
Date:
2021-05-06 17:21:13 UTC
Severity:
normal
Tags:
#981857#5
Date:
2021-02-04 16:20:22 UTC
From:
To:
Dear Maintainer,

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 --

Am I mistaken or is this a real bug ?

#981857#10
Date:
2021-02-12 09:58:51 UTC
From:
To:

#981857#15
Date:
2021-02-12 10:06:55 UTC
From:
To: