aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2013-10-10 05:41:20 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-10-14 11:16:08 -0400
commitef1f7df9170dbd875ce198ba84e6ab80f6fc139e (patch)
treeac15a3cbf8c4a05b8b1919cf195189e00c3a2956 /net/ipv4
parent20a69341f2d00cd042e81c82289fba8a13c05a25 (diff)
netfilter: nf_tables: expression ops overloading
Split the expression ops into two parts and support overloading of the runtime expression ops based on the requested function through a ->select_ops() callback. This can be used to provide optimized implementations, for instance for loading small aligned amounts of data from the packet or inlining frequently used operations into the main evaluation loop. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/nf_table_nat_ipv4.c18
-rw-r--r--net/ipv4/netfilter/nft_reject_ipv4.c18
2 files changed, 24 insertions, 12 deletions
diff --git a/net/ipv4/netfilter/nf_table_nat_ipv4.c b/net/ipv4/netfilter/nf_table_nat_ipv4.c
index 2a6f184c10bd..2ecce39077a3 100644
--- a/net/ipv4/netfilter/nf_table_nat_ipv4.c
+++ b/net/ipv4/netfilter/nf_table_nat_ipv4.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> 2 * Copyright (c) 2008-2009 Patrick McHardy <kaber@trash.net>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
@@ -149,15 +149,21 @@ nla_put_failure:
149 return -1; 149 return -1;
150} 150}
151 151
152static struct nft_expr_ops nft_nat_ops __read_mostly = { 152static struct nft_expr_type nft_nat_type;
153 .name = "nat", 153static const struct nft_expr_ops nft_nat_ops = {
154 .type = &nft_nat_type,
154 .size = NFT_EXPR_SIZE(sizeof(struct nft_nat)), 155 .size = NFT_EXPR_SIZE(sizeof(struct nft_nat)),
155 .owner = THIS_MODULE,
156 .eval = nft_nat_eval, 156 .eval = nft_nat_eval,
157 .init = nft_nat_init, 157 .init = nft_nat_init,
158 .dump = nft_nat_dump, 158 .dump = nft_nat_dump,
159};
160
161static struct nft_expr_type nft_nat_type __read_mostly = {
162 .name = "nat",
163 .ops = &nft_nat_ops,
159 .policy = nft_nat_policy, 164 .policy = nft_nat_policy,
160 .maxattr = NFTA_NAT_MAX, 165 .maxattr = NFTA_NAT_MAX,
166 .owner = THIS_MODULE,
161}; 167};
162 168
163/* 169/*
@@ -382,7 +388,7 @@ static int __init nf_table_nat_init(void)
382 if (err < 0) 388 if (err < 0)
383 goto err1; 389 goto err1;
384 390
385 err = nft_register_expr(&nft_nat_ops); 391 err = nft_register_expr(&nft_nat_type);
386 if (err < 0) 392 if (err < 0)
387 goto err2; 393 goto err2;
388 394
@@ -396,7 +402,7 @@ err1:
396 402
397static void __exit nf_table_nat_exit(void) 403static void __exit nf_table_nat_exit(void)
398{ 404{
399 nft_unregister_expr(&nft_nat_ops); 405 nft_unregister_expr(&nft_nat_type);
400 nft_unregister_table(&nf_table_nat_ipv4, AF_INET); 406 nft_unregister_table(&nf_table_nat_ipv4, AF_INET);
401} 407}
402 408
diff --git a/net/ipv4/netfilter/nft_reject_ipv4.c b/net/ipv4/netfilter/nft_reject_ipv4.c
index b4ee8d3bb1e4..fff5ba1a33b7 100644
--- a/net/ipv4/netfilter/nft_reject_ipv4.c
+++ b/net/ipv4/netfilter/nft_reject_ipv4.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> 2 * Copyright (c) 2008-2009 Patrick McHardy <kaber@trash.net>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
@@ -88,25 +88,31 @@ nla_put_failure:
88 return -1; 88 return -1;
89} 89}
90 90
91static struct nft_expr_ops reject_ops __read_mostly = { 91static struct nft_expr_type nft_reject_type;
92 .name = "reject", 92static const struct nft_expr_ops nft_reject_ops = {
93 .type = &nft_reject_type,
93 .size = NFT_EXPR_SIZE(sizeof(struct nft_reject)), 94 .size = NFT_EXPR_SIZE(sizeof(struct nft_reject)),
94 .owner = THIS_MODULE,
95 .eval = nft_reject_eval, 95 .eval = nft_reject_eval,
96 .init = nft_reject_init, 96 .init = nft_reject_init,
97 .dump = nft_reject_dump, 97 .dump = nft_reject_dump,
98};
99
100static struct nft_expr_type nft_reject_type __read_mostly = {
101 .name = "reject",
102 .ops = &nft_reject_ops,
98 .policy = nft_reject_policy, 103 .policy = nft_reject_policy,
99 .maxattr = NFTA_REJECT_MAX, 104 .maxattr = NFTA_REJECT_MAX,
105 .owner = THIS_MODULE,
100}; 106};
101 107
102static int __init nft_reject_module_init(void) 108static int __init nft_reject_module_init(void)
103{ 109{
104 return nft_register_expr(&reject_ops); 110 return nft_register_expr(&nft_reject_type);
105} 111}
106 112
107static void __exit nft_reject_module_exit(void) 113static void __exit nft_reject_module_exit(void)
108{ 114{
109 nft_unregister_expr(&reject_ops); 115 nft_unregister_expr(&nft_reject_type);
110} 116}
111 117
112module_init(nft_reject_module_init); 118module_init(nft_reject_module_init);