Re: git: 8c7149c73f8f - main - wpa_supplicant: Handle systems without INET (legacy IP) support

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Mon, 28 Apr 2025 00:13:54 UTC
On 4/27/25 19:05, Cy Schubert wrote:
> The branch main has been updated by cy:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=8c7149c73f8f2301369f271c98470b72973b0c01
> 
> commit 8c7149c73f8f2301369f271c98470b72973b0c01
> Author:     Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
> AuthorDate: 2025-04-28 00:02:04 +0000
> Commit:     Cy Schubert <cy@FreeBSD.org>
> CommitDate: 2025-04-28 00:04:45 +0000
> 
>      wpa_supplicant: Handle systems without INET (legacy IP) support
>      
>      Currently, wpa_supplicant fails when legacy IP support is disabled
>      in FreeBSD (i.e., the world built with WITHOUT_INET and nooptions
>      INET in the kernel config). The proposed patch allows running
>      wpa_supplicant and connecting to wireless networks without INET
>      support when INET6 is available.
>      
>      Reviewed by:            cy, adrian, philip, roy_marples.name
>      Differential Revision:  https://reviews.freebsd.org/D49959
> ---

It looks like we really only invoke interface ('i' group) ioctls on this 
socket, is there any particular reason we didn't just use a PF_LOCAL 
socket?  It'd be less complex and match what ifconfig does for a lot of 
its work.

Thanks,

Kyle Evans

>   contrib/wpa/src/drivers/driver_bsd.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/contrib/wpa/src/drivers/driver_bsd.c b/contrib/wpa/src/drivers/driver_bsd.c
> index 6efaa9c27ff2..d23d720789f9 100644
> --- a/contrib/wpa/src/drivers/driver_bsd.c
> +++ b/contrib/wpa/src/drivers/driver_bsd.c
> @@ -1800,9 +1800,19 @@ bsd_global_init(void *ctx)
>   
>   	global->sock = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
>   	if (global->sock < 0) {
> +	    if (errno == EAFNOSUPPORT) {
> +		wpa_printf(MSG_INFO, "INET not supported, trying INET6...");
> +		global->sock = socket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
> +		if (global->sock < 0) {
> +		    wpa_printf(MSG_ERROR, "socket[PF_INET6,SOCK_DGRAM]: %s",
> +			       strerror(errno));
> +		    goto fail1;
> +		}
> +	    } else {
>   		wpa_printf(MSG_ERROR, "socket[PF_INET,SOCK_DGRAM]: %s",
>   			   strerror(errno));
>   		goto fail1;
> +	    }
>   	}
>   
>   	global->route = socket(PF_ROUTE,