]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netfilter/xt_owner.c
Merge git://git.infradead.org/battery-2.6
[linux-2.6-omap-h63xx.git] / net / netfilter / xt_owner.c
index d382f9cc38b0b5fbf90c4af50f4c5b5a2c7b2e65..f19ebd9b78f5040b6a16ff84a7771e8530e830c2 100644 (file)
@@ -4,8 +4,8 @@
  *
  * (C) 2000 Marc Boucher <marc@mbsi.ca>
  *
- * Copyright © CC Computer Consultants GmbH, 2007
- * Contact: <jengelh@computergmbh.de>
+ * Copyright © CC Computer Consultants GmbH, 2007 - 2008
+ * <jengelh@computergmbh.de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
 #include <linux/netfilter_ipv6/ip6t_owner.h>
 
 static bool
-owner_mt_v0(const struct sk_buff *skb, const struct net_device *in,
-            const struct net_device *out, const struct xt_match *match,
-            const void *matchinfo, int offset, unsigned int protoff,
-            bool *hotdrop)
+owner_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
 {
-       const struct ipt_owner_info *info = matchinfo;
+       const struct ipt_owner_info *info = par->matchinfo;
        const struct file *filp;
 
        if (skb->sk == NULL || skb->sk->sk_socket == NULL)
@@ -50,12 +47,9 @@ owner_mt_v0(const struct sk_buff *skb, const struct net_device *in,
 }
 
 static bool
-owner_mt6_v0(const struct sk_buff *skb, const struct net_device *in,
-             const struct net_device *out, const struct xt_match *match,
-             const void *matchinfo, int offset, unsigned int protoff,
-             bool *hotdrop)
+owner_mt6_v0(const struct sk_buff *skb, const struct xt_match_param *par)
 {
-       const struct ip6t_owner_info *info = matchinfo;
+       const struct ip6t_owner_info *info = par->matchinfo;
        const struct file *filp;
 
        if (skb->sk == NULL || skb->sk->sk_socket == NULL)
@@ -79,12 +73,9 @@ owner_mt6_v0(const struct sk_buff *skb, const struct net_device *in,
 }
 
 static bool
-owner_mt(const struct sk_buff *skb, const struct net_device *in,
-         const struct net_device *out, const struct xt_match *match,
-         const void *matchinfo, int offset, unsigned int protoff,
-         bool *hotdrop)
+owner_mt(const struct sk_buff *skb, const struct xt_match_param *par)
 {
-       const struct xt_owner_match_info *info = matchinfo;
+       const struct xt_owner_match_info *info = par->matchinfo;
        const struct file *filp;
 
        if (skb->sk == NULL || skb->sk->sk_socket == NULL)
@@ -102,24 +93,23 @@ owner_mt(const struct sk_buff *skb, const struct net_device *in,
                       (XT_OWNER_UID | XT_OWNER_GID)) == 0;
 
        if (info->match & XT_OWNER_UID)
-               if ((filp->f_uid != info->uid) ^
-                   !!(info->invert & XT_OWNER_UID))
+               if ((filp->f_uid >= info->uid_min &&
+                   filp->f_uid <= info->uid_max) ^
+                   !(info->invert & XT_OWNER_UID))
                        return false;
 
        if (info->match & XT_OWNER_GID)
-               if ((filp->f_gid != info->gid) ^
-                   !!(info->invert & XT_OWNER_GID))
+               if ((filp->f_gid >= info->gid_min &&
+                   filp->f_gid <= info->gid_max) ^
+                   !(info->invert & XT_OWNER_GID))
                        return false;
 
        return true;
 }
 
-static bool
-owner_mt_check_v0(const char *tablename, const void *ip,
-                  const struct xt_match *match, void *matchinfo,
-                  unsigned int hook_mask)
+static bool owner_mt_check_v0(const struct xt_mtchk_param *par)
 {
-       const struct ipt_owner_info *info = matchinfo;
+       const struct ipt_owner_info *info = par->matchinfo;
 
        if (info->match & (IPT_OWNER_PID | IPT_OWNER_SID | IPT_OWNER_COMM)) {
                printk(KERN_WARNING KBUILD_MODNAME
@@ -131,12 +121,9 @@ owner_mt_check_v0(const char *tablename, const void *ip,
        return true;
 }
 
-static bool
-owner_mt6_check_v0(const char *tablename, const void *ip,
-                   const struct xt_match *match, void *matchinfo,
-                   unsigned int hook_mask)
+static bool owner_mt6_check_v0(const struct xt_mtchk_param *par)
 {
-       const struct ip6t_owner_info *info = matchinfo;
+       const struct ip6t_owner_info *info = par->matchinfo;
 
        if (info->match & (IP6T_OWNER_PID | IP6T_OWNER_SID)) {
                printk(KERN_WARNING KBUILD_MODNAME
@@ -151,7 +138,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = {
        {
                .name       = "owner",
                .revision   = 0,
-               .family     = AF_INET,
+               .family     = NFPROTO_IPV4,
                .match      = owner_mt_v0,
                .matchsize  = sizeof(struct ipt_owner_info),
                .checkentry = owner_mt_check_v0,
@@ -162,7 +149,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = {
        {
                .name       = "owner",
                .revision   = 0,
-               .family     = AF_INET6,
+               .family     = NFPROTO_IPV6,
                .match      = owner_mt6_v0,
                .matchsize  = sizeof(struct ip6t_owner_info),
                .checkentry = owner_mt6_check_v0,
@@ -173,17 +160,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = {
        {
                .name       = "owner",
                .revision   = 1,
-               .family     = AF_INET,
-               .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     = AF_INET6,
+               .family     = NFPROTO_UNSPEC,
                .match      = owner_mt,
                .matchsize  = sizeof(struct xt_owner_match_info),
                .hooks      = (1 << NF_INET_LOCAL_OUT) |