This patchset fixes some issues that came with the routing cache removal.
1) IPsec and others (udp, ipvs) may cache output routes, these routes
need to be invalidated on pmtu events in the same way e.g. tcp socket
cached routes are invalidated. With this we always invalidate or update
(if we already use a nh exeption route) the old route on pmtu events.
This has the drawback that we may needlessly invalidate an uncached route,
but this fixes all the users that cache routes and pmtu events are rare, so
this should not be a real issue.
2) We create nh exeptions if a user (e.g. tracepath) tries to do pmtu
dicsovery with packets bigger than the output device mtu. The device mtu
is not learned and does not expire, so don't create an exeption route.
3) We report cached pmtu values to userspace even if they are expired.
Fix this by checking for expiration before we report.
Some protocols, like IPsec still cache routes. So we need to invalidate
the old route on pmtu events to avoid the reuse of stale routes.
We also need to update the mtu and expire time of the route if we already
use a nh exeption route, otherwise we ignore newly learned pmtu values
after the first expiration.
With this patch we always invalidate or update the route on pmtu events.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
When a local tool like tracepath tries to send packets bigger than
the device mtu, we create a nh exeption and set the pmtu to device
mtu. The device mtu does not expire, so check if the device mtu is
smaller than the reported pmtu and don't crerate a nh exeption in
that case.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
We report cached pmtu values even if they are already expired.
Change this to not report these values after they are expired.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
From: Eric Dumazet <hidden> Date: 2012-10-08 09:55:48
On Mon, 2012-10-08 at 10:48 +0200, Steffen Klassert wrote:
quoted hunk
We report cached pmtu values even if they are already expired.
Change this to not report these values after they are expired.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
@@ -2187,8 +2187,16 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,nla_put_be32(skb,RTA_GATEWAY,rt->rt_gateway))gotonla_put_failure;+expires=rt->dst.expires;+if(expires){+if(time_before(jiffies,expires))+expires-=jiffies;
Seeing this racy code, we could fix it as well.
jiffies is volatile and can change between the test and subtraction.
So we could in theory get strange result.
I suggest using :
if (expires) {
unsigned long now = jiffies;
if (time_before(now, expires))
expires -= now;
else
expires = 0;
}
or
if (expires)
expires = max_t(signed long, 0L, expires - jiffies);
On Mon, Oct 08, 2012 at 11:55:44AM +0200, Eric Dumazet wrote:
On Mon, 2012-10-08 at 10:48 +0200, Steffen Klassert wrote:
quoted
We report cached pmtu values even if they are already expired.
Change this to not report these values after they are expired.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
@@ -2187,8 +2187,16 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,nla_put_be32(skb,RTA_GATEWAY,rt->rt_gateway))gotonla_put_failure;+expires=rt->dst.expires;+if(expires){+if(time_before(jiffies,expires))+expires-=jiffies;
Seeing this racy code, we could fix it as well.
Sure, we can :)
jiffies is volatile and can change between the test and subtraction.
So we could in theory get strange result.
I suggest using :
if (expires) {
unsigned long now = jiffies;
if (time_before(now, expires))
expires -= now;
else
expires = 0;
}
I'll go with the version above and send an updated patch.
Thanks.
We report cached pmtu values even if they are already expired.
Change this to not report these values after they are expired
and fix a race in the expire time calculation, as suggested by
Eric Dumazet.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
This patchset fixes some issues that came with the routing cache removal.
1) IPsec and others (udp, ipvs) may cache output routes, these routes
need to be invalidated on pmtu events in the same way e.g. tcp socket
cached routes are invalidated. With this we always invalidate or update
(if we already use a nh exeption route) the old route on pmtu events.
This has the drawback that we may needlessly invalidate an uncached route,
but this fixes all the users that cache routes and pmtu events are rare, so
this should not be a real issue.
2) We create nh exeptions if a user (e.g. tracepath) tries to do pmtu
dicsovery with packets bigger than the output device mtu. The device mtu
is not learned and does not expire, so don't create an exeption route.
3) We report cached pmtu values to userspace even if they are expired.
Fix this by checking for expiration before we report.