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[] = {
{
.family = AF_INET,
.name = "CLASSIFY", .name = "CLASSIFY",
.target = target, .target = target,
.targetsize = sizeof(struct xt_classify_target_info), .targetsize = sizeof(struct xt_classify_target_info),
.table = "mangle", .table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) | .hooks = (1 << NF_IP_LOCAL_OUT) |
(1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING), (1 << NF_IP_POST_ROUTING),
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
static struct xt_target classify6_reg = { {
.name = "CLASSIFY", .name = "CLASSIFY",
.family = AF_INET6,
.target = target, .target = target,
.targetsize = sizeof(struct xt_classify_target_info), .targetsize = sizeof(struct xt_classify_target_info),
.table = "mangle", .table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) | .hooks = (1 << NF_IP_LOCAL_OUT) |
(1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING), (1 << NF_IP_POST_ROUTING),
.family = AF_INET6,
.me = THIS_MODULE, .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", .name = "CONNMARK",
.family = AF_INET,
.checkentry = checkentry,
.target = target, .target = target,
.targetsize = sizeof(struct xt_connmark_target_info), .targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE .me = THIS_MODULE
}; },
{
static struct xt_target connmark6_reg = {
.name = "CONNMARK", .name = "CONNMARK",
.family = AF_INET6,
.checkentry = checkentry,
.target = target, .target = target,
.targetsize = sizeof(struct xt_connmark_target_info), .targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
.family = AF_INET6,
.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", .name = "CONNSECMARK",
.family = AF_INET,
.checkentry = checkentry,
.target = target, .target = target,
.targetsize = sizeof(struct xt_connsecmark_target_info), .targetsize = sizeof(struct xt_connsecmark_target_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry,
.me = THIS_MODULE, .me = THIS_MODULE,
.family = AF_INET, },
.revision = 0, {
};
static struct xt_target ip6t_connsecmark_reg = {
.name = "CONNSECMARK", .name = "CONNSECMARK",
.family = AF_INET6,
.checkentry = checkentry,
.target = target, .target = target,
.targetsize = sizeof(struct xt_connsecmark_target_info), .targetsize = sizeof(struct xt_connsecmark_target_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry,
.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", .name = "DSCP",
.family = AF_INET,
.checkentry = checkentry,
.target = target, .target = target,
.targetsize = sizeof(struct xt_DSCP_info), .targetsize = sizeof(struct xt_DSCP_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_target xt_dscp6_reg = {
.name = "DSCP", .name = "DSCP",
.family = AF_INET6,
.checkentry = checkentry,
.target = target6, .target = target6,
.targetsize = sizeof(struct xt_DSCP_info), .targetsize = sizeof(struct xt_DSCP_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry,
.family = AF_INET6,
.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", .name = "MARK",
.family = AF_INET,
.revision = 0,
.checkentry = checkentry_v0,
.target = target_v0, .target = target_v0,
.targetsize = sizeof(struct xt_mark_target_info), .targetsize = sizeof(struct xt_mark_target_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE, .me = THIS_MODULE,
.family = AF_INET, },
.revision = 0, {
};
static struct xt_target ipt_mark_reg_v1 = {
.name = "MARK", .name = "MARK",
.family = AF_INET,
.revision = 1,
.checkentry = checkentry_v1,
.target = target_v1, .target = target_v1,
.targetsize = sizeof(struct xt_mark_target_info_v1), .targetsize = sizeof(struct xt_mark_target_info_v1),
.table = "mangle", .table = "mangle",
.checkentry = checkentry_v1,
.me = THIS_MODULE, .me = THIS_MODULE,
.family = AF_INET, },
.revision = 1, {
};
static struct xt_target ip6t_mark_reg_v0 = {
.name = "MARK", .name = "MARK",
.family = AF_INET6,
.revision = 0,
.checkentry = checkentry_v0,
.target = target_v0, .target = target_v0,
.targetsize = sizeof(struct xt_mark_target_info), .targetsize = sizeof(struct xt_mark_target_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE, .me = THIS_MODULE,
.family = AF_INET6, },
.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", .name = "NFQUEUE",
.family = AF_INET,
.target = target, .target = target,
.targetsize = sizeof(struct xt_NFQ_info), .targetsize = sizeof(struct xt_NFQ_info),
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_target ip6t_NFQ_reg = {
.name = "NFQUEUE", .name = "NFQUEUE",
.family = AF_INET6,
.target = target, .target = target,
.targetsize = sizeof(struct xt_NFQ_info), .targetsize = sizeof(struct xt_NFQ_info),
.family = AF_INET6,
.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", .name = "NOTRACK",
.family = AF_INET,
.target = target, .target = target,
.targetsize = 0,
.table = "raw", .table = "raw",
.family = AF_INET,
.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",
.family = AF_INET6,
.me = THIS_MODULE, .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", .name = "SECMARK",
.family = AF_INET,
.checkentry = checkentry,
.target = target, .target = target,
.targetsize = sizeof(struct xt_secmark_target_info), .targetsize = sizeof(struct xt_secmark_target_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry,
.me = THIS_MODULE, .me = THIS_MODULE,
.family = AF_INET, },
.revision = 0, {
};
static struct xt_target ip6t_secmark_reg = {
.name = "SECMARK", .name = "SECMARK",
.family = AF_INET6,
.checkentry = checkentry,
.target = target, .target = target,
.targetsize = sizeof(struct xt_secmark_target_info), .targetsize = sizeof(struct xt_secmark_target_info),
.table = "mangle", .table = "mangle",
.checkentry = checkentry,
.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", .name = "comment",
.family = AF_INET,
.match = match, .match = match,
.matchsize = sizeof(struct xt_comment_info), .matchsize = sizeof(struct xt_comment_info),
.family = AF_INET,
.me = THIS_MODULE .me = THIS_MODULE
}; },
{
static struct xt_match comment6_match = {
.name = "comment", .name = "comment",
.family = AF_INET6,
.match = match, .match = match,
.matchsize = sizeof(struct xt_comment_info), .matchsize = sizeof(struct xt_comment_info),
.family = AF_INET6,
.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", .name = "connbytes",
.match = match, .family = AF_INET,
.checkentry = check, .checkentry = check,
.match = match,
.matchsize = sizeof(struct xt_connbytes_info), .matchsize = sizeof(struct xt_connbytes_info),
.family = AF_INET,
.me = THIS_MODULE .me = THIS_MODULE
}; },
static struct xt_match connbytes6_match = { {
.name = "connbytes", .name = "connbytes",
.match = match, .family = AF_INET6,
.checkentry = check, .checkentry = check,
.match = match,
.matchsize = sizeof(struct xt_connbytes_info), .matchsize = sizeof(struct xt_connbytes_info),
.family = AF_INET6,
.me = THIS_MODULE .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", .name = "connmark",
.match = match, .family = AF_INET,
.matchsize = sizeof(struct xt_connmark_info),
.checkentry = checkentry, .checkentry = checkentry,
.match = match,
.destroy = destroy, .destroy = destroy,
.family = AF_INET, .matchsize = sizeof(struct xt_connmark_info),
.me = THIS_MODULE .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,28 +141,27 @@ checkentry(const char *tablename, ...@@ -141,28 +141,27 @@ 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",
.family = AF_INET,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_dccp_info), .matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP, .proto = IPPROTO_DCCP,
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
static struct xt_match dccp6_match = {
{
.name = "dccp", .name = "dccp",
.family = AF_INET6,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_dccp_info), .matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP, .proto = IPPROTO_DCCP,
.checkentry = checkentry,
.family = AF_INET6,
.me = THIS_MODULE, .me = THIS_MODULE,
},
}; };
static int __init xt_dccp_init(void) static int __init xt_dccp_init(void)
{ {
int ret; int ret;
...@@ -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", .name = "dscp",
.match = match, .family = AF_INET,
.checkentry = checkentry, .checkentry = checkentry,
.match = match,
.matchsize = sizeof(struct xt_dscp_info), .matchsize = sizeof(struct xt_dscp_info),
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match dscp6_match = {
.name = "dscp", .name = "dscp",
.match = match6, .family = AF_INET6,
.checkentry = checkentry, .checkentry = checkentry,
.match = match6,
.matchsize = sizeof(struct xt_dscp_info), .matchsize = sizeof(struct xt_dscp_info),
.family = AF_INET6,
.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", .name = "esp",
.family = AF_INET, .family = AF_INET,
.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 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", .name = "helper",
.match = match, .family = AF_INET,
.matchsize = sizeof(struct xt_helper_info),
.checkentry = check, .checkentry = check,
.match = match,
.destroy = destroy, .destroy = destroy,
.family = AF_INET, .matchsize = sizeof(struct xt_helper_info),
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
static struct xt_match helper6_match = { {
.name = "helper", .name = "helper",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_helper_info),
.checkentry = check, .checkentry = check,
.match = match,
.destroy = destroy, .destroy = destroy,
.family = AF_INET6, .matchsize = sizeof(struct xt_helper_info),
.me = THIS_MODULE, .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", .name = "length",
.family = AF_INET,
.match = match, .match = match,
.matchsize = sizeof(struct xt_length_info), .matchsize = sizeof(struct xt_length_info),
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match length6_match = {
.name = "length", .name = "length",
.family = AF_INET6,
.match = match6, .match = match6,
.matchsize = sizeof(struct xt_length_info), .matchsize = sizeof(struct xt_length_info),
.family = AF_INET6,
.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", .name = "limit",
.family = AF_INET,
.checkentry = ipt_limit_checkentry,
.match = ipt_limit_match, .match = ipt_limit_match,
.matchsize = sizeof(struct xt_rateinfo), .matchsize = sizeof(struct xt_rateinfo),
.checkentry = ipt_limit_checkentry,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
static struct xt_match limit6_reg = { {
.name = "limit", .name = "limit",
.family = AF_INET6,
.checkentry = ipt_limit_checkentry,
.match = ipt_limit_match, .match = ipt_limit_match,
.matchsize = sizeof(struct xt_rateinfo), .matchsize = sizeof(struct xt_rateinfo),
.checkentry = ipt_limit_checkentry,
.family = AF_INET6,
.me = THIS_MODULE, .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", .name = "mac",
.family = AF_INET,
.match = match, .match = match,
.matchsize = sizeof(struct xt_mac_info), .matchsize = sizeof(struct xt_mac_info),
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) | .hooks = (1 << NF_IP_PRE_ROUTING) |
(1 << NF_IP_LOCAL_IN) |
(1 << NF_IP_FORWARD), (1 << NF_IP_FORWARD),
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
static struct xt_match mac6_match = { {
.name = "mac", .name = "mac",
.family = AF_INET6,
.match = match, .match = match,
.matchsize = sizeof(struct xt_mac_info), .matchsize = sizeof(struct xt_mac_info),
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) | .hooks = (1 << NF_IP_PRE_ROUTING) |
(1 << NF_IP_LOCAL_IN) |
(1 << NF_IP_FORWARD), (1 << NF_IP_FORWARD),
.family = AF_INET6,
.me = THIS_MODULE, .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", .name = "mark",
.family = AF_INET,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_mark_info), .matchsize = sizeof(struct xt_mark_info),
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match mark6_match = {
.name = "mark", .name = "mark",
.family = AF_INET6,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_mark_info), .matchsize = sizeof(struct xt_mark_info),
.checkentry = checkentry,
.family = AF_INET6,
.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", .name = "multiport",
.family = AF_INET,
.revision = 0, .revision = 0,
.checkentry = checkentry,
.match = match,
.matchsize = sizeof(struct xt_multiport), .matchsize = sizeof(struct xt_multiport),
.match = &match,
.checkentry = &checkentry,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match multiport_match_v1 = {
.name = "multiport", .name = "multiport",
.family = AF_INET,
.revision = 1, .revision = 1,
.checkentry = checkentry_v1,
.match = match_v1,
.matchsize = sizeof(struct xt_multiport_v1), .matchsize = sizeof(struct xt_multiport_v1),
.match = &match_v1,
.checkentry = &checkentry_v1,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match multiport6_match = {
.name = "multiport", .name = "multiport",
.family = AF_INET6,
.revision = 0, .revision = 0,
.checkentry = checkentry6,
.match = match,
.matchsize = sizeof(struct xt_multiport), .matchsize = sizeof(struct xt_multiport),
.match = &match,
.checkentry = &checkentry6,
.family = AF_INET6,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match multiport6_match_v1 = {
.name = "multiport", .name = "multiport",
.family = AF_INET6,
.revision = 1, .revision = 1,
.checkentry = checkentry6_v1,
.match = match_v1,
.matchsize = sizeof(struct xt_multiport_v1), .matchsize = sizeof(struct xt_multiport_v1),
.match = &match_v1,
.checkentry = &checkentry6_v1,
.family = AF_INET6,
.me = THIS_MODULE, .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", .name = "physdev",
.family = AF_INET,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_physdev_info), .matchsize = sizeof(struct xt_physdev_info),
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match physdev6_match = {
.name = "physdev", .name = "physdev",
.family = AF_INET6,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_physdev_info), .matchsize = sizeof(struct xt_physdev_info),
.checkentry = checkentry,
.family = AF_INET6,
.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", .name = "pkttype",
.family = AF_INET,
.match = match, .match = match,
.matchsize = sizeof(struct xt_pkttype_info), .matchsize = sizeof(struct xt_pkttype_info),
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match pkttype6_match = {
.name = "pkttype", .name = "pkttype",
.family = AF_INET6,
.match = match, .match = match,
.matchsize = sizeof(struct xt_pkttype_info), .matchsize = sizeof(struct xt_pkttype_info),
.family = AF_INET6,
.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", .name = "policy",
.family = AF_INET, .family = AF_INET,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_policy_info), .matchsize = sizeof(struct xt_policy_info),
.checkentry = checkentry,
.family = AF_INET, .family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match policy6_match = {
.name = "policy", .name = "policy",
.family = AF_INET6, .family = AF_INET6,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_policy_info), .matchsize = sizeof(struct xt_policy_info),
.checkentry = checkentry,
.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", .name = "quota",
.family = AF_INET, .family = AF_INET,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_quota_info), .matchsize = sizeof(struct xt_quota_info),
.checkentry = checkentry,
.me = THIS_MODULE .me = THIS_MODULE
}; },
{
static struct xt_match quota_match6 = {
.name = "quota", .name = "quota",
.family = AF_INET6, .family = AF_INET6,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_quota_info), .matchsize = sizeof(struct xt_quota_info),
.checkentry = checkentry,
.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", .name = "sctp",
.family = AF_INET,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_sctp_info), .matchsize = sizeof(struct xt_sctp_info),
.proto = IPPROTO_SCTP, .proto = IPPROTO_SCTP,
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE .me = THIS_MODULE
}; },
{
static struct xt_match sctp6_match = {
.name = "sctp", .name = "sctp",
.family = AF_INET6,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_sctp_info), .matchsize = sizeof(struct xt_sctp_info),
.proto = IPPROTO_SCTP, .proto = IPPROTO_SCTP,
.checkentry = checkentry,
.family = AF_INET6,
.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", .name = "state",
.match = match, .family = AF_INET,
.checkentry = check, .checkentry = check,
.match = match,
.destroy = destroy, .destroy = destroy,
.matchsize = sizeof(struct xt_state_info), .matchsize = sizeof(struct xt_state_info),
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match state6_match = {
.name = "state", .name = "state",
.match = match, .family = AF_INET6,
.checkentry = check, .checkentry = check,
.match = match,
.destroy = destroy, .destroy = destroy,
.matchsize = sizeof(struct xt_state_info), .matchsize = sizeof(struct xt_state_info),
.family = AF_INET6,
.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", .name = "statistic",
.family = AF_INET,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_statistic_info), .matchsize = sizeof(struct xt_statistic_info),
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match statistic_match6 = {
.name = "statistic", .name = "statistic",
.family = AF_INET6,
.checkentry = checkentry,
.match = match, .match = match,
.matchsize = sizeof(struct xt_statistic_info), .matchsize = sizeof(struct xt_statistic_info),
.checkentry = checkentry,
.family = AF_INET6,
.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", .name = "string",
.match = match, .family = AF_INET,
.matchsize = sizeof(struct xt_string_info),
.checkentry = checkentry, .checkentry = checkentry,
.match = match,
.destroy = destroy, .destroy = destroy,
.family = AF_INET, .matchsize = sizeof(struct xt_string_info),
.me = THIS_MODULE .me = THIS_MODULE
}; },
static struct xt_match string6_match = { {
.name = "string", .name = "string",
.match = match, .family = AF_INET6,
.matchsize = sizeof(struct xt_string_info),
.checkentry = checkentry, .checkentry = checkentry,
.match = match,
.destroy = destroy, .destroy = destroy,
.family = AF_INET6, .matchsize = sizeof(struct xt_string_info),
.me = THIS_MODULE .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", .name = "tcpmss",
.family = AF_INET,
.match = match, .match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info), .matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP, .proto = IPPROTO_TCP,
.family = AF_INET,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match tcpmss6_match = {
.name = "tcpmss", .name = "tcpmss",
.family = AF_INET6,
.match = match, .match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info), .matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP, .proto = IPPROTO_TCP,
.family = AF_INET6,
.me = THIS_MODULE, .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", .name = "tcp",
.family = AF_INET,
.checkentry = tcp_checkentry,
.match = tcp_match, .match = tcp_match,
.matchsize = sizeof(struct xt_tcp), .matchsize = sizeof(struct xt_tcp),
.proto = IPPROTO_TCP, .proto = IPPROTO_TCP,
.family = AF_INET,
.checkentry = tcp_checkentry,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match tcp6_matchstruct = {
.name = "tcp", .name = "tcp",
.family = AF_INET6,
.checkentry = tcp_checkentry,
.match = tcp_match, .match = tcp_match,
.matchsize = sizeof(struct xt_tcp), .matchsize = sizeof(struct xt_tcp),
.proto = IPPROTO_TCP, .proto = IPPROTO_TCP,
.family = AF_INET6,
.checkentry = tcp_checkentry,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
{
static struct xt_match udp_matchstruct = {
.name = "udp", .name = "udp",
.family = AF_INET,
.checkentry = udp_checkentry,
.match = udp_match, .match = udp_match,
.matchsize = sizeof(struct xt_udp), .matchsize = sizeof(struct xt_udp),
.proto = IPPROTO_UDP, .proto = IPPROTO_UDP,
.family = AF_INET,
.checkentry = udp_checkentry,
.me = THIS_MODULE, .me = THIS_MODULE,
}; },
static struct xt_match udp6_matchstruct = { {
.name = "udp", .name = "udp",
.family = AF_INET6,
.checkentry = udp_checkentry,
.match = udp_match, .match = udp_match,
.matchsize = sizeof(struct xt_udp), .matchsize = sizeof(struct xt_udp),
.proto = IPPROTO_UDP, .proto = IPPROTO_UDP,
.family = AF_INET6,
.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