OSDN Git Service

ipv6: introduce RT6_LOOKUP_F_DST_NOREF flag in ip6_pol_route()
authorWei Wang <weiwan@google.com>
Fri, 21 Jun 2019 00:36:37 +0000 (17:36 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 23 Jun 2019 20:24:17 +0000 (13:24 -0700)
commit0e09edcce7ad9c8120eb8462334e1c9e8f3be09a
treec4e892bb20a039357fd2905f560a3692d37f6645
parent8c25c0cb5bb4e63170bb7760179ec294a3827694
ipv6: introduce RT6_LOOKUP_F_DST_NOREF flag in ip6_pol_route()

This new flag is to instruct the route lookup function to not take
refcnt on the dst entry. The user which does route lookup with this flag
must properly use rcu protection.
ip6_pol_route() is the major route lookup function for both tx and rx
path.
In this function:
Do not take refcnt on dst if RT6_LOOKUP_F_DST_NOREF flag is set, and
directly return the route entry. The caller should be holding rcu lock
when using this flag, and decide whether to take refcnt or not.

One note on the dst cache in the uncached_list:
As uncached_list does not consume refcnt, one refcnt is always returned
back to the caller even if RT6_LOOKUP_F_DST_NOREF flag is set.
Uncached dst is only possible in the output path. So in such call path,
caller MUST check if the dst is in the uncached_list before assuming
that there is no refcnt taken on the returned dst.

Signed-off-by: Wei Wang <weiwan@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Acked-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip6_route.h
net/ipv6/route.c