Choosing best API-way to full dump/restore nftables
Dear colleagues,
In CRIU (Checkpoint/Restore In Userspace) we want to add support nft dump/restore. Initial implementation directly uses nft list ruleset > dumpfile/nft -f dumpfile but it's not the best way because fork/exec is needed. We want to use some API. But after diving into libnftnl and nftables code I've realized that it's not so simple: in libnftnl there is some partial code for JSON support in nftables too. But as I see in libnftnl JSON doesn't fully supported. In nftables I've found tests/json_echo/run-test.py test that uses libnftables.so shared library that exports some functions for dumping/restoring full ruleset as JSON. After some googling, I've found that recently CLI and API interfaces related to JSON/XML exporting functions of nft have changed significantly. Question is: What API I could use to have confidence that in the near future it will not be deprecated? (We need only make *full* dump/restore nftables)
Thanks
Regards, Alex
Pablo Neira Ayuso
maintainerHi,
Quoted 17 lines · Alexander Mikhalitsyn
Dear colleagues,
In CRIU (Checkpoint/Restore In Userspace) we want to add support nft dump/restore. Initial implementation directly uses
nft list ruleset dumpfile/nft -f dumpfilebut it's not the best way because fork/exec is needed. We want to use some API. But after diving into libnftnl and nftables code I've realized that it's not so
simple: in libnftnl there is some partial code for JSON support in nftables too. But as I see in libnftnl JSON doesn't fully supported. In nftables I've foundtests/json_echo/run-test.pytest that uses libnftables.so shared library that exports some functions for dumping/restoring full ruleset as JSON. After some googling, I've found that recently CLI and API interfaces related to JSON/XML exporting functions of nft have changed significantly. Question is: What API I could use to have confidence that in the near future it will not be deprecated? (We need only make *full* dump/restore nftables)
Please, see:
man 3 libnftables