From 14ef9587e36b14cc52cf032f48e84960a8402524 Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 9 Mar 2022 17:29:52 +0000 Subject: [PATCH] Change the logic around rounding up the needed memory for sysctls since the network state can change between the two sysctl calls. Adding 10% extra works for larger routing tables but can be too little on smaller tables to hold even a single extra message. Instead of that add at least 1024 bytes or 10% (whichever is bigger) and round the size up to the next page. With this there are no more sporadic errors in the bgpd integration tests. OK sthen@ --- sys/net/rtsock.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index da157d46e0e..bf0f9c01ce2 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.326 2022/02/25 23:51:03 guenther Exp $ */ +/* $OpenBSD: rtsock.c,v 1.327 2022/03/09 17:29:52 claudio Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -2218,9 +2218,12 @@ sysctl_rtable(int *name, u_int namelen, void *where, size_t *given, void *new, *given = w.w_where - (caddr_t)where; if (*given < w.w_needed) return (ENOMEM); - } else - *given = w.w_needed + w.w_needed / 10; - + } else if (w.w_needed == 0) { + *given = 0; + } else { + *given = roundup(w.w_needed + MAX(w.w_needed / 10, 1024), + PAGE_SIZE); + } return (error); } -- 2.20.1