netfilter: nf_tables: merge exthdr expression into nft core
authorFlorian Westphal <fw@strlen.de>
Mon, 16 Apr 2018 17:15:56 +0000 (19:15 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 26 Apr 2018 22:00:56 +0000 (00:00 +0200)
before:
   text    data     bss     dec     hex filename
   5056     844       0    5900    170c net/netfilter/nft_exthdr.ko
 102456    2316     401  105173   19ad5 net/netfilter/nf_tables.ko

after:
 106410    2392     401  109203   1aa93 net/netfilter/nf_tables.ko

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_tables_core.h
net/netfilter/Kconfig
net/netfilter/Makefile
net/netfilter/nf_tables_core.c
net/netfilter/nft_exthdr.c

index d6a358ae374922995e4541c2cb0428cc38da70bf..cd6915b6c054e363e8bb621068b5e18e87fa8905 100644 (file)
@@ -12,6 +12,7 @@ extern struct nft_expr_type nft_dynset_type;
 extern struct nft_expr_type nft_range_type;
 extern struct nft_expr_type nft_meta_type;
 extern struct nft_expr_type nft_rt_type;
+extern struct nft_expr_type nft_exthdr_type;
 
 int nf_tables_core_module_init(void);
 void nf_tables_core_module_exit(void);
index 771f1a4f3376300710d6319de5b04abe96848ad6..f66586fb41cdaca2928a60f20a6481b3c75674aa 100644 (file)
@@ -474,12 +474,6 @@ config NF_TABLES_NETDEV
        help
          This option enables support for the "netdev" table.
 
-config NFT_EXTHDR
-       tristate "Netfilter nf_tables exthdr module"
-       help
-         This option adds the "exthdr" expression that you can use to match
-         IPv6 extension headers and tcp options.
-
 config NFT_NUMGEN
        tristate "Netfilter nf_tables number generator module"
        help
index 128dbcfaa1943f7eacad5ffa90dcaa4e13b0185c..b37ce0bc9ab73b3c8be9446f697ee5a2b3d55366 100644 (file)
@@ -76,11 +76,10 @@ obj-$(CONFIG_NF_DUP_NETDEV) += nf_dup_netdev.o
 nf_tables-objs := nf_tables_core.o nf_tables_api.o nft_chain_filter.o \
                  nf_tables_trace.o nft_immediate.o nft_cmp.o nft_range.o \
                  nft_bitwise.o nft_byteorder.o nft_payload.o nft_lookup.o \
-                 nft_dynset.o nft_meta.o nft_rt.o
+                 nft_dynset.o nft_meta.o nft_rt.o nft_exthdr.o
 
 obj-$(CONFIG_NF_TABLES)                += nf_tables.o
 obj-$(CONFIG_NFT_COMPAT)       += nft_compat.o
-obj-$(CONFIG_NFT_EXTHDR)       += nft_exthdr.o
 obj-$(CONFIG_NFT_NUMGEN)       += nft_numgen.o
 obj-$(CONFIG_NFT_CT)           += nft_ct.o
 obj-$(CONFIG_NFT_FLOW_OFFLOAD) += nft_flow_offload.o
index 481ce2c0bbbf20c4bf474443c1d7436b06dd4bd2..9cf47c4cb9d5f9b8b97e52eab6ed0768297ec718 100644 (file)
@@ -253,6 +253,7 @@ static struct nft_expr_type *nft_basic_types[] = {
        &nft_range_type,
        &nft_meta_type,
        &nft_rt_type,
+       &nft_exthdr_type,
 };
 
 int __init nf_tables_core_module_init(void)
index 47ec1046ad11536e337f709d1f41a267a77cf1d3..a940c9fd9045e5495a42d93f76db26283c6de5f1 100644 (file)
 
 #include <asm/unaligned.h>
 #include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
 #include <linux/netlink.h>
 #include <linux/netfilter.h>
 #include <linux/netfilter/nf_tables.h>
+#include <net/netfilter/nf_tables_core.h>
 #include <net/netfilter/nf_tables.h>
 #include <net/tcp.h>
 
@@ -353,7 +352,6 @@ static int nft_exthdr_dump_set(struct sk_buff *skb, const struct nft_expr *expr)
        return nft_exthdr_dump_common(skb, priv);
 }
 
-static struct nft_expr_type nft_exthdr_type;
 static const struct nft_expr_ops nft_exthdr_ipv6_ops = {
        .type           = &nft_exthdr_type,
        .size           = NFT_EXPR_SIZE(sizeof(struct nft_exthdr)),
@@ -407,27 +405,10 @@ nft_exthdr_select_ops(const struct nft_ctx *ctx,
        return ERR_PTR(-EOPNOTSUPP);
 }
 
-static struct nft_expr_type nft_exthdr_type __read_mostly = {
+struct nft_expr_type nft_exthdr_type __read_mostly = {
        .name           = "exthdr",
        .select_ops     = nft_exthdr_select_ops,
        .policy         = nft_exthdr_policy,
        .maxattr        = NFTA_EXTHDR_MAX,
        .owner          = THIS_MODULE,
 };
-
-static int __init nft_exthdr_module_init(void)
-{
-       return nft_register_expr(&nft_exthdr_type);
-}
-
-static void __exit nft_exthdr_module_exit(void)
-{
-       nft_unregister_expr(&nft_exthdr_type);
-}
-
-module_init(nft_exthdr_module_init);
-module_exit(nft_exthdr_module_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
-MODULE_ALIAS_NFT_EXPR("exthdr");