[NETFILTER]: x_tables: make use of mass registation helpers
authorPatrick McHardy <kaber@trash.net>
Tue, 22 Aug 2006 07:34:04 +0000 (00:34 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 22 Sep 2006 21:55:32 +0000 (14:55 -0700)
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
32 files changed:
net/ipv6/netfilter/ip6t_REJECT.c
net/netfilter/xt_CLASSIFY.c
net/netfilter/xt_CONNMARK.c
net/netfilter/xt_CONNSECMARK.c
net/netfilter/xt_DSCP.c
net/netfilter/xt_MARK.c
net/netfilter/xt_NFQUEUE.c
net/netfilter/xt_NOTRACK.c
net/netfilter/xt_SECMARK.c
net/netfilter/xt_comment.c
net/netfilter/xt_connbytes.c
net/netfilter/xt_connmark.c
net/netfilter/xt_conntrack.c
net/netfilter/xt_dccp.c
net/netfilter/xt_dscp.c
net/netfilter/xt_esp.c
net/netfilter/xt_helper.c
net/netfilter/xt_length.c
net/netfilter/xt_limit.c
net/netfilter/xt_mac.c
net/netfilter/xt_mark.c
net/netfilter/xt_multiport.c
net/netfilter/xt_physdev.c
net/netfilter/xt_pkttype.c
net/netfilter/xt_policy.c
net/netfilter/xt_quota.c
net/netfilter/xt_sctp.c
net/netfilter/xt_state.c
net/netfilter/xt_statistic.c
net/netfilter/xt_string.c
net/netfilter/xt_tcpmss.c
net/netfilter/xt_tcpudp.c

index c4eba1aeb3233eff2424fa608d36ae329f692430..7929ff4021660c2d330717dd77b566d6663a7122 100644 (file)
@@ -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)
index e54e57730012de72a1467c1cb16f96edd9492b02..1f92edd059336a9bf042d9c1059c4ef62fcde8d6 100644 (file)
@@ -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);
index 19989a915433378437e02833908581525786671d..e577356b5c7117ad84fa7c0d0d08d544eadeec6f 100644 (file)
@@ -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);
index 8c011e0207695fbe170ecb03e9cc7510c547a496..48f7fc3c85cdd4df40052ab53b6b3709963eba0a 100644 (file)
@@ -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);
index 79df8165cd791704fd465fa0166bbfd21673a2ad..a1cd9723644fa370e0101b416db425c2abb06af8 100644 (file)
@@ -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);
index ee9c34edc76c4e8d8b920013c8f4825b6de37a36..0a61272194677767828114d107f829a439adfc58 100644 (file)
@@ -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);
index 86ccceb61fdde78b06d27d6c12dc4686849f7046..7b982283abdbe297fdb66d7e1ff0189caa8f3317 100644 (file)
@@ -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);
index 98f4b5363ce8e8e4adcce549cfe63119c24db610..cab881d4424ca59d01f0fd9428527fd37ea7f7c4 100644 (file)
@@ -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);
index de9537ad9a7c5307f48cdbe41147e88ae19132a3..4300988786c9c3eb8554e8655714567e7b4a1243 100644 (file)
@@ -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)
 {
-       xt_unregister_target(&ip6t_secmark_reg);
-       xt_unregister_target(&ipt_secmark_reg);
+       xt_unregister_targets(xt_secmark_target, ARRAY_SIZE(xt_secmark_target));
 }
 
 module_init(xt_secmark_init);
index 197609cb06d7e6cb6249d291aeb06abc00abec75..7db492d652203af3441089d3017a7b3101bb28a5 100644 (file)
@@ -29,41 +29,32 @@ match(const struct sk_buff *skb,
        return 1;
 }
 
-static struct xt_match comment_match = {
-       .name           = "comment",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_comment_info),
-       .family         = AF_INET,
-       .me             = THIS_MODULE
-};
-
-static struct xt_match comment6_match = {
-       .name           = "comment",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_comment_info),
-       .family         = AF_INET6,
-       .me             = THIS_MODULE
+static struct xt_match xt_comment_match[] = {
+       {
+               .name           = "comment",
+               .family         = AF_INET,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_comment_info),
+               .me             = THIS_MODULE
+       },
+       {
+               .name           = "comment",
+               .family         = AF_INET6,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_comment_info),
+               .me             = THIS_MODULE
+       },
 };
 
 static int __init xt_comment_init(void)
 {
-       int ret;
-
-       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;
+       return xt_register_matches(xt_comment_match,
+                                  ARRAY_SIZE(xt_comment_match));
 }
 
 static void __exit xt_comment_fini(void)
 {
-       xt_unregister_match(&comment_match);
-       xt_unregister_match(&comment6_match);
+       xt_unregister_matches(xt_comment_match, ARRAY_SIZE(xt_comment_match));
 }
 
 module_init(xt_comment_init);
