Commit 4470bbc7 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NETFILTER]: x_tables: make use of mass registation helpers

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 52d9c42e
...@@ -257,9 +257,7 @@ static struct ip6t_target ip6t_reject_reg = { ...@@ -257,9 +257,7 @@ static struct ip6t_target ip6t_reject_reg = {
static int __init ip6t_reject_init(void) static int __init ip6t_reject_init(void)
{ {
if (ip6t_register_target(&ip6t_reject_reg)) return ip6t_register_target(&ip6t_reject_reg);
return -EINVAL;
return 0;
} }
static void __exit ip6t_reject_fini(void) static void __exit ip6t_reject_fini(void)
......
...@@ -40,47 +40,41 @@ target(struct sk_buff **pskb, ...@@ -40,47 +40,41 @@ target(struct sk_buff **pskb,
return XT_CONTINUE; return XT_CONTINUE;
} }
static struct xt_target classify_reg = { static struct xt_target xt_classify_target[] = {
.name = "CLASSIFY", {
.target = target, .family = AF_INET,
.targetsize = sizeof(struct xt_classify_target_info), .name = "CLASSIFY",
.table = "mangle", .target = target,
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) | .targetsize = sizeof(struct xt_classify_target_info),
(1 << NF_IP_POST_ROUTING), .table = "mangle",
.family = AF_INET, .hooks = (1 << NF_IP_LOCAL_OUT) |
.me = THIS_MODULE, (1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING),
.me = THIS_MODULE,
},
{
.name = "CLASSIFY",
.family = AF_INET6,
.target = target,
.targetsize = sizeof(struct xt_classify_target_info),
.table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) |
(1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING),
.me = THIS_MODULE,
},
}; };
static struct xt_target classify6_reg = {
.name = "CLASSIFY",
.target = target,
.targetsize = sizeof(struct xt_classify_target_info),
.table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING),
.family = AF_INET6,
.me = THIS_MODULE,
};
static int __init xt_classify_init(void) static int __init xt_classify_init(void)
{ {
int ret; return xt_register_targets(xt_classify_target,
ARRAY_SIZE(xt_classify_target));
ret = xt_register_target(&classify_reg);
if (ret)
return ret;
ret = xt_register_target(&classify6_reg);
if (ret)
xt_unregister_target(&classify_reg);
return ret;
} }
static void __exit xt_classify_fini(void) static void __exit xt_classify_fini(void)
{ {
xt_unregister_target(&classify_reg); xt_unregister_targets(xt_classify_target,
xt_unregister_target(&classify6_reg); ARRAY_SIZE(xt_classify_target));
} }
module_init(xt_classify_init); module_init(xt_classify_init);
......
...@@ -110,45 +110,36 @@ checkentry(const char *tablename, ...@@ -110,45 +110,36 @@ checkentry(const char *tablename,
return 1; return 1;
} }
static struct xt_target connmark_reg = { static struct xt_target xt_connmark_target[] = {
.name = "CONNMARK", {
.target = target, .name = "CONNMARK",
.targetsize = sizeof(struct xt_connmark_target_info), .family = AF_INET,
.checkentry = checkentry, .checkentry = checkentry,
.family = AF_INET, .target = target,
.me = THIS_MODULE .targetsize = sizeof(struct xt_connmark_target_info),
}; .me = THIS_MODULE
},
static struct xt_target connmark6_reg = { {
.name = "CONNMARK", .name = "CONNMARK",
.target = target, .family = AF_INET6,
.targetsize = sizeof(struct xt_connmark_target_info), .checkentry = checkentry,
.checkentry = checkentry, .target = target,
.family = AF_INET6, .targetsize = sizeof(struct xt_connmark_target_info),
.me = THIS_MODULE .me = THIS_MODULE
},
}; };
static int __init xt_connmark_init(void) static int __init xt_connmark_init(void)
{ {
int ret;
need_conntrack(); need_conntrack();
return xt_register_targets(xt_connmark_target,
ret = xt_register_target(&connmark_reg); ARRAY_SIZE(xt_connmark_target));
if (ret)
return ret;
ret = xt_register_target(&connmark6_reg);
if (ret)
xt_unregister_target(&connmark_reg);
return ret;
} }
static void __exit xt_connmark_fini(void) static void __exit xt_connmark_fini(void)
{ {
xt_unregister_target(&connmark_reg); xt_unregister_targets(xt_connmark_target,
xt_unregister_target(&connmark6_reg); ARRAY_SIZE(xt_connmark_target));
} }
module_init(xt_connmark_init); module_init(xt_connmark_init);
......
...@@ -106,49 +106,38 @@ static int checkentry(const char *tablename, const void *entry, ...@@ -106,49 +106,38 @@ static int checkentry(const char *tablename, const void *entry,
return 1; return 1;
} }
static struct xt_target ipt_connsecmark_reg = { static struct xt_target xt_connsecmark_target[] = {
.name = "CONNSECMARK", {
.target = target, .name = "CONNSECMARK",
.targetsize = sizeof(struct xt_connsecmark_target_info), .family = AF_INET,
.table = "mangle", .checkentry = checkentry,
.checkentry = checkentry, .target = target,
.me = THIS_MODULE, .targetsize = sizeof(struct xt_connsecmark_target_info),
.family = AF_INET, .table = "mangle",
.revision = 0, .me = THIS_MODULE,
}; },
{
static struct xt_target ip6t_connsecmark_reg = { .name = "CONNSECMARK",
.name = "CONNSECMARK", .family = AF_INET6,
.target = target, .checkentry = checkentry,
.targetsize = sizeof(struct xt_connsecmark_target_info), .target = target,
.table = "mangle", .targetsize = sizeof(struct xt_connsecmark_target_info),
.checkentry = checkentry, .table = "mangle",
.me = THIS_MODULE, .me = THIS_MODULE,
.family = AF_INET6, },
.revision = 0,
}; };
static int __init xt_connsecmark_init(void) static int __init xt_connsecmark_init(void)
{ {
int err;
need_conntrack(); need_conntrack();
return xt_register_targets(xt_connsecmark_targets,
err = xt_register_target(&ipt_connsecmark_reg); ARRAY_SIZE(xt_connsecmark_targets));
if (err)
return err;
err = xt_register_target(&ip6t_connsecmark_reg);
if (err)
xt_unregister_target(&ipt_connsecmark_reg);
return err;
} }
static void __exit xt_connsecmark_fini(void) static void __exit xt_connsecmark_fini(void)
{ {
xt_unregister_target(&ip6t_connsecmark_reg); xt_unregister_targets(xt_connsecmark_targets,
xt_unregister_target(&ipt_connsecmark_reg); ARRAY_SIZE(xt_connsecmark_targets));
} }
module_init(xt_connsecmark_init); module_init(xt_connsecmark_init);
......
...@@ -86,44 +86,35 @@ static int checkentry(const char *tablename, ...@@ -86,44 +86,35 @@ static int checkentry(const char *tablename,
return 1; return 1;
} }
static struct xt_target xt_dscp_reg = { static struct xt_target xt_dscp_target[] = {
.name = "DSCP", {
.target = target, .name = "DSCP",
.targetsize = sizeof(struct xt_DSCP_info), .family = AF_INET,
.table = "mangle", .checkentry = checkentry,
.checkentry = checkentry, .target = target,
.family = AF_INET, .targetsize = sizeof(struct xt_DSCP_info),
.me = THIS_MODULE, .table = "mangle",
}; .me = THIS_MODULE,
},
static struct xt_target xt_dscp6_reg = { {
.name = "DSCP", .name = "DSCP",
.target = target6, .family = AF_INET6,
.targetsize = sizeof(struct xt_DSCP_info), .checkentry = checkentry,
.table = "mangle", .target = target6,
.checkentry = checkentry, .targetsize = sizeof(struct xt_DSCP_info),
.family = AF_INET6, .table = "mangle",
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_dscp_target_init(void) static int __init xt_dscp_target_init(void)
{ {
int ret; return xt_register_targets(xt_dscp_target, ARRAY_SIZE(xt_dscp_target));
ret = xt_register_target(&xt_dscp_reg);
if (ret)
return ret;
ret = xt_register_target(&xt_dscp6_reg);
if (ret)
xt_unregister_target(&xt_dscp_reg);
return ret;
} }
static void __exit xt_dscp_target_fini(void) static void __exit xt_dscp_target_fini(void)
{ {
xt_unregister_target(&xt_dscp_reg); xt_unregister_targets(xt_dscp_target, ARRAY_SIZE(xt_dscp_target));
xt_unregister_target(&xt_dscp6_reg);
} }
module_init(xt_dscp_target_init); module_init(xt_dscp_target_init);
......
...@@ -112,65 +112,47 @@ checkentry_v1(const char *tablename, ...@@ -112,65 +112,47 @@ checkentry_v1(const char *tablename,
return 1; return 1;
} }
static struct xt_target ipt_mark_reg_v0 = { static struct xt_target xt_mark_target[] = {
.name = "MARK", {
.target = target_v0, .name = "MARK",
.targetsize = sizeof(struct xt_mark_target_info), .family = AF_INET,
.table = "mangle", .revision = 0,
.checkentry = checkentry_v0, .checkentry = checkentry_v0,
.me = THIS_MODULE, .target = target_v0,
.family = AF_INET, .targetsize = sizeof(struct xt_mark_target_info),
.revision = 0, .table = "mangle",
}; .me = THIS_MODULE,
},
static struct xt_target ipt_mark_reg_v1 = { {
.name = "MARK", .name = "MARK",
.target = target_v1, .family = AF_INET,
.targetsize = sizeof(struct xt_mark_target_info_v1), .revision = 1,
.table = "mangle", .checkentry = checkentry_v1,
.checkentry = checkentry_v1, .target = target_v1,
.me = THIS_MODULE, .targetsize = sizeof(struct xt_mark_target_info_v1),
.family = AF_INET, .table = "mangle",
.revision = 1, .me = THIS_MODULE,
}; },
{
static struct xt_target ip6t_mark_reg_v0 = { .name = "MARK",
.name = "MARK", .family = AF_INET6,
.target = target_v0, .revision = 0,
.targetsize = sizeof(struct xt_mark_target_info), .checkentry = checkentry_v0,
.table = "mangle", .target = target_v0,
.checkentry = checkentry_v0, .targetsize = sizeof(struct xt_mark_target_info),
.me = THIS_MODULE, .table = "mangle",
.family = AF_INET6, .me = THIS_MODULE,
.revision = 0, },
}; };
static int __init xt_mark_init(void) static int __init xt_mark_init(void)
{ {
int err; return xt_register_targets(xt_mark_target, ARRAY_SIZE(xt_mark_target));
err = xt_register_target(&ipt_mark_reg_v0);
if (err)
return err;
err = xt_register_target(&ipt_mark_reg_v1);
if (err)
xt_unregister_target(&ipt_mark_reg_v0);
err = xt_register_target(&ip6t_mark_reg_v0);
if (err) {
xt_unregister_target(&ipt_mark_reg_v0);
xt_unregister_target(&ipt_mark_reg_v1);
}
return err;
} }
static void __exit xt_mark_fini(void) static void __exit xt_mark_fini(void)
{ {
xt_unregister_target(&ipt_mark_reg_v0); xt_unregister_targets(xt_mark_target, ARRAY_SIZE(xt_mark_target));
xt_unregister_target(&ipt_mark_reg_v1);
xt_unregister_target(&ip6t_mark_reg_v0);
} }
module_init(xt_mark_init); module_init(xt_mark_init);
......
...@@ -37,57 +37,39 @@ target(struct sk_buff **pskb, ...@@ -37,57 +37,39 @@ target(struct sk_buff **pskb,
return NF_QUEUE_NR(tinfo->queuenum); return NF_QUEUE_NR(tinfo->queuenum);
} }
static struct xt_target ipt_NFQ_reg = { static struct xt_target xt_nfqueue_target[] = {
.name = "NFQUEUE", {
.target = target, .name = "NFQUEUE",
.targetsize = sizeof(struct xt_NFQ_info), .family = AF_INET,
.family = AF_INET, .target = target,
.me = THIS_MODULE, .targetsize = sizeof(struct xt_NFQ_info),
}; .me = THIS_MODULE,
},
static struct xt_target ip6t_NFQ_reg = { {
.name = "NFQUEUE", .name = "NFQUEUE",
.target = target, .family = AF_INET6,
.targetsize = sizeof(struct xt_NFQ_info), .target = target,
.family = AF_INET6, .targetsize = sizeof(struct xt_NFQ_info),
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_target arpt_NFQ_reg = { .name = "NFQUEUE",
.name = "NFQUEUE", .family = NF_ARP,
.target = target, .target = target,
.targetsize = sizeof(struct xt_NFQ_info), .targetsize = sizeof(struct xt_NFQ_info),
.family = NF_ARP, .me = THIS_MODULE,
.me = THIS_MODULE, },
}; };
static int __init xt_nfqueue_init(void) static int __init xt_nfqueue_init(void)
{ {
int ret; return xt_register_targets(xt_nfqueue_target,
ret = xt_register_target(&ipt_NFQ_reg); ARRAY_SIZE(xt_nfqueue_target));
if (ret)
return ret;
ret = xt_register_target(&ip6t_NFQ_reg);
if (ret)
goto out_ip;
ret = xt_register_target(&arpt_NFQ_reg);
if (ret)
goto out_ip6;
return ret;
out_ip6:
xt_unregister_target(&ip6t_NFQ_reg);
out_ip:
xt_unregister_target(&ipt_NFQ_reg);
return ret;
} }
static void __exit xt_nfqueue_fini(void) static void __exit xt_nfqueue_fini(void)
{ {
xt_unregister_target(&arpt_NFQ_reg); xt_register_targets(xt_nfqueue_target, ARRAY_SIZE(xt_nfqueue_target));
xt_unregister_target(&ip6t_NFQ_reg);
xt_unregister_target(&ipt_NFQ_reg);
} }
module_init(xt_nfqueue_init); module_init(xt_nfqueue_init);
......
...@@ -34,43 +34,32 @@ target(struct sk_buff **pskb, ...@@ -34,43 +34,32 @@ target(struct sk_buff **pskb,
return XT_CONTINUE; return XT_CONTINUE;
} }
static struct xt_target notrack_reg = { static struct xt_target xt_notrack_target[] = {
.name = "NOTRACK", {
.target = target, .name = "NOTRACK",
.targetsize = 0, .family = AF_INET,
.table = "raw", .target = target,
.family = AF_INET, .table = "raw",
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_target notrack6_reg = { .name = "NOTRACK",
.name = "NOTRACK", .family = AF_INET6,
.target = target, .target = target,
.targetsize = 0, .table = "raw",
.table = "raw", .me = THIS_MODULE,
.family = AF_INET6, },
.me = THIS_MODULE,
}; };
static int __init xt_notrack_init(void) static int __init xt_notrack_init(void)
{ {
int ret; return xt_register_targets(xt_notrack_target,
ARRAY_SIZE(xt_notrack_target));
ret = xt_register_target(&notrack_reg);
if (ret)
return ret;
ret = xt_register_target(&notrack6_reg);
if (ret)
xt_unregister_target(&notrack_reg);
return ret;
} }
static void __exit xt_notrack_fini(void) static void __exit xt_notrack_fini(void)
{ {
xt_unregister_target(&notrack6_reg); xt_unregister_targets(xt_notrack_target, ARRAY_SIZE(xt_notrack_target));
xt_unregister_target(&notrack_reg);
} }
module_init(xt_notrack_init); module_init(xt_notrack_init);
......
...@@ -111,47 +111,36 @@ static int checkentry(const char *tablename, const void *entry, ...@@ -111,47 +111,36 @@ static int checkentry(const char *tablename, const void *entry,
return 1; return 1;
} }
static struct xt_target ipt_secmark_reg = { static struct xt_target xt_secmark_target = {
.name = "SECMARK", {
.target = target, .name = "SECMARK",
.targetsize = sizeof(struct xt_secmark_target_info), .family = AF_INET,
.table = "mangle", .checkentry = checkentry,
.checkentry = checkentry, .target = target,
.me = THIS_MODULE, .targetsize = sizeof(struct xt_secmark_target_info),
.family = AF_INET, .table = "mangle",
.revision = 0, .me = THIS_MODULE,
}; },
{
static struct xt_target ip6t_secmark_reg = { .name = "SECMARK",
.name = "SECMARK", .family = AF_INET6,
.target = target, .checkentry = checkentry,
.targetsize = sizeof(struct xt_secmark_target_info), .target = target,
.table = "mangle", .targetsize = sizeof(struct xt_secmark_target_info),
.checkentry = checkentry, .table = "mangle",
.me = THIS_MODULE, .me = THIS_MODULE,
.family = AF_INET6, },
.revision = 0,
}; };
static int __init xt_secmark_init(void) static int __init xt_secmark_init(void)
{ {
int err; return xt_register_targets(xt_secmark_target,
ARRAY_SIZE(xt_secmark_target));
err = xt_register_target(&ipt_secmark_reg);
if (err)
return err;
err = xt_register_target(&ip6t_secmark_reg);
if (err)
xt_unregister_target(&ipt_secmark_reg);
return err;
} }
static void __exit xt_secmark_fini(void) static void __exit xt_secmark_fini(void)
{ {
xt_unregister_target(&ip6t_secmark_reg); xt_unregister_targets(xt_secmark_target, ARRAY_SIZE(xt_secmark_target));
xt_unregister_target(&ipt_secmark_reg);
} }
module_init(xt_secmark_init); module_init(xt_secmark_init);
......
...@@ -29,41 +29,32 @@ match(const struct sk_buff *skb, ...@@ -29,41 +29,32 @@ match(const struct sk_buff *skb,
return 1; return 1;
} }
static struct xt_match comment_match = { static struct xt_match xt_comment_match[] = {
.name = "comment", {
.match = match, .name = "comment",
.matchsize = sizeof(struct xt_comment_info), .family = AF_INET,
.family = AF_INET, .match = match,
.me = THIS_MODULE .matchsize = sizeof(struct xt_comment_info),
}; .me = THIS_MODULE
},
static struct xt_match comment6_match = { {
.name = "comment", .name = "comment",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_comment_info), .match = match,
.family = AF_INET6, .matchsize = sizeof(struct xt_comment_info),
.me = THIS_MODULE .me = THIS_MODULE
},
}; };
static int __init xt_comment_init(void) static int __init xt_comment_init(void)
{ {
int ret; return xt_register_matches(xt_comment_match,
ARRAY_SIZE(xt_comment_match));
ret = xt_register_match(&comment_match);
if (ret)
return ret;
ret = xt_register_match(&comment6_match);
if (ret)
xt_unregister_match(&comment_match);
return ret;
} }
static void __exit xt_comment_fini(void) static void __exit xt_comment_fini(void)
{ {
xt_unregister_match(&comment_match); xt_unregister_matches(xt_comment_match, ARRAY_SIZE(xt_comment_match));
xt_unregister_match(&comment6_match);
} }
module_init(xt_comment_init); module_init(xt_comment_init);
......
...@@ -143,40 +143,35 @@ static int check(const char *tablename, ...@@ -143,40 +143,35 @@ static int check(const char *tablename,
return 1; return 1;
} }
static struct xt_match connbytes_match = { static struct xt_match xt_connbytes_match = {
.name = "connbytes", {
.match = match, .name = "connbytes",
.checkentry = check, .family = AF_INET,
.matchsize = sizeof(struct xt_connbytes_info), .checkentry = check,
.family = AF_INET, .match = match,
.me = THIS_MODULE .matchsize = sizeof(struct xt_connbytes_info),
}; .me = THIS_MODULE
static struct xt_match connbytes6_match = { },
.name = "connbytes", {
.match = match, .name = "connbytes",
.checkentry = check, .family = AF_INET6,
.matchsize = sizeof(struct xt_connbytes_info), .checkentry = check,
.family = AF_INET6, .match = match,
.me = THIS_MODULE .matchsize = sizeof(struct xt_connbytes_info),
.me = THIS_MODULE
},
}; };
static int __init xt_connbytes_init(void) static int __init xt_connbytes_init(void)
{ {
int ret; return xt_register_matches(xt_connbytes_match,
ret = xt_register_match(&connbytes_match); ARRAY_SIZE(xt_connbytes_match));
if (ret)
return ret;
ret = xt_register_match(&connbytes6_match);
if (ret)
xt_unregister_match(&connbytes_match);
return ret;
} }
static void __exit xt_connbytes_fini(void) static void __exit xt_connbytes_fini(void)
{ {
xt_unregister_match(&connbytes_match); xt_unregister_matches(xt_connbytes_match,
xt_unregister_match(&connbytes6_match); ARRAY_SIZE(xt_connbytes_match));
} }
module_init(xt_connbytes_init); module_init(xt_connbytes_init);
......
...@@ -82,46 +82,37 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize) ...@@ -82,46 +82,37 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
#endif #endif
} }
static struct xt_match connmark_match = { static struct xt_match xt_connmark_match[] = {
.name = "connmark", {
.match = match, .name = "connmark",
.matchsize = sizeof(struct xt_connmark_info), .family = AF_INET,
.checkentry = checkentry, .checkentry = checkentry,
.destroy = destroy, .match = match,
.family = AF_INET, .destroy = destroy,
.me = THIS_MODULE .matchsize = sizeof(struct xt_connmark_info),
}; .me = THIS_MODULE
},
static struct xt_match connmark6_match = { {
.name = "connmark", .name = "connmark",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_connmark_info), .checkentry = checkentry,
.checkentry = checkentry, .match = match,
.destroy = destroy, .destroy = destroy,
.family = AF_INET6, .matchsize = sizeof(struct xt_connmark_info),
.me = THIS_MODULE .me = THIS_MODULE
},
}; };
static int __init xt_connmark_init(void) static int __init xt_connmark_init(void)
{ {
int ret;
need_conntrack(); need_conntrack();
return xt_register_matches(xt_connmark_match,
ret = xt_register_match(&connmark_match); ARRAY_SIZE(xt_connmark_match));
if (ret)
return ret;
ret = xt_register_match(&connmark6_match);
if (ret)
xt_unregister_match(&connmark_match);
return ret;
} }
static void __exit xt_connmark_fini(void) static void __exit xt_connmark_fini(void)
{ {
xt_unregister_match(&connmark6_match); xt_register_matches(xt_connmark_match, ARRAY_SIZE(xt_connmark_match));
xt_unregister_match(&connmark_match);
} }
module_init(xt_connmark_init); module_init(xt_connmark_init);
......
...@@ -241,11 +241,8 @@ static struct xt_match conntrack_match = { ...@@ -241,11 +241,8 @@ static struct xt_match conntrack_match = {
static int __init xt_conntrack_init(void) static int __init xt_conntrack_init(void)
{ {
int ret;
need_conntrack(); need_conntrack();
ret = xt_register_match(&conntrack_match); return xt_register_match(&conntrack_match);
return ret;
} }
static void __exit xt_conntrack_fini(void) static void __exit xt_conntrack_fini(void)
......
...@@ -141,27 +141,26 @@ checkentry(const char *tablename, ...@@ -141,27 +141,26 @@ checkentry(const char *tablename,
&& !(info->invflags & ~info->flags); && !(info->invflags & ~info->flags);
} }
static struct xt_match dccp_match = static struct xt_match xt_dccp_match[] = {
{ {
.name = "dccp", .name = "dccp",
.match = match, .family = AF_INET,
.matchsize = sizeof(struct xt_dccp_info), .checkentry = checkentry,
.proto = IPPROTO_DCCP, .match = match,
.checkentry = checkentry, .matchsize = sizeof(struct xt_dccp_info),
.family = AF_INET, .proto = IPPROTO_DCCP,
.me = THIS_MODULE, .me = THIS_MODULE,
},
{
.name = "dccp",
.family = AF_INET6,
.checkentry = checkentry,
.match = match,
.matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP,
.me = THIS_MODULE,
},
}; };
static struct xt_match dccp6_match =
{
.name = "dccp",
.match = match,
.matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP,
.checkentry = checkentry,
.family = AF_INET6,
.me = THIS_MODULE,
};
static int __init xt_dccp_init(void) static int __init xt_dccp_init(void)
{ {
...@@ -173,27 +172,19 @@ static int __init xt_dccp_init(void) ...@@ -173,27 +172,19 @@ static int __init xt_dccp_init(void)
dccp_optbuf = kmalloc(256 * 4, GFP_KERNEL); dccp_optbuf = kmalloc(256 * 4, GFP_KERNEL);
if (!dccp_optbuf) if (!dccp_optbuf)
return -ENOMEM; return -ENOMEM;
ret = xt_register_match(&dccp_match); ret = xt_register_matches(xt_dccp_match, ARRAY_SIZE(xt_dccp_match));
if (ret) if (ret)
goto out_kfree; goto out_kfree;
ret = xt_register_match(&dccp6_match);
if (ret)
goto out_unreg;
return ret; return ret;
out_unreg:
xt_unregister_match(&dccp_match);
out_kfree: out_kfree:
kfree(dccp_optbuf); kfree(dccp_optbuf);
return ret; return ret;
} }
static void __exit xt_dccp_fini(void) static void __exit xt_dccp_fini(void)
{ {
xt_unregister_match(&dccp6_match); xt_unregister_matches(xt_dccp_match, ARRAY_SIZE(xt_dccp_match));
xt_unregister_match(&dccp_match);
kfree(dccp_optbuf); kfree(dccp_optbuf);
} }
......
...@@ -71,42 +71,33 @@ static int checkentry(const char *tablename, ...@@ -71,42 +71,33 @@ static int checkentry(const char *tablename,
return 1; return 1;
} }
static struct xt_match dscp_match = { static struct xt_match xt_dscp_match[] = {
.name = "dscp", {
.match = match, .name = "dscp",
.checkentry = checkentry, .family = AF_INET,
.matchsize = sizeof(struct xt_dscp_info), .checkentry = checkentry,
.family = AF_INET, .match = match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_dscp_info),
}; .me = THIS_MODULE,
},
static struct xt_match dscp6_match = { {
.name = "dscp", .name = "dscp",
.match = match6, .family = AF_INET6,
.checkentry = checkentry, .checkentry = checkentry,
.matchsize = sizeof(struct xt_dscp_info), .match = match6,
.family = AF_INET6, .matchsize = sizeof(struct xt_dscp_info),
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_dscp_match_init(void) static int __init xt_dscp_match_init(void)
{ {
int ret; return xt_register_matches(xt_dscp_match, ARRAY_SIZE(xt_dscp_match));
ret = xt_register_match(&dscp_match);
if (ret)
return ret;
ret = xt_register_match(&dscp6_match);
if (ret)
xt_unregister_match(&dscp_match);
return ret;
} }
static void __exit xt_dscp_match_fini(void) static void __exit xt_dscp_match_fini(void)
{ {
xt_unregister_match(&dscp_match); xt_unregister_matches(xt_dscp_match, ARRAY_SIZE(xt_dscp_match));
xt_unregister_match(&dscp6_match);
} }
module_init(xt_dscp_match_init); module_init(xt_dscp_match_init);
......
...@@ -92,44 +92,35 @@ checkentry(const char *tablename, ...@@ -92,44 +92,35 @@ checkentry(const char *tablename,
return 1; return 1;
} }
static struct xt_match esp_match = { static struct xt_match xt_esp_match[] = {
.name = "esp", {
.family = AF_INET, .name = "esp",
.proto = IPPROTO_ESP, .family = AF_INET,
.match = &match, .checkentry = checkentry,
.matchsize = sizeof(struct xt_esp), .match = match,
.checkentry = &checkentry, .matchsize = sizeof(struct xt_esp),
.me = THIS_MODULE, .proto = IPPROTO_ESP,
}; .me = THIS_MODULE,
},
static struct xt_match esp6_match = { {
.name = "esp", .name = "esp",
.family = AF_INET6, .family = AF_INET6,
.proto = IPPROTO_ESP, .checkentry = checkentry,
.match = &match, .match = match,
.matchsize = sizeof(struct xt_esp), .matchsize = sizeof(struct xt_esp),
.checkentry = &checkentry, .proto = IPPROTO_ESP,
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_esp_init(void) static int __init xt_esp_init(void)
{ {
int ret; return xt_register_matches(xt_esp_match, ARRAY_SIZE(xt_esp_match));
ret = xt_register_match(&esp_match);
if (ret)
return ret;
ret = xt_register_match(&esp6_match);
if (ret)
xt_unregister_match(&esp_match);
return ret;
} }
static void __exit xt_esp_cleanup(void) static void __exit xt_esp_cleanup(void)
{ {
xt_unregister_match(&esp_match); xt_unregister_matches(xt_esp_match, ARRAY_SIZE(xt_esp_match));
xt_unregister_match(&esp6_match);
} }
module_init(xt_esp_init); module_init(xt_esp_init);
......
...@@ -163,45 +163,37 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize) ...@@ -163,45 +163,37 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
#endif #endif
} }
static struct xt_match helper_match = { static struct xt_match xt_helper_match[] = {
.name = "helper", {
.match = match, .name = "helper",
.matchsize = sizeof(struct xt_helper_info), .family = AF_INET,
.checkentry = check, .checkentry = check,
.destroy = destroy, .match = match,
.family = AF_INET, .destroy = destroy,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_helper_info),
}; .me = THIS_MODULE,
static struct xt_match helper6_match = { },
.name = "helper", {
.match = match, .name = "helper",
.matchsize = sizeof(struct xt_helper_info), .family = AF_INET6,
.checkentry = check, .checkentry = check,
.destroy = destroy, .match = match,
.family = AF_INET6, .destroy = destroy,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_helper_info),
.me = THIS_MODULE,
},
}; };
static int __init xt_helper_init(void) static int __init xt_helper_init(void)
{ {
int ret;
need_conntrack(); need_conntrack();
return xt_register_matches(xt_helper_match,
ret = xt_register_match(&helper_match); ARRAY_SIZE(xt_helper_match));
if (ret < 0)
return ret;
ret = xt_register_match(&helper6_match);
if (ret < 0)
xt_unregister_match(&helper_match);
return ret;
} }
static void __exit xt_helper_fini(void) static void __exit xt_helper_fini(void)
{ {
xt_unregister_match(&helper_match); xt_unregister_matches(xt_helper_match, ARRAY_SIZE(xt_helper_match));
xt_unregister_match(&helper6_match);
} }
module_init(xt_helper_init); module_init(xt_helper_init);
......
...@@ -52,39 +52,32 @@ match6(const struct sk_buff *skb, ...@@ -52,39 +52,32 @@ match6(const struct sk_buff *skb,
return (pktlen >= info->min && pktlen <= info->max) ^ info->invert; return (pktlen >= info->min && pktlen <= info->max) ^ info->invert;
} }
static struct xt_match length_match = { static struct xt_match xt_length_match[] = {
.name = "length", {
.match = match, .name = "length",
.matchsize = sizeof(struct xt_length_info), .family = AF_INET,
.family = AF_INET, .match = match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_length_info),
}; .me = THIS_MODULE,
},
static struct xt_match length6_match = { {
.name = "length", .name = "length",
.match = match6, .family = AF_INET6,
.matchsize = sizeof(struct xt_length_info), .match = match6,
.family = AF_INET6, .matchsize = sizeof(struct xt_length_info),
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_length_init(void) static int __init xt_length_init(void)
{ {
int ret; return xt_register_matches(xt_length_match,
ret = xt_register_match(&length_match); ARRAY_SIZE(xt_length_match));
if (ret)
return ret;
ret = xt_register_match(&length6_match);
if (ret)
xt_unregister_match(&length_match);
return ret;
} }
static void __exit xt_length_fini(void) static void __exit xt_length_fini(void)
{ {
xt_unregister_match(&length_match); xt_unregister_matches(xt_length_match, ARRAY_SIZE(xt_length_match));
xt_unregister_match(&length6_match);
} }
module_init(xt_length_init); module_init(xt_length_init);
......
...@@ -136,42 +136,33 @@ ipt_limit_checkentry(const char *tablename, ...@@ -136,42 +136,33 @@ ipt_limit_checkentry(const char *tablename,
return 1; return 1;
} }
static struct xt_match ipt_limit_reg = { static struct xt_match xt_limit_match[] = {
.name = "limit", {
.match = ipt_limit_match, .name = "limit",
.matchsize = sizeof(struct xt_rateinfo), .family = AF_INET,
.checkentry = ipt_limit_checkentry, .checkentry = ipt_limit_checkentry,
.family = AF_INET, .match = ipt_limit_match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_rateinfo),
}; .me = THIS_MODULE,
static struct xt_match limit6_reg = { },
.name = "limit", {
.match = ipt_limit_match, .name = "limit",
.matchsize = sizeof(struct xt_rateinfo), .family = AF_INET6,
.checkentry = ipt_limit_checkentry, .checkentry = ipt_limit_checkentry,
.family = AF_INET6, .match = ipt_limit_match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_rateinfo),
.me = THIS_MODULE,
},
}; };
static int __init xt_limit_init(void) static int __init xt_limit_init(void)
{ {
int ret; return xt_register_matches(xt_limit_match, ARRAY_SIZE(xt_limit_match));
ret = xt_register_match(&ipt_limit_reg);
if (ret)
return ret;
ret = xt_register_match(&limit6_reg);
if (ret)
xt_unregister_match(&ipt_limit_reg);
return ret;
} }
static void __exit xt_limit_fini(void) static void __exit xt_limit_fini(void)
{ {
xt_unregister_match(&ipt_limit_reg); xt_unregister_matches(xt_limit_match, ARRAY_SIZE(xt_limit_match));
xt_unregister_match(&limit6_reg);
} }
module_init(xt_limit_init); module_init(xt_limit_init);
......
...@@ -43,43 +43,37 @@ match(const struct sk_buff *skb, ...@@ -43,43 +43,37 @@ match(const struct sk_buff *skb,
^ info->invert)); ^ info->invert));
} }
static struct xt_match mac_match = { static struct xt_match xt_mac_match[] = {
.name = "mac", {
.match = match, .name = "mac",
.matchsize = sizeof(struct xt_mac_info), .family = AF_INET,
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) | .match = match,
(1 << NF_IP_FORWARD), .matchsize = sizeof(struct xt_mac_info),
.family = AF_INET, .hooks = (1 << NF_IP_PRE_ROUTING) |
.me = THIS_MODULE, (1 << NF_IP_LOCAL_IN) |
}; (1 << NF_IP_FORWARD),
static struct xt_match mac6_match = { .me = THIS_MODULE,
.name = "mac", },
.match = match, {
.matchsize = sizeof(struct xt_mac_info), .name = "mac",
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) | .family = AF_INET6,
(1 << NF_IP_FORWARD), .match = match,
.family = AF_INET6, .matchsize = sizeof(struct xt_mac_info),
.me = THIS_MODULE, .hooks = (1 << NF_IP_PRE_ROUTING) |
(1 << NF_IP_LOCAL_IN) |
(1 << NF_IP_FORWARD),
.me = THIS_MODULE,
},
}; };
static int __init xt_mac_init(void) static int __init xt_mac_init(void)
{ {
int ret; return xt_register_matches(xt_mac_match, ARRAY_SIZE(xt_mac_match));
ret = xt_register_match(&mac_match);
if (ret)
return ret;
ret = xt_register_match(&mac6_match);
if (ret)
xt_unregister_match(&mac_match);
return ret;
} }
static void __exit xt_mac_fini(void) static void __exit xt_mac_fini(void)
{ {
xt_unregister_match(&mac_match); xt_unregister_matches(xt_mac_match, ARRAY_SIZE(xt_mac_match));
xt_unregister_match(&mac6_match);
} }
module_init(xt_mac_init); module_init(xt_mac_init);
......
...@@ -51,42 +51,33 @@ checkentry(const char *tablename, ...@@ -51,42 +51,33 @@ checkentry(const char *tablename,
return 1; return 1;
} }
static struct xt_match mark_match = { static struct xt_match xt_mark_match[] = {
.name = "mark", {
.match = match, .name = "mark",
.matchsize = sizeof(struct xt_mark_info), .family = AF_INET,
.checkentry = checkentry, .checkentry = checkentry,
.family = AF_INET, .match = match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_mark_info),
}; .me = THIS_MODULE,
},
static struct xt_match mark6_match = { {
.name = "mark", .name = "mark",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_mark_info), .checkentry = checkentry,
.checkentry = checkentry, .match = match,
.family = AF_INET6, .matchsize = sizeof(struct xt_mark_info),
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_mark_init(void) static int __init xt_mark_init(void)
{ {
int ret; return xt_register_matches(xt_mark_match, ARRAY_SIZE(xt_mark_match));
ret = xt_register_match(&mark_match);
if (ret)
return ret;
ret = xt_register_match(&mark6_match);
if (ret)
xt_unregister_match(&mark_match);
return ret;
} }
static void __exit xt_mark_fini(void) static void __exit xt_mark_fini(void)
{ {
xt_unregister_match(&mark_match); xt_unregister_matches(xt_mark_match, ARRAY_SIZE(xt_mark_match));
xt_unregister_match(&mark6_match);
} }
module_init(xt_mark_init); module_init(xt_mark_init);
......
...@@ -231,84 +231,55 @@ checkentry6_v1(const char *tablename, ...@@ -231,84 +231,55 @@ checkentry6_v1(const char *tablename,
multiinfo->count); multiinfo->count);
} }
static struct xt_match multiport_match = { static struct xt_match xt_multiport_match[] = {
.name = "multiport", {
.revision = 0, .name = "multiport",
.matchsize = sizeof(struct xt_multiport), .family = AF_INET,
.match = &match, .revision = 0,
.checkentry = &checkentry, .checkentry = checkentry,
.family = AF_INET, .match = match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_multiport),
}; .me = THIS_MODULE,
},
static struct xt_match multiport_match_v1 = { {
.name = "multiport", .name = "multiport",
.revision = 1, .family = AF_INET,
.matchsize = sizeof(struct xt_multiport_v1), .revision = 1,
.match = &match_v1, .checkentry = checkentry_v1,
.checkentry = &checkentry_v1, .match = match_v1,
.family = AF_INET, .matchsize = sizeof(struct xt_multiport_v1),
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match multiport6_match = { .name = "multiport",
.name = "multiport", .family = AF_INET6,
.revision = 0, .revision = 0,
.matchsize = sizeof(struct xt_multiport), .checkentry = checkentry6,
.match = &match, .match = match,
.checkentry = &checkentry6, .matchsize = sizeof(struct xt_multiport),
.family = AF_INET6, .me = THIS_MODULE,
.me = THIS_MODULE, },
}; {
.name = "multiport",
static struct xt_match multiport6_match_v1 = { .family = AF_INET6,
.name = "multiport", .revision = 1,
.revision = 1, .checkentry = checkentry6_v1,
.matchsize = sizeof(struct xt_multiport_v1), .match = match_v1,
.match = &match_v1, .matchsize = sizeof(struct xt_multiport_v1),
.checkentry = &checkentry6_v1, .me = THIS_MODULE,
.family = AF_INET6, },
.me = THIS_MODULE,
}; };
static int __init xt_multiport_init(void) static int __init xt_multiport_init(void)
{ {
int ret; return xt_register_matches(xt_multiport_match,
ARRAY_SIZE(xt_multiport_match));
ret = xt_register_match(&multiport_match);
if (ret)
goto out;
ret = xt_register_match(&multiport_match_v1);
if (ret)
goto out_unreg_multi_v0;
ret = xt_register_match(&multiport6_match);
if (ret)
goto out_unreg_multi_v1;
ret = xt_register_match(&multiport6_match_v1);
if (ret)
goto out_unreg_multi6_v0;
return ret;
out_unreg_multi6_v0:
xt_unregister_match(&multiport6_match);
out_unreg_multi_v1:
xt_unregister_match(&multiport_match_v1);
out_unreg_multi_v0:
xt_unregister_match(&multiport_match);
out:
return ret;
} }
static void __exit xt_multiport_fini(void) static void __exit xt_multiport_fini(void)
{ {
xt_unregister_match(&multiport_match); xt_unregister_matches(xt_multiport_match,
xt_unregister_match(&multiport_match_v1); ARRAY_SIZE(xt_multiport_match));
xt_unregister_match(&multiport6_match);
xt_unregister_match(&multiport6_match_v1);
} }
module_init(xt_multiport_init); module_init(xt_multiport_init);
......
...@@ -132,43 +132,34 @@ checkentry(const char *tablename, ...@@ -132,43 +132,34 @@ checkentry(const char *tablename,
return 1; return 1;
} }
static struct xt_match physdev_match = { static struct xt_match xt_physdev_match[] = {
.name = "physdev", {
.match = match, .name = "physdev",
.matchsize = sizeof(struct xt_physdev_info), .family = AF_INET,
.checkentry = checkentry, .checkentry = checkentry,
.family = AF_INET, .match = match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_physdev_info),
}; .me = THIS_MODULE,
},
static struct xt_match physdev6_match = { {
.name = "physdev", .name = "physdev",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_physdev_info), .checkentry = checkentry,
.checkentry = checkentry, .match = match,
.family = AF_INET6, .matchsize = sizeof(struct xt_physdev_info),
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_physdev_init(void) static int __init xt_physdev_init(void)
{ {
int ret; return xt_register_matches(xt_physdev_match,
ARRAY_SIZE(xt_physdev_match));
ret = xt_register_match(&physdev_match);
if (ret < 0)
return ret;
ret = xt_register_match(&physdev6_match);
if (ret < 0)
xt_unregister_match(&physdev_match);
return ret;
} }
static void __exit xt_physdev_fini(void) static void __exit xt_physdev_fini(void)
{ {
xt_unregister_match(&physdev_match); xt_unregister_matches(xt_physdev_match, ARRAY_SIZE(xt_physdev_match));
xt_unregister_match(&physdev6_match);
} }
module_init(xt_physdev_init); module_init(xt_physdev_init);
......
...@@ -43,40 +43,32 @@ static int match(const struct sk_buff *skb, ...@@ -43,40 +43,32 @@ static int match(const struct sk_buff *skb,
return (type == info->pkttype) ^ info->invert; return (type == info->pkttype) ^ info->invert;
} }
static struct xt_match pkttype_match = { static struct xt_match xt_pkttype_match[] = {
.name = "pkttype", {
.match = match, .name = "pkttype",
.matchsize = sizeof(struct xt_pkttype_info), .family = AF_INET,
.family = AF_INET, .match = match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_pkttype_info),
}; .me = THIS_MODULE,
},
static struct xt_match pkttype6_match = { {
.name = "pkttype", .name = "pkttype",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_pkttype_info), .match = match,
.family = AF_INET6, .matchsize = sizeof(struct xt_pkttype_info),
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_pkttype_init(void) static int __init xt_pkttype_init(void)
{ {
int ret; return xt_register_matches(xt_pkttype_match,
ret = xt_register_match(&pkttype_match); ARRAY_SIZE(xt_pkttype_match));
if (ret)
return ret;
ret = xt_register_match(&pkttype6_match);
if (ret)
xt_unregister_match(&pkttype_match);
return ret;
} }
static void __exit xt_pkttype_fini(void) static void __exit xt_pkttype_fini(void)
{ {
xt_unregister_match(&pkttype_match); xt_unregister_matches(xt_pkttype_match, ARRAY_SIZE(xt_pkttype_match));
xt_unregister_match(&pkttype6_match);
} }
module_init(xt_pkttype_init); module_init(xt_pkttype_init);
......
...@@ -165,43 +165,36 @@ static int checkentry(const char *tablename, const void *ip_void, ...@@ -165,43 +165,36 @@ static int checkentry(const char *tablename, const void *ip_void,
return 1; return 1;
} }
static struct xt_match policy_match = { static struct xt_match xt_policy_match[] = {
.name = "policy", {
.family = AF_INET, .name = "policy",
.match = match, .family = AF_INET,
.matchsize = sizeof(struct xt_policy_info), .checkentry = checkentry,
.checkentry = checkentry, .match = match,
.family = AF_INET, .matchsize = sizeof(struct xt_policy_info),
.me = THIS_MODULE, .family = AF_INET,
}; .me = THIS_MODULE,
},
static struct xt_match policy6_match = { {
.name = "policy", .name = "policy",
.family = AF_INET6, .family = AF_INET6,
.match = match, .checkentry = checkentry,
.matchsize = sizeof(struct xt_policy_info), .match = match,
.checkentry = checkentry, .matchsize = sizeof(struct xt_policy_info),
.family = AF_INET6, .family = AF_INET6,
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init init(void) static int __init init(void)
{ {
int ret; return xt_register_matches(xt_policy_match,
ARRAY_SIZE(xt_policy_match));
ret = xt_register_match(&policy_match);
if (ret)
return ret;
ret = xt_register_match(&policy6_match);
if (ret)
xt_unregister_match(&policy_match);
return ret;
} }
static void __exit fini(void) static void __exit fini(void)
{ {
xt_unregister_match(&policy6_match); xt_unregister_matches(xt_policy_match, ARRAY_SIZE(xt_policy_match));
xt_unregister_match(&policy_match);
} }
module_init(init); module_init(init);
......
...@@ -52,46 +52,33 @@ checkentry(const char *tablename, const void *entry, ...@@ -52,46 +52,33 @@ checkentry(const char *tablename, const void *entry,
return 1; return 1;
} }
static struct xt_match quota_match = { static struct xt_match xt_quota_match[] = {
.name = "quota", {
.family = AF_INET, .name = "quota",
.match = match, .family = AF_INET,
.matchsize = sizeof(struct xt_quota_info), .checkentry = checkentry,
.checkentry = checkentry, .match = match,
.me = THIS_MODULE .matchsize = sizeof(struct xt_quota_info),
}; .me = THIS_MODULE
},
static struct xt_match quota_match6 = { {
.name = "quota", .name = "quota",
.family = AF_INET6, .family = AF_INET6,
.match = match, .checkentry = checkentry,
.matchsize = sizeof(struct xt_quota_info), .match = match,
.checkentry = checkentry, .matchsize = sizeof(struct xt_quota_info),
.me = THIS_MODULE .me = THIS_MODULE
},
}; };
static int __init xt_quota_init(void) static int __init xt_quota_init(void)
{ {
int ret; return xt_register_matches(xt_quota_match, ARRAY_SIZE(xt_quota_match));
ret = xt_register_match(&quota_match);
if (ret)
goto err1;
ret = xt_register_match(&quota_match6);
if (ret)
goto err2;
return ret;
err2:
xt_unregister_match(&quota_match);
err1:
return ret;
} }
static void __exit xt_quota_fini(void) static void __exit xt_quota_fini(void)
{ {
xt_unregister_match(&quota_match6); xt_unregister_matches(xt_quota_match, ARRAY_SIZE(xt_quota_match));
xt_unregister_match(&quota_match);
} }
module_init(xt_quota_init); module_init(xt_quota_init);
......
...@@ -178,44 +178,35 @@ checkentry(const char *tablename, ...@@ -178,44 +178,35 @@ checkentry(const char *tablename,
| SCTP_CHUNK_MATCH_ONLY))); | SCTP_CHUNK_MATCH_ONLY)));
} }
static struct xt_match sctp_match = { static struct xt_match xt_sctp_match[] = {
.name = "sctp", {
.match = match, .name = "sctp",
.matchsize = sizeof(struct xt_sctp_info), .family = AF_INET,
.proto = IPPROTO_SCTP, .checkentry = checkentry,
.checkentry = checkentry, .match = match,
.family = AF_INET, .matchsize = sizeof(struct xt_sctp_info),
.me = THIS_MODULE .proto = IPPROTO_SCTP,
}; .me = THIS_MODULE
},
static struct xt_match sctp6_match = { {
.name = "sctp", .name = "sctp",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_sctp_info), .checkentry = checkentry,
.proto = IPPROTO_SCTP, .match = match,
.checkentry = checkentry, .matchsize = sizeof(struct xt_sctp_info),
.family = AF_INET6, .proto = IPPROTO_SCTP,
.me = THIS_MODULE .me = THIS_MODULE
},
}; };
static int __init xt_sctp_init(void) static int __init xt_sctp_init(void)
{ {
int ret; return xt_register_matches(xt_sctp_match, ARRAY_SIZE(xt_sctp_match));
ret = xt_register_match(&sctp_match);
if (ret)
return ret;
ret = xt_register_match(&sctp6_match);
if (ret)
xt_unregister_match(&sctp_match);
return ret;
} }
static void __exit xt_sctp_fini(void) static void __exit xt_sctp_fini(void)
{ {
xt_unregister_match(&sctp6_match); xt_unregister_matches(xt_sctp_match, ARRAY_SIZE(xt_sctp_match));
xt_unregister_match(&sctp_match);
} }
module_init(xt_sctp_init); module_init(xt_sctp_init);
......
...@@ -69,47 +69,36 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize) ...@@ -69,47 +69,36 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
#endif #endif
} }
static struct xt_match state_match = { static struct xt_match xt_state_match[] = {
.name = "state", {
.match = match, .name = "state",
.checkentry = check, .family = AF_INET,
.destroy = destroy, .checkentry = check,
.matchsize = sizeof(struct xt_state_info), .match = match,
.family = AF_INET, .destroy = destroy,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_state_info),
}; .me = THIS_MODULE,
},
static struct xt_match state6_match = { {
.name = "state", .name = "state",
.match = match, .family = AF_INET6,
.checkentry = check, .checkentry = check,
.destroy = destroy, .match = match,
.matchsize = sizeof(struct xt_state_info), .destroy = destroy,
.family = AF_INET6, .matchsize = sizeof(struct xt_state_info),
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_state_init(void) static int __init xt_state_init(void)
{ {
int ret;
need_conntrack(); need_conntrack();
return xt_register_matches(xt_state_match, ARRAY_SIZE(xt_state_match));
ret = xt_register_match(&state_match);
if (ret < 0)
return ret;
ret = xt_register_match(&state6_match);
if (ret < 0)
xt_unregister_match(&state_match);
return ret;
} }
static void __exit xt_state_fini(void) static void __exit xt_state_fini(void)
{ {
xt_unregister_match(&state_match); xt_unregister_matches(xt_state_match, ARRAY_SIZE(xt_state_match));
xt_unregister_match(&state6_match);
} }
module_init(xt_state_init); module_init(xt_state_init);
......
...@@ -66,46 +66,35 @@ checkentry(const char *tablename, const void *entry, ...@@ -66,46 +66,35 @@ checkentry(const char *tablename, const void *entry,
return 1; return 1;
} }
static struct xt_match statistic_match = { static struct xt_match xt_statistic_match[] = {
.name = "statistic", {
.match = match, .name = "statistic",
.matchsize = sizeof(struct xt_statistic_info), .family = AF_INET,
.checkentry = checkentry, .checkentry = checkentry,
.family = AF_INET, .match = match,
.me = THIS_MODULE, .matchsize = sizeof(struct xt_statistic_info),
}; .me = THIS_MODULE,
},
static struct xt_match statistic_match6 = { {
.name = "statistic", .name = "statistic",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_statistic_info), .checkentry = checkentry,
.checkentry = checkentry, .match = match,
.family = AF_INET6, .matchsize = sizeof(struct xt_statistic_info),
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_statistic_init(void) static int __init xt_statistic_init(void)
{ {
int ret; return xt_register_matches(xt_statistic_match,
ARRAY_SIZE(xt_statistic_match));
ret = xt_register_match(&statistic_match);
if (ret)
goto err1;
ret = xt_register_match(&statistic_match6);
if (ret)
goto err2;
return ret;
err2:
xt_unregister_match(&statistic_match);
err1:
return ret;
} }
static void __exit xt_statistic_fini(void) static void __exit xt_statistic_fini(void)
{ {
xt_unregister_match(&statistic_match6); xt_unregister_matches(xt_statistic_match,
xt_unregister_match(&statistic_match); ARRAY_SIZE(xt_statistic_match));
} }
module_init(xt_statistic_init); module_init(xt_statistic_init);
......
...@@ -75,43 +75,35 @@ static void destroy(const struct xt_match *match, void *matchinfo, ...@@ -75,43 +75,35 @@ static void destroy(const struct xt_match *match, void *matchinfo,
textsearch_destroy(STRING_TEXT_PRIV(matchinfo)->config); textsearch_destroy(STRING_TEXT_PRIV(matchinfo)->config);
} }
static struct xt_match string_match = { static struct xt_match xt_string_match[] = {
.name = "string", {
.match = match, .name = "string",
.matchsize = sizeof(struct xt_string_info), .family = AF_INET,
.checkentry = checkentry, .checkentry = checkentry,
.destroy = destroy, .match = match,
.family = AF_INET, .destroy = destroy,
.me = THIS_MODULE .matchsize = sizeof(struct xt_string_info),
}; .me = THIS_MODULE
static struct xt_match string6_match = { },
.name = "string", {
.match = match, .name = "string",
.matchsize = sizeof(struct xt_string_info), .family = AF_INET6,
.checkentry = checkentry, .checkentry = checkentry,
.destroy = destroy, .match = match,
.family = AF_INET6, .destroy = destroy,
.me = THIS_MODULE .matchsize = sizeof(struct xt_string_info),
.me = THIS_MODULE
},
}; };
static int __init xt_string_init(void) static int __init xt_string_init(void)
{ {
int ret; return xt_register_matches(xt_string_match, ARRAY_SIZE(xt_string_match));
ret = xt_register_match(&string_match);
if (ret)
return ret;
ret = xt_register_match(&string6_match);
if (ret)
xt_unregister_match(&string_match);
return ret;
} }
static void __exit xt_string_fini(void) static void __exit xt_string_fini(void)
{ {
xt_unregister_match(&string_match); xt_unregister_matches(xt_string_match, ARRAY_SIZE(xt_string_match));
xt_unregister_match(&string6_match);
} }
module_init(xt_string_init); module_init(xt_string_init);
......
...@@ -93,43 +93,34 @@ match(const struct sk_buff *skb, ...@@ -93,43 +93,34 @@ match(const struct sk_buff *skb,
info->invert, hotdrop); info->invert, hotdrop);
} }
static struct xt_match tcpmss_match = { static struct xt_match xt_tcpmss_match[] = {
.name = "tcpmss", {
.match = match, .name = "tcpmss",
.matchsize = sizeof(struct xt_tcpmss_match_info), .family = AF_INET,
.proto = IPPROTO_TCP, .match = match,
.family = AF_INET, .matchsize = sizeof(struct xt_tcpmss_match_info),
.me = THIS_MODULE, .proto = IPPROTO_TCP,
.me = THIS_MODULE,
},
{
.name = "tcpmss",
.family = AF_INET6,
.match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP,
.me = THIS_MODULE,
},
}; };
static struct xt_match tcpmss6_match = {
.name = "tcpmss",
.match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP,
.family = AF_INET6,
.me = THIS_MODULE,
};
static int __init xt_tcpmss_init(void) static int __init xt_tcpmss_init(void)
{ {
int ret; return xt_register_matches(xt_tcpmss_match,
ret = xt_register_match(&tcpmss_match); ARRAY_SIZE(xt_tcpmss_match));
if (ret)
return ret;
ret = xt_register_match(&tcpmss6_match);
if (ret)
xt_unregister_match(&tcpmss_match);
return ret;
} }
static void __exit xt_tcpmss_fini(void) static void __exit xt_tcpmss_fini(void)
{ {
xt_unregister_match(&tcpmss6_match); xt_unregister_matches(xt_tcpmss_match, ARRAY_SIZE(xt_tcpmss_match));
xt_unregister_match(&tcpmss_match);
} }
module_init(xt_tcpmss_init); module_init(xt_tcpmss_init);
......
...@@ -199,81 +199,54 @@ udp_checkentry(const char *tablename, ...@@ -199,81 +199,54 @@ udp_checkentry(const char *tablename,
return !(udpinfo->invflags & ~XT_UDP_INV_MASK); return !(udpinfo->invflags & ~XT_UDP_INV_MASK);
} }
static struct xt_match tcp_matchstruct = { static struct xt_match xt_tcpudp_match[] = {
.name = "tcp", {
.match = tcp_match, .name = "tcp",
.matchsize = sizeof(struct xt_tcp), .family = AF_INET,
.proto = IPPROTO_TCP, .checkentry = tcp_checkentry,
.family = AF_INET, .match = tcp_match,
.checkentry = tcp_checkentry, .matchsize = sizeof(struct xt_tcp),
.me = THIS_MODULE, .proto = IPPROTO_TCP,
}; .me = THIS_MODULE,
},
static struct xt_match tcp6_matchstruct = { {
.name = "tcp", .name = "tcp",
.match = tcp_match, .family = AF_INET6,
.matchsize = sizeof(struct xt_tcp), .checkentry = tcp_checkentry,
.proto = IPPROTO_TCP, .match = tcp_match,
.family = AF_INET6, .matchsize = sizeof(struct xt_tcp),
.checkentry = tcp_checkentry, .proto = IPPROTO_TCP,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match udp_matchstruct = { .name = "udp",
.name = "udp", .family = AF_INET,
.match = udp_match, .checkentry = udp_checkentry,
.matchsize = sizeof(struct xt_udp), .match = udp_match,
.proto = IPPROTO_UDP, .matchsize = sizeof(struct xt_udp),
.family = AF_INET, .proto = IPPROTO_UDP,
.checkentry = udp_checkentry, .me = THIS_MODULE,
.me = THIS_MODULE, },
}; {
static struct xt_match udp6_matchstruct = { .name = "udp",
.name = "udp", .family = AF_INET6,
.match = udp_match, .checkentry = udp_checkentry,
.matchsize = sizeof(struct xt_udp), .match = udp_match,
.proto = IPPROTO_UDP, .matchsize = sizeof(struct xt_udp),
.family = AF_INET6, .proto = IPPROTO_UDP,
.checkentry = udp_checkentry, .me = THIS_MODULE,
.me = THIS_MODULE, },
}; };
static int __init xt_tcpudp_init(void) static int __init xt_tcpudp_init(void)
{ {
int ret; return xt_register_matches(xt_tcpudp_match,
ret = xt_register_match(&tcp_matchstruct); ARRAY_SIZE(xt_tcpudp_match));
if (ret)
return ret;
ret = xt_register_match(&tcp6_matchstruct);
if (ret)
goto out_unreg_tcp;
ret = xt_register_match(&udp_matchstruct);
if (ret)
goto out_unreg_tcp6;
ret = xt_register_match(&udp6_matchstruct);
if (ret)
goto out_unreg_udp;
return ret;
out_unreg_udp:
xt_unregister_match(&udp_matchstruct);
out_unreg_tcp6:
xt_unregister_match(&tcp6_matchstruct);
out_unreg_tcp:
xt_unregister_match(&tcp_matchstruct);
return ret;
} }
static void __exit xt_tcpudp_fini(void) static void __exit xt_tcpudp_fini(void)
{ {
xt_unregister_match(&udp6_matchstruct); xt_unregister_matches(xt_tcpudp_match, ARRAY_SIZE(xt_tcpudp_match));
xt_unregister_match(&udp_matchstruct);
xt_unregister_match(&tcp6_matchstruct);
xt_unregister_match(&tcp_matchstruct);
} }
module_init(xt_tcpudp_init); module_init(xt_tcpudp_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment