Skip to contentSkip to conversation

Proposing to add a structure to UserData

DISCUSSION sbezverk 3 participants 4 messages Feb 13, 2020 – Feb 17, 2020 netfilter

lore
Share & tools
lore

sbezverk

author
#0 lore raw

Hello Pablo,

I would like to propose to add some structure to UserData. Currently nft tool uses UserData to carry comments and it prints out whatever is stored in it without much of processing. Since UserData is the only available mechanism to store some metadata for a rule, if it is used, then comments in nft cli get totally screwed up.

What do you think about to add a little structure to userdata in order to preserve nft comments and at the same time allow developers to use UserData for other things.

If we could add attributes to UserData indicating type NFT_USERDATA_COMMENT with length, then we could preserve nft comments and at the same time allow to use UserData for other things.

What do you think?

Thank you
Serguei

maintainer
#1 lore raw
Quoted 1 line · sbezverk

I would like to propose to add some structure to UserData. Currently nft tool uses UserData to carry comments and it prints out whatever is stored in it without much of processing. Since UserData is the only available mechanism to store some metadata for a rule, if it is used, then comments in nft cli get totally screwed up.

Then you are using it wrong :-)

Userdata is structured, its not used only for comments. Which userdata are you referring to? We have this for rules, sets, and elements.

Quoted 2 lines

If we could add attributes to UserData indicating type NFT_USERDATA_COMMENT with length, then we could preserve nft comments and at the same time allow to use UserData for other things. What do you think?

As far as I can see what you want is already implemented, for example rule comments live in NFTNL_UDATA_RULE_COMMENT sub-type.

author
#2 lore raw

Hi Florian,

Thank you for letting me know, I checked golang unix package and I did not find definition for NFTNL_UDATA_RULE_COMMENT. That explains why I did not use it. Could you please point me where UDATA relate types and subtypes are defined, so I could replicate them in go.

Thank you
Serguei

On 2020-02-17, 9:40 AM, "Florian Westphal" <[email protected]> wrote:

sbezverk <[email protected]> wrote:
> I would like to propose to add some structure to UserData. Currently nft tool uses UserData to carry comments and it prints out whatever is stored in it without much of processing. Since UserData is the only available mechanism to store some metadata for a rule, if it is used, then comments in nft cli get totally screwed up.

Then you are using it wrong :-)

Userdata is structured, its not used only for comments. Which userdata are you referring to? We have this for rules, sets, and elements.

> If we could add attributes to UserData indicating type NFT_USERDATA_COMMENT with length, then we could preserve nft comments and at the same time allow to use UserData for other things. > What do you think?

As far as I can see what you want is already implemented, for example rule comments live in NFTNL_UDATA_RULE_COMMENT sub-type.

reviewer
#3 lore raw

Hi Serguei,

Quoted 2 lines · sbezverk

Thank you for letting me know, I checked golang unix package and I did not find definition for NFTNL_UDATA_RULE_COMMENT. That explains why I did not use it. Could you please point me where UDATA relate types and subtypes are defined, so I could replicate them in go.

Please check libnftnl/udata.h. In general, all NFTNL_* named defines belong to libnftnl.

Cheers, Phil