Skip to content

Commit 60006a4

Browse files
tracywwnjdavem330
authored andcommitted
ipv6: prepare fib6_remove_prefsrc() for exception table
After we move cached dst entries into the exception table under its parent route, current fib6_remove_prefsrc() no longer can access them. This commit makes fib6_remove_prefsrc() also go through all routes in the exception table to remove the pref src. This is a preparation patch in order to move all cached dst into the exception table. Signed-off-by: Wei Wang <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 35732d0 commit 60006a4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

net/ipv6/route.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,12 @@ static int rt6_insert_exception(struct rt6_info *nrt,
12641264
if (ort->rt6i_src.plen)
12651265
src_key = &nrt->rt6i_src.addr;
12661266
#endif
1267+
1268+
/* Update rt6i_prefsrc as it could be changed
1269+
* in rt6_remove_prefsrc()
1270+
*/
1271+
nrt->rt6i_prefsrc = ort->rt6i_prefsrc;
1272+
12671273
rt6_ex = __rt6_find_exception_spinlock(&bucket, &nrt->rt6i_dst.addr,
12681274
src_key);
12691275
if (rt6_ex)
@@ -1432,6 +1438,25 @@ static void rt6_update_exception_stamp_rt(struct rt6_info *rt)
14321438
rcu_read_unlock();
14331439
}
14341440

1441+
static void rt6_exceptions_remove_prefsrc(struct rt6_info *rt)
1442+
{
1443+
struct rt6_exception_bucket *bucket;
1444+
struct rt6_exception *rt6_ex;
1445+
int i;
1446+
1447+
bucket = rcu_dereference_protected(rt->rt6i_exception_bucket,
1448+
lockdep_is_held(&rt6_exception_lock));
1449+
1450+
if (bucket) {
1451+
for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) {
1452+
hlist_for_each_entry(rt6_ex, &bucket->chain, hlist) {
1453+
rt6_ex->rt6i->rt6i_prefsrc.plen = 0;
1454+
}
1455+
bucket++;
1456+
}
1457+
}
1458+
}
1459+
14351460
struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
14361461
int oif, struct flowi6 *fl6, int flags)
14371462
{
@@ -3159,8 +3184,12 @@ static int fib6_remove_prefsrc(struct rt6_info *rt, void *arg)
31593184
if (((void *)rt->dst.dev == dev || !dev) &&
31603185
rt != net->ipv6.ip6_null_entry &&
31613186
ipv6_addr_equal(addr, &rt->rt6i_prefsrc.addr)) {
3187+
spin_lock_bh(&rt6_exception_lock);
31623188
/* remove prefsrc entry */
31633189
rt->rt6i_prefsrc.plen = 0;
3190+
/* need to update cache as well */
3191+
rt6_exceptions_remove_prefsrc(rt);
3192+
spin_unlock_bh(&rt6_exception_lock);
31643193
}
31653194
return 0;
31663195
}

0 commit comments

Comments
 (0)