Skip to content

Commit

Permalink
netfilter: rpfilter: Convert rpfilter_lookup_reverse to new dev helper
Browse files Browse the repository at this point in the history
Convert rpfilter_lookup_reverse to the new device checking helper
and remove the duplicate code.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David Ahern authored and David S. Miller committed Sep 21, 2018
1 parent 78f2756 commit 91a1782
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions net/ipv4/netfilter/ipt_rpfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ static bool rpfilter_lookup_reverse(struct net *net, struct flowi4 *fl4,
const struct net_device *dev, u8 flags)
{
struct fib_result res;
bool dev_match;
int ret __maybe_unused;

if (fib_lookup(net, fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE))
Expand All @@ -46,21 +45,7 @@ static bool rpfilter_lookup_reverse(struct net *net, struct flowi4 *fl4,
if (res.type != RTN_LOCAL || !(flags & XT_RPFILTER_ACCEPT_LOCAL))
return false;
}
dev_match = false;
#ifdef CONFIG_IP_ROUTE_MULTIPATH
for (ret = 0; ret < res.fi->fib_nhs; ret++) {
struct fib_nh *nh = &res.fi->fib_nh[ret];

if (nh->nh_dev == dev) {
dev_match = true;
break;
}
}
#else
if (FIB_RES_DEV(res) == dev)
dev_match = true;
#endif
return dev_match || flags & XT_RPFILTER_LOOSE;
return fib_info_nh_uses_dev(res.fi, dev) || flags & XT_RPFILTER_LOOSE;
}

static bool
Expand Down

0 comments on commit 91a1782

Please sign in to comment.