]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
netfilter: ebt: Use new helper ebt_invalid_target to check target
authorGao Feng <gfree.wind@vip.163.com>
Wed, 31 May 2017 08:55:43 +0000 (16:55 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 19 Jun 2017 17:09:19 +0000 (19:09 +0200)
Use the new helper function ebt_invalid_target instead of the old
macro INVALID_TARGET and other duplicated codes to enhance the readability.

Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter_bridge/ebtables.h
net/bridge/netfilter/ebt_dnat.c
net/bridge/netfilter/ebt_mark.c
net/bridge/netfilter/ebt_redirect.c
net/bridge/netfilter/ebt_snat.c

index e0cbf17af780e1d3e4c2be6bba351c9a27cebf88..2c2a5514b0df98a0fd92294aad15b00855c9256a 100644 (file)
@@ -122,8 +122,6 @@ extern unsigned int ebt_do_table(struct sk_buff *skb,
 #define BASE_CHAIN (par->hook_mask & (1 << NF_BR_NUMHOOKS))
 /* Clear the bit in the hook mask that tells if the rule is on a base chain */
 #define CLEAR_BASE_CHAIN_BIT (par->hook_mask &= ~(1 << NF_BR_NUMHOOKS))
-/* True if the target is not a standard target */
-#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0)
 
 static inline bool ebt_invalid_target(int target)
 {
index e0bb624c3845eff5d756830504709eeb3d5bf960..dfc86a0199dab9683ff7cd8e7346b7ea19c8ce13 100644 (file)
@@ -61,7 +61,7 @@ static int ebt_dnat_tg_check(const struct xt_tgchk_param *par)
            (strcmp(par->table, "broute") != 0 ||
            hook_mask & ~(1 << NF_BR_BROUTING)))
                return -EINVAL;
-       if (INVALID_TARGET)
+       if (ebt_invalid_target(info->target))
                return -EINVAL;
        return 0;
 }
index 66697cbd0a8b82c9e132aebda93b96ee09e48fe8..19f0f9592d32e906f9d42ab8608c8f042031e820 100644 (file)
@@ -44,7 +44,7 @@ static int ebt_mark_tg_check(const struct xt_tgchk_param *par)
        tmp = info->target | ~EBT_VERDICT_BITS;
        if (BASE_CHAIN && tmp == EBT_RETURN)
                return -EINVAL;
-       if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
+       if (ebt_invalid_target(tmp))
                return -EINVAL;
        tmp = info->target & ~EBT_VERDICT_BITS;
        if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE &&
index 8d2a85e0594ee3c5c91c3c4b4c05c71fc6f40601..a7223eaf490b74b92b8725702033b859070ccdcb 100644 (file)
@@ -47,7 +47,7 @@ static int ebt_redirect_tg_check(const struct xt_tgchk_param *par)
            (strcmp(par->table, "broute") != 0 ||
            hook_mask & ~(1 << NF_BR_BROUTING)))
                return -EINVAL;
-       if (INVALID_TARGET)
+       if (ebt_invalid_target(info->target))
                return -EINVAL;
        return 0;
 }
index e56ccd060d2680da042322cea43177a27744b7ca..11cf9e9e9222e241cf803a54d376fc9274279447 100644 (file)
@@ -51,7 +51,7 @@ static int ebt_snat_tg_check(const struct xt_tgchk_param *par)
        if (BASE_CHAIN && tmp == EBT_RETURN)
                return -EINVAL;
 
-       if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
+       if (ebt_invalid_target(tmp))
                return -EINVAL;
        tmp = info->target | EBT_VERDICT_BITS;
        if ((tmp & ~NAT_ARP_BIT) != ~NAT_ARP_BIT)