From nobody Sat Dec 2 20:38:30 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SjMFy6Qjnz52VwB; Sat, 2 Dec 2023 20:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SjMFy60Nlz4dh8; Sat, 2 Dec 2023 20:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701549510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cGF8cVUa76wbmLcMjwXX0JC9bD4Ezl0WFKvxpNqhkGQ=; b=Y1SFmt/dhKbz2IGRFwPjc2nmFfWNM6b4IwSO+yv/owAVB3OsAbLtF7MwzsmeXjUzF2+wre B4ATh/ULwSiXlMqRO3NtCcdgqHHtT4f/k00TE715R3TVmSt4XZ7wqhkeOK9nEPOcID96hs swjUNdgyp13/fNySVaY8/1XWrwVvYBtxhlCPbbj9Z8MDxrtOV2hMbdrMYw9Phh+TVaqjvg Hv51UvQlrB3Rg2htqJcUEhdKNmk2ucbUcsCr6cQ7LjmuqAqRr/ADDbqEgbdBUwoaUwEZVj /ttJhpWvovzoABDrwlvb8jW7FzpMd1M4zcrv3R297Ylad1VVJUPAwzeYlqRfdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701549510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cGF8cVUa76wbmLcMjwXX0JC9bD4Ezl0WFKvxpNqhkGQ=; b=QtoeEbYFzz5dHTwdL9zZ1+8AQj94EB9UM4548ylmC1wkOX7QUx2ippyQHls3gYPnLqrhO/ hSgprx28TIe0s0WdDxvpH2RTVnzeB1PGxUBirwNlKKSRO0ESCYpZWKQKm0CrLqPAn65hOe 8HbA+nQ87hdFHZfHUHB11bMtV6NSTjIdmdr6Hzps7HzqVYUVS/bUrT7yPHQW/OmESWhU18 R0UfSPc1ToCFrkqc/scR3PyaBeMWNrAnA88H1WixtxFCxk0PhzYXk+LFgaDgJ57cM+WedE dnuXpc2kBR+gXiJ44wND22oVNPY7uDM8iz60Z/LT2Ww94ZrjNYI6k4XYhd8Hrw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701549510; a=rsa-sha256; cv=none; b=Xi/21nWiHYuWL+mVjP4BECGWFOXk53rOV5xcN8+byzUcNXPtYyiSqKnsl5gzXGAe7B9t59 XhqzYKGVFmAe1H4q8Erl+vAQ3nFP8lXXHkmLOCDS9VogZ9iiaKIJSlh1+DDJNbFWnxtUe+ AG1v7LBmuO3fWZilNIckIh6uzmJvZZ1rl2DJ8yNC80Q11nPwJO7JIVnDbhSqFqT66NzrL1 r+9ClvNLp+RbtqApw0bvPyUIVKTI1VEyrrpDY/9W2G7T0eg4fgYNxFLgQeWc+y0wsOJ9iV kzsY+OiBoXVBeEbMby+CLjxSFMSpzpxib/a2WtKBaeYhp6mnfF19bw2dlY5JXQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SjMFy4wQdzX7D; Sat, 2 Dec 2023 20:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B2KcUm8001429; Sat, 2 Dec 2023 20:38:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B2KcUPJ001426; Sat, 2 Dec 2023 20:38:30 GMT (envelope-from git) Date: Sat, 2 Dec 2023 20:38:30 GMT Message-Id: <202312022038.3B2KcUPJ001426@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 1edc20b76953 - main - wpa: ctrl_iface set sendbuf size List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1edc20b76953d9ef571b0bcf89b206b98ed13d9b Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=1edc20b76953d9ef571b0bcf89b206b98ed13d9b commit 1edc20b76953d9ef571b0bcf89b206b98ed13d9b Author: Bjoern A. Zeeb AuthorDate: 2023-11-12 20:33:41 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-12-02 20:37:36 +0000 wpa: ctrl_iface set sendbuf size In order to avoid running into the default net.local.dgram.maxdgram of 2K currently when calling sendto(2) try to set the sndbuf size to the maximum ctrl message size. While on 14 and 15 this does not actually raise the limit anymore (and be7c095ac99ad29fd72b780c7d58949a38656c66 raised it for syslogd and this), FreeBSD 13 still requires this change and it will work as expected there. In addition we always ensure a large enough send buffer this way independent of kernel defaults. The problem occured, e.g., when the scan_list result had enough BSSIDs so the text output would exceed 2048 bytes. Sponsored by: The FreeBSD Foundation MFC after: 3 days PR: 274990 Reviewed by: cy, adrian (with previous comment) Differential Revision: https://reviews.freebsd.org/D42558 --- contrib/wpa/wpa_supplicant/ctrl_iface_unix.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/contrib/wpa/wpa_supplicant/ctrl_iface_unix.c b/contrib/wpa/wpa_supplicant/ctrl_iface_unix.c index 639573dae75e..deeed2b11833 100644 --- a/contrib/wpa/wpa_supplicant/ctrl_iface_unix.c +++ b/contrib/wpa/wpa_supplicant/ctrl_iface_unix.c @@ -506,6 +506,10 @@ static int wpas_ctrl_iface_open_sock(struct wpa_supplicant *wpa_s, struct group *grp; char *endp; int flags; +#if defined(__FreeBSD__) + int optval, rc; + socklen_t optlen; +#endif buf = os_strdup(wpa_s->conf->ctrl_interface); if (buf == NULL) @@ -679,6 +683,22 @@ havesock: } } +#if defined(__FreeBSD__) + /* Ensure we can send a full length message atomically. */ + optval = 0; + optlen = sizeof(optval); + if (getsockopt(priv->sock, SOL_SOCKET, SO_SNDBUF, &optval, &optlen) == -1) { + wpa_printf(MSG_INFO, "failed to get sndbuf for sock=%d: %s", + priv->sock, strerror(errno)); + } else if (optval < CTRL_IFACE_MAX_LEN) { + optval = CTRL_IFACE_MAX_LEN; + if (setsockopt(priv->sock, SOL_SOCKET, SO_SNDBUF, &optval, + sizeof(optval)) == -1) + wpa_printf(MSG_ERROR, "failed to set sndbuf for " + "sock=%d: %s", priv->sock, strerror(errno)); + } +#endif + eloop_register_read_sock(priv->sock, wpa_supplicant_ctrl_iface_receive, wpa_s, priv); wpa_msg_register_cb(wpa_supplicant_ctrl_iface_msg_cb);