aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2014-04-14 08:41:27 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2014-04-23 07:55:30 -0400
commitaa45660c6b59388fac3995a8c2998d710ef28fd4 (patch)
tree2d18122c239e5ce5bee263ac833df78d992c4de0
parent758dbcecf180a161e15971a2674fa6e65622a281 (diff)
netfilter: nf_tables: Make meta expression core functions public
This will be useful to create network family dedicated META expression as for NFPROTO_BRIDGE for instance. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/net/netfilter/nft_meta.h36
-rw-r--r--net/netfilter/nft_meta.c50
2 files changed, 61 insertions, 25 deletions
diff --git a/include/net/netfilter/nft_meta.h b/include/net/netfilter/nft_meta.h
new file mode 100644
index 000000000000..0ee47c3e2e31
--- /dev/null
+++ b/include/net/netfilter/nft_meta.h
@@ -0,0 +1,36 @@
1#ifndef _NFT_META_H_
2#define _NFT_META_H_
3
4struct nft_meta {
5 enum nft_meta_keys key:8;
6 union {
7 enum nft_registers dreg:8;
8 enum nft_registers sreg:8;
9 };
10};
11
12extern const struct nla_policy nft_meta_policy[];
13
14int nft_meta_get_init(const struct nft_ctx *ctx,
15 const struct nft_expr *expr,
16 const struct nlattr * const tb[]);
17
18int nft_meta_set_init(const struct nft_ctx *ctx,
19 const struct nft_expr *expr,
20 const struct nlattr * const tb[]);
21
22int nft_meta_get_dump(struct sk_buff *skb,
23 const struct nft_expr *expr);
24
25int nft_meta_set_dump(struct sk_buff *skb,
26 const struct nft_expr *expr);
27
28void nft_meta_get_eval(const struct nft_expr *expr,
29 struct nft_data data[NFT_REG_MAX + 1],
30 const struct nft_pktinfo *pkt);
31
32void nft_meta_set_eval(const struct nft_expr *expr,
33 struct nft_data data[NFT_REG_MAX + 1],
34 const struct nft_pktinfo *pkt);
35
36#endif
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 6d0b8cc27f2a..852b178c6ae7 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -18,18 +18,11 @@
18#include <net/sock.h> 18#include <net/sock.h>
19#include <net/tcp_states.h> /* for TCP_TIME_WAIT */ 19#include <net/tcp_states.h> /* for TCP_TIME_WAIT */
20#include <net/netfilter/nf_tables.h> 20#include <net/netfilter/nf_tables.h>
21#include <net/netfilter/nft_meta.h>
21 22
22struct nft_meta { 23void nft_meta_get_eval(const struct nft_expr *expr,
23 enum nft_meta_keys key:8; 24 struct nft_data data[NFT_REG_MAX + 1],
24 union { 25 const struct nft_pktinfo *pkt)
25 enum nft_registers dreg:8;
26 enum nft_registers sreg:8;
27 };
28};
29
30static void nft_meta_get_eval(const struct nft_expr *expr,
31 struct nft_data data[NFT_REG_MAX + 1],
32 const struct nft_pktinfo *pkt)
33{ 26{
34 const struct nft_meta *priv = nft_expr_priv(expr); 27 const struct nft_meta *priv = nft_expr_priv(expr);
35 const struct sk_buff *skb = pkt->skb; 28 const struct sk_buff *skb = pkt->skb;
@@ -140,10 +133,11 @@ static void nft_meta_get_eval(const struct nft_expr *expr,
140err: 133err:
141 data[NFT_REG_VERDICT].verdict = NFT_BREAK; 134 data[NFT_REG_VERDICT].verdict = NFT_BREAK;
142} 135}
136EXPORT_SYMBOL_GPL(nft_meta_get_eval);
143 137
144static void nft_meta_set_eval(const struct nft_expr *expr, 138void nft_meta_set_eval(const struct nft_expr *expr,
145 struct nft_data data[NFT_REG_MAX + 1], 139 struct nft_data data[NFT_REG_MAX + 1],
146 const struct nft_pktinfo *pkt) 140 const struct nft_pktinfo *pkt)
147{ 141{
148 const struct nft_meta *meta = nft_expr_priv(expr); 142 const struct nft_meta *meta = nft_expr_priv(expr);
149 struct sk_buff *skb = pkt->skb; 143 struct sk_buff *skb = pkt->skb;
@@ -163,16 +157,18 @@ static void nft_meta_set_eval(const struct nft_expr *expr,
163 WARN_ON(1); 157 WARN_ON(1);
164 } 158 }
165} 159}
160EXPORT_SYMBOL_GPL(nft_meta_set_eval);
166 161
167static const struct nla_policy nft_meta_policy[NFTA_META_MAX + 1] = { 162const struct nla_policy nft_meta_policy[NFTA_META_MAX + 1] = {
168 [NFTA_META_DREG] = { .type = NLA_U32 }, 163 [NFTA_META_DREG] = { .type = NLA_U32 },
169 [NFTA_META_KEY] = { .type = NLA_U32 }, 164 [NFTA_META_KEY] = { .type = NLA_U32 },
170 [NFTA_META_SREG] = { .type = NLA_U32 }, 165 [NFTA_META_SREG] = { .type = NLA_U32 },
171}; 166};
167EXPORT_SYMBOL_GPL(nft_meta_policy);
172 168
173static int nft_meta_get_init(const struct nft_ctx *ctx, 169int nft_meta_get_init(const struct nft_ctx *ctx,
174 const struct nft_expr *expr, 170 const struct nft_expr *expr,
175 const struct nlattr * const tb[]) 171 const struct nlattr * const tb[])
176{ 172{
177 struct nft_meta *priv = nft_expr_priv(expr); 173 struct nft_meta *priv = nft_expr_priv(expr);
178 int err; 174 int err;
@@ -215,10 +211,11 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
215 211
216 return 0; 212 return 0;
217} 213}
214EXPORT_SYMBOL_GPL(nft_meta_get_init);
218 215
219static int nft_meta_set_init(const struct nft_ctx *ctx, 216int nft_meta_set_init(const struct nft_ctx *ctx,
220 const struct nft_expr *expr, 217 const struct nft_expr *expr,
221 const struct nlattr * const tb[]) 218 const struct nlattr * const tb[])
222{ 219{
223 struct nft_meta *priv = nft_expr_priv(expr); 220 struct nft_meta *priv = nft_expr_priv(expr);
224 int err; 221 int err;
@@ -240,9 +237,10 @@ static int nft_meta_set_init(const struct nft_ctx *ctx,
240 237
241 return 0; 238 return 0;
242} 239}
240EXPORT_SYMBOL_GPL(nft_meta_set_init);
243 241
244static int nft_meta_get_dump(struct sk_buff *skb, 242int nft_meta_get_dump(struct sk_buff *skb,
245 const struct nft_expr *expr) 243 const struct nft_expr *expr)
246{ 244{
247 const struct nft_meta *priv = nft_expr_priv(expr); 245 const struct nft_meta *priv = nft_expr_priv(expr);
248 246
@@ -255,9 +253,10 @@ static int nft_meta_get_dump(struct sk_buff *skb,
255nla_put_failure: 253nla_put_failure:
256 return -1; 254 return -1;
257} 255}
256EXPORT_SYMBOL_GPL(nft_meta_get_dump);
258 257
259static int nft_meta_set_dump(struct sk_buff *skb, 258int nft_meta_set_dump(struct sk_buff *skb,
260 const struct nft_expr *expr) 259 const struct nft_expr *expr)
261{ 260{
262 const struct nft_meta *priv = nft_expr_priv(expr); 261 const struct nft_meta *priv = nft_expr_priv(expr);
263 262
@@ -271,6 +270,7 @@ static int nft_meta_set_dump(struct sk_buff *skb,
271nla_put_failure: 270nla_put_failure:
272 return -1; 271 return -1;
273} 272}
273EXPORT_SYMBOL_GPL(nft_meta_set_dump);
274 274
275static struct nft_expr_type nft_meta_type; 275static struct nft_expr_type nft_meta_type;
276static const struct nft_expr_ops nft_meta_get_ops = { 276static const struct nft_expr_ops nft_meta_get_ops = {