Skip to content

Commit 4e587ea

Browse files
tracywwnjdavem330
authored andcommitted
ipv6: fix sparse warning on rt6i_node
Commit c5cff85 adds rcu grace period before freeing fib6_node. This generates a new sparse warning on rt->rt6i_node related code: net/ipv6/route.c:1394:30: error: incompatible types in comparison expression (different address spaces) ./include/net/ip6_fib.h:187:14: error: incompatible types in comparison expression (different address spaces) This commit adds "__rcu" tag for rt6i_node and makes sure corresponding rcu API is used for it. After this fix, sparse no longer generates the above warning. Fixes: c5cff85 ("ipv6: add rcu grace period before freeing fib6_node") Signed-off-by: Wei Wang <[email protected]> Acked-by: Eric Dumazet <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0f30868 commit 4e587ea

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

include/net/ip6_fib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct rt6_info {
105105
* the same cache line.
106106
*/
107107
struct fib6_table *rt6i_table;
108-
struct fib6_node *rt6i_node;
108+
struct fib6_node __rcu *rt6i_node;
109109

110110
struct in6_addr rt6i_gateway;
111111

net/ipv6/addrconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5556,7 +5556,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
55565556
* our DAD process, so we don't need
55575557
* to do it again
55585558
*/
5559-
if (!(ifp->rt->rt6i_node))
5559+
if (!rcu_access_pointer(ifp->rt->rt6i_node))
55605560
ip6_ins_rt(ifp->rt);
55615561
if (ifp->idev->cnf.forwarding)
55625562
addrconf_join_anycast(ifp);

net/ipv6/ip6_fib.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
889889

890890
rt->dst.rt6_next = iter;
891891
*ins = rt;
892-
rt->rt6i_node = fn;
892+
rcu_assign_pointer(rt->rt6i_node, fn);
893893
atomic_inc(&rt->rt6i_ref);
894894
if (!info->skip_notify)
895895
inet6_rt_notify(RTM_NEWROUTE, rt, info, nlflags);
@@ -915,7 +915,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
915915
return err;
916916

917917
*ins = rt;
918-
rt->rt6i_node = fn;
918+
rcu_assign_pointer(rt->rt6i_node, fn);
919919
rt->dst.rt6_next = iter->dst.rt6_next;
920920
atomic_inc(&rt->rt6i_ref);
921921
if (!info->skip_notify)
@@ -1480,8 +1480,9 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
14801480

14811481
int fib6_del(struct rt6_info *rt, struct nl_info *info)
14821482
{
1483+
struct fib6_node *fn = rcu_dereference_protected(rt->rt6i_node,
1484+
lockdep_is_held(&rt->rt6i_table->tb6_lock));
14831485
struct net *net = info->nl_net;
1484-
struct fib6_node *fn = rt->rt6i_node;
14851486
struct rt6_info **rtp;
14861487

14871488
#if RT6_DEBUG >= 2
@@ -1670,7 +1671,9 @@ static int fib6_clean_node(struct fib6_walker *w)
16701671
if (res) {
16711672
#if RT6_DEBUG >= 2
16721673
pr_debug("%s: del failed: rt=%p@%p err=%d\n",
1673-
__func__, rt, rt->rt6i_node, res);
1674+
__func__, rt,
1675+
rcu_access_pointer(rt->rt6i_node),
1676+
res);
16741677
#endif
16751678
continue;
16761679
}

net/ipv6/route.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,8 @@ static void rt6_do_update_pmtu(struct rt6_info *rt, u32 mtu)
13831383
static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
13841384
{
13851385
return !(rt->rt6i_flags & RTF_CACHE) &&
1386-
(rt->rt6i_flags & RTF_PCPU || rt->rt6i_node);
1386+
(rt->rt6i_flags & RTF_PCPU ||
1387+
rcu_access_pointer(rt->rt6i_node));
13871388
}
13881389

13891390
static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,

0 commit comments

Comments
 (0)