src: Export nftnl_set_clone symbol
PATCH 1/1 src: Export nftnl_set_clone symbol
Seems that nftnl_set_clone is forgot to be exported, we add it back.
--- src/set.c | 1 + 1 file changed, 1 insertion(+)
src/set.c +1 -0
@@ -360,6 +360,7 @@ uint64_t nftnl_set_get_u64(const struct nftnl_set *s, uint16_t attr)return val ? *val :0 ; } +EXPORT_SYMBOL (nftnl_set_clone);struct nftnl_set *nftnl_set_clone (const struct nftnl_set *set) {struct nftnl_set *newset;
Signature · 1 line
2.52.0
Phil Sutter
reviewerHi chlorodose,
Quoted 12 lines · chlorodose
Seems that
nftnl_set_cloneis forgot to be exported, we add it back.Signed-off-by chlorodose <[email protected]>--- src/set.c | 1 + 1 file changed, 1 insertion(+)src/set.c +0
-0
src/set.c uint64_t nftnl_set_get_u64(const struct nftnl_set *s, uint16_t attr) · line 366
Quoted 7 lines
src/set.c +1
-0@@ -360,6 +360,7 @@ uint64_t nftnl_set_get_u64(const struct nftnl_set *s, uint16_t attr)return val ? *val :0 ; } +EXPORT_SYMBOL (nftnl_set_clone);struct nftnl_set *nftnl_set_clone (const struct nftnl_set *set) {struct nftnl_set *newset;
Don't you also have to add it to src/libnftnl.map? How did you test this patch?
Looking at the function itself, I fear the code is not correct anymore. E.g., it does not clone expr_list or user.data. If I was to decide, I'd rather drop it entirely instead of polishing it up. What's your use-case?
Cheers, Phil
Pablo Neira Ayuso
maintainerQuoted 26 lines · Phil Sutter
Hi chlorodose,
Quoted 12 lines · chlorodose
Seems that
nftnl_set_cloneis forgot to be exported, we add it back.Signed-off-by chlorodose <[email protected]>--- src/set.c | 1 + 1 file changed, 1 insertion(+)src/set.c +0
-0src/set.c uint64_t nftnl_set_get_u64(const struct nftnl_set *s, uint16_t attr) · line 366
Quoted 7 lines
src/set.c +1
-0@@ -360,6 +360,7 @@ uint64_t nftnl_set_get_u64(const struct nftnl_set *s, uint16_t attr)return val ? *val :0 ; } +EXPORT_SYMBOL (nftnl_set_clone);struct nftnl_set *nftnl_set_clone (const struct nftnl_set *set) {struct nftnl_set *newset;Don't you also have to add it to src/libnftnl.map? How did you test this patch?
Quoted 4 lines
Looking at the function itself, I fear the code is not correct anymore. E.g., it does not clone
expr_listor user.data. If I was to decide, I'd rather drop it entirely instead of polishing it up. What's your use-case?
Indeed, this function is internal and it is incomplete. it does not provide a full clone.
Phil Sutter
reviewerQuoted 27 lines · Pablo Neira Ayuso
Quoted 26 lines · Phil Sutter
Hi chlorodose,
Quoted 12 lines · chlorodose
Seems that
nftnl_set_cloneis forgot to be exported, we add it back.Signed-off-by chlorodose <[email protected]>--- src/set.c | 1 + 1 file changed, 1 insertion(+)src/set.c +0
-0src/set.c uint64_t nftnl_set_get_u64(const struct nftnl_set *s, uint16_t attr) · line 366
Quoted 7 lines
src/set.c +1
-0@@ -360,6 +360,7 @@ uint64_t nftnl_set_get_u64(const struct nftnl_set *s, uint16_t attr)return val ? *val :0 ; } +EXPORT_SYMBOL (nftnl_set_clone);struct nftnl_set *nftnl_set_clone (const struct nftnl_set *set) {struct nftnl_set *newset;Don't you also have to add it to src/libnftnl.map? How did you test this patch?
Quoted 7 lines
Quoted 4 lines
Looking at the function itself, I fear the code is not correct anymore. E.g., it does not clone
expr_listor user.data. If I was to decide, I'd rather drop it entirely instead of polishing it up. What's your use-case?Indeed, this function is internal and it is incomplete. it does not provide a full clone.
I don't see it called inside libnftnl, though. Ah, it seems to have been used by the JSON API dropped in commit 80077787f8f21 ("src: remove json support"). And since we did not export it yet, we're safe to drop it unless chlorodose has a proper use-case for it.
Cheers, Phil
I have a use case where I want to construct a daemon that keeps a reference to an nft_set and repeatedly uses it to handle requests to add elems. I assume I must clone the nft_set from a clean copy each time, otherwise I'll resend all previous elements to the kernel. But I'm just starting to learn nftables, so I'm not sure my understanding is correct. Am I misunderstanding something here?
Phil Sutter
reviewerHi Chloro,
Quoted 6 lines · Chloro Dose
I have a use case where I want to construct a daemon that keeps a reference to an
nft_setand repeatedly uses it to handle requests to add elems. I assume I must clone thenft_setfrom a clean copy each time, otherwise I'll resend all previous elements to the kernel. But I'm just starting to learn nftables, so I'm not sure my understanding is correct. Am I misunderstanding something here?
All you need to keep record of is the set's name and that of the table it belongs to as well as the latter's family. With this data you may generate a NFT_MSG_NEWSETELEM-type message for the kernel to add one or many elements to an existing set. For reference, mnl_nft_setelem_batch() in nftables.git/src/mnl.c should be a good example of how to do this using libnftnl and libmnl.
Cheers, Phil