netfilter: xtables: use NFPROTO_UNSPEC in more extensions
authorJan Engelhardt <jengelh@medozas.de>
Wed, 8 Oct 2008 09:35:20 +0000 (11:35 +0200)
committerPatrick McHardy <kaber@trash.net>
Wed, 8 Oct 2008 09:35:20 +0000 (11:35 +0200)
Lots of extensions are completely family-independent, so squash some code.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
net/netfilter/xt_MARK.c
net/netfilter/xt_NOTRACK.c
net/netfilter/xt_comment.c
net/netfilter/xt_mac.c
net/netfilter/xt_owner.c
net/netfilter/xt_physdev.c
net/netfilter/xt_realm.c

index 123ee0ba78c656ac5a0da1b6a95aff2bd09337f0..67574bcfb8ac8016e65d211ce6126806a157f229 100644 (file)
@@ -149,7 +149,7 @@ static int mark_tg_compat_to_user_v1(void __user *dst, void *src)
 static struct xt_target mark_tg_reg[] __read_mostly = {
        {
                .name           = "MARK",
-               .family         = NFPROTO_IPV4,
+               .family         = NFPROTO_UNSPEC,
                .revision       = 0,
                .checkentry     = mark_tg_check_v0,
                .target         = mark_tg_v0,
@@ -164,37 +164,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = {
        },
        {
                .name           = "MARK",
-               .family         = NFPROTO_IPV4,
-               .revision       = 1,
-               .checkentry     = mark_tg_check_v1,
-               .target         = mark_tg_v1,
-               .targetsize     = sizeof(struct xt_mark_target_info_v1),
-#ifdef CONFIG_COMPAT
-               .compatsize     = sizeof(struct compat_xt_mark_target_info_v1),
-               .compat_from_user = mark_tg_compat_from_user_v1,
-               .compat_to_user = mark_tg_compat_to_user_v1,
-#endif
-               .table          = "mangle",
-               .me             = THIS_MODULE,
-       },
-       {
-               .name           = "MARK",
-               .family         = NFPROTO_IPV6,
-               .revision       = 0,
-               .checkentry     = mark_tg_check_v0,
-               .target         = mark_tg_v0,
-               .targetsize     = sizeof(struct xt_mark_target_info),
-#ifdef CONFIG_COMPAT
-               .compatsize     = sizeof(struct compat_xt_mark_target_info),
-               .compat_from_user = mark_tg_compat_from_user_v0,
-               .compat_to_user = mark_tg_compat_to_user_v0,
-#endif
-               .table          = "mangle",
-               .me             = THIS_MODULE,
-       },
-       {
-               .name           = "MARK",
-               .family         = NFPROTO_IPV6,
+               .family         = NFPROTO_UNSPEC,
                .revision       = 1,
                .checkentry     = mark_tg_check_v1,
                .target         = mark_tg_v1,
index cc50295cd11edad99b72125014cdd692030a9b0e..e7a0a54fd4eae42f268ee91262532e00fa84199b 100644 (file)
@@ -30,31 +30,23 @@ notrack_tg(struct sk_buff *skb, const struct xt_target_param *par)
        return XT_CONTINUE;
 }
 
-static struct xt_target notrack_tg_reg[] __read_mostly = {
-       {
-               .name           = "NOTRACK",
-               .family         = NFPROTO_IPV4,
-               .target         = notrack_tg,
-               .table          = "raw",
-               .me             = THIS_MODULE,
-       },
-       {
-               .name           = "NOTRACK",
-               .family         = NFPROTO_IPV6,
-               .target         = notrack_tg,
-               .table          = "raw",
-               .me             = THIS_MODULE,
-       },
+static struct xt_target notrack_tg_reg __read_mostly = {
+       .name     = "NOTRACK",
+       .revision = 0,
+       .family   = NFPROTO_UNSPEC,
+       .target   = notrack_tg,
+       .table    = "raw",
+       .me       = THIS_MODULE,
 };
 
 static int __init notrack_tg_init(void)
 {
-       return xt_register_targets(notrack_tg_reg, ARRAY_SIZE(notrack_tg_reg));
+       return xt_register_target(&notrack_tg_reg);
 }
 
 static void __exit notrack_tg_exit(void)
 {
-       xt_unregister_targets(notrack_tg_reg, ARRAY_SIZE(notrack_tg_reg));
+       xt_unregister_target(&notrack_tg_reg);
 }
 
 module_init(notrack_tg_init);
index bd7aa57af4286e9ab5df9ef45bc1e09eac9daca8..e82179832acd252bd6595b940fb97388612cad0d 100644 (file)
@@ -22,31 +22,23 @@ comment_mt(const struct sk_buff *skb, const struct xt_match_param *par)
        return true;
 }
 
-static struct xt_match comment_mt_reg[] __read_mostly = {
-       {
-               .name           = "comment",
-               .family         = NFPROTO_IPV4,
-               .match          = comment_mt,
-               .matchsize      = sizeof(struct xt_comment_info),
-               .me             = THIS_MODULE
-       },
-       {
-               .name           = "comment",
-               .family         = NFPROTO_IPV6,
-               .match          = comment_mt,
-               .matchsize      = sizeof(struct xt_comment_info),
-               .me             = THIS_MODULE
-       },
+static struct xt_match comment_mt_reg __read_mostly = {
+       .name      = "comment",
+       .revision  = 0,
+       .family    = NFPROTO_UNSPEC,
+       .match     = comment_mt,
+       .matchsize = sizeof(struct xt_comment_info),
+       .me        = THIS_MODULE,
 };
 
 static int __init comment_mt_init(void)
 {
-       return xt_register_matches(comment_mt_reg, ARRAY_SIZE(comment_mt_reg));
+       return xt_register_match(&comment_mt_reg);
 }
 
 static void __exit comment_mt_exit(void)
 {
-       xt_unregister_matches(comment_mt_reg, ARRAY_SIZE(comment_mt_reg));
+       xt_unregister_match(&comment_mt_reg);
 }
 
 module_init(comment_mt_init);
index 269f9d8aef5fa02c6e8edba605f6c6521b7ac1f6..c2007116ce5bb66db44ae43590e8ba94330d03ea 100644 (file)
@@ -36,37 +36,25 @@ static bool mac_mt(const struct sk_buff *skb, const struct xt_match_param *par)
                ^ info->invert);
 }
 
-static struct xt_match mac_mt_reg[] __read_mostly = {
-       {
-               .name           = "mac",
-               .family         = NFPROTO_IPV4,
-               .match          = mac_mt,
-               .matchsize      = sizeof(struct xt_mac_info),
-               .hooks          = (1 << NF_INET_PRE_ROUTING) |
-                                 (1 << NF_INET_LOCAL_IN) |
-                                 (1 << NF_INET_FORWARD),
-               .me             = THIS_MODULE,
-       },
-       {
-               .name           = "mac",
-               .family         = NFPROTO_IPV6,
-               .match          = mac_mt,
-               .matchsize      = sizeof(struct xt_mac_info),
-               .hooks          = (1 << NF_INET_PRE_ROUTING) |
-                                 (1 << NF_INET_LOCAL_IN) |
-                                 (1 << NF_INET_FORWARD),
-               .me             = THIS_MODULE,
-       },
+static struct xt_match mac_mt_reg __read_mostly = {
+       .name      = "mac",
+       .revision  = 0,
+       .family    = NFPROTO_UNSPEC,
+       .match     = mac_mt,
+       .matchsize = sizeof(struct xt_mac_info),
+       .hooks     = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN) |
+                    (1 << NF_INET_FORWARD),
+       .me        = THIS_MODULE,
 };
 
 static int __init mac_mt_init(void)
 {
-       return xt_register_matches(mac_mt_reg, ARRAY_SIZE(mac_mt_reg));
+       return xt_register_match(&mac_mt_reg);
 }
 
 static void __exit mac_mt_exit(void)
 {
-       xt_unregister_matches(mac_mt_reg, ARRAY_SIZE(mac_mt_reg));
+       xt_unregister_match(&mac_mt_reg);
 }
 
 module_init(mac_mt_init);
index 32f84e84d9e6621b927e675cc508d12f9b43fbc6..f19ebd9b78f5040b6a16ff84a7771e8530e830c2 100644 (file)
@@ -160,17 +160,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = {
        {
                .name       = "owner",
                .revision   = 1,
-               .family     = NFPROTO_IPV4,
-               .match      = owner_mt,
-               .matchsize  = sizeof(struct xt_owner_match_info),
-               .hooks      = (1 << NF_INET_LOCAL_OUT) |
-                             (1 << NF_INET_POST_ROUTING),
-               .me         = THIS_MODULE,
-       },
-       {
-               .name       = "owner",
-               .revision   = 1,
-               .family     = NFPROTO_IPV6,
+               .family     = NFPROTO_UNSPEC,
                .match      = owner_mt,
                .matchsize  = sizeof(struct xt_owner_match_info),
                .hooks      = (1 << NF_INET_LOCAL_OUT) |
index b01786d2dd919cefb2b39effa981d321ec55885f..1bcdfc12cf59827028c682d898ea15f45df3e6a6 100644 (file)
@@ -112,33 +112,24 @@ static bool physdev_mt_check(const struct xt_mtchk_param *par)
        return true;
 }
 
-static struct xt_match physdev_mt_reg[] __read_mostly = {
-       {
-               .name           = "physdev",
-               .family         = NFPROTO_IPV4,
-               .checkentry     = physdev_mt_check,
-               .match          = physdev_mt,
-               .matchsize      = sizeof(struct xt_physdev_info),
-               .me             = THIS_MODULE,
-       },
-       {
-               .name           = "physdev",
-               .family         = NFPROTO_IPV6,
-               .checkentry     = physdev_mt_check,
-               .match          = physdev_mt,
-               .matchsize      = sizeof(struct xt_physdev_info),
-               .me             = THIS_MODULE,
-       },
+static struct xt_match physdev_mt_reg __read_mostly = {
+       .name       = "physdev",
+       .revision   = 0,
+       .family     = NFPROTO_UNSPEC,
+       .checkentry = physdev_mt_check,
+       .match      = physdev_mt,
+       .matchsize  = sizeof(struct xt_physdev_info),
+       .me         = THIS_MODULE,
 };
 
 static int __init physdev_mt_init(void)
 {
-       return xt_register_matches(physdev_mt_reg, ARRAY_SIZE(physdev_mt_reg));
+       return xt_register_match(&physdev_mt_reg);
 }
 
 static void __exit physdev_mt_exit(void)
 {
-       xt_unregister_matches(physdev_mt_reg, ARRAY_SIZE(physdev_mt_reg));
+       xt_unregister_match(&physdev_mt_reg);
 }
 
 module_init(physdev_mt_init);
index b25942110ed71129db98c801f3b5093269a76078..67419287bc7e143003164d2850378066cac6cd41 100644 (file)
@@ -36,7 +36,7 @@ static struct xt_match realm_mt_reg __read_mostly = {
        .matchsize      = sizeof(struct xt_realm_info),
        .hooks          = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_FORWARD) |
                          (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_LOCAL_IN),
-       .family         = NFPROTO_IPV4,
+       .family         = NFPROTO_UNSPEC,
        .me             = THIS_MODULE
 };