index 1396fe2d07c14bc1b2f5ac0a0b15c444db597fd7..2d49948d3c38773a3fe5ccd39ba8f80538b542c0 100644 (file)
@@ -143,40 +143,35 @@ static int check(const char *tablename,
        return 1;
 }
 
-static struct xt_match connbytes_match = {
-       .name           = "connbytes",
-       .match          = match,
-       .checkentry     = check,
-       .matchsize      = sizeof(struct xt_connbytes_info),
-       .family         = AF_INET,
-       .me             = THIS_MODULE
-};
-static struct xt_match connbytes6_match = {
-       .name           = "connbytes",
-       .match          = match,
-       .checkentry     = check,
-       .matchsize      = sizeof(struct xt_connbytes_info),
-       .family         = AF_INET6,
-       .me             = THIS_MODULE
+static struct xt_match xt_connbytes_match = {
+       {
+               .name           = "connbytes",
+               .family         = AF_INET,
+               .checkentry     = check,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_connbytes_info),
+               .me             = THIS_MODULE
+       },
+       {
+               .name           = "connbytes",
+               .family         = AF_INET6,
+               .checkentry     = check,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_connbytes_info),
+               .me             = THIS_MODULE
+       },
 };
 
 static int __init xt_connbytes_init(void)
 {
-       int ret;
-       ret = xt_register_match(&connbytes_match);
-       if (ret)
-               return ret;
-
-       ret = xt_register_match(&connbytes6_match);
-       if (ret)
-               xt_unregister_match(&connbytes_match);
-       return ret;
+       return xt_register_matches(xt_connbytes_match,
+                                  ARRAY_SIZE(xt_connbytes_match));
 }
 
 static void __exit xt_connbytes_fini(void)
 {
-       xt_unregister_match(&connbytes_match);
-       xt_unregister_match(&connbytes6_match);
+       xt_unregister_matches(xt_connbytes_match,
+                             ARRAY_SIZE(xt_connbytes_match));
 }
 
 module_init(xt_connbytes_init);
index 56324c8aff0a76c9507fc4133dd5ad194d360bfb..a97b2d455b797cc4efb10b874192ff4561021d3b 100644 (file)
@@ -82,46 +82,37 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
 #endif
 }
 
-static struct xt_match connmark_match = {
-       .name           = "connmark",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_connmark_info),
-       .checkentry     = checkentry,
-       .destroy        = destroy,
-       .family         = AF_INET,
-       .me             = THIS_MODULE
-};
-
-static struct xt_match connmark6_match = {
-       .name           = "connmark",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_connmark_info),
-       .checkentry     = checkentry,
-       .destroy        = destroy,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE
+static struct xt_match xt_connmark_match[] = {
+       {
+               .name           = "connmark",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_connmark_info),
+               .me             = THIS_MODULE
+       },
+       {
+               .name           = "connmark",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_connmark_info),
+               .me             = THIS_MODULE
+       },
 };
 
 static int __init xt_connmark_init(void)
 {
-       int ret;
-
        need_conntrack();
-
-       ret = xt_register_match(&connmark_match);
-       if (ret)
-               return ret;
-
-       ret = xt_register_match(&connmark6_match);
-       if (ret)
-               xt_unregister_match(&connmark_match);
-       return ret;
+       return xt_register_matches(xt_connmark_match,
+                                  ARRAY_SIZE(xt_connmark_match));
 }
 
 static void __exit xt_connmark_fini(void)
 {
-       xt_unregister_match(&connmark6_match);
-       xt_unregister_match(&connmark_match);
+       xt_register_matches(xt_connmark_match, ARRAY_SIZE(xt_connmark_match));
 }
 
 module_init(xt_connmark_init);
index 145489a4c3f291f07b7a7d8a2d38f4dbcda0d444..1540885174ee4cea4583395a4130112b5a417560 100644 (file)
@@ -241,11 +241,8 @@ static struct xt_match conntrack_match = {
 
 static int __init xt_conntrack_init(void)
 {
-       int ret;
        need_conntrack();
-       ret = xt_register_match(&conntrack_match);
-
-       return ret;
+       return xt_register_match(&conntrack_match);
 }
 
 static void __exit xt_conntrack_fini(void)
index 2e2f825dad4c35744d0121aafbe1e74e7bd362c5..5ca6f5288f469d30929e7e18df33a368153628f5 100644 (file)
@@ -141,27 +141,26 @@ checkentry(const char *tablename,
                && !(info->invflags & ~info->flags);
 }
 
-static struct xt_match dccp_match = 
-{ 
-       .name           = "dccp",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_dccp_info),
-       .proto          = IPPROTO_DCCP,
-       .checkentry     = checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
+static struct xt_match xt_dccp_match[] = {
+       {
+               .name           = "dccp",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_dccp_info),
+               .proto          = IPPROTO_DCCP,
+               .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)
 {
@@ -173,27 +172,19 @@ static int __init xt_dccp_init(void)
        dccp_optbuf = kmalloc(256 * 4, GFP_KERNEL);
        if (!dccp_optbuf)
                return -ENOMEM;
-       ret = xt_register_match(&dccp_match);
+       ret = xt_register_matches(xt_dccp_match, ARRAY_SIZE(xt_dccp_match));
        if (ret)
                goto out_kfree;
-       ret = xt_register_match(&dccp6_match);
-       if (ret)
-               goto out_unreg;
-
        return ret;
 
-out_unreg:
-       xt_unregister_match(&dccp_match);
 out_kfree:
        kfree(dccp_optbuf);
-
        return ret;
 }
 
 static void __exit xt_dccp_fini(void)
 {
-       xt_unregister_match(&dccp6_match);
-       xt_unregister_match(&dccp_match);
+       xt_unregister_matches(xt_dccp_match, ARRAY_SIZE(xt_dccp_match));
        kfree(dccp_optbuf);
 }
 
index 82e250d1f007bf1fa8998bfa15a93b4857566db7..d84075c30159b6627b2e164700373ef9a61d9568 100644 (file)
@@ -71,42 +71,33 @@ static int checkentry(const char *tablename,
        return 1;
 }
 
-static struct xt_match dscp_match = {
-       .name           = "dscp",
-       .match          = match,
-       .checkentry     = checkentry,
-       .matchsize      = sizeof(struct xt_dscp_info),
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match dscp6_match = {
-       .name           = "dscp",
-       .match          = match6,
-       .checkentry     = checkentry,
-       .matchsize      = sizeof(struct xt_dscp_info),
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_dscp_match[] = {
+       {
+               .name           = "dscp",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_dscp_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "dscp",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match6,
+               .matchsize      = sizeof(struct xt_dscp_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_dscp_match_init(void)
 {
-       int ret;
-       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;
+       return xt_register_matches(xt_dscp_match, ARRAY_SIZE(xt_dscp_match));
 }
 
 static void __exit xt_dscp_match_fini(void)
 {
-       xt_unregister_match(&dscp_match);
-       xt_unregister_match(&dscp6_match);
+       xt_unregister_matches(xt_dscp_match, ARRAY_SIZE(xt_dscp_match));
 }
 
 module_init(xt_dscp_match_init);
index 9dad6281e0c1084f606a53b7fd0866cb70bc2cc0..7b19bc9ea205c05da3e567817264e0488f3c0e2d 100644 (file)
@@ -92,44 +92,35 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct xt_match esp_match = {
-       .name           = "esp",
-       .family         = AF_INET,
-       .proto          = IPPROTO_ESP,
-       .match          = &match,
-       .matchsize      = sizeof(struct xt_esp),
-       .checkentry     = &checkentry,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match esp6_match = {
-       .name           = "esp",
-       .family         = AF_INET6,
-       .proto          = IPPROTO_ESP,
-       .match          = &match,
-       .matchsize      = sizeof(struct xt_esp),
-       .checkentry     = &checkentry,
-       .me             = THIS_MODULE,
+static struct xt_match xt_esp_match[] = {
+       {
+               .name           = "esp",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_esp),
+               .proto          = IPPROTO_ESP,
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "esp",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_esp),
+               .proto          = IPPROTO_ESP,
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_esp_init(void)
 {
-       int ret;
-       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;
+       return xt_register_matches(xt_esp_match, ARRAY_SIZE(xt_esp_match));
 }
 
 static void __exit xt_esp_cleanup(void)
 {
-       xt_unregister_match(&esp_match);
-       xt_unregister_match(&esp6_match);
+       xt_unregister_matches(xt_esp_match, ARRAY_SIZE(xt_esp_match));
 }
 
 module_init(xt_esp_init);
index 799c2a43e3b900285e4b52270e862f6428d86cd9..db453a7a154eb327018748891aa1f9ec48b1c07d 100644 (file)
@@ -163,45 +163,37 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
 #endif
 }
 
-static struct xt_match helper_match = {
-       .name           = "helper",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_helper_info),
-       .checkentry     = check,
-       .destroy        = destroy,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-static struct xt_match helper6_match = {
-       .name           = "helper",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_helper_info),
-       .checkentry     = check,
-       .destroy        = destroy,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_helper_match[] = {
+       {
+               .name           = "helper",
+               .family         = AF_INET,
+               .checkentry     = check,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_helper_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "helper",
+               .family         = AF_INET6,
+               .checkentry     = check,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_helper_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_helper_init(void)
 {
-       int ret;
        need_conntrack();
-
-       ret = xt_register_match(&helper_match);
-       if (ret < 0)
-               return ret;
-
-       ret = xt_register_match(&helper6_match);
-       if (ret < 0)
-               xt_unregister_match(&helper_match);
-
-       return ret;
+       return xt_register_matches(xt_helper_match,
+                                  ARRAY_SIZE(xt_helper_match));
 }
 
 static void __exit xt_helper_fini(void)
 {
-       xt_unregister_match(&helper_match);
-       xt_unregister_match(&helper6_match);
+       xt_unregister_matches(xt_helper_match, ARRAY_SIZE(xt_helper_match));
 }
 
 module_init(xt_helper_init);
index 109132c9a1462727267a4aab426215ed97495a00..67fd30d9f303232bfd64bfda54c0e7746b2adc47 100644 (file)
@@ -52,39 +52,32 @@ match6(const struct sk_buff *skb,
        return (pktlen >= info->min && pktlen <= info->max) ^ info->invert;
 }
 
-static struct xt_match length_match = {
-       .name           = "length",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_length_info),
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match length6_match = {
-       .name           = "length",
-       .match          = match6,
-       .matchsize      = sizeof(struct xt_length_info),
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_length_match[] = {
+       {
+               .name           = "length",
+               .family         = AF_INET,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_length_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "length",
+               .family         = AF_INET6,
+               .match          = match6,
+               .matchsize      = sizeof(struct xt_length_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_length_init(void)
 {
-       int ret;
-       ret = xt_register_match(&length_match);
-       if (ret)
-               return ret;
-       ret = xt_register_match(&length6_match);
-       if (ret)
-               xt_unregister_match(&length_match);
-
-       return ret;
+       return xt_register_matches(xt_length_match,
+                                  ARRAY_SIZE(xt_length_match));
 }
 
 static void __exit xt_length_fini(void)
 {
-       xt_unregister_match(&length_match);
-       xt_unregister_match(&length6_match);
+       xt_unregister_matches(xt_length_match, ARRAY_SIZE(xt_length_match));
 }
 
 module_init(xt_length_init);
index ce7fdb7e4e07ce38e798d9f3f515fc30b1be79de..e8d5e7ac695ab158d629bd54167f8f9ab239a8ab 100644 (file)
@@ -136,42 +136,33 @@ ipt_limit_checkentry(const char *tablename,
        return 1;
 }
 
-static struct xt_match ipt_limit_reg = {
-       .name           = "limit",
-       .match          = ipt_limit_match,
-       .matchsize      = sizeof(struct xt_rateinfo),
-       .checkentry     = ipt_limit_checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-static struct xt_match limit6_reg = {
-       .name           = "limit",
-       .match          = ipt_limit_match,
-       .matchsize      = sizeof(struct xt_rateinfo),
-       .checkentry     = ipt_limit_checkentry,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_limit_match[] = {
+       {
+               .name           = "limit",
+               .family         = AF_INET,
+               .checkentry     = ipt_limit_checkentry,
+               .match          = ipt_limit_match,
+               .matchsize      = sizeof(struct xt_rateinfo),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "limit",
+               .family         = AF_INET6,
+               .checkentry     = ipt_limit_checkentry,
+               .match          = ipt_limit_match,
+               .matchsize      = sizeof(struct xt_rateinfo),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_limit_init(void)
 {
-       int ret;
-       
-       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;
+       return xt_register_matches(xt_limit_match, ARRAY_SIZE(xt_limit_match));
 }
 
 static void __exit xt_limit_fini(void)
 {
-       xt_unregister_match(&ipt_limit_reg);
-       xt_unregister_match(&limit6_reg);
+       xt_unregister_matches(xt_limit_match, ARRAY_SIZE(xt_limit_match));
 }
 
 module_init(xt_limit_init);
index 356290ffe386e789148306e117c3c4dd07264488..425fc21e31f54f95013382007075c12d35f8a709 100644 (file)
@@ -43,43 +43,37 @@ match(const struct sk_buff *skb,
                ^ info->invert));
 }
 
-static struct xt_match mac_match = {
-       .name           = "mac",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_mac_info),
-       .hooks          = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
-                         (1 << NF_IP_FORWARD),
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-static struct xt_match mac6_match = {
-       .name           = "mac",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_mac_info),
-       .hooks          = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
-                         (1 << NF_IP_FORWARD),
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_mac_match[] = {
+       {
+               .name           = "mac",
+               .family         = AF_INET,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_mac_info),
+               .hooks          = (1 << NF_IP_PRE_ROUTING) |
+                                 (1 << NF_IP_LOCAL_IN) |
+                                 (1 << NF_IP_FORWARD),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "mac",
+               .family         = AF_INET6,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_mac_info),
+               .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)
 {
-       int ret;
-       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;
+       return xt_register_matches(xt_mac_match, ARRAY_SIZE(xt_mac_match));
 }
 
 static void __exit xt_mac_fini(void)
 {
-       xt_unregister_match(&mac_match);
-       xt_unregister_match(&mac6_match);
+       xt_unregister_matches(xt_mac_match, ARRAY_SIZE(xt_mac_match));
 }
 
 module_init(xt_mac_init);
index 876bc57977381bc62ffd6c11c077cd3570428e1f..39f9b079f5d4ac7d1254442bc991876f881a7c00 100644 (file)
@@ -51,42 +51,33 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct xt_match mark_match = {
-       .name           = "mark",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_mark_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match mark6_match = {
-       .name           = "mark",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_mark_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_mark_match[] = {
+       {
+               .name           = "mark",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_mark_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "mark",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_mark_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_mark_init(void)
 {
-       int ret;
-       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;
+       return xt_register_matches(xt_mark_match, ARRAY_SIZE(xt_mark_match));
 }
 
 static void __exit xt_mark_fini(void)
 {
-       xt_unregister_match(&mark_match);
-       xt_unregister_match(&mark6_match);
+       xt_unregister_matches(xt_mark_match, ARRAY_SIZE(xt_mark_match));
 }
 
 module_init(xt_mark_init);
index 1ff0a25396e75251844da5aae739b4062323c88e..e74f9bb98b3c6e0a584303eb923f95229979f5fb 100644 (file)
@@ -231,84 +231,55 @@ checkentry6_v1(const char *tablename,
                     multiinfo->count);
 }
 
-static struct xt_match multiport_match = {
-       .name           = "multiport",
-       .revision       = 0,
-       .matchsize      = sizeof(struct xt_multiport),
-       .match          = &match,
-       .checkentry     = &checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match multiport_match_v1 = {
-       .name           = "multiport",
-       .revision       = 1,
-       .matchsize      = sizeof(struct xt_multiport_v1),
-       .match          = &match_v1,
-       .checkentry     = &checkentry_v1,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match multiport6_match = {
-       .name           = "multiport",
-       .revision       = 0,
-       .matchsize      = sizeof(struct xt_multiport),
-       .match          = &match,
-       .checkentry     = &checkentry6,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match multiport6_match_v1 = {
-       .name           = "multiport",
-       .revision       = 1,
-       .matchsize      = sizeof(struct xt_multiport_v1),
-       .match          = &match_v1,
-       .checkentry     = &checkentry6_v1,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_multiport_match[] = {
+       {
+               .name           = "multiport",
+               .family         = AF_INET,
+               .revision       = 0,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_multiport),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "multiport",
+               .family         = AF_INET,
+               .revision       = 1,
+               .checkentry     = checkentry_v1,
+               .match          = match_v1,
+               .matchsize      = sizeof(struct xt_multiport_v1),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "multiport",
+               .family         = AF_INET6,
+               .revision       = 0,
+               .checkentry     = checkentry6,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_multiport),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "multiport",
+               .family         = AF_INET6,
+               .revision       = 1,
+               .checkentry     = checkentry6_v1,
+               .match          = match_v1,
+               .matchsize      = sizeof(struct xt_multiport_v1),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_multiport_init(void)
 {
-       int ret;
-
-       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;
+       return xt_register_matches(xt_multiport_match,
+                                  ARRAY_SIZE(xt_multiport_match));
 }
 
 static void __exit xt_multiport_fini(void)
 {
-       xt_unregister_match(&multiport_match);
-       xt_unregister_match(&multiport_match_v1);
-       xt_unregister_match(&multiport6_match);
-       xt_unregister_match(&multiport6_match_v1);
+       xt_unregister_matches(xt_multiport_match,
+                             ARRAY_SIZE(xt_multiport_match));
 }
 
 module_init(xt_multiport_init);
index 63a96546746575979e2200b87d9a557c774e6970..af3d70f96ecdff678836090d434dd5764cd42f59 100644 (file)
@@ -132,43 +132,34 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct xt_match physdev_match = {
-       .name           = "physdev",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_physdev_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match physdev6_match = {
-       .name           = "physdev",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_physdev_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_physdev_match[] = {
+       {
+               .name           = "physdev",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_physdev_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "physdev",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_physdev_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_physdev_init(void)
 {
-       int ret;
-
-       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;
+       return xt_register_matches(xt_physdev_match,
+                                  ARRAY_SIZE(xt_physdev_match));
 }
 
 static void __exit xt_physdev_fini(void)
 {
-       xt_unregister_match(&physdev_match);
-       xt_unregister_match(&physdev6_match);
+       xt_unregister_matches(xt_physdev_match, ARRAY_SIZE(xt_physdev_match));
 }
 
 module_init(xt_physdev_init);
index d2f5320a80bf6a91f97ff2790ec2f3d5540c87e2..16e7b080428760c69559135a49bd3cfe76cbad81 100644 (file)
@@ -43,40 +43,32 @@ static int match(const struct sk_buff *skb,
        return (type == info->pkttype) ^ info->invert;
 }
 
-static struct xt_match pkttype_match = {
-       .name           = "pkttype",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_pkttype_info),
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match pkttype6_match = {
-       .name           = "pkttype",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_pkttype_info),
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_pkttype_match[] = {
+       {
+               .name           = "pkttype",
+               .family         = AF_INET,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_pkttype_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "pkttype",
+               .family         = AF_INET6,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_pkttype_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_pkttype_init(void)
 {
-       int ret;
-       ret = xt_register_match(&pkttype_match);
-       if (ret)
-               return ret;
-
-       ret = xt_register_match(&pkttype6_match);
-       if (ret)
-               xt_unregister_match(&pkttype_match);
-
-       return ret;
+       return xt_register_matches(xt_pkttype_match,
+                                  ARRAY_SIZE(xt_pkttype_match));
 }
 
 static void __exit xt_pkttype_fini(void)
 {
-       xt_unregister_match(&pkttype_match);
-       xt_unregister_match(&pkttype6_match);
+       xt_unregister_matches(xt_pkttype_match, ARRAY_SIZE(xt_pkttype_match));
 }
 
 module_init(xt_pkttype_init);
index ba1ca03abad326b4d37bf5dceb8338792294b17e..f5639c451112cc2232c02b458536374aef476230 100644 (file)
@@ -165,43 +165,36 @@ static int checkentry(const char *tablename, const void *ip_void,
        return 1;
 }
 
-static struct xt_match policy_match = {
-       .name           = "policy",
-       .family         = AF_INET,
-       .match          = match,
-       .matchsize      = sizeof(struct xt_policy_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match policy6_match = {
-       .name           = "policy",
-       .family         = AF_INET6,
-       .match          = match,
-       .matchsize      = sizeof(struct xt_policy_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_policy_match[] = {
+       {
+               .name           = "policy",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_policy_info),
+               .family         = AF_INET,
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "policy",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_policy_info),
+               .family         = AF_INET6,
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init init(void)
 {
-       int ret;
-
-       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;
+       return xt_register_matches(xt_policy_match,
+                                  ARRAY_SIZE(xt_policy_match));
 }
 
 static void __exit fini(void)
 {
-       xt_unregister_match(&policy6_match);
-       xt_unregister_match(&policy_match);
+       xt_unregister_matches(xt_policy_match, ARRAY_SIZE(xt_policy_match));
 }
 
 module_init(init);
index be8d3c26b56828bc3fb2e580d84dedecbb8e86d0..cc44f87cb8e685945a8d456d15d62c1f45ce10ae 100644 (file)
@@ -52,46 +52,33 @@ checkentry(const char *tablename, const void *entry,
        return 1;
 }
 
-static struct xt_match quota_match = {
-       .name           = "quota",
-       .family         = AF_INET,
-       .match          = match,
-       .matchsize      = sizeof(struct xt_quota_info),
-       .checkentry     = checkentry,
-       .me             = THIS_MODULE
-};
-
-static struct xt_match quota_match6 = {
-       .name           = "quota",
-       .family         = AF_INET6,
-       .match          = match,
-       .matchsize      = sizeof(struct xt_quota_info),
-       .checkentry     = checkentry,
-       .me             = THIS_MODULE
+static struct xt_match xt_quota_match[] = {
+       {
+               .name           = "quota",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_quota_info),
+               .me             = THIS_MODULE
+       },
+       {
+               .name           = "quota",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_quota_info),
+               .me             = THIS_MODULE
+       },
 };
 
 static int __init xt_quota_init(void)
 {
-       int ret;
-
-       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;
+       return xt_register_matches(xt_quota_match, ARRAY_SIZE(xt_quota_match));
 }
 
 static void __exit xt_quota_fini(void)
 {
-       xt_unregister_match(&quota_match6);
-       xt_unregister_match(&quota_match);
+       xt_unregister_matches(xt_quota_match, ARRAY_SIZE(xt_quota_match));
 }
 
 module_init(xt_quota_init);
index 843383e01d4155179c66928fafd08e5e64f2f8ac..5628621170e6baab82057d8024fdc24f3d822813 100644 (file)
@@ -178,44 +178,35 @@ checkentry(const char *tablename,
                                | SCTP_CHUNK_MATCH_ONLY)));
 }
 
-static struct xt_match sctp_match = {
-       .name           = "sctp",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_sctp_info),
-       .proto          = IPPROTO_SCTP,
-       .checkentry     = checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE
-};
-
-static struct xt_match sctp6_match = {
-       .name           = "sctp",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_sctp_info),
-       .proto          = IPPROTO_SCTP,
-       .checkentry     = checkentry,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE
+static struct xt_match xt_sctp_match[] = {
+       {
+               .name           = "sctp",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_sctp_info),
+               .proto          = IPPROTO_SCTP,
+               .me             = THIS_MODULE
+       },
+       {
+               .name           = "sctp",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_sctp_info),
+               .proto          = IPPROTO_SCTP,
+               .me             = THIS_MODULE
+       },
 };
 
 static int __init xt_sctp_init(void)
 {
-       int ret;
-       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;
+       return xt_register_matches(xt_sctp_match, ARRAY_SIZE(xt_sctp_match));
 }
 
 static void __exit xt_sctp_fini(void)
 {
-       xt_unregister_match(&sctp6_match);
-       xt_unregister_match(&sctp_match);
+       xt_unregister_matches(xt_sctp_match, ARRAY_SIZE(xt_sctp_match));
 }
 
 module_init(xt_sctp_init);
index f9e304dc4504e6e3c201c2d70e370f516a56f744..5f9492e3b2b1c50ce56b0178538e256230f310e0 100644 (file)
@@ -69,47 +69,36 @@ destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
 #endif
 }
 
-static struct xt_match state_match = {
-       .name           = "state",
-       .match          = match,
-       .checkentry     = check,
-       .destroy        = destroy,
-       .matchsize      = sizeof(struct xt_state_info),
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match state6_match = {
-       .name           = "state",
-       .match          = match,
-       .checkentry     = check,
-       .destroy        = destroy,
-       .matchsize      = sizeof(struct xt_state_info),
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_state_match[] = {
+       {
+               .name           = "state",
+               .family         = AF_INET,
+               .checkentry     = check,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_state_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "state",
+               .family         = AF_INET6,
+               .checkentry     = check,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_state_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_state_init(void)
 {
-       int ret;
-
        need_conntrack();
-
-       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;
+       return xt_register_matches(xt_state_match, ARRAY_SIZE(xt_state_match));
 }
 
 static void __exit xt_state_fini(void)
 {
-       xt_unregister_match(&state_match);
-       xt_unregister_match(&state6_match);
+       xt_unregister_matches(xt_state_match, ARRAY_SIZE(xt_state_match));
 }
 
 module_init(xt_state_init);
index de1037f58596d3268e9ec4c7387b4787938d6b27..5181630a87fc9bfddfd52f6299ff482a5c3a7076 100644 (file)
@@ -66,46 +66,35 @@ checkentry(const char *tablename, const void *entry,
        return 1;
 }
 
-static struct xt_match statistic_match = {
-       .name           = "statistic",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_statistic_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match statistic_match6 = {
-       .name           = "statistic",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_statistic_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_statistic_match[] = {
+       {
+               .name           = "statistic",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_statistic_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "statistic",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_statistic_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_statistic_init(void)
 {
-       int ret;
-
-       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;
+       return xt_register_matches(xt_statistic_match,
+                                  ARRAY_SIZE(xt_statistic_match));
 }
 
 static void __exit xt_statistic_fini(void)
 {
-       xt_unregister_match(&statistic_match6);
-       xt_unregister_match(&statistic_match);
+       xt_unregister_matches(xt_statistic_match,
+                             ARRAY_SIZE(xt_statistic_match));
 }
 
 module_init(xt_statistic_init);
index 275330fcdaaab9dfebba281e3baf5e80671c884c..1a1c1d17d85e0d0d2cef0010be5135601d34e870 100644 (file)
@@ -75,43 +75,35 @@ static void destroy(const struct xt_match *match, void *matchinfo,
        textsearch_destroy(STRING_TEXT_PRIV(matchinfo)->config);
 }
 
-static struct xt_match string_match = {
-       .name           = "string",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_string_info),
-       .checkentry     = checkentry,
-       .destroy        = destroy,
-       .family         = AF_INET,
-       .me             = THIS_MODULE
-};
-static struct xt_match string6_match = {
-       .name           = "string",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_string_info),
-       .checkentry     = checkentry,
-       .destroy        = destroy,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE
+static struct xt_match xt_string_match[] = {
+       {
+               .name           = "string",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_string_info),
+               .me             = THIS_MODULE
+       },
+       {
+               .name           = "string",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .destroy        = destroy,
+               .matchsize      = sizeof(struct xt_string_info),
+               .me             = THIS_MODULE
+       },
 };
 
 static int __init xt_string_init(void)
 {
-       int ret;
-
-       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;
+       return xt_register_matches(xt_string_match, ARRAY_SIZE(xt_string_match));
 }
 
 static void __exit xt_string_fini(void)
 {
-       xt_unregister_match(&string_match);
-       xt_unregister_match(&string6_match);
+       xt_unregister_matches(xt_string_match, ARRAY_SIZE(xt_string_match));
 }
 
 module_init(xt_string_init);
index cf7d335cadcd157aaa242a0ed13afe4f0a3735fc..7baa9ebc46c14d321d432ddccc4b2450729924ba 100644 (file)
@@ -93,43 +93,34 @@ match(const struct sk_buff *skb,
                               info->invert, hotdrop);
 }
 
-static struct xt_match tcpmss_match = {
-       .name           = "tcpmss",
-       .match          = match,
-       .matchsize      = sizeof(struct xt_tcpmss_match_info),
-       .proto          = IPPROTO_TCP,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
+static struct xt_match xt_tcpmss_match[] = {
+       {
+               .name           = "tcpmss",
+               .family         = AF_INET,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_tcpmss_match_info),
+               .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)
 {
-       int ret;
-       ret = xt_register_match(&tcpmss_match);
-       if (ret)
-               return ret;
-
-       ret = xt_register_match(&tcpmss6_match);
-       if (ret)
-               xt_unregister_match(&tcpmss_match);
-
-       return ret;
+       return xt_register_matches(xt_tcpmss_match,
+                                  ARRAY_SIZE(xt_tcpmss_match));
 }
 
 static void __exit xt_tcpmss_fini(void)
 {
-       xt_unregister_match(&tcpmss6_match);
-       xt_unregister_match(&tcpmss_match);
+       xt_unregister_matches(xt_tcpmss_match, ARRAY_SIZE(xt_tcpmss_match));
 }
 
 module_init(xt_tcpmss_init);
index a9a63aa6893692a774b52c1cae9441262c2c1602..54aab051af869c5f4e2d2c90e46ee29c236c889e 100644 (file)
@@ -199,81 +199,54 @@ udp_checkentry(const char *tablename,
        return !(udpinfo->invflags & ~XT_UDP_INV_MASK);
 }
 
-static struct xt_match tcp_matchstruct = {
-       .name           = "tcp",
-       .match          = tcp_match,
-       .matchsize      = sizeof(struct xt_tcp),
-       .proto          = IPPROTO_TCP,
-       .family         = AF_INET,
-       .checkentry     = tcp_checkentry,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match tcp6_matchstruct = {
-       .name           = "tcp",
-       .match          = tcp_match,
-       .matchsize      = sizeof(struct xt_tcp),
-       .proto          = IPPROTO_TCP,
-       .family         = AF_INET6,
-       .checkentry     = tcp_checkentry,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match udp_matchstruct = {
-       .name           = "udp",
-       .match          = udp_match,
-       .matchsize      = sizeof(struct xt_udp),
-       .proto          = IPPROTO_UDP,
-       .family         = AF_INET,
-       .checkentry     = udp_checkentry,
-       .me             = THIS_MODULE,
-};
-static struct xt_match udp6_matchstruct = {
-       .name           = "udp",
-       .match          = udp_match,
-       .matchsize      = sizeof(struct xt_udp),
-       .proto          = IPPROTO_UDP,
-       .family         = AF_INET6,
-       .checkentry     = udp_checkentry,
-       .me             = THIS_MODULE,
+static struct xt_match xt_tcpudp_match[] = {
+       {
+               .name           = "tcp",
+               .family         = AF_INET,
+               .checkentry     = tcp_checkentry,
+               .match          = tcp_match,
+               .matchsize      = sizeof(struct xt_tcp),
+               .proto          = IPPROTO_TCP,
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "tcp",
+               .family         = AF_INET6,
+               .checkentry     = tcp_checkentry,
+               .match          = tcp_match,
+               .matchsize      = sizeof(struct xt_tcp),
+               .proto          = IPPROTO_TCP,
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "udp",
+               .family         = AF_INET,
+               .checkentry     = udp_checkentry,
+               .match          = udp_match,
+               .matchsize      = sizeof(struct xt_udp),
+               .proto          = IPPROTO_UDP,
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "udp",
+               .family         = AF_INET6,
+               .checkentry     = udp_checkentry,
+               .match          = udp_match,
+               .matchsize      = sizeof(struct xt_udp),
+               .proto          = IPPROTO_UDP,
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init xt_tcpudp_init(void)
 {
-       int ret;
-       ret = xt_register_match(&tcp_matchstruct);
-       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;
+       return xt_register_matches(xt_tcpudp_match,
+                                  ARRAY_SIZE(xt_tcpudp_match));
 }
 
 static void __exit xt_tcpudp_fini(void)
 {
-       xt_unregister_match(&udp6_matchstruct);
-       xt_unregister_match(&udp_matchstruct);
-       xt_unregister_match(&tcp6_matchstruct);
-       xt_unregister_match(&tcp_matchstruct);
+       xt_unregister_matches(xt_tcpudp_match, ARRAY_SIZE(xt_tcpudp_match));
 }
 
 module_init(xt_tcpudp_init);