Commit f5bbe7ee authored by Wei Wang's avatar Wei Wang Committed by David S. Miller

ipv6: prepare rt6_mtu_change() for exception table

If we move all cached dst into the exception table under the main route,
current rt6_mtu_change() will no longer be able to access them.
This commit makes rt6_mtu_change_route() function to also go through all
cached routes in the exception table under the main route and do proper
updates on the mtu.
This is a preparation in order to move all cached routes into the
exception table.
Signed-off-by: default avatarWei Wang <weiwan@google.com>
Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 60006a48
...@@ -1269,6 +1269,14 @@ static int rt6_insert_exception(struct rt6_info *nrt, ...@@ -1269,6 +1269,14 @@ static int rt6_insert_exception(struct rt6_info *nrt,
* in rt6_remove_prefsrc() * in rt6_remove_prefsrc()
*/ */
nrt->rt6i_prefsrc = ort->rt6i_prefsrc; nrt->rt6i_prefsrc = ort->rt6i_prefsrc;
/* rt6_mtu_change() might lower mtu on ort.
* Only insert this exception route if its mtu
* is less than ort's mtu value.
*/
if (nrt->rt6i_pmtu >= dst_mtu(&ort->dst)) {
err = -EINVAL;
goto out;
}
rt6_ex = __rt6_find_exception_spinlock(&bucket, &nrt->rt6i_dst.addr, rt6_ex = __rt6_find_exception_spinlock(&bucket, &nrt->rt6i_dst.addr,
src_key); src_key);
...@@ -1457,6 +1465,32 @@ static void rt6_exceptions_remove_prefsrc(struct rt6_info *rt) ...@@ -1457,6 +1465,32 @@ static void rt6_exceptions_remove_prefsrc(struct rt6_info *rt)
} }
} }
static void rt6_exceptions_update_pmtu(struct rt6_info *rt, int mtu)
{
struct rt6_exception_bucket *bucket;
struct rt6_exception *rt6_ex;
int i;
bucket = rcu_dereference_protected(rt->rt6i_exception_bucket,
lockdep_is_held(&rt6_exception_lock));
if (bucket) {
for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) {
hlist_for_each_entry(rt6_ex, &bucket->chain, hlist) {
struct rt6_info *entry = rt6_ex->rt6i;
/* For RTF_CACHE with rt6i_pmtu == 0
* (i.e. a redirected route),
* the metrics of its rt->dst.from has already
* been updated.
*/
if (entry->rt6i_pmtu && entry->rt6i_pmtu > mtu)
entry->rt6i_pmtu = mtu;
}
bucket++;
}
}
}
struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
int oif, struct flowi6 *fl6, int flags) int oif, struct flowi6 *fl6, int flags)
{ {
...@@ -3296,6 +3330,10 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) ...@@ -3296,6 +3330,10 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
if (rt->dst.dev == arg->dev && if (rt->dst.dev == arg->dev &&
dst_metric_raw(&rt->dst, RTAX_MTU) && dst_metric_raw(&rt->dst, RTAX_MTU) &&
!dst_metric_locked(&rt->dst, RTAX_MTU)) { !dst_metric_locked(&rt->dst, RTAX_MTU)) {
spin_lock_bh(&rt6_exception_lock);
/* This case will be removed once the exception table
* is hooked up.
*/
if (rt->rt6i_flags & RTF_CACHE) { if (rt->rt6i_flags & RTF_CACHE) {
/* For RTF_CACHE with rt6i_pmtu == 0 /* For RTF_CACHE with rt6i_pmtu == 0
* (i.e. a redirected route), * (i.e. a redirected route),
...@@ -3309,6 +3347,8 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) ...@@ -3309,6 +3347,8 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
dst_mtu(&rt->dst) == idev->cnf.mtu6)) { dst_mtu(&rt->dst) == idev->cnf.mtu6)) {
dst_metric_set(&rt->dst, RTAX_MTU, arg->mtu); dst_metric_set(&rt->dst, RTAX_MTU, arg->mtu);
} }
rt6_exceptions_update_pmtu(rt, arg->mtu);
spin_unlock_bh(&rt6_exception_lock);
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment