Skip to content

Commit 8a22543

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nf_tables: make meta expression builtin
size net/netfilter/nft_meta.ko text data bss dec hex filename 5826 936 1 6763 1a6b net/netfilter/nft_meta.ko 96407 2064 400 98871 18237 net/netfilter/nf_tables.ko after: 100826 2240 401 103467 1942b net/netfilter/nf_tables.ko Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent bd2bbdb commit 8a22543

File tree

5 files changed

+4
-29
lines changed

5 files changed

+4
-29
lines changed

include/net/netfilter/nf_tables_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extern struct nft_expr_type nft_byteorder_type;
1010
extern struct nft_expr_type nft_payload_type;
1111
extern struct nft_expr_type nft_dynset_type;
1212
extern struct nft_expr_type nft_range_type;
13+
extern struct nft_expr_type nft_meta_type;
1314

1415
int nf_tables_core_module_init(void);
1516
void nf_tables_core_module_exit(void);

net/netfilter/Kconfig

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,6 @@ config NFT_EXTHDR
480480
This option adds the "exthdr" expression that you can use to match
481481
IPv6 extension headers and tcp options.
482482

483-
config NFT_META
484-
tristate "Netfilter nf_tables meta module"
485-
help
486-
This option adds the "meta" expression that you can use to match and
487-
to set packet metainformation such as the packet mark.
488-
489483
config NFT_RT
490484
tristate "Netfilter nf_tables routing module"
491485
help

net/netfilter/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ obj-$(CONFIG_NF_DUP_NETDEV) += nf_dup_netdev.o
7676
nf_tables-objs := nf_tables_core.o nf_tables_api.o nft_chain_filter.o \
7777
nf_tables_trace.o nft_immediate.o nft_cmp.o nft_range.o \
7878
nft_bitwise.o nft_byteorder.o nft_payload.o nft_lookup.o \
79-
nft_dynset.o
79+
nft_dynset.o nft_meta.o
8080

8181
obj-$(CONFIG_NF_TABLES) += nf_tables.o
8282
obj-$(CONFIG_NFT_COMPAT) += nft_compat.o
8383
obj-$(CONFIG_NFT_EXTHDR) += nft_exthdr.o
84-
obj-$(CONFIG_NFT_META) += nft_meta.o
8584
obj-$(CONFIG_NFT_RT) += nft_rt.o
8685
obj-$(CONFIG_NFT_NUMGEN) += nft_numgen.o
8786
obj-$(CONFIG_NFT_CT) += nft_ct.o

net/netfilter/nf_tables_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ static struct nft_expr_type *nft_basic_types[] = {
251251
&nft_payload_type,
252252
&nft_dynset_type,
253253
&nft_range_type,
254+
&nft_meta_type,
254255
};
255256

256257
int __init nf_tables_core_module_init(void)

net/netfilter/nft_meta.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*/
1212

1313
#include <linux/kernel.h>
14-
#include <linux/init.h>
15-
#include <linux/module.h>
1614
#include <linux/netlink.h>
1715
#include <linux/netfilter.h>
1816
#include <linux/netfilter/nf_tables.h>
@@ -495,7 +493,6 @@ static void nft_meta_set_destroy(const struct nft_ctx *ctx,
495493
static_branch_dec(&nft_trace_enabled);
496494
}
497495

498-
static struct nft_expr_type nft_meta_type;
499496
static const struct nft_expr_ops nft_meta_get_ops = {
500497
.type = &nft_meta_type,
501498
.size = NFT_EXPR_SIZE(sizeof(struct nft_meta)),
@@ -534,27 +531,10 @@ nft_meta_select_ops(const struct nft_ctx *ctx,
534531
return ERR_PTR(-EINVAL);
535532
}
536533

537-
static struct nft_expr_type nft_meta_type __read_mostly = {
534+
struct nft_expr_type nft_meta_type __read_mostly = {
538535
.name = "meta",
539536
.select_ops = nft_meta_select_ops,
540537
.policy = nft_meta_policy,
541538
.maxattr = NFTA_META_MAX,
542539
.owner = THIS_MODULE,
543540
};
544-
545-
static int __init nft_meta_module_init(void)
546-
{
547-
return nft_register_expr(&nft_meta_type);
548-
}
549-
550-
static void __exit nft_meta_module_exit(void)
551-
{
552-
nft_unregister_expr(&nft_meta_type);
553-
}
554-
555-
module_init(nft_meta_module_init);
556-
module_exit(nft_meta_module_exit);
557-
558-
MODULE_LICENSE("GPL");
559-
MODULE_AUTHOR("Patrick McHardy <[email protected]>");
560-
MODULE_ALIAS_NFT_EXPR("meta");

0 commit comments

Comments
 (0)