]> granicus.if.org Git - ipset/commitdiff
netfilter: xt_set: Check hook mask correctly
authorSerhey Popovych <serhe.popovych@gmail.com>
Mon, 30 Apr 2018 18:26:02 +0000 (21:26 +0300)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 30 May 2018 08:00:40 +0000 (10:00 +0200)
Inserting rule before one with SET target we get error with warning in
dmesg(1) output:

  # iptables -A FORWARD -t mangle -j SET --map-set test src --map-prio
  # iptables -I FORWARD 1 -t mangle -j ACCEPT
  iptables: Invalid argument. Run `dmesg' for more information.
  # dmesg |tail -n1
  [268578.026643] mapping of prio or/and queue is allowed only from \
  OUTPUT/FORWARD/POSTROUTING chains

Rather than checking for supported hook bits for SET target check for
unsupported one as done in all rest of matches and targets.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
kernel/net/netfilter/xt_set.c

index a7ac9134d63bf9e5029c43f0fce65d39f3c197ed..f10c6de8e0c0c327644c2627ef83ba8f78f68017 100644 (file)
@@ -510,7 +510,7 @@ set_target_v3_checkentry(const struct xt_tgchk_param *par)
                }
                if (((info->flags & IPSET_FLAG_MAP_SKBPRIO) |
                     (info->flags & IPSET_FLAG_MAP_SKBQUEUE)) &&
-                    !(par->hook_mask & (1 << NF_INET_FORWARD |
+                    (par->hook_mask & ~(1 << NF_INET_FORWARD |
                                         1 << NF_INET_LOCAL_OUT |
                                         1 << NF_INET_POST_ROUTING))) {
                        pr_warn("mapping of prio or/and queue is allowed only from OUTPUT/FORWARD/POSTROUTING chains\n");