public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: KuhnChris <kuhnchris+github@kuhnchris.eu>
To: passt-dev@passt.top
Cc: KuhnChris <kuhnchris+github@kuhnchris.eu>
Subject: [PATCH 2/3] sbrivio/manual buffer size due to musl being 1024
Date: Fri,  3 Mar 2023 22:49:30 +0000	[thread overview]
Message-ID: <20230303224931.11791-2-kuhnchris+github@kuhnchris.eu> (raw)
In-Reply-To: <20230303224931.11791-1-kuhnchris+github@kuhnchris.eu>

---
 netlink.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/netlink.c b/netlink.c
index 8f785ca..0e0be4f 100644
--- a/netlink.c
+++ b/netlink.c
@@ -34,6 +34,8 @@
 #include "log.h"
 #include "netlink.h"
 
+#define NLBUFSIZ	(8192 * sizeof(struct nlmsghdr)) /* See netlink(7) */
+
 /* Socket in init, in target namespace, sequence (just needs to be monotonic) */
 static int nl_sock	= -1;
 static int nl_sock_ns	= -1;
@@ -105,7 +107,7 @@ fail:
 static int nl_req(int ns, char *buf, const void *req, ssize_t len)
 {
 	int s = ns ? nl_sock_ns : nl_sock, done = 0;
-	char flush[BUFSIZ];
+	char flush[NLBUFSIZ];
 	ssize_t n;
 
 	while (!done && (n = recv(s, flush, sizeof(flush), MSG_DONTWAIT)) > 0) {
@@ -121,7 +123,8 @@ static int nl_req(int ns, char *buf, const void *req, ssize_t len)
 		}
 	}
 
-	if ((send(s, req, len, 0) < len) || (len = recv(s, buf, BUFSIZ, 0)) < 0)
+	if ((send(s, req, len, 0) < len) ||
+	    (len = recv(s, buf, NLBUFSIZ, 0)) < 0)
 		return -errno;
 
 	return len;
@@ -149,7 +152,7 @@ unsigned int nl_get_ext_if(sa_family_t af)
 	};
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
@@ -227,7 +230,7 @@ void nl_route(int ns, unsigned int ifi, sa_family_t af, void *gw)
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
 	struct rtmsg *rtm;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
@@ -336,7 +339,7 @@ void nl_addr(int ns, unsigned int ifi, sa_family_t af,
 	struct ifaddrmsg *ifa;
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
@@ -446,7 +449,7 @@ void nl_link(int ns, unsigned int ifi, void *mac, int up, int mtu)
 	struct ifinfomsg *ifm;
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
-- 
@@ -34,6 +34,8 @@
 #include "log.h"
 #include "netlink.h"
 
+#define NLBUFSIZ	(8192 * sizeof(struct nlmsghdr)) /* See netlink(7) */
+
 /* Socket in init, in target namespace, sequence (just needs to be monotonic) */
 static int nl_sock	= -1;
 static int nl_sock_ns	= -1;
@@ -105,7 +107,7 @@ fail:
 static int nl_req(int ns, char *buf, const void *req, ssize_t len)
 {
 	int s = ns ? nl_sock_ns : nl_sock, done = 0;
-	char flush[BUFSIZ];
+	char flush[NLBUFSIZ];
 	ssize_t n;
 
 	while (!done && (n = recv(s, flush, sizeof(flush), MSG_DONTWAIT)) > 0) {
@@ -121,7 +123,8 @@ static int nl_req(int ns, char *buf, const void *req, ssize_t len)
 		}
 	}
 
-	if ((send(s, req, len, 0) < len) || (len = recv(s, buf, BUFSIZ, 0)) < 0)
+	if ((send(s, req, len, 0) < len) ||
+	    (len = recv(s, buf, NLBUFSIZ, 0)) < 0)
 		return -errno;
 
 	return len;
@@ -149,7 +152,7 @@ unsigned int nl_get_ext_if(sa_family_t af)
 	};
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
@@ -227,7 +230,7 @@ void nl_route(int ns, unsigned int ifi, sa_family_t af, void *gw)
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
 	struct rtmsg *rtm;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
@@ -336,7 +339,7 @@ void nl_addr(int ns, unsigned int ifi, sa_family_t af,
 	struct ifaddrmsg *ifa;
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
@@ -446,7 +449,7 @@ void nl_link(int ns, unsigned int ifi, void *mac, int up, int mtu)
 	struct ifinfomsg *ifm;
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
-	char buf[BUFSIZ];
+	char buf[NLBUFSIZ];
 	ssize_t n;
 	size_t na;
 
-- 
2.38.4


  reply	other threads:[~2023-03-03 22:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 22:49 [PATCH 1/3] musl adaptations KuhnChris
2023-03-03 22:49 ` KuhnChris [this message]
2023-03-04  9:54   ` [PATCH 2/3] sbrivio/manual buffer size due to musl being 1024 Stefano Brivio
2023-03-03 22:49 ` [PATCH 3/3] define _bswap_constant_16/32 for musl This uses the implementation from libiio (https://github.com/analogdevicesinc/libiio/commit/9c6c6a432a0cbe2832bc97a7eeddfb61f6b8b856) Also restored the old behavior from the old util.h KuhnChris
2023-03-04  9:55   ` Stefano Brivio
2023-03-04  9:54 ` [PATCH 1/3] musl adaptations Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230303224931.11791-2-kuhnchris+github@kuhnchris.eu \
    --to=kuhnchris+github@kuhnchris.eu \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).