aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-10-10 17:21:26 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-10-14 11:16:11 -0400
commit9370761c56b66aa5c65e069a7b010111a025018d (patch)
tree0b9080fdb768fc5f8f16c685de605d07347283f9 /include/net
parentc29b72e02573b8fe5e6cae5d192a6a4772e7bbd6 (diff)
netfilter: nf_tables: convert built-in tables/chains to chain types
This patch converts built-in tables/chains to chain types that allows you to deploy customized table and chain configurations from userspace. After this patch, you have to specify the chain type when creating a new chain: add chain ip filter output { type filter hook input priority 0; } ^^^^ ------ The existing chain types after this patch are: filter, route and nat. Note that tables are just containers of chains with no specific semantics, which is a significant change with regards to iptables. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/netfilter/nf_tables.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 66d0359702c6..8403f7f52e81 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -336,7 +336,6 @@ static inline struct nft_expr *nft_expr_last(const struct nft_rule *rule)
336 336
337enum nft_chain_flags { 337enum nft_chain_flags {
338 NFT_BASE_CHAIN = 0x1, 338 NFT_BASE_CHAIN = 0x1,
339 NFT_CHAIN_BUILTIN = 0x2,
340}; 339};
341 340
342/** 341/**
@@ -362,14 +361,23 @@ struct nft_chain {
362 char name[NFT_CHAIN_MAXNAMELEN]; 361 char name[NFT_CHAIN_MAXNAMELEN];
363}; 362};
364 363
364enum nft_chain_type {
365 NFT_CHAIN_T_DEFAULT = 0,
366 NFT_CHAIN_T_ROUTE,
367 NFT_CHAIN_T_NAT,
368 NFT_CHAIN_T_MAX
369};
370
365/** 371/**
366 * struct nft_base_chain - nf_tables base chain 372 * struct nft_base_chain - nf_tables base chain
367 * 373 *
368 * @ops: netfilter hook ops 374 * @ops: netfilter hook ops
375 * @type: chain type
369 * @chain: the chain 376 * @chain: the chain
370 */ 377 */
371struct nft_base_chain { 378struct nft_base_chain {
372 struct nf_hook_ops ops; 379 struct nf_hook_ops ops;
380 enum nft_chain_type type;
373 struct nft_chain chain; 381 struct nft_chain chain;
374}; 382};
375 383
@@ -384,10 +392,6 @@ extern unsigned int nft_do_chain(const struct nf_hook_ops *ops,
384 const struct net_device *out, 392 const struct net_device *out,
385 int (*okfn)(struct sk_buff *)); 393 int (*okfn)(struct sk_buff *));
386 394
387enum nft_table_flags {
388 NFT_TABLE_BUILTIN = 0x1,
389};
390
391/** 395/**
392 * struct nft_table - nf_tables table 396 * struct nft_table - nf_tables table
393 * 397 *
@@ -431,8 +435,17 @@ struct nft_af_info {
431extern int nft_register_afinfo(struct nft_af_info *); 435extern int nft_register_afinfo(struct nft_af_info *);
432extern void nft_unregister_afinfo(struct nft_af_info *); 436extern void nft_unregister_afinfo(struct nft_af_info *);
433 437
434extern int nft_register_table(struct nft_table *, int family); 438struct nf_chain_type {
435extern void nft_unregister_table(struct nft_table *, int family); 439 unsigned int hook_mask;
440 const char *name;
441 enum nft_chain_type type;
442 nf_hookfn *fn[NF_MAX_HOOKS];
443 struct module *me;
444 int family;
445};
446
447extern int nft_register_chain_type(struct nf_chain_type *);
448extern void nft_unregister_chain_type(struct nf_chain_type *);
436 449
437extern int nft_register_expr(struct nft_expr_type *); 450extern int nft_register_expr(struct nft_expr_type *);
438extern void nft_unregister_expr(struct nft_expr_type *); 451extern void nft_unregister_expr(struct nft_expr_type *);
@@ -440,8 +453,8 @@ extern void nft_unregister_expr(struct nft_expr_type *);
440#define MODULE_ALIAS_NFT_FAMILY(family) \ 453#define MODULE_ALIAS_NFT_FAMILY(family) \
441 MODULE_ALIAS("nft-afinfo-" __stringify(family)) 454 MODULE_ALIAS("nft-afinfo-" __stringify(family))
442 455
443#define MODULE_ALIAS_NFT_TABLE(family, name) \ 456#define MODULE_ALIAS_NFT_CHAIN(family, name) \
444 MODULE_ALIAS("nft-table-" __stringify(family) "-" name) 457 MODULE_ALIAS("nft-chain-" __stringify(family) "-" name)
445 458
446#define MODULE_ALIAS_NFT_EXPR(name) \ 459#define MODULE_ALIAS_NFT_EXPR(name) \
447 MODULE_ALIAS("nft-expr-" name) 460 MODULE_ALIAS("nft-expr-" name)