]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
netfilter: xtables: make use of caller family rather than match family
authorJan Engelhardt <jengelh@medozas.de>
Wed, 17 Mar 2010 23:44:52 +0000 (00:44 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Thu, 18 Mar 2010 13:20:06 +0000 (14:20 +0100)
The matches can have .family = NFPROTO_UNSPEC, and though that is not
the case for the touched modules, it seems better to just use the
nfproto from the caller.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
net/netfilter/xt_dscp.c
net/netfilter/xt_hashlimit.c
net/netfilter/xt_policy.c
net/netfilter/xt_recent.c
net/netfilter/xt_state.c

index 0280d3a8c16172bc924f53b233c4527fe6b1e7b0..fe58cd01ef99804cf02cfc7ffc3bf69bfcccbe72 100644 (file)
@@ -58,7 +58,7 @@ static bool tos_mt(const struct sk_buff *skb, const struct xt_match_param *par)
 {
        const struct xt_tos_match_info *info = par->matchinfo;
 
-       if (par->match->family == NFPROTO_IPV4)
+       if (par->family == NFPROTO_IPV4)
                return ((ip_hdr(skb)->tos & info->tos_mask) ==
                       info->tos_value) ^ !!info->invert;
        else
index ba9601a767aa09f6c97ad4188317e937056ae5e4..1fdb50a90f1cb79634446603a7500e3ac700f715 100644 (file)
@@ -703,8 +703,8 @@ static bool hashlimit_mt_check_v0(const struct xt_mtchk_param *par)
                return false;
 
        mutex_lock(&hashlimit_mutex);
-       r->hinfo = htable_find_get(net, r->name, par->match->family);
-       if (!r->hinfo && htable_create_v0(net, r, par->match->family) != 0) {
+       r->hinfo = htable_find_get(net, r->name, par->family);
+       if (!r->hinfo && htable_create_v0(net, r, par->family) != 0) {
                mutex_unlock(&hashlimit_mutex);
                return false;
        }
@@ -730,7 +730,7 @@ static bool hashlimit_mt_check(const struct xt_mtchk_param *par)
                return false;
        if (info->name[sizeof(info->name)-1] != '\0')
                return false;
-       if (par->match->family == NFPROTO_IPV4) {
+       if (par->family == NFPROTO_IPV4) {
                if (info->cfg.srcmask > 32 || info->cfg.dstmask > 32)
                        return false;
        } else {
@@ -739,8 +739,8 @@ static bool hashlimit_mt_check(const struct xt_mtchk_param *par)
        }
 
        mutex_lock(&hashlimit_mutex);
-       info->hinfo = htable_find_get(net, info->name, par->match->family);
-       if (!info->hinfo && htable_create(net, info, par->match->family) != 0) {
+       info->hinfo = htable_find_get(net, info->name, par->family);
+       if (!info->hinfo && htable_create(net, info, par->family) != 0) {
                mutex_unlock(&hashlimit_mutex);
                return false;
        }
index 4cbfebda8fa11795af6887e33761a374b50857ce..cc033d2c35ea651523dcc799caa218678cfd1dbf 100644 (file)
@@ -116,9 +116,9 @@ policy_mt(const struct sk_buff *skb, const struct xt_match_param *par)
        int ret;
 
        if (info->flags & XT_POLICY_MATCH_IN)
-               ret = match_policy_in(skb, info, par->match->family);
+               ret = match_policy_in(skb, info, par->family);
        else
-               ret = match_policy_out(skb, info, par->match->family);
+               ret = match_policy_out(skb, info, par->family);
 
        if (ret < 0)
                ret = info->flags & XT_POLICY_MATCH_NONE ? true : false;
index d2e7c80cd3c36ab8a939ada49ca873f9be61eefa..a0ea1a21c470800ea6312a7ca3499bce91eb87e7 100644 (file)
@@ -233,7 +233,7 @@ recent_mt(const struct sk_buff *skb, const struct xt_match_param *par)
        u_int8_t ttl;
        bool ret = info->invert;
 
-       if (par->match->family == NFPROTO_IPV4) {
+       if (par->family == NFPROTO_IPV4) {
                const struct iphdr *iph = ip_hdr(skb);
 
                if (info->side == XT_RECENT_DEST)
@@ -259,12 +259,12 @@ recent_mt(const struct sk_buff *skb, const struct xt_match_param *par)
 
        spin_lock_bh(&recent_lock);
        t = recent_table_lookup(recent_net, info->name);
-       e = recent_entry_lookup(t, &addr, par->match->family,
+       e = recent_entry_lookup(t, &addr, par->family,
                                (info->check_set & XT_RECENT_TTL) ? ttl : 0);
        if (e == NULL) {
                if (!(info->check_set & XT_RECENT_SET))
                        goto out;
-               e = recent_entry_init(t, &addr, par->match->family, ttl);
+               e = recent_entry_init(t, &addr, par->family, ttl);
                if (e == NULL)
                        *par->hotdrop = true;
                ret = !ret;
index 4c946cbd731f7cfe47b9333b13c7e861906f9298..ef09b2e2970f3d7a19123ae15f98f3922dc262b9 100644 (file)
@@ -39,9 +39,9 @@ state_mt(const struct sk_buff *skb, const struct xt_match_param *par)
 
 static bool state_mt_check(const struct xt_mtchk_param *par)
 {
-       if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
+       if (nf_ct_l3proto_try_module_get(par->family) < 0) {
                printk(KERN_WARNING "can't load conntrack support for "
-                                   "proto=%u\n", par->match->family);
+                                   "proto=%u\n", par->family);
                return false;
        }
        return true;
@@ -49,7 +49,7 @@ static bool state_mt_check(const struct xt_mtchk_param *par)
 
 static void state_mt_destroy(const struct xt_mtdtor_param *par)
 {
-       nf_ct_l3proto_module_put(par->match->family);
+       nf_ct_l3proto_module_put(par->family);
 }
 
 static struct xt_match state_mt_reg[] __read_mostly = {