On Mon, 24 Jul 2023 16:09:30 +1000
David Gibson <david(a)gibson.dropbear.id.au> wrote:
Currently we set NLBUFSIZ large enough for 8192
netlink headers (128kiB in
total), and reference netlink(7). However netlink(7) says nothing about
reponse buffer sizes, and the documents which do reference 8192 *bytes* not
8192 headers.
Oops.
Update NLBUFSIZ to 64kiB with a more detailed
rationale.
Link:
https://bugs.passt.top/show_bug.cgi?id=67
Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
netlink.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/netlink.c b/netlink.c
index cdd65c0..d553ddd 100644
--- a/netlink.c
+++ b/netlink.c
@@ -35,7 +35,14 @@
#include "log.h"
#include "netlink.h"
-#define NLBUFSIZ (8192 * sizeof(struct nlmsghdr)) /* See netlink(7) */
+/* Netlink expects a buffer of at least 8kiB or the system page size,
+ * whichever is larger. 32kiB is recommended for more efficient.
+ * Since the largest page size on any remotely common Linux setup is
+ * 64kiB (ppc64), that should cover it.
+ *
+ *
https://www.kernel.org/doc/html/next/userspace-api/netlink/intro.html#buffe…
+ */
+#define NLBUFSIZ 65536
I'm fine with this, but we also have PAGE_SIZE and MAX() defined. Or
maybe it's more reasonable to keep this constant. I'm not sure.
Well, my thought was that this approach also works for the rare case
that the runtime page size doesn't equal the compile time page size
(e.g. built on ppc64le with 4kiB pagesize, then run on ppc64le with
64kiB pagesize).
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!