# Re: \[PATCH v2 net-next 3/5\] ipv6: honor RT6\_LOOKUP\_F\_DST\_NOREF in rule lookup logic

- From: David Ahern \<hidden\>
- Date: 2019-06-19 23:12:36 
- List: netdev
- Page: https://ratatoskr.run/netdev/2019/06/11139293
- Thread: https://ratatoskr.run/netdev/2019/06/11139287/t.md

```text
On 6/19/19 4:31 PM, Wei Wang wrote:
> diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
> index bcfae13409b5..d22b6c140f23 100644
> --- a/net/ipv6/fib6_rules.c
> +++ b/net/ipv6/fib6_rules.c
> @@ -113,14 +113,15 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
>  		rt = lookup(net, net->ipv6.fib6_local_tbl, fl6, skb, flags);
>  		if (rt != net->ipv6.ip6_null_entry && rt->dst.error != -EAGAIN)
>  			return &rt->dst;
> -		ip6_rt_put(rt);
> +		ip6_rt_put_flags(rt, flags);
>  		rt = lookup(net, net->ipv6.fib6_main_tbl, fl6, skb, flags);
>  		if (rt->dst.error != -EAGAIN)
>  			return &rt->dst;
> -		ip6_rt_put(rt);
> +		ip6_rt_put_flags(rt, flags);
>  	}
>  
> -	dst_hold(&net->ipv6.ip6_null_entry->dst);
> +	if (!(flags & RT6_LOOKUP_F_DST_NOREF))
> +		dst_hold(&net->ipv6.ip6_null_entry->dst);
>  	return &net->ipv6.ip6_null_entry->dst;
>  }
>  

What about the fib6_rule_lookup when CONFIG_IPV6_MULTIPLE_TABLES is
configured off? If caller passes in RT6_LOOKUP_F_DST_NOREF that version
is still taking a reference in the error path and does a put after the
lookup.
```
