Skip to contentSkip to conversation

How to add set element with libnftnl?

DISCUSSION Ian Pilcher 1 participant 1 message Oct 17, 2022

lore
Share & tools
lore
#0 lore raw

I have some C code that uses libmnl to add entries to old style IP sets. I am trying to port this code to nftables, using libnftnl.

I haven't found any documentation other than the examples, and unfortunately nft-set-elem-add.c seems to completely ignore the actual type of the data that it's putting into the set.

Can anyone help me figure out how do use libnftnl to perform the equivalent of the following?

* nft add element TYPE TABLE SET_NAME '{ IPV4_ADDRESS }'
* nft add element TYPE TABLE SET_NAME '{ IPV4_ADDRESS timeout TIME }'
* nft add element TYPE TABLE SET_NAME '{ IPV6_ADDRESS }'
* nft add element TYPE TABLE SET_NAME '{ IPV6_ADDRESS timeout TIME }'

TIA!

Signature · 3 lines
========================================================================
Google                                      Where SkyNet meets Idiocracy
========================================================================