netfilter: nf_tables: move struct net pointer to base chain
[cascardo/linux.git] / include / net / netfilter / nf_tables.h
index decb9a0..ace67a5 100644 (file)
@@ -409,74 +409,6 @@ struct nft_rule {
                __attribute__((aligned(__alignof__(struct nft_expr))));
 };
 
-/**
- *     struct nft_trans - nf_tables object update in transaction
- *
- *     @list: used internally
- *     @msg_type: message type
- *     @ctx: transaction context
- *     @data: internal information related to the transaction
- */
-struct nft_trans {
-       struct list_head                list;
-       int                             msg_type;
-       struct nft_ctx                  ctx;
-       char                            data[0];
-};
-
-struct nft_trans_rule {
-       struct nft_rule                 *rule;
-};
-
-#define nft_trans_rule(trans)  \
-       (((struct nft_trans_rule *)trans->data)->rule)
-
-struct nft_trans_set {
-       struct nft_set  *set;
-       u32             set_id;
-};
-
-#define nft_trans_set(trans)   \
-       (((struct nft_trans_set *)trans->data)->set)
-#define nft_trans_set_id(trans)        \
-       (((struct nft_trans_set *)trans->data)->set_id)
-
-struct nft_trans_chain {
-       bool            update;
-       char            name[NFT_CHAIN_MAXNAMELEN];
-       struct nft_stats __percpu *stats;
-       u8              policy;
-};
-
-#define nft_trans_chain_update(trans)  \
-       (((struct nft_trans_chain *)trans->data)->update)
-#define nft_trans_chain_name(trans)    \
-       (((struct nft_trans_chain *)trans->data)->name)
-#define nft_trans_chain_stats(trans)   \
-       (((struct nft_trans_chain *)trans->data)->stats)
-#define nft_trans_chain_policy(trans)  \
-       (((struct nft_trans_chain *)trans->data)->policy)
-
-struct nft_trans_table {
-       bool            update;
-       bool            enable;
-};
-
-#define nft_trans_table_update(trans)  \
-       (((struct nft_trans_table *)trans->data)->update)
-#define nft_trans_table_enable(trans)  \
-       (((struct nft_trans_table *)trans->data)->enable)
-
-struct nft_trans_elem {
-       struct nft_set          *set;
-       struct nft_set_elem     elem;
-};
-
-#define nft_trans_elem_set(trans)      \
-       (((struct nft_trans_elem *)trans->data)->set)
-#define nft_trans_elem(trans)  \
-       (((struct nft_trans_elem *)trans->data)->elem)
-
 static inline struct nft_expr *nft_expr_first(const struct nft_rule *rule)
 {
        return (struct nft_expr *)&rule->data[0];
@@ -517,7 +449,6 @@ enum nft_chain_flags {
  *
  *     @rules: list of rules in the chain
  *     @list: used internally
- *     @net: net namespace that this chain belongs to
  *     @table: table that this chain belongs to
  *     @handle: chain handle
  *     @use: number of jump references to this chain
@@ -528,7 +459,6 @@ enum nft_chain_flags {
 struct nft_chain {
        struct list_head                rules;
        struct list_head                list;
-       struct net                      *net;
        struct nft_table                *table;
        u64                             handle;
        u32                             use;
@@ -544,6 +474,25 @@ enum nft_chain_type {
        NFT_CHAIN_T_MAX
 };
 
+/**
+ *     struct nf_chain_type - nf_tables chain type info
+ *
+ *     @name: name of the type
+ *     @type: numeric identifier
+ *     @family: address family
+ *     @owner: module owner
+ *     @hook_mask: mask of valid hooks
+ *     @hooks: hookfn overrides
+ */
+struct nf_chain_type {
+       const char                      *name;
+       enum nft_chain_type             type;
+       int                             family;
+       struct module                   *owner;
+       unsigned int                    hook_mask;
+       nf_hookfn                       *hooks[NF_MAX_HOOKS];
+};
+
 int nft_chain_validate_dependency(const struct nft_chain *chain,
                                  enum nft_chain_type type);
 int nft_chain_validate_hooks(const struct nft_chain *chain,
@@ -561,6 +510,7 @@ struct nft_stats {
  *     struct nft_base_chain - nf_tables base chain
  *
  *     @ops: netfilter hook ops
+ *     @pnet: net namespace that this chain belongs to
  *     @type: chain type
  *     @policy: default policy
  *     @stats: per-cpu chain stats
@@ -568,6 +518,7 @@ struct nft_stats {
  */
 struct nft_base_chain {
        struct nf_hook_ops              ops[NFT_HOOK_OPS_MAX];
+       possible_net_t                  pnet;
        const struct nf_chain_type      *type;
        u8                              policy;
        struct nft_stats __percpu       *stats;
@@ -600,7 +551,7 @@ struct nft_table {
        u64                             hgenerator;
        u32                             use;
        u16                             flags;
-       char                            name[];
+       char                            name[NFT_TABLE_MAXNAMELEN];
 };
 
 /**
@@ -630,25 +581,6 @@ struct nft_af_info {
 int nft_register_afinfo(struct net *, struct nft_af_info *);
 void nft_unregister_afinfo(struct nft_af_info *);
 
-/**
- *     struct nf_chain_type - nf_tables chain type info
- *
- *     @name: name of the type
- *     @type: numeric identifier
- *     @family: address family
- *     @owner: module owner
- *     @hook_mask: mask of valid hooks
- *     @hooks: hookfn overrides
- */
-struct nf_chain_type {
-       const char                      *name;
-       enum nft_chain_type             type;
-       int                             family;
-       struct module                   *owner;
-       unsigned int                    hook_mask;
-       nf_hookfn                       *hooks[NF_MAX_HOOKS];
-};
-
 int nft_register_chain_type(const struct nf_chain_type *);
 void nft_unregister_chain_type(const struct nf_chain_type *);
 
@@ -673,4 +605,72 @@ void nft_unregister_expr(struct nft_expr_type *);
 #define MODULE_ALIAS_NFT_SET() \
        MODULE_ALIAS("nft-set")
 
+/**
+ *     struct nft_trans - nf_tables object update in transaction
+ *
+ *     @list: used internally
+ *     @msg_type: message type
+ *     @ctx: transaction context
+ *     @data: internal information related to the transaction
+ */
+struct nft_trans {
+       struct list_head                list;
+       int                             msg_type;
+       struct nft_ctx                  ctx;
+       char                            data[0];
+};
+
+struct nft_trans_rule {
+       struct nft_rule                 *rule;
+};
+
+#define nft_trans_rule(trans)  \
+       (((struct nft_trans_rule *)trans->data)->rule)
+
+struct nft_trans_set {
+       struct nft_set                  *set;
+       u32                             set_id;
+};
+
+#define nft_trans_set(trans)   \
+       (((struct nft_trans_set *)trans->data)->set)
+#define nft_trans_set_id(trans)        \
+       (((struct nft_trans_set *)trans->data)->set_id)
+
+struct nft_trans_chain {
+       bool                            update;
+       char                            name[NFT_CHAIN_MAXNAMELEN];
+       struct nft_stats __percpu       *stats;
+       u8                              policy;
+};
+
+#define nft_trans_chain_update(trans)  \
+       (((struct nft_trans_chain *)trans->data)->update)
+#define nft_trans_chain_name(trans)    \
+       (((struct nft_trans_chain *)trans->data)->name)
+#define nft_trans_chain_stats(trans)   \
+       (((struct nft_trans_chain *)trans->data)->stats)
+#define nft_trans_chain_policy(trans)  \
+       (((struct nft_trans_chain *)trans->data)->policy)
+
+struct nft_trans_table {
+       bool                            update;
+       bool                            enable;
+};
+
+#define nft_trans_table_update(trans)  \
+       (((struct nft_trans_table *)trans->data)->update)
+#define nft_trans_table_enable(trans)  \
+       (((struct nft_trans_table *)trans->data)->enable)
+
+struct nft_trans_elem {
+       struct nft_set                  *set;
+       struct nft_set_elem             elem;
+};
+
+#define nft_trans_elem_set(trans)      \
+       (((struct nft_trans_elem *)trans->data)->set)
+#define nft_trans_elem(trans)  \
+       (((struct nft_trans_elem *)trans->data)->elem)
+
 #endif /* _NET_NF_TABLES_H */