diff options
author | Cy Schubert <cy@FreeBSD.org> | 2023-11-29 16:16:49 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2023-11-29 16:18:11 +0000 |
commit | 60c99d3a93081cc603e104c0e6c9fe389e774657 (patch) | |
tree | 53070bcb3cee0373c67939fb41abaaffb5367815 | |
parent | b118f66e4c1af43b0dbb0580122e119890886b76 (diff) | |
download | ports-60c99d3a93081cc603e104c0e6c9fe389e774657.tar.gz ports-60c99d3a93081cc603e104c0e6c9fe389e774657.zip |
security/wpa_supplicant*: 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.
The problem occured, e.g., when the scan_list result had enough BSSIDs
so the text output would exceed 2048 bytes.
Written by: bz
PR: 274990
Obtained from: https://reviews.freebsd.org/D42558
4 files changed, 74 insertions, 1 deletions
diff --git a/security/wpa_supplicant-devel/Makefile b/security/wpa_supplicant-devel/Makefile index 8ae521bddb93..93751e2c2054 100644 --- a/security/wpa_supplicant-devel/Makefile +++ b/security/wpa_supplicant-devel/Makefile @@ -1,5 +1,6 @@ PORTNAME= wpa_supplicant PORTVERSION= ${COMMIT_DATE} +PORTREVISION= 1 CATEGORIES= security net PKGNAMESUFFIX= -devel diff --git a/security/wpa_supplicant-devel/files/patch-wpa__supplicant_ctrl__iface__unix.c b/security/wpa_supplicant-devel/files/patch-wpa__supplicant_ctrl__iface__unix.c new file mode 100644 index 000000000000..cc73ac35cd35 --- /dev/null +++ b/security/wpa_supplicant-devel/files/patch-wpa__supplicant_ctrl__iface__unix.c @@ -0,0 +1,36 @@ +--- wpa_supplicant/ctrl_iface_unix.c.orig 2022-01-16 12:51:29.000000000 -0800 ++++ wpa_supplicant/ctrl_iface_unix.c 2023-11-29 08:12:07.843443000 -0800 +@@ -506,6 +506,10 @@ + 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) +@@ -678,6 +682,22 @@ + /* Not fatal, continue on.*/ + } + } ++ ++#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); diff --git a/security/wpa_supplicant/Makefile b/security/wpa_supplicant/Makefile index 917544b9cf72..fbb215fe0e82 100644 --- a/security/wpa_supplicant/Makefile +++ b/security/wpa_supplicant/Makefile @@ -1,6 +1,6 @@ PORTNAME= wpa_supplicant PORTVERSION= 2.10 -PORTREVISION= 9 +PORTREVISION= 10 CATEGORIES= security net MASTER_SITES= https://w1.fi/releases/ diff --git a/security/wpa_supplicant/files/patch-wpa__supplicant_ctrl__iface__unix.c b/security/wpa_supplicant/files/patch-wpa__supplicant_ctrl__iface__unix.c new file mode 100644 index 000000000000..cc73ac35cd35 --- /dev/null +++ b/security/wpa_supplicant/files/patch-wpa__supplicant_ctrl__iface__unix.c @@ -0,0 +1,36 @@ +--- wpa_supplicant/ctrl_iface_unix.c.orig 2022-01-16 12:51:29.000000000 -0800 ++++ wpa_supplicant/ctrl_iface_unix.c 2023-11-29 08:12:07.843443000 -0800 +@@ -506,6 +506,10 @@ + 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) +@@ -678,6 +682,22 @@ + /* Not fatal, continue on.*/ + } + } ++ ++#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); |