table: add table owner support
Pablo Neira Ayuso
maintainerPATCH 1/1 table: add table owner support
Add support for NFTA_TABLE_OWNER.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- include/libnftnl/table.h | 1 + include/linux/netfilter/nf_tables.h | 1 + src/table.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-)
include/libnftnl/table.h +1 -0
@@ -24,6 +24,7 @@ enum nftnl_table_attr {NFTNL_TABLE_USE ,NFTNL_TABLE_HANDLE ,NFTNL_TABLE_USERDATA , +NFTNL_TABLE_OWNER , __NFTNL_TABLE_MAX };#define NFTNL_TABLE_MAX (__NFTNL_TABLE_MAX - 1)
include/linux/netfilter/nf_tables.h +1 -0
@@ -181,6 +181,7 @@ enum nft_table_attributes {NFTA_TABLE_HANDLE ,NFTA_TABLE_PAD ,NFTA_TABLE_USERDATA , +NFTA_TABLE_OWNER , __NFTA_TABLE_MAX };#define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
src/table.c +13 -1
@@ -34,6 +34,7 @@ struct nftnl_table {uint64_t handle;uint32_t use;uint32_t flags; +uint32_t owner;struct {void *data;uint32_t len;
@@ -76,8 +77,8 @@ void nftnl_table_unset(struct nftnl_table *t, uint16_t attr)case NFTNL_TABLE_FLAGS :case NFTNL_TABLE_HANDLE :case NFTNL_TABLE_FAMILY : -break ;case NFTNL_TABLE_USE : +case NFTNL_TABLE_OWNER :break ; } t->flags &= ~(1 << attr);
@@ -127,6 +128,9 @@ int nftnl_table_set_data(struct nftnl_table *t, uint16_t attr,memcpy (t->user.data, data, data_len); t->user.len = data_len;break ; +case NFTNL_TABLE_OWNER : +memcpy (&t->owner, data,sizeof (t->owner)); +break ; } t->flags |= (1 << attr);return 0 ;
@@ -188,6 +192,9 @@ const void *nftnl_table_get_data(const struct nftnl_table *t, uint16_t attr,case NFTNL_TABLE_USERDATA : *data_len = t->user.len;return t->user.data; +case NFTNL_TABLE_OWNER : + *data_len =sizeof (uint32_t ); +return &t->owner; }return NULL ; }
@@ -258,6 +265,7 @@ static int nftnl_table_parse_attr_cb(const struct nlattr *attr, void *data)break ;case NFTA_TABLE_FLAGS :case NFTA_TABLE_USE : +case NFTA_TABLE_OWNER :if (mnl_attr_validate (attr,MNL_TYPE_U32 ) <0 )abi_breakage ();break ;
@@ -308,6 +316,10 @@ int nftnl_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_table *t)if (ret <0 )return ret; } +if (tb[NFTA_TABLE_OWNER ]) { + t->owner =ntohl (mnl_attr_get_u32 (tb[NFTA_TABLE_OWNER ])); + t->flags |= (1 <<NFTNL_TABLE_OWNER ); + } t->family = nfg->nfgen_family; t->flags |= (1 <<NFTNL_TABLE_FAMILY );
Signature · 1 line
2.20.1