Skip to content

Commit

Permalink
ipv6: Use result arg in fib_lookup_arg consistently
Browse files Browse the repository at this point in the history
arg.result is sometimes used as fib6_result and sometimes used to
hold the rt6_info. Add rt6_info to fib6_result and make the use
of arg.result consistent through ipv6 rules.

The rt6 entry is filled in for lookups returning a dst_entry, but not
for direct fib_lookups that just want a fib6_info.

Fixes: effda4d ("ipv6: Pass fib6_result to fib lookups")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
dsahern authored and davem330 committed Apr 24, 2019
1 parent b2f97f7 commit a65120b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/net/ip6_fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ struct fib6_result {
struct fib6_info *f6i;
u32 fib6_flags;
u8 fib6_type;
struct rt6_info *rt6;
};

#define for_each_fib6_node_rt_rcu(fn) \
Expand Down
15 changes: 11 additions & 4 deletions net/ipv6/fib6_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
int flags, pol_lookup_t lookup)
{
if (net->ipv6.fib6_has_custom_rules) {
struct fib6_result res = {};
struct fib_lookup_arg arg = {
.lookup_ptr = lookup,
.lookup_data = skb,
.result = &res,
.flags = FIB_LOOKUP_NOREF,
};

Expand All @@ -106,8 +108,8 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
fib_rules_lookup(net->ipv6.fib6_rules_ops,
flowi6_to_flowi(fl6), flags, &arg);

if (arg.result)
return arg.result;
if (res.rt6)
return &res.rt6->dst;
} else {
struct rt6_info *rt;

Expand Down Expand Up @@ -191,6 +193,7 @@ static int fib6_rule_action_alt(struct fib_rule *rule, struct flowi *flp,
static int __fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
int flags, struct fib_lookup_arg *arg)
{
struct fib6_result *res = arg->result;
struct flowi6 *flp6 = &flp->u.ip6;
struct rt6_info *rt = NULL;
struct fib6_table *table;
Expand Down Expand Up @@ -245,7 +248,7 @@ static int __fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
discard_pkt:
dst_hold(&rt->dst);
out:
arg->result = rt;
res->rt6 = rt;
return err;
}

Expand All @@ -260,9 +263,13 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,

static bool fib6_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
{
struct rt6_info *rt = (struct rt6_info *) arg->result;
struct fib6_result *res = arg->result;
struct rt6_info *rt = res->rt6;
struct net_device *dev = NULL;

if (!rt)
return false;

if (rt->rt6i_idev)
dev = rt->rt6i_idev->dev;

Expand Down

0 comments on commit a65120b

Please sign in to comment.