[PATCH] network: Increase max route size when checking IPv6 forwarding

Brooks Swinnerton posted 1 patch 1 year, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20230121005805.55292-1-bswinnerton@gmail.com
src/util/virnetdevip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] network: Increase max route size when checking IPv6 forwarding
Posted by Brooks Swinnerton 1 year, 3 months ago
In d9ee51e, virNetDevIPCheckIPv6Forwarding was updated to walk the
contents of /proc/net/ipv6_route so that it could check to see if the
RTF_ADDRCONF was set on any IPv6 routes to ultimately determine if
enabling forwarding would result in an error due to accept_ra=1 being
set on the interface.

The implementation added in that commit limited the number of routes
that could be read from /proc/net/ipv6_route to 100_000, each with 150
characters. This is problematic for machines that have a full IPv6
routing table, as the IPv6 routing table has now grown to over 160_000
(it was closer to 100_000 at the time of that commit).

This patch increases the maximum route size from 100_000 to 1_000_000.
While a million routes is somewhat arbitrary, it's meant to be a value
that can be supported for the forseeable future. APNIC, one of the five
regional internet registries, recently published a forecast of IPv6
table growth which anticipates a worst-case growth to 1_000_000 in
January of 2029.

Signed-off-by: Brooks Swinnerton <bswinnerton@gmail.com>
---
 src/util/virnetdevip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 2eacb64ebe..034b392ee7 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -529,7 +529,7 @@ virNetDevIPCheckIPv6Forwarding(void)
     char *cur;
     g_autofree char *buf = NULL;
     /* lines are 150 chars */
-    enum {MAX_ROUTE_SIZE = 150*100000};
+    enum {MAX_ROUTE_SIZE = 150*1000000};

     /* This is /proc/sys/net/ipv6/conf/all/accept_ra */
     int all_accept_ra = virNetDevIPGetAcceptRA(NULL);
--
2.39.1
Re: [PATCH] network: Increase max route size when checking IPv6 forwarding
Posted by Michal Prívozník 1 year, 3 months ago
On 1/21/23 01:58, Brooks Swinnerton wrote:
> In d9ee51e, virNetDevIPCheckIPv6Forwarding was updated to walk the
> contents of /proc/net/ipv6_route so that it could check to see if the
> RTF_ADDRCONF was set on any IPv6 routes to ultimately determine if
> enabling forwarding would result in an error due to accept_ra=1 being
> set on the interface.
> 
> The implementation added in that commit limited the number of routes
> that could be read from /proc/net/ipv6_route to 100_000, each with 150
> characters. This is problematic for machines that have a full IPv6
> routing table, as the IPv6 routing table has now grown to over 160_000
> (it was closer to 100_000 at the time of that commit).
> 
> This patch increases the maximum route size from 100_000 to 1_000_000.
> While a million routes is somewhat arbitrary, it's meant to be a value
> that can be supported for the forseeable future. APNIC, one of the five
> regional internet registries, recently published a forecast of IPv6
> table growth which anticipates a worst-case growth to 1_000_000 in
> January of 2029.
> 

Not to mention that 150 chars long line is expectation that's not always
met. For interfaces with sufficiently long names we can get longer lines:

# tail -n1 /proc/net/ipv6_route | wc -c
156

But I agree, ~143MiB ought to be enough for everyone :-)

> Signed-off-by: Brooks Swinnerton <bswinnerton@gmail.com>
> ---
>  src/util/virnetdevip.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

and pushed. Congratulations on your first libvirt contribution!

Michal