aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--include/net/netfilter/nf_tables.h42
-rw-r--r--net/ipv4/netfilter/nf_table_nat_ipv4.c18
-rw-r--r--net/ipv4/netfilter/nft_reject_ipv4.c18
-rw-r--r--net/netfilter/nf_tables_api.c101
-rw-r--r--net/netfilter/nft_bitwise.c18
-rw-r--r--net/netfilter/nft_byteorder.c18
-rw-r--r--net/netfilter/nft_cmp.c18
-rw-r--r--net/netfilter/nft_counter.c22
-rw-r--r--net/netfilter/nft_ct.c18
-rw-r--r--net/netfilter/nft_expr_template.c20
-rw-r--r--net/netfilter/nft_exthdr.c16
-rw-r--r--net/netfilter/nft_immediate.c18
-rw-r--r--net/netfilter/nft_limit.c18
-rw-r--r--net/netfilter/nft_log.c18
-rw-r--r--net/netfilter/nft_lookup.c16
-rw-r--r--net/netfilter/nft_meta.c18
-rw-r--r--net/netfilter/nft_payload.c18
17 files changed, 267 insertions, 148 deletions
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 677dd79380ed..66d0359702c6 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -222,25 +222,45 @@ extern int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,
222extern void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set, 222extern void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set,
223 struct nft_set_binding *binding); 223 struct nft_set_binding *binding);
224 224
225
225/** 226/**
226 * struct nft_expr_ops - nf_tables expression operations 227 * struct nft_expr_type - nf_tables expression type
227 * 228 *
228 * @eval: Expression evaluation function 229 * @select_ops: function to select nft_expr_ops
229 * @init: initialization function 230 * @ops: default ops, used when no select_ops functions is present
230 * @destroy: destruction function
231 * @dump: function to dump parameters
232 * @list: used internally 231 * @list: used internally
233 * @name: Identifier 232 * @name: Identifier
234 * @owner: module reference 233 * @owner: module reference
235 * @policy: netlink attribute policy 234 * @policy: netlink attribute policy
236 * @maxattr: highest netlink attribute number 235 * @maxattr: highest netlink attribute number
236 */
237struct nft_expr_type {
238 const struct nft_expr_ops *(*select_ops)(const struct nlattr * const tb[]);
239 const struct nft_expr_ops *ops;
240 struct list_head list;
241 const char *name;
242 struct module *owner;
243 const struct nla_policy *policy;
244 unsigned int maxattr;
245};
246
247/**
248 * struct nft_expr_ops - nf_tables expression operations
249 *
250 * @eval: Expression evaluation function
237 * @size: full expression size, including private data size 251 * @size: full expression size, including private data size
252 * @init: initialization function
253 * @destroy: destruction function
254 * @dump: function to dump parameters
255 * @type: expression type
238 */ 256 */
239struct nft_expr; 257struct nft_expr;
240struct nft_expr_ops { 258struct nft_expr_ops {
241 void (*eval)(const struct nft_expr *expr, 259 void (*eval)(const struct nft_expr *expr,
242 struct nft_data data[NFT_REG_MAX + 1], 260 struct nft_data data[NFT_REG_MAX + 1],
243 const struct nft_pktinfo *pkt); 261 const struct nft_pktinfo *pkt);
262 unsigned int size;
263
244 int (*init)(const struct nft_ctx *ctx, 264 int (*init)(const struct nft_ctx *ctx,
245 const struct nft_expr *expr, 265 const struct nft_expr *expr,
246 const struct nlattr * const tb[]); 266 const struct nlattr * const tb[]);
@@ -248,14 +268,10 @@ struct nft_expr_ops {
248 int (*dump)(struct sk_buff *skb, 268 int (*dump)(struct sk_buff *skb,
249 const struct nft_expr *expr); 269 const struct nft_expr *expr);
250 const struct nft_data * (*get_verdict)(const struct nft_expr *expr); 270 const struct nft_data * (*get_verdict)(const struct nft_expr *expr);
251 struct list_head list; 271 const struct nft_expr_type *type;
252 const char *name;
253 struct module *owner;
254 const struct nla_policy *policy;
255 unsigned int maxattr;
256 unsigned int size;
257}; 272};
258 273
274#define NFT_EXPR_MAXATTR 16
259#define NFT_EXPR_SIZE(size) (sizeof(struct nft_expr) + \ 275#define NFT_EXPR_SIZE(size) (sizeof(struct nft_expr) + \
260 ALIGN(size, __alignof__(struct nft_expr))) 276 ALIGN(size, __alignof__(struct nft_expr)))
261 277
@@ -418,8 +434,8 @@ extern void nft_unregister_afinfo(struct nft_af_info *);
418extern int nft_register_table(struct nft_table *, int family); 434extern int nft_register_table(struct nft_table *, int family);
419extern void nft_unregister_table(struct nft_table *, int family); 435extern void nft_unregister_table(struct nft_table *, int family);
420 436
421extern int nft_register_expr(struct nft_expr_ops *); 437extern int nft_register_expr(struct nft_expr_type *);
422extern void nft_unregister_expr(struct nft_expr_ops *); 438extern void nft_unregister_expr(struct nft_expr_type *);
423 439
424#define MODULE_ALIAS_NFT_FAMILY(family) \ 440#define MODULE_ALIAS_NFT_FAMILY(family) \
425 MODULE_ALIAS("nft-afinfo-" __stringify(family)) 441 MODULE_ALIAS("nft-afinfo-" __stringify(family))
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);
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 5092c817c222..6dac9a3c9c40 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -840,64 +840,64 @@ static void nft_ctx_init(struct nft_ctx *ctx,
840 */ 840 */
841 841
842/** 842/**
843 * nft_register_expr - register nf_tables expr operations 843 * nft_register_expr - register nf_tables expr type
844 * @ops: expr operations 844 * @ops: expr type
845 * 845 *
846 * Registers the expr operations for use with nf_tables. Returns zero on 846 * Registers the expr type for use with nf_tables. Returns zero on
847 * success or a negative errno code otherwise. 847 * success or a negative errno code otherwise.
848 */ 848 */
849int nft_register_expr(struct nft_expr_ops *ops) 849int nft_register_expr(struct nft_expr_type *type)
850{ 850{
851 nfnl_lock(NFNL_SUBSYS_NFTABLES); 851 nfnl_lock(NFNL_SUBSYS_NFTABLES);
852 list_add_tail(&ops->list, &nf_tables_expressions); 852 list_add_tail(&type->list, &nf_tables_expressions);
853 nfnl_unlock(NFNL_SUBSYS_NFTABLES); 853 nfnl_unlock(NFNL_SUBSYS_NFTABLES);
854 return 0; 854 return 0;
855} 855}
856EXPORT_SYMBOL_GPL(nft_register_expr); 856EXPORT_SYMBOL_GPL(nft_register_expr);
857 857
858/** 858/**
859 * nft_unregister_expr - unregister nf_tables expr operations 859 * nft_unregister_expr - unregister nf_tables expr type
860 * @ops: expr operations 860 * @ops: expr type
861 * 861 *
862 * Unregisters the expr operations for use with nf_tables. 862 * Unregisters the expr typefor use with nf_tables.
863 */ 863 */
864void nft_unregister_expr(struct nft_expr_ops *ops) 864void nft_unregister_expr(struct nft_expr_type *type)
865{ 865{
866 nfnl_lock(NFNL_SUBSYS_NFTABLES); 866 nfnl_lock(NFNL_SUBSYS_NFTABLES);
867 list_del(&ops->list); 867 list_del(&type->list);
868 nfnl_unlock(NFNL_SUBSYS_NFTABLES); 868 nfnl_unlock(NFNL_SUBSYS_NFTABLES);
869} 869}
870EXPORT_SYMBOL_GPL(nft_unregister_expr); 870EXPORT_SYMBOL_GPL(nft_unregister_expr);
871 871
872static const struct nft_expr_ops *__nft_expr_ops_get(struct nlattr *nla) 872static const struct nft_expr_type *__nft_expr_type_get(struct nlattr *nla)
873{ 873{
874 const struct nft_expr_ops *ops; 874 const struct nft_expr_type *type;
875 875
876 list_for_each_entry(ops, &nf_tables_expressions, list) { 876 list_for_each_entry(type, &nf_tables_expressions, list) {
877 if (!nla_strcmp(nla, ops->name)) 877 if (!nla_strcmp(nla, type->name))
878 return ops; 878 return type;
879 } 879 }
880 return NULL; 880 return NULL;
881} 881}
882 882
883static const struct nft_expr_ops *nft_expr_ops_get(struct nlattr *nla) 883static const struct nft_expr_type *nft_expr_type_get(struct nlattr *nla)
884{ 884{
885 const struct nft_expr_ops *ops; 885 const struct nft_expr_type *type;
886 886
887 if (nla == NULL) 887 if (nla == NULL)
888 return ERR_PTR(-EINVAL); 888 return ERR_PTR(-EINVAL);
889 889
890 ops = __nft_expr_ops_get(nla); 890 type = __nft_expr_type_get(nla);
891 if (ops != NULL && try_module_get(ops->owner)) 891 if (type != NULL && try_module_get(type->owner))
892 return ops; 892 return type;
893 893
894#ifdef CONFIG_MODULES 894#ifdef CONFIG_MODULES
895 if (ops == NULL) { 895 if (type == NULL) {
896 nfnl_unlock(NFNL_SUBSYS_NFTABLES); 896 nfnl_unlock(NFNL_SUBSYS_NFTABLES);
897 request_module("nft-expr-%.*s", 897 request_module("nft-expr-%.*s",
898 nla_len(nla), (char *)nla_data(nla)); 898 nla_len(nla), (char *)nla_data(nla));
899 nfnl_lock(NFNL_SUBSYS_NFTABLES); 899 nfnl_lock(NFNL_SUBSYS_NFTABLES);
900 if (__nft_expr_ops_get(nla)) 900 if (__nft_expr_type_get(nla))
901 return ERR_PTR(-EAGAIN); 901 return ERR_PTR(-EAGAIN);
902 } 902 }
903#endif 903#endif
@@ -912,7 +912,7 @@ static const struct nla_policy nft_expr_policy[NFTA_EXPR_MAX + 1] = {
912static int nf_tables_fill_expr_info(struct sk_buff *skb, 912static int nf_tables_fill_expr_info(struct sk_buff *skb,
913 const struct nft_expr *expr) 913 const struct nft_expr *expr)
914{ 914{
915 if (nla_put_string(skb, NFTA_EXPR_NAME, expr->ops->name)) 915 if (nla_put_string(skb, NFTA_EXPR_NAME, expr->ops->type->name))
916 goto nla_put_failure; 916 goto nla_put_failure;
917 917
918 if (expr->ops->dump) { 918 if (expr->ops->dump) {
@@ -932,28 +932,52 @@ nla_put_failure:
932 932
933struct nft_expr_info { 933struct nft_expr_info {
934 const struct nft_expr_ops *ops; 934 const struct nft_expr_ops *ops;
935 struct nlattr *tb[NFTA_EXPR_MAX + 1]; 935 struct nlattr *tb[NFT_EXPR_MAXATTR + 1];
936}; 936};
937 937
938static int nf_tables_expr_parse(const struct nlattr *nla, 938static int nf_tables_expr_parse(const struct nlattr *nla,
939 struct nft_expr_info *info) 939 struct nft_expr_info *info)
940{ 940{
941 const struct nft_expr_type *type;
941 const struct nft_expr_ops *ops; 942 const struct nft_expr_ops *ops;
943 struct nlattr *tb[NFTA_EXPR_MAX + 1];
942 int err; 944 int err;
943 945
944 err = nla_parse_nested(info->tb, NFTA_EXPR_MAX, nla, nft_expr_policy); 946 err = nla_parse_nested(tb, NFTA_EXPR_MAX, nla, nft_expr_policy);
945 if (err < 0) 947 if (err < 0)
946 return err; 948 return err;
947 949
948 ops = nft_expr_ops_get(info->tb[NFTA_EXPR_NAME]); 950 type = nft_expr_type_get(tb[NFTA_EXPR_NAME]);
949 if (IS_ERR(ops)) 951 if (IS_ERR(type))
950 return PTR_ERR(ops); 952 return PTR_ERR(type);
953
954 if (tb[NFTA_EXPR_DATA]) {
955 err = nla_parse_nested(info->tb, type->maxattr,
956 tb[NFTA_EXPR_DATA], type->policy);
957 if (err < 0)
958 goto err1;
959 } else
960 memset(info->tb, 0, sizeof(info->tb[0]) * (type->maxattr + 1));
961
962 if (type->select_ops != NULL) {
963 ops = type->select_ops((const struct nlattr * const *)info->tb);
964 if (IS_ERR(ops)) {
965 err = PTR_ERR(ops);
966 goto err1;
967 }
968 } else
969 ops = type->ops;
970
951 info->ops = ops; 971 info->ops = ops;
952 return 0; 972 return 0;
973
974err1:
975 module_put(type->owner);
976 return err;
953} 977}
954 978
955static int nf_tables_newexpr(const struct nft_ctx *ctx, 979static int nf_tables_newexpr(const struct nft_ctx *ctx,
956 struct nft_expr_info *info, 980 const struct nft_expr_info *info,
957 struct nft_expr *expr) 981 struct nft_expr *expr)
958{ 982{
959 const struct nft_expr_ops *ops = info->ops; 983 const struct nft_expr_ops *ops = info->ops;
@@ -961,23 +985,11 @@ static int nf_tables_newexpr(const struct nft_ctx *ctx,
961 985
962 expr->ops = ops; 986 expr->ops = ops;
963 if (ops->init) { 987 if (ops->init) {
964 struct nlattr *ma[ops->maxattr + 1]; 988 err = ops->init(ctx, expr, (const struct nlattr **)info->tb);
965
966 if (info->tb[NFTA_EXPR_DATA]) {
967 err = nla_parse_nested(ma, ops->maxattr,
968 info->tb[NFTA_EXPR_DATA],
969 ops->policy);
970 if (err < 0)
971 goto err1;
972 } else
973 memset(ma, 0, sizeof(ma[0]) * (ops->maxattr + 1));
974
975 err = ops->init(ctx, expr, (const struct nlattr **)ma);
976 if (err < 0) 989 if (err < 0)
977 goto err1; 990 goto err1;
978 } 991 }
979 992
980 info->ops = NULL;
981 return 0; 993 return 0;
982 994
983err1: 995err1:
@@ -989,7 +1001,7 @@ static void nf_tables_expr_destroy(struct nft_expr *expr)
989{ 1001{
990 if (expr->ops->destroy) 1002 if (expr->ops->destroy)
991 expr->ops->destroy(expr); 1003 expr->ops->destroy(expr);
992 module_put(expr->ops->owner); 1004 module_put(expr->ops->type->owner);
993} 1005}
994 1006
995/* 1007/*
@@ -1313,6 +1325,7 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
1313 err = nf_tables_newexpr(&ctx, &info[i], expr); 1325 err = nf_tables_newexpr(&ctx, &info[i], expr);
1314 if (err < 0) 1326 if (err < 0)
1315 goto err2; 1327 goto err2;
1328 info[i].ops = NULL;
1316 expr = nft_expr_next(expr); 1329 expr = nft_expr_next(expr);
1317 } 1330 }
1318 1331
@@ -1341,7 +1354,7 @@ err2:
1341err1: 1354err1:
1342 for (i = 0; i < n; i++) { 1355 for (i = 0; i < n; i++) {
1343 if (info[i].ops != NULL) 1356 if (info[i].ops != NULL)
1344 module_put(info[i].ops->owner); 1357 module_put(info[i].ops->type->owner);
1345 } 1358 }
1346 return err; 1359 return err;
1347} 1360}
diff --git a/net/netfilter/nft_bitwise.c b/net/netfilter/nft_bitwise.c
index 0f7501506367..4fb6ee2c1106 100644
--- a/net/netfilter/nft_bitwise.c
+++ b/net/netfilter/nft_bitwise.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
@@ -118,23 +118,29 @@ nla_put_failure:
118 return -1; 118 return -1;
119} 119}
120 120
121static struct nft_expr_ops nft_bitwise_ops __read_mostly = { 121static struct nft_expr_type nft_bitwise_type;
122 .name = "bitwise", 122static const struct nft_expr_ops nft_bitwise_ops = {
123 .type = &nft_bitwise_type,
123 .size = NFT_EXPR_SIZE(sizeof(struct nft_bitwise)), 124 .size = NFT_EXPR_SIZE(sizeof(struct nft_bitwise)),
124 .owner = THIS_MODULE,
125 .eval = nft_bitwise_eval, 125 .eval = nft_bitwise_eval,
126 .init = nft_bitwise_init, 126 .init = nft_bitwise_init,
127 .dump = nft_bitwise_dump, 127 .dump = nft_bitwise_dump,
128};
129
130static struct nft_expr_type nft_bitwise_type __read_mostly = {
131 .name = "bitwise",
132 .ops = &nft_bitwise_ops,
128 .policy = nft_bitwise_policy, 133 .policy = nft_bitwise_policy,
129 .maxattr = NFTA_BITWISE_MAX, 134 .maxattr = NFTA_BITWISE_MAX,
135 .owner = THIS_MODULE,
130}; 136};
131 137
132int __init nft_bitwise_module_init(void) 138int __init nft_bitwise_module_init(void)
133{ 139{
134 return nft_register_expr(&nft_bitwise_ops); 140 return nft_register_expr(&nft_bitwise_type);
135} 141}
136 142
137void nft_bitwise_module_exit(void) 143void nft_bitwise_module_exit(void)
138{ 144{
139 nft_unregister_expr(&nft_bitwise_ops); 145 nft_unregister_expr(&nft_bitwise_type);
140} 146}
diff --git a/net/netfilter/nft_byteorder.c b/net/netfilter/nft_byteorder.c
index 8b0657a4d17b..c39ed8d29df1 100644
--- a/net/netfilter/nft_byteorder.c
+++ b/net/netfilter/nft_byteorder.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
@@ -145,23 +145,29 @@ nla_put_failure:
145 return -1; 145 return -1;
146} 146}
147 147
148static struct nft_expr_ops nft_byteorder_ops __read_mostly = { 148static struct nft_expr_type nft_byteorder_type;
149 .name = "byteorder", 149static const struct nft_expr_ops nft_byteorder_ops = {
150 .type = &nft_byteorder_type,
150 .size = NFT_EXPR_SIZE(sizeof(struct nft_byteorder)), 151 .size = NFT_EXPR_SIZE(sizeof(struct nft_byteorder)),
151 .owner = THIS_MODULE,
152 .eval = nft_byteorder_eval, 152 .eval = nft_byteorder_eval,
153 .init = nft_byteorder_init, 153 .init = nft_byteorder_init,
154 .dump = nft_byteorder_dump, 154 .dump = nft_byteorder_dump,
155};
156
157static struct nft_expr_type nft_byteorder_type __read_mostly = {
158 .name = "byteorder",
159 .ops = &nft_byteorder_ops,
155 .policy = nft_byteorder_policy, 160 .policy = nft_byteorder_policy,
156 .maxattr = NFTA_BYTEORDER_MAX, 161 .maxattr = NFTA_BYTEORDER_MAX,
162 .owner = THIS_MODULE,
157}; 163};
158 164
159int __init nft_byteorder_module_init(void) 165int __init nft_byteorder_module_init(void)
160{ 166{
161 return nft_register_expr(&nft_byteorder_ops); 167 return nft_register_expr(&nft_byteorder_type);
162} 168}
163 169
164void nft_byteorder_module_exit(void) 170void nft_byteorder_module_exit(void)
165{ 171{
166 nft_unregister_expr(&nft_byteorder_ops); 172 nft_unregister_expr(&nft_byteorder_type);
167} 173}
diff --git a/net/netfilter/nft_cmp.c b/net/netfilter/nft_cmp.c
index e734d670120a..2c9d5fef2e63 100644
--- a/net/netfilter/nft_cmp.c
+++ b/net/netfilter/nft_cmp.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
@@ -124,23 +124,29 @@ nla_put_failure:
124 return -1; 124 return -1;
125} 125}
126 126
127static struct nft_expr_ops nft_cmp_ops __read_mostly = { 127static struct nft_expr_type nft_cmp_type;
128 .name = "cmp", 128static const struct nft_expr_ops nft_cmp_ops = {
129 .type = &nft_cmp_type,
129 .size = NFT_EXPR_SIZE(sizeof(struct nft_cmp_expr)), 130 .size = NFT_EXPR_SIZE(sizeof(struct nft_cmp_expr)),
130 .owner = THIS_MODULE,
131 .eval = nft_cmp_eval, 131 .eval = nft_cmp_eval,
132 .init = nft_cmp_init, 132 .init = nft_cmp_init,
133 .dump = nft_cmp_dump, 133 .dump = nft_cmp_dump,
134};
135
136static struct nft_expr_type nft_cmp_type __read_mostly = {
137 .name = "cmp",
138 .ops = &nft_cmp_ops,
134 .policy = nft_cmp_policy, 139 .policy = nft_cmp_policy,
135 .maxattr = NFTA_CMP_MAX, 140 .maxattr = NFTA_CMP_MAX,
141 .owner = THIS_MODULE,
136}; 142};
137 143
138int __init nft_cmp_module_init(void) 144int __init nft_cmp_module_init(void)
139{ 145{
140 return nft_register_expr(&nft_cmp_ops); 146 return nft_register_expr(&nft_cmp_type);
141} 147}
142 148
143void nft_cmp_module_exit(void) 149void nft_cmp_module_exit(void)
144{ 150{
145 nft_unregister_expr(&nft_cmp_ops); 151 nft_unregister_expr(&nft_cmp_type);
146} 152}
diff --git a/net/netfilter/nft_counter.c b/net/netfilter/nft_counter.c
index 33c5d36819bb..c89ee486ce54 100644
--- a/net/netfilter/nft_counter.c
+++ b/net/netfilter/nft_counter.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
@@ -78,25 +78,31 @@ static int nft_counter_init(const struct nft_ctx *ctx,
78 return 0; 78 return 0;
79} 79}
80 80
81static struct nft_expr_ops nft_counter_ops __read_mostly = { 81static struct nft_expr_type nft_counter_type;
82 .name = "counter", 82static const struct nft_expr_ops nft_counter_ops = {
83 .type = &nft_counter_type,
83 .size = NFT_EXPR_SIZE(sizeof(struct nft_counter)), 84 .size = NFT_EXPR_SIZE(sizeof(struct nft_counter)),
84 .policy = nft_counter_policy,
85 .maxattr = NFTA_COUNTER_MAX,
86 .owner = THIS_MODULE,
87 .eval = nft_counter_eval, 85 .eval = nft_counter_eval,
88 .init = nft_counter_init, 86 .init = nft_counter_init,
89 .dump = nft_counter_dump, 87 .dump = nft_counter_dump,
90}; 88};
91 89
90static struct nft_expr_type nft_counter_type __read_mostly = {
91 .name = "counter",
92 .ops = &nft_counter_ops,
93 .policy = nft_counter_policy,
94 .maxattr = NFTA_COUNTER_MAX,
95 .owner = THIS_MODULE,
96};
97
92static int __init nft_counter_module_init(void) 98static int __init nft_counter_module_init(void)
93{ 99{
94 return nft_register_expr(&nft_counter_ops); 100 return nft_register_expr(&nft_counter_type);
95} 101}
96 102
97static void __exit nft_counter_module_exit(void) 103static void __exit nft_counter_module_exit(void)
98{ 104{
99 nft_unregister_expr(&nft_counter_ops); 105 nft_unregister_expr(&nft_counter_type);
100} 106}
101 107
102module_init(nft_counter_module_init); 108module_init(nft_counter_module_init);
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index a1756d678226..955f4e6e7089 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.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
@@ -222,26 +222,32 @@ nla_put_failure:
222 return -1; 222 return -1;
223} 223}
224 224
225static struct nft_expr_ops nft_ct_ops __read_mostly = { 225static struct nft_expr_type nft_ct_type;
226 .name = "ct", 226static const struct nft_expr_ops nft_ct_ops = {
227 .type = &nft_ct_type,
227 .size = NFT_EXPR_SIZE(sizeof(struct nft_ct)), 228 .size = NFT_EXPR_SIZE(sizeof(struct nft_ct)),
228 .owner = THIS_MODULE,
229 .eval = nft_ct_eval, 229 .eval = nft_ct_eval,
230 .init = nft_ct_init, 230 .init = nft_ct_init,
231 .destroy = nft_ct_destroy, 231 .destroy = nft_ct_destroy,
232 .dump = nft_ct_dump, 232 .dump = nft_ct_dump,
233};
234
235static struct nft_expr_type nft_ct_type __read_mostly = {
236 .name = "ct",
237 .ops = &nft_ct_ops,
233 .policy = nft_ct_policy, 238 .policy = nft_ct_policy,
234 .maxattr = NFTA_CT_MAX, 239 .maxattr = NFTA_CT_MAX,
240 .owner = THIS_MODULE,
235}; 241};
236 242
237static int __init nft_ct_module_init(void) 243static int __init nft_ct_module_init(void)
238{ 244{
239 return nft_register_expr(&nft_ct_ops); 245 return nft_register_expr(&nft_ct_type);
240} 246}
241 247
242static void __exit nft_ct_module_exit(void) 248static void __exit nft_ct_module_exit(void)
243{ 249{
244 nft_unregister_expr(&nft_ct_ops); 250 nft_unregister_expr(&nft_ct_type);
245} 251}
246 252
247module_init(nft_ct_module_init); 253module_init(nft_ct_module_init);
diff --git a/net/netfilter/nft_expr_template.c b/net/netfilter/nft_expr_template.c
index 9fc8eb308193..b6eed4d5a096 100644
--- a/net/netfilter/nft_expr_template.c
+++ b/net/netfilter/nft_expr_template.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
@@ -33,7 +33,7 @@ static const struct nla_policy nft_template_policy[NFTA_TEMPLATE_MAX + 1] = {
33 33
34static int nft_template_init(const struct nft_ctx *ctx, 34static int nft_template_init(const struct nft_ctx *ctx,
35 const struct nft_expr *expr, 35 const struct nft_expr *expr,
36 const struct nlattr *tb[]) 36 const struct nlattr * const tb[])
37{ 37{
38 struct nft_template *priv = nft_expr_priv(expr); 38 struct nft_template *priv = nft_expr_priv(expr);
39 39
@@ -58,26 +58,32 @@ nla_put_failure:
58 return -1; 58 return -1;
59} 59}
60 60
61static struct nft_expr_ops template_ops __read_mostly = { 61static struct nft_expr_type nft_template_type;
62 .name = "template", 62static const struct nft_expr_ops nft_template_ops = {
63 .type = &nft_template_type,
63 .size = NFT_EXPR_SIZE(sizeof(struct nft_template)), 64 .size = NFT_EXPR_SIZE(sizeof(struct nft_template)),
64 .owner = THIS_MODULE,
65 .eval = nft_template_eval, 65 .eval = nft_template_eval,
66 .init = nft_template_init, 66 .init = nft_template_init,
67 .destroy = nft_template_destroy, 67 .destroy = nft_template_destroy,
68 .dump = nft_template_dump, 68 .dump = nft_template_dump,
69};
70
71static struct nft_expr_type nft_template_type __read_mostly = {
72 .name = "template",
73 .ops = &nft_template_ops,
69 .policy = nft_template_policy, 74 .policy = nft_template_policy,
70 .maxattr = NFTA_TEMPLATE_MAX, 75 .maxattr = NFTA_TEMPLATE_MAX,
76 .owner = THIS_MODULE,
71}; 77};
72 78
73static int __init nft_template_module_init(void) 79static int __init nft_template_module_init(void)
74{ 80{
75 return nft_register_expr(&template_ops); 81 return nft_register_expr(&nft_template_type);
76} 82}
77 83
78static void __exit nft_template_module_exit(void) 84static void __exit nft_template_module_exit(void)
79{ 85{
80 nft_unregister_expr(&template_ops); 86 nft_unregister_expr(&nft_template_type);
81} 87}
82 88
83module_init(nft_template_module_init); 89module_init(nft_template_module_init);
diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index 21c6a6b7b662..8e0bb75e7c51 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -98,25 +98,31 @@ nla_put_failure:
98 return -1; 98 return -1;
99} 99}
100 100
101static struct nft_expr_ops exthdr_ops __read_mostly = { 101static struct nft_expr_type nft_exthdr_type;
102 .name = "exthdr", 102static const struct nft_expr_ops nft_exthdr_ops = {
103 .type = &nft_exthdr_type,
103 .size = NFT_EXPR_SIZE(sizeof(struct nft_exthdr)), 104 .size = NFT_EXPR_SIZE(sizeof(struct nft_exthdr)),
104 .owner = THIS_MODULE,
105 .eval = nft_exthdr_eval, 105 .eval = nft_exthdr_eval,
106 .init = nft_exthdr_init, 106 .init = nft_exthdr_init,
107 .dump = nft_exthdr_dump, 107 .dump = nft_exthdr_dump,
108};
109
110static struct nft_expr_type nft_exthdr_type __read_mostly = {
111 .name = "exthdr",
112 .ops = &nft_exthdr_ops,
108 .policy = nft_exthdr_policy, 113 .policy = nft_exthdr_policy,
109 .maxattr = NFTA_EXTHDR_MAX, 114 .maxattr = NFTA_EXTHDR_MAX,
115 .owner = THIS_MODULE,
110}; 116};
111 117
112static int __init nft_exthdr_module_init(void) 118static int __init nft_exthdr_module_init(void)
113{ 119{
114 return nft_register_expr(&exthdr_ops); 120 return nft_register_expr(&nft_exthdr_type);
115} 121}
116 122
117static void __exit nft_exthdr_module_exit(void) 123static void __exit nft_exthdr_module_exit(void)
118{ 124{
119 nft_unregister_expr(&exthdr_ops); 125 nft_unregister_expr(&nft_exthdr_type);
120} 126}
121 127
122module_init(nft_exthdr_module_init); 128module_init(nft_exthdr_module_init);
diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c
index 78334bf37007..1bfeeaf865b6 100644
--- a/net/netfilter/nft_immediate.c
+++ b/net/netfilter/nft_immediate.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
@@ -100,25 +100,31 @@ static const struct nft_data *nft_immediate_get_verdict(const struct nft_expr *e
100 return NULL; 100 return NULL;
101} 101}
102 102
103static struct nft_expr_ops nft_imm_ops __read_mostly = { 103static struct nft_expr_type nft_imm_type;
104 .name = "immediate", 104static const struct nft_expr_ops nft_imm_ops = {
105 .type = &nft_imm_type,
105 .size = NFT_EXPR_SIZE(sizeof(struct nft_immediate_expr)), 106 .size = NFT_EXPR_SIZE(sizeof(struct nft_immediate_expr)),
106 .owner = THIS_MODULE,
107 .eval = nft_immediate_eval, 107 .eval = nft_immediate_eval,
108 .init = nft_immediate_init, 108 .init = nft_immediate_init,
109 .destroy = nft_immediate_destroy, 109 .destroy = nft_immediate_destroy,
110 .dump = nft_immediate_dump, 110 .dump = nft_immediate_dump,
111 .get_verdict = nft_immediate_get_verdict, 111 .get_verdict = nft_immediate_get_verdict,
112};
113
114static struct nft_expr_type nft_imm_type __read_mostly = {
115 .name = "immediate",
116 .ops = &nft_imm_ops,
112 .policy = nft_immediate_policy, 117 .policy = nft_immediate_policy,
113 .maxattr = NFTA_IMMEDIATE_MAX, 118 .maxattr = NFTA_IMMEDIATE_MAX,
119 .owner = THIS_MODULE,
114}; 120};
115 121
116int __init nft_immediate_module_init(void) 122int __init nft_immediate_module_init(void)
117{ 123{
118 return nft_register_expr(&nft_imm_ops); 124 return nft_register_expr(&nft_imm_type);
119} 125}
120 126
121void nft_immediate_module_exit(void) 127void nft_immediate_module_exit(void)
122{ 128{
123 nft_unregister_expr(&nft_imm_ops); 129 nft_unregister_expr(&nft_imm_type);
124} 130}
diff --git a/net/netfilter/nft_limit.c b/net/netfilter/nft_limit.c
index e0e3fc8aebc3..85da5bd02f64 100644
--- a/net/netfilter/nft_limit.c
+++ b/net/netfilter/nft_limit.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
@@ -84,25 +84,31 @@ nla_put_failure:
84 return -1; 84 return -1;
85} 85}
86 86
87static struct nft_expr_ops nft_limit_ops __read_mostly = { 87static struct nft_expr_type nft_limit_type;
88 .name = "limit", 88static const struct nft_expr_ops nft_limit_ops = {
89 .type = &nft_limit_type,
89 .size = NFT_EXPR_SIZE(sizeof(struct nft_limit)), 90 .size = NFT_EXPR_SIZE(sizeof(struct nft_limit)),
90 .owner = THIS_MODULE,
91 .eval = nft_limit_eval, 91 .eval = nft_limit_eval,
92 .init = nft_limit_init, 92 .init = nft_limit_init,
93 .dump = nft_limit_dump, 93 .dump = nft_limit_dump,
94};
95
96static struct nft_expr_type nft_limit_type __read_mostly = {
97 .name = "limit",
98 .ops = &nft_limit_ops,
94 .policy = nft_limit_policy, 99 .policy = nft_limit_policy,
95 .maxattr = NFTA_LIMIT_MAX, 100 .maxattr = NFTA_LIMIT_MAX,
101 .owner = THIS_MODULE,
96}; 102};
97 103
98static int __init nft_limit_module_init(void) 104static int __init nft_limit_module_init(void)
99{ 105{
100 return nft_register_expr(&nft_limit_ops); 106 return nft_register_expr(&nft_limit_type);
101} 107}
102 108
103static void __exit nft_limit_module_exit(void) 109static void __exit nft_limit_module_exit(void)
104{ 110{
105 nft_unregister_expr(&nft_limit_ops); 111 nft_unregister_expr(&nft_limit_type);
106} 112}
107 113
108module_init(nft_limit_module_init); 114module_init(nft_limit_module_init);
diff --git a/net/netfilter/nft_log.c b/net/netfilter/nft_log.c
index da495c3b1e7e..57cad072a13e 100644
--- a/net/netfilter/nft_log.c
+++ b/net/netfilter/nft_log.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
@@ -110,26 +110,32 @@ nla_put_failure:
110 return -1; 110 return -1;
111} 111}
112 112
113static struct nft_expr_ops nft_log_ops __read_mostly = { 113static struct nft_expr_type nft_log_type;
114 .name = "log", 114static const struct nft_expr_ops nft_log_ops = {
115 .type = &nft_log_type,
115 .size = NFT_EXPR_SIZE(sizeof(struct nft_log)), 116 .size = NFT_EXPR_SIZE(sizeof(struct nft_log)),
116 .owner = THIS_MODULE,
117 .eval = nft_log_eval, 117 .eval = nft_log_eval,
118 .init = nft_log_init, 118 .init = nft_log_init,
119 .destroy = nft_log_destroy, 119 .destroy = nft_log_destroy,
120 .dump = nft_log_dump, 120 .dump = nft_log_dump,
121};
122
123static struct nft_expr_type nft_log_type __read_mostly = {
124 .name = "log",
125 .ops = &nft_log_ops,
121 .policy = nft_log_policy, 126 .policy = nft_log_policy,
122 .maxattr = NFTA_LOG_MAX, 127 .maxattr = NFTA_LOG_MAX,
128 .owner = THIS_MODULE,
123}; 129};
124 130
125static int __init nft_log_module_init(void) 131static int __init nft_log_module_init(void)
126{ 132{
127 return nft_register_expr(&nft_log_ops); 133 return nft_register_expr(&nft_log_type);
128} 134}
129 135
130static void __exit nft_log_module_exit(void) 136static void __exit nft_log_module_exit(void)
131{ 137{
132 nft_unregister_expr(&nft_log_ops); 138 nft_unregister_expr(&nft_log_type);
133} 139}
134 140
135module_init(nft_log_module_init); 141module_init(nft_log_module_init);
diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
index 4962d2173678..8a6116b75b5a 100644
--- a/net/netfilter/nft_lookup.c
+++ b/net/netfilter/nft_lookup.c
@@ -112,24 +112,30 @@ nla_put_failure:
112 return -1; 112 return -1;
113} 113}
114 114
115static struct nft_expr_ops nft_lookup_ops __read_mostly = { 115static struct nft_expr_type nft_lookup_type;
116 .name = "lookup", 116static const struct nft_expr_ops nft_lookup_ops = {
117 .type = &nft_lookup_type,
117 .size = NFT_EXPR_SIZE(sizeof(struct nft_lookup)), 118 .size = NFT_EXPR_SIZE(sizeof(struct nft_lookup)),
118 .owner = THIS_MODULE,
119 .eval = nft_lookup_eval, 119 .eval = nft_lookup_eval,
120 .init = nft_lookup_init, 120 .init = nft_lookup_init,
121 .destroy = nft_lookup_destroy, 121 .destroy = nft_lookup_destroy,
122 .dump = nft_lookup_dump, 122 .dump = nft_lookup_dump,
123};
124
125static struct nft_expr_type nft_lookup_type __read_mostly = {
126 .name = "lookup",
127 .ops = &nft_lookup_ops,
123 .policy = nft_lookup_policy, 128 .policy = nft_lookup_policy,
124 .maxattr = NFTA_LOOKUP_MAX, 129 .maxattr = NFTA_LOOKUP_MAX,
130 .owner = THIS_MODULE,
125}; 131};
126 132
127int __init nft_lookup_module_init(void) 133int __init nft_lookup_module_init(void)
128{ 134{
129 return nft_register_expr(&nft_lookup_ops); 135 return nft_register_expr(&nft_lookup_type);
130} 136}
131 137
132void nft_lookup_module_exit(void) 138void nft_lookup_module_exit(void)
133{ 139{
134 nft_unregister_expr(&nft_lookup_ops); 140 nft_unregister_expr(&nft_lookup_type);
135} 141}
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 96735aa2f039..8c28220a90b3 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.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
@@ -193,25 +193,31 @@ nla_put_failure:
193 return -1; 193 return -1;
194} 194}
195 195
196static struct nft_expr_ops nft_meta_ops __read_mostly = { 196static struct nft_expr_type nft_meta_type;
197 .name = "meta", 197static const struct nft_expr_ops nft_meta_ops = {
198 .type = &nft_meta_type,
198 .size = NFT_EXPR_SIZE(sizeof(struct nft_meta)), 199 .size = NFT_EXPR_SIZE(sizeof(struct nft_meta)),
199 .owner = THIS_MODULE,
200 .eval = nft_meta_eval, 200 .eval = nft_meta_eval,
201 .init = nft_meta_init, 201 .init = nft_meta_init,
202 .dump = nft_meta_dump, 202 .dump = nft_meta_dump,
203};
204
205static struct nft_expr_type nft_meta_type __read_mostly = {
206 .name = "meta",
207 .ops = &nft_meta_ops,
203 .policy = nft_meta_policy, 208 .policy = nft_meta_policy,
204 .maxattr = NFTA_META_MAX, 209 .maxattr = NFTA_META_MAX,
210 .owner = THIS_MODULE,
205}; 211};
206 212
207static int __init nft_meta_module_init(void) 213static int __init nft_meta_module_init(void)
208{ 214{
209 return nft_register_expr(&nft_meta_ops); 215 return nft_register_expr(&nft_meta_type);
210} 216}
211 217
212static void __exit nft_meta_module_exit(void) 218static void __exit nft_meta_module_exit(void)
213{ 219{
214 nft_unregister_expr(&nft_meta_ops); 220 nft_unregister_expr(&nft_meta_type);
215} 221}
216 222
217module_init(nft_meta_module_init); 223module_init(nft_meta_module_init);
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 329f134b3f89..d99db6e37fb1 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.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
@@ -115,23 +115,29 @@ nla_put_failure:
115 return -1; 115 return -1;
116} 116}
117 117
118static struct nft_expr_ops nft_payload_ops __read_mostly = { 118static struct nft_expr_type nft_payload_type;
119 .name = "payload", 119static const struct nft_expr_ops nft_payload_ops = {
120 .type = &nft_payload_type,
120 .size = NFT_EXPR_SIZE(sizeof(struct nft_payload)), 121 .size = NFT_EXPR_SIZE(sizeof(struct nft_payload)),
121 .owner = THIS_MODULE,
122 .eval = nft_payload_eval, 122 .eval = nft_payload_eval,
123 .init = nft_payload_init, 123 .init = nft_payload_init,
124 .dump = nft_payload_dump, 124 .dump = nft_payload_dump,
125};
126
127static struct nft_expr_type nft_payload_type __read_mostly = {
128 .name = "payload",
129 .ops = &nft_payload_ops,
125 .policy = nft_payload_policy, 130 .policy = nft_payload_policy,
126 .maxattr = NFTA_PAYLOAD_MAX, 131 .maxattr = NFTA_PAYLOAD_MAX,
132 .owner = THIS_MODULE,
127}; 133};
128 134
129int __init nft_payload_module_init(void) 135int __init nft_payload_module_init(void)
130{ 136{
131 return nft_register_expr(&nft_payload_ops); 137 return nft_register_expr(&nft_payload_type);
132} 138}
133 139
134void nft_payload_module_exit(void) 140void nft_payload_module_exit(void)
135{ 141{
136 nft_unregister_expr(&nft_payload_ops); 142 nft_unregister_expr(&nft_payload_type);
137} 143}