@@ -332,10 +332,10 @@ int __init xfrm6_init(void)/**Weneedagooddefaultvalueforthexfrm6gcthreshold.*Inipv4wesetittotheroutehashtablesize*8,which-*ishalfthesizeofthemaximaumroutecacheforipv4.It+*ishalfthesizeofthemaximumroutecacheforipv4.
The routing cache is removed, so this comment is obsolete. But it reminds
me that we set the gc threshold to ip_rt_max_size/2 in ipv4. With the
routing cache removal patch, ip_rt_max_size was set to INT_MAX. So the gc
starts to remove entries when a threshold of INT_MAX/2 is reached.
cat /proc/sys/net/ipv4/xfrm4_gc_thresh
1073741823
I guess this was not intentional.
@@ -332,10 +332,10 @@ int __init xfrm6_init(void)/**Weneedagooddefaultvalueforthexfrm6gcthreshold.*Inipv4wesetittotheroutehashtablesize*8,which-*ishalfthesizeofthemaximaumroutecacheforipv4.It+*ishalfthesizeofthemaximumroutecacheforipv4.
The routing cache is removed, so this comment is obsolete. But it reminds
me that we set the gc threshold to ip_rt_max_size/2 in ipv4. With the
routing cache removal patch, ip_rt_max_size was set to INT_MAX. So the gc
starts to remove entries when a threshold of INT_MAX/2 is reached.
cat /proc/sys/net/ipv4/xfrm4_gc_thresh
1073741823
I guess this was not intentional.
Do you mean for IPSEC routes? For non-IPSEC routes on ipv4 there
is nothing to garbage collect.
The routing cache is removed, so this comment is obsolete. But it reminds
me that we set the gc threshold to ip_rt_max_size/2 in ipv4. With the
routing cache removal patch, ip_rt_max_size was set to INT_MAX. So the gc
starts to remove entries when a threshold of INT_MAX/2 is reached.
cat /proc/sys/net/ipv4/xfrm4_gc_thresh
1073741823
I guess this was not intentional.
Do you mean for IPSEC routes? For non-IPSEC routes on ipv4 there
is nothing to garbage collect.
Yes, I mean IPsec routes. We still cache them at the flow cache
and at sockets, so we should do some garbage collecting.
We could either go back to a static threshold, as it was before
git commit a33bc5c15154c835aae26f16e6a3a7d9ad4acb45
xfrm: select sane defaults for xfrm[4|6] gc_thresh
or do the same as ipv6 does. I'll take care of this.
Btw. it seems to me that the flow cache has similar limitations
as the routing cache had. At least I was able to fill the flow
cache with a nmap scan from a remote entity. In practice, it's
hard to DOS the flow cache because we use a Jenkins hash with
a random initialization value, but this was the same with the
routing cache.
The routing cache is removed, so this comment is obsolete. But it reminds
me that we set the gc threshold to ip_rt_max_size/2 in ipv4. With the
routing cache removal patch, ip_rt_max_size was set to INT_MAX. So the gc
starts to remove entries when a threshold of INT_MAX/2 is reached.
cat /proc/sys/net/ipv4/xfrm4_gc_thresh
1073741823
I guess this was not intentional.
Do you mean for IPSEC routes? For non-IPSEC routes on ipv4 there
is nothing to garbage collect.
Yes, I mean IPsec routes. We still cache them at the flow cache
and at sockets, so we should do some garbage collecting.
We could either go back to a static threshold, as it was before
git commit a33bc5c15154c835aae26f16e6a3a7d9ad4acb45
xfrm: select sane defaults for xfrm[4|6] gc_thresh
or do the same as ipv6 does. I'll take care of this.
Actually, the ipv6 side of the xfrm gc threshold is a bit confusing.
The calculation depends on FIB6_TABLE_HASHSZ which has nothing to
do with maximum number of routes. FIB6_TABLE_HASHSZ just reflects
how many different routing tables we can use. It depends on whether
policy routing is enabled and is either 1 or 256. The maximum number
of routes for ipv6 defaults to 4096. So maybe the xfrm gc threshold
should depend somehow on this value.
For the ipv4 side I plan to go back to a static xfrm gc threshold
as it was before we did this dynamically.
I'll apply the patch below to the ipsec tree if there no other
ideas on how to choose the xfrm gc threshold.
Subject: [PATCH] xfrm: Fix the gc threshold value for ipv4
The xfrm gc threshold value depends on ip_rt_max_size. This
value was set to INT_MAX with the routing cache removal patch,
so we start doing garbage collecting when we have INT_MAX/2
IPsec routes cached. Fix this by going back to the static
threshold of 1024 routes.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
include/net/xfrm.h | 2 +-
net/ipv4/route.c | 2 +-
net/ipv4/xfrm4_policy.c | 13 +------------
3 files changed, 3 insertions(+), 14 deletions(-)
Subject: [PATCH] xfrm: Fix the gc threshold value for ipv4
The xfrm gc threshold value depends on ip_rt_max_size. This
value was set to INT_MAX with the routing cache removal patch,
so we start doing garbage collecting when we have INT_MAX/2
IPsec routes cached. Fix this by going back to the static
threshold of 1024 routes.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Subject: [PATCH] xfrm: Fix the gc threshold value for ipv4
The xfrm gc threshold value depends on ip_rt_max_size. This
value was set to INT_MAX with the routing cache removal patch,
so we start doing garbage collecting when we have INT_MAX/2
IPsec routes cached. Fix this by going back to the static
threshold of 1024 routes.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This looks fine to me.
I've just applied this to the ipsec tree.
I'll do the same for the ipv6 side. ipv6 does not handle the maximum
number of routes dynamically, so no need to try to handle the IPsec
gc threshold dynamically.