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@
-/* $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 $ */
/*
*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);
}