* [PATCH libnftnl] object: define nftnl_obj_unset()
@ 2024-01-02 13:25 Pablo Neira Ayuso
2024-01-02 17:50 ` Nicholas Vinson
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2024-01-02 13:25 UTC (permalink / raw)
To: netfilter-devel
For consistency with existing objects, implement this interface.
This is already defined in libnftnl.map so the intention was to
provide it.
Fixes: 5573d0146c1a ("src: support for stateful objects")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/object.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/object.c b/src/object.c
index 9e768610cddb..0814be744448 100644
--- a/src/object.c
+++ b/src/object.c
@@ -69,6 +69,34 @@ bool nftnl_obj_is_set(const struct nftnl_obj *obj, uint16_t attr)
return obj->flags & (1 << attr);
}
+EXPORT_SYMBOL(nftnl_obj_unset);
+void nftnl_obj_unset(struct nftnl_obj *obj, uint16_t attr)
+{
+ if (!(obj->flags & (1 << attr)))
+ return;
+
+ switch (attr) {
+ case NFTNL_OBJ_TABLE:
+ xfree(obj->table);
+ break;
+ case NFTNL_OBJ_NAME:
+ xfree(obj->name);
+ break;
+ case NFTNL_OBJ_USERDATA:
+ xfree(obj->user.data);
+ break;
+ case NFTNL_OBJ_TYPE:
+ case NFTNL_OBJ_FAMILY:
+ case NFTNL_OBJ_USE:
+ case NFTNL_OBJ_HANDLE:
+ break;
+ default:
+ break;
+ }
+
+ obj->flags &= ~(1 << attr);
+}
+
static uint32_t nftnl_obj_validate[NFTNL_OBJ_MAX + 1] = {
[NFTNL_OBJ_FAMILY] = sizeof(uint32_t),
[NFTNL_OBJ_USE] = sizeof(uint32_t),
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH libnftnl] object: define nftnl_obj_unset()
2024-01-02 13:25 [PATCH libnftnl] object: define nftnl_obj_unset() Pablo Neira Ayuso
@ 2024-01-02 17:50 ` Nicholas Vinson
2024-01-03 10:32 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Vinson @ 2024-01-02 17:50 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, nvinson234
I manually applied this patch and got the following build error:
error: use of undeclared identifier 'nftnl_obj_unset'; did you mean
'nftnl_obj_set'
I think a declaration for nftnl_obj_unset() needs to be added to
include/libnftnl/object.h. Other than that, this patch looks OK to me.
Regards,
Nicholas Vinson
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH libnftnl] object: define nftnl_obj_unset()
2024-01-02 17:50 ` Nicholas Vinson
@ 2024-01-03 10:32 ` Pablo Neira Ayuso
2024-01-03 14:53 ` Nicholas Vinson
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2024-01-03 10:32 UTC (permalink / raw)
To: Nicholas Vinson; +Cc: netfilter-devel
Hi Nicholas,
On Tue, Jan 02, 2024 at 12:50:58PM -0500, Nicholas Vinson wrote:
> I manually applied this patch and got the following build error:
>
> error: use of undeclared identifier 'nftnl_obj_unset'; did you mean
> 'nftnl_obj_set'
>
> I think a declaration for nftnl_obj_unset() needs to be added to
> include/libnftnl/object.h. Other than that, this patch looks OK to me.
$ git grep nftnl_obj_unset
include/libnftnl/object.h:void nftnl_obj_unset(struct nftnl_obj *ne, uint16_t attr);
src/libnftnl.map: nftnl_obj_unset;
src/object.c:EXPORT_SYMBOL(nftnl_obj_unset);
src/object.c:void nftnl_obj_unset(struct nftnl_obj *obj, uint16_t attr
the header file already has a declaration for this (which was part of
5573d0146c1a ("src: support for stateful objects").
What is missing then?
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH libnftnl] object: define nftnl_obj_unset()
2024-01-03 10:32 ` Pablo Neira Ayuso
@ 2024-01-03 14:53 ` Nicholas Vinson
0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Vinson @ 2024-01-03 14:53 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On 1/3/24 05:32, Pablo Neira Ayuso wrote:
> Hi Nicholas,
>
> On Tue, Jan 02, 2024 at 12:50:58PM -0500, Nicholas Vinson wrote:
>> I manually applied this patch and got the following build error:
>>
>> error: use of undeclared identifier 'nftnl_obj_unset'; did you mean
>> 'nftnl_obj_set'
>>
>> I think a declaration for nftnl_obj_unset() needs to be added to
>> include/libnftnl/object.h. Other than that, this patch looks OK to me.
> $ git grep nftnl_obj_unset
> include/libnftnl/object.h:void nftnl_obj_unset(struct nftnl_obj *ne, uint16_t attr);
> src/libnftnl.map: nftnl_obj_unset;
> src/object.c:EXPORT_SYMBOL(nftnl_obj_unset);
> src/object.c:void nftnl_obj_unset(struct nftnl_obj *obj, uint16_t attr
>
> the header file already has a declaration for this (which was part of
> 5573d0146c1a ("src: support for stateful objects").
>
> What is missing then?
A mistake on my part. I failed to revert to properly revert my patch
before testing this change.
Everything looks good to me.
Thanks.
>
> Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-03 14:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-02 13:25 [PATCH libnftnl] object: define nftnl_obj_unset() Pablo Neira Ayuso
2024-01-02 17:50 ` Nicholas Vinson
2024-01-03 10:32 ` Pablo Neira Ayuso
2024-01-03 14:53 ` Nicholas Vinson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.