From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.insanity.kuhnchris.eu (insanity.kuhnchris.eu [37.59.36.123]) by passt.top (Postfix) with ESMTPS id 2A5645A024D for ; Fri, 3 Mar 2023 23:49:38 +0100 (CET) From: KuhnChris DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kuhnchris.eu; s=mail; t=1677883780; bh=q/TjJaejE0r76YNA5LQeofu/kFgwtrGRTyQKTRIHcYU=; h=From:To:Cc:Subject:In-Reply-To:References; b=fpbJHF5MgcLKdmz1Zpcy+hoiaPSHO7lcXx4D/Pl+mPbq/ccHdlkheYyAIR6EuDJa3 DkerH6oqK/SnyI/c1uEhOByyM/J9yisDBj5BHe+ZuUhov750Q7o9gWycF1L+h+6SXu 15cj8emeEwLm7BfxiO4JX3VoJNN8PYn7arc6SzJXlsRJyXSaxm2f8EVoabVOuSg84b EQum0aAN9WkNr/o4et9FYnoeTDROOAhWKw5eg3/g6WRHPgtyTNWbaidYsccdPAQ6fJ iVkjCgOEwiobsjOF8fDcb9UcqRSnKLJ/pH1rAhtnbKAJ6MQTS0+t6yFs+7Veur5fkW Lc66udFqjfnlQ== To: passt-dev@passt.top Subject: [PATCH 2/3] sbrivio/manual buffer size due to musl being 1024 Date: Fri, 3 Mar 2023 22:49:30 +0000 Message-Id: <20230303224931.11791-2-kuhnchris+github@kuhnchris.eu> In-Reply-To: <20230303224931.11791-1-kuhnchris+github@kuhnchris.eu> References: <20230303224931.11791-1-kuhnchris+github@kuhnchris.eu> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-MailFrom: kuhnchris+github@kuhnchris.eu X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: OOFRTWVYFTLS2I3QHFV2O3RQ4WVJMTBZ X-Message-ID-Hash: OOFRTWVYFTLS2I3QHFV2O3RQ4WVJMTBZ X-Mailman-Approved-At: Sat, 04 Mar 2023 09:52:28 +0100 CC: KuhnChris X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --- 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; -- 2.38.4