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

[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 = {
static int __init ip6t_reject_init(void)
{
if (ip6t_register_target(&ip6t_reject_reg))
return -EINVAL;
return 0;
return ip6t_register_target(&ip6t_reject_reg);
}
static void __exit ip6t_reject_fini(void)
......
......@@ -40,47 +40,41 @@ target(struct sk_buff **pskb,
return XT_CONTINUE;
}
static struct xt_target classify_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_INET,
.me = THIS_MODULE,
static struct xt_target xt_classify_target[] = {
{
.family = AF_INET,
.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),
.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)
{
int ret;
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;
return xt_register_targets(xt_classify_target,
ARRAY_SIZE(xt_classify_target));
}
static void __exit xt_classify_fini(void)
{
xt_unregister_target(&classify_reg);
xt_unregister_target(&classify6_reg);
xt_unregister_targets(xt_classify_target,
ARRAY_SIZE(xt_classify_target));
}
module_init(xt_classify_init);
......
......@@ -110,45 +110,36 @@ checkentry(const char *tablename,
return 1;
}
static struct xt_target connmark_reg = {
.name = "CONNMARK",
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE
};
static struct xt_target connmark6_reg = {
.name = "CONNMARK",
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
.family = AF_INET6,
.me = THIS_MODULE
static struct xt_target xt_connmark_target[] = {
{
.name = "CONNMARK",
.family = AF_INET,
.checkentry = checkentry,
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.me = THIS_MODULE
},
{
.name = "CONNMARK",
.family = AF_INET6,
.checkentry = checkentry,
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.me = THIS_MODULE
},
};
static int __init xt_connmark_init(void)
{
int ret;
need_conntrack();
ret = xt_register_target(&connmark_reg);
if (ret)
return ret;
ret = xt_register_target(&connmark6_reg);
if (ret)
xt_unregister_target(&connmark_reg);
return ret;
return xt_register_targets(xt_connmark_target,
ARRAY_SIZE(xt_connmark_target));
}
static void __exit xt_connmark_fini(void)
{
xt_unregister_target(&connmark_reg);
xt_unregister_target(&connmark6_reg);
xt_unregister_targets(xt_connmark_target,
ARRAY_SIZE(xt_connmark_target));
}
module_init(xt_connmark_init);
......
......@@ -106,49 +106,38 @@ static int checkentry(const char *tablename, const void *entry,
return 1;
}
static struct xt_target ipt_connsecmark_reg = {
.name = "CONNSECMARK",
.target = target,
.targetsize = sizeof(struct xt_connsecmark_target_info),
.table = "mangle",
.checkentry = checkentry,
.me = THIS_MODULE,
.family = AF_INET,
.revision = 0,
};
static struct xt_target ip6t_connsecmark_reg = {
.name = "CONNSECMARK",
.target = target,
.targetsize = sizeof(struct xt_connsecmark_target_info),
.table = "mangle",
.checkentry = checkentry,
.me = THIS_MODULE,
.family = AF_INET6,
.revision = 0,
static struct xt_target xt_connsecmark_target[] = {
{
.name = "CONNSECMARK",
.family = AF_INET,
.checkentry = checkentry,
.target = target,
.targetsize = sizeof(struct xt_connsecmark_target_info),
.table = "mangle",
.me = THIS_MODULE,
},
{
.name = "CONNSECMARK",
.family = AF_INET6,
.checkentry = checkentry,
.target = target,
.targetsize = sizeof(struct xt_connsecmark_target_info),
.table = "mangle",
.me = THIS_MODULE,
},
};
static int __init xt_connsecmark_init(void)
{
int err;
need_conntrack();
err = xt_register_target(&ipt_connsecmark_reg);
if (err)
return err;
err = xt_register_target(&ip6t_connsecmark_reg);
if (err)
xt_unregister_target(&ipt_connsecmark_reg);
return err;
return xt_register_targets(xt_connsecmark_targets,
ARRAY_SIZE(xt_connsecmark_targets));
}
static void __exit xt_connsecmark_fini(void)
{
xt_unregister_target(&ip6t_connsecmark_reg);
xt_unregister_target(&ipt_connsecmark_reg);
xt_unregister_targets(xt_connsecmark_targets,
ARRAY_SIZE(xt_connsecmark_targets));
}
module_init(xt_connsecmark_init);
......
......@@ -86,44 +86,35 @@ static int checkentry(const char *tablename,
return 1;
}
static struct xt_target xt_dscp_reg = {
.name = "DSCP",
.target = target,
.targetsize = sizeof(struct xt_DSCP_info),
.table = "mangle",
.checkentry = checkentry,
.family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_target xt_dscp6_reg = {
.name = "DSCP",
.target = target6,
.targetsize = sizeof(struct xt_DSCP_info),
.table = "mangle",
.checkentry = checkentry,
.family = AF_INET6,
.me = THIS_MODULE,
static struct xt_target xt_dscp_target[] = {
{
.name = "DSCP",
.family = AF_INET,
.checkentry = checkentry,
.target = target,
.targetsize = sizeof(struct xt_DSCP_info),
.table = "mangle",
.me = THIS_MODULE,
},
{
.name = "DSCP",
.family = AF_INET6,
.checkentry = checkentry,
.target = target6,
.targetsize = sizeof(struct xt_DSCP_info),
.table = "mangle",
.me = THIS_MODULE,
},
};
static int __init xt_dscp_target_init(void)
{
int ret;
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;
return xt_register_targets(xt_dscp_target, ARRAY_SIZE(xt_dscp_target));
}
static void __exit xt_dscp_target_fini(void)
{
xt_unregister_target(&xt_dscp_reg);
xt_unregister_target(&xt_dscp6_reg);
xt_unregister_targets(xt_dscp_target, ARRAY_SIZE(xt_dscp_target));
}
module_init(xt_dscp_target_init);
......
......@@ -112,65 +112,47 @@ checkentry_v1(const char *tablename,
return 1;
}
static struct xt_target ipt_mark_reg_v0 = {
.name = "MARK",
.target = target_v0,
.targetsize = sizeof(struct xt_mark_target_info),
.table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE,
.family = AF_INET,
.revision = 0,
};
static struct xt_target ipt_mark_reg_v1 = {
.name = "MARK",
.target = target_v1,
.targetsize = sizeof(struct xt_mark_target_info_v1),
.table = "mangle",
.checkentry = checkentry_v1,
.me = THIS_MODULE,
.family = AF_INET,
.revision = 1,
};
static struct xt_target ip6t_mark_reg_v0 = {
.name = "MARK",
.target = target_v0,
.targetsize = sizeof(struct xt_mark_target_info),
.table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE,
.family = AF_INET6,
.revision = 0,
static struct xt_target xt_mark_target[] = {
{
.name = "MARK",
.family = AF_INET,
.revision = 0,
.checkentry = checkentry_v0,
.target = target_v0,
.targetsize = sizeof(struct xt_mark_target_info),
.table = "mangle",
.me = THIS_MODULE,
},
{
.name = "MARK",
.family = AF_INET,
.revision = 1,
.checkentry = checkentry_v1,
.target = target_v1,
.targetsize = sizeof(struct xt_mark_target_info_v1),
.table = "mangle",
.me = THIS_MODULE,
},
{
.name = "MARK",
.family = AF_INET6,
.revision = 0,
.checkentry = checkentry_v0,
.target = target_v0,
.targetsize = sizeof(struct xt_mark_target_info),
.table = "mangle",
.me = THIS_MODULE,
},
};
static int __init xt_mark_init(void)
{
int err;
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;
return xt_register_targets(xt_mark_target, ARRAY_SIZE(xt_mark_target));
}
static void __exit xt_mark_fini(void)
{
xt_unregister_target(&ipt_mark_reg_v0);
xt_unregister_target(&ipt_mark_reg_v1);
xt_unregister_target(&ip6t_mark_reg_v0);
xt_unregister_targets(xt_mark_target, ARRAY_SIZE(xt_mark_target));
}
module_init(xt_mark_init);
......
......@@ -37,57 +37,39 @@ target(struct sk_buff **pskb,
return NF_QUEUE_NR(tinfo->queuenum);
}
static struct xt_target ipt_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
.family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_target ip6t_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
.family = AF_INET6,
.me = THIS_MODULE,
};
static struct xt_target arpt_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
.family = NF_ARP,
.me = THIS_MODULE,
static struct xt_target xt_nfqueue_target[] = {
{
.name = "NFQUEUE",
.family = AF_INET,
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
.me = THIS_MODULE,
},
{
.name = "NFQUEUE",
.family = AF_INET6,
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
.me = THIS_MODULE,
},
{
.name = "NFQUEUE",
.family = NF_ARP,
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
.me = THIS_MODULE,
},
};
static int __init xt_nfqueue_init(void)
{
int ret;
ret = xt_register_target(&ipt_NFQ_reg);
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;
return xt_register_targets(xt_nfqueue_target,
ARRAY_SIZE(xt_nfqueue_target));
}
static void __exit xt_nfqueue_fini(void)
{
xt_unregister_target(&arpt_NFQ_reg);
xt_unregister_target(&ip6t_NFQ_reg);
xt_unregister_target(&ipt_NFQ_reg);
xt_register_targets(xt_nfqueue_target, ARRAY_SIZE(xt_nfqueue_target));
}
module_init(xt_nfqueue_init);
......
......@@ -34,43 +34,32 @@ target(struct sk_buff **pskb,
return XT_CONTINUE;
}
static struct xt_target notrack_reg = {
.name = "NOTRACK",
.target = target,
.targetsize = 0,
.table = "raw",
.family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_target notrack6_reg = {
.name = "NOTRACK",
.target = target,
.targetsize = 0,
.table = "raw",
.family = AF_INET6,
.me = THIS_MODULE,
static struct xt_target xt_notrack_target[] = {
{
.name = "NOTRACK",
.family = AF_INET,
.target = target,
.table = "raw",
.me = THIS_MODULE,
},
{
.name = "NOTRACK",
.family = AF_INET6,
.target = target,
.table = "raw",
.me = THIS_MODULE,
},
};
static int __init xt_notrack_init(void)
{
int ret;
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;
return xt_register_targets(xt_notrack_target,
ARRAY_SIZE(xt_notrack_target));
}
static void __exit xt_notrack_fini(void)
{
xt_unregister_target(&notrack6_reg);
xt_unregister_target(&notrack_reg);
xt_unregister_targets(xt_notrack_target, ARRAY_SIZE(xt_notrack_target));
}
module_init(xt_notrack_init);
......
......@@ -111,47 +111,36 @@ static int checkentry(const char *tablename, const void *entry,
return 1;
}
static struct xt_target ipt_secmark_reg = {
.name = "SECMARK",
.target = target,
.targetsize = sizeof(struct xt_secmark_target_info),
.table = "mangle",
.checkentry = checkentry,
.me = THIS_MODULE,
.family = AF_INET,
.revision = 0,
};
static struct xt_target ip6t_secmark_reg = {
.name = "SECMARK",
.target = target,
.targetsize = sizeof(struct xt_secmark_target_info),
.table = "mangle",
.checkentry = checkentry,
.me = THIS_MODULE,
.family = AF_INET6,
.revision = 0,
static struct xt_target xt_secmark_target = {
{
.name = "SECMARK",
.family = AF_INET,
.checkentry = checkentry,
.target = target,
.targetsize = sizeof(struct xt_secmark_target_info),
.table = "mangle",
.me = THIS_MODULE,
},
{
.name = "SECMARK",
.family = AF_INET6,
.checkentry = checkentry,
.target = target,
.targetsize = sizeof(struct xt_secmark_target_info),
.table = "mangle",
.me = THIS_MODULE,
},
};
static int __init xt_secmark_init(void)
{
int err;
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;
return xt_register_targets(xt_secmark_target,
ARRAY_SIZE(xt_secmark_target));
}
static void __exit xt_secmark_fini(void)
{