Commit 3ecbfd65 authored by Harsha Sharma's avatar Harsha Sharma Committed by Pablo Neira Ayuso

netfilter: nf_tables: allocate handle and delete objects via handle

This patch allows deletion of objects via unique handle which can be
listed via '-a' option.
Signed-off-by: default avatarHarsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent cc2d5863
...@@ -374,6 +374,7 @@ void nft_unregister_set(struct nft_set_type *type); ...@@ -374,6 +374,7 @@ void nft_unregister_set(struct nft_set_type *type);
* @list: table set list node * @list: table set list node
* @bindings: list of set bindings * @bindings: list of set bindings
* @name: name of the set * @name: name of the set
* @handle: unique handle of the set
* @ktype: key type (numeric type defined by userspace, not used in the kernel) * @ktype: key type (numeric type defined by userspace, not used in the kernel)
* @dtype: data type (verdict or numeric type defined by userspace) * @dtype: data type (verdict or numeric type defined by userspace)
* @objtype: object type (see NFT_OBJECT_* definitions) * @objtype: object type (see NFT_OBJECT_* definitions)
...@@ -396,6 +397,7 @@ struct nft_set { ...@@ -396,6 +397,7 @@ struct nft_set {
struct list_head list; struct list_head list;
struct list_head bindings; struct list_head bindings;
char *name; char *name;
u64 handle;
u32 ktype; u32 ktype;
u32 dtype; u32 dtype;
u32 objtype; u32 objtype;
...@@ -946,6 +948,7 @@ unsigned int nft_do_chain(struct nft_pktinfo *pkt, void *priv); ...@@ -946,6 +948,7 @@ unsigned int nft_do_chain(struct nft_pktinfo *pkt, void *priv);
* @objects: stateful objects in the table * @objects: stateful objects in the table
* @flowtables: flow tables in the table * @flowtables: flow tables in the table
* @hgenerator: handle generator state * @hgenerator: handle generator state
* @handle: table handle
* @use: number of chain references to this table * @use: number of chain references to this table
* @flags: table flag (see enum nft_table_flags) * @flags: table flag (see enum nft_table_flags)
* @genmask: generation mask * @genmask: generation mask
...@@ -959,6 +962,7 @@ struct nft_table { ...@@ -959,6 +962,7 @@ struct nft_table {
struct list_head objects; struct list_head objects;
struct list_head flowtables; struct list_head flowtables;
u64 hgenerator; u64 hgenerator;
u64 handle;
u32 use; u32 use;
u16 family:6, u16 family:6,
flags:8, flags:8,
...@@ -983,9 +987,9 @@ int nft_verdict_dump(struct sk_buff *skb, int type, ...@@ -983,9 +987,9 @@ int nft_verdict_dump(struct sk_buff *skb, int type,
* @name: name of this stateful object * @name: name of this stateful object
* @genmask: generation mask * @genmask: generation mask
* @use: number of references to this stateful object * @use: number of references to this stateful object
* @data: object data, layout depends on type * @handle: unique object handle
* @ops: object operations * @ops: object operations
* @data: pointer to object data * @data: object data, layout depends on type
*/ */
struct nft_object { struct nft_object {
struct list_head list; struct list_head list;
...@@ -993,6 +997,7 @@ struct nft_object { ...@@ -993,6 +997,7 @@ struct nft_object {
struct nft_table *table; struct nft_table *table;
u32 genmask:2, u32 genmask:2,
use:30; use:30;
u64 handle;
/* runtime data below here */ /* runtime data below here */
const struct nft_object_ops *ops ____cacheline_aligned; const struct nft_object_ops *ops ____cacheline_aligned;
unsigned char data[] unsigned char data[]
...@@ -1074,6 +1079,7 @@ void nft_unregister_obj(struct nft_object_type *obj_type); ...@@ -1074,6 +1079,7 @@ void nft_unregister_obj(struct nft_object_type *obj_type);
* @ops_len: number of hooks in array * @ops_len: number of hooks in array
* @genmask: generation mask * @genmask: generation mask
* @use: number of references to this flow table * @use: number of references to this flow table
* @handle: unique object handle
* @data: rhashtable and garbage collector * @data: rhashtable and garbage collector
* @ops: array of hooks * @ops: array of hooks
*/ */
...@@ -1086,6 +1092,7 @@ struct nft_flowtable { ...@@ -1086,6 +1092,7 @@ struct nft_flowtable {
int ops_len; int ops_len;
u32 genmask:2, u32 genmask:2,
use:30; use:30;
u64 handle;
/* runtime data below here */ /* runtime data below here */
struct nf_hook_ops *ops ____cacheline_aligned; struct nf_hook_ops *ops ____cacheline_aligned;
struct nf_flowtable data; struct nf_flowtable data;
......
...@@ -174,6 +174,8 @@ enum nft_table_attributes { ...@@ -174,6 +174,8 @@ enum nft_table_attributes {
NFTA_TABLE_NAME, NFTA_TABLE_NAME,
NFTA_TABLE_FLAGS, NFTA_TABLE_FLAGS,
NFTA_TABLE_USE, NFTA_TABLE_USE,
NFTA_TABLE_HANDLE,
NFTA_TABLE_PAD,
__NFTA_TABLE_MAX __NFTA_TABLE_MAX
}; };
#define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1) #define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
...@@ -317,6 +319,7 @@ enum nft_set_desc_attributes { ...@@ -317,6 +319,7 @@ enum nft_set_desc_attributes {
* @NFTA_SET_GC_INTERVAL: garbage collection interval (NLA_U32) * @NFTA_SET_GC_INTERVAL: garbage collection interval (NLA_U32)
* @NFTA_SET_USERDATA: user data (NLA_BINARY) * @NFTA_SET_USERDATA: user data (NLA_BINARY)
* @NFTA_SET_OBJ_TYPE: stateful object type (NLA_U32: NFT_OBJECT_*) * @NFTA_SET_OBJ_TYPE: stateful object type (NLA_U32: NFT_OBJECT_*)
* @NFTA_SET_HANDLE: set handle (NLA_U64)
*/ */
enum nft_set_attributes { enum nft_set_attributes {
NFTA_SET_UNSPEC, NFTA_SET_UNSPEC,
...@@ -335,6 +338,7 @@ enum nft_set_attributes { ...@@ -335,6 +338,7 @@ enum nft_set_attributes {
NFTA_SET_USERDATA, NFTA_SET_USERDATA,
NFTA_SET_PAD, NFTA_SET_PAD,
NFTA_SET_OBJ_TYPE, NFTA_SET_OBJ_TYPE,
NFTA_SET_HANDLE,
__NFTA_SET_MAX __NFTA_SET_MAX
}; };
#define NFTA_SET_MAX (__NFTA_SET_MAX - 1) #define NFTA_SET_MAX (__NFTA_SET_MAX - 1)
...@@ -1314,6 +1318,7 @@ enum nft_ct_helper_attributes { ...@@ -1314,6 +1318,7 @@ enum nft_ct_helper_attributes {
* @NFTA_OBJ_TYPE: stateful object type (NLA_U32) * @NFTA_OBJ_TYPE: stateful object type (NLA_U32)
* @NFTA_OBJ_DATA: stateful object data (NLA_NESTED) * @NFTA_OBJ_DATA: stateful object data (NLA_NESTED)
* @NFTA_OBJ_USE: number of references to this expression (NLA_U32) * @NFTA_OBJ_USE: number of references to this expression (NLA_U32)
* @NFTA_OBJ_HANDLE: object handle (NLA_U64)
*/ */
enum nft_object_attributes { enum nft_object_attributes {
NFTA_OBJ_UNSPEC, NFTA_OBJ_UNSPEC,
...@@ -1322,6 +1327,8 @@ enum nft_object_attributes { ...@@ -1322,6 +1327,8 @@ enum nft_object_attributes {
NFTA_OBJ_TYPE, NFTA_OBJ_TYPE,
NFTA_OBJ_DATA, NFTA_OBJ_DATA,
NFTA_OBJ_USE, NFTA_OBJ_USE,
NFTA_OBJ_HANDLE,
NFTA_OBJ_PAD,
__NFTA_OBJ_MAX __NFTA_OBJ_MAX
}; };
#define NFTA_OBJ_MAX (__NFTA_OBJ_MAX - 1) #define NFTA_OBJ_MAX (__NFTA_OBJ_MAX - 1)
...@@ -1333,6 +1340,7 @@ enum nft_object_attributes { ...@@ -1333,6 +1340,7 @@ enum nft_object_attributes {
* @NFTA_FLOWTABLE_NAME: name of this flow table (NLA_STRING) * @NFTA_FLOWTABLE_NAME: name of this flow table (NLA_STRING)
* @NFTA_FLOWTABLE_HOOK: netfilter hook configuration(NLA_U32) * @NFTA_FLOWTABLE_HOOK: netfilter hook configuration(NLA_U32)
* @NFTA_FLOWTABLE_USE: number of references to this flow table (NLA_U32) * @NFTA_FLOWTABLE_USE: number of references to this flow table (NLA_U32)
* @NFTA_FLOWTABLE_HANDLE: object handle (NLA_U64)
*/ */
enum nft_flowtable_attributes { enum nft_flowtable_attributes {
NFTA_FLOWTABLE_UNSPEC, NFTA_FLOWTABLE_UNSPEC,
...@@ -1340,6 +1348,8 @@ enum nft_flowtable_attributes { ...@@ -1340,6 +1348,8 @@ enum nft_flowtable_attributes {
NFTA_FLOWTABLE_NAME, NFTA_FLOWTABLE_NAME,
NFTA_FLOWTABLE_HOOK, NFTA_FLOWTABLE_HOOK,
NFTA_FLOWTABLE_USE, NFTA_FLOWTABLE_USE,
NFTA_FLOWTABLE_HANDLE,
NFTA_FLOWTABLE_PAD,
__NFTA_FLOWTABLE_MAX __NFTA_FLOWTABLE_MAX
}; };
#define NFTA_FLOWTABLE_MAX (__NFTA_FLOWTABLE_MAX - 1) #define NFTA_FLOWTABLE_MAX (__NFTA_FLOWTABLE_MAX - 1)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment