summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2022-03-09 17:29:53 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2022-03-09 17:29:53 +0000
commite28e021073d21b16ebbf969e7ca12e67362839d8 (patch)
treec4461d36f11f4090b489c5d714e39f73cea06b7a /sys/net
parent8496446a9e7dd01500e49b3acce0f4f48fd78f68 (diff)
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@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/rtsock.c11
1 files 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);
}