# [SOLVED] wpa_supplicant does not start

## ConiKost

Hi!

I am running Gentoo on my Raspberry Pi 3 and have installed wpa_supplicant, to be able to connect to my WiFi.

With using "iw scan", I can see my SSID.

There seems to be problem with sockets

wpa_supplicant cannot start, as it fails to start the control interface.

I think, it's not a problem of wpa_supplicant, but more there is something wrong with sockets, maybe eben some kernel option missing?

```

ctrl_iface bind(PF_UNIX) failed: Invalid argument

```

On my x86 Gentoo notebook, wpa_supplicant is running fine with that config.

Kernel is build from raspberrypi-sources (4.4.9999)

```

cd /usr/share/linux

KERNEL=kernel7

make zImage modules dtbs

sudo make modules_install

sudo cp arch/arm/boot/dts/*.dtb /boot/

sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/

sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/

sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img

```

This is the error during start of wpa_supplicant:

```

Using existing control interface directory.

ctrl_interface_group=10 (from group name 'wheel')

ctrl_iface bind(PF_UNIX) failed: Invalid argument

ctrl_iface exists, but does not allow connections - assuming it was leftover from forced program termination

Could not unlink existing ctrl_iface socket '/var/run/wpa_supplicant/wlan0': No such file or directory

Failed to initialize control interface 'DIR=/var/run/wpa_supplicant GROUP=wheel'.

You may have another wpa_supplicant process already running or the file was

left by an unclean termination of wpa_supplicant in which case you will need

to manually remove this file before starting wpa_supplicant again.

```

My wpa_supplicant configuration:

```

# Zugriff für Gruppe "wheel" erlauben

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

update_config=1

# Battlestar Galactica (2.4 GHz, WPA2)

network={

        group=CCMP

        key_mgmt=WPA-PSK

        pairwise=CCMP

        priority=1

        proto=WPA2

        # psk="xxxxxx"

        psk=xxxxxx

        scan_ssid=1

        ssid="Battlestar Galactica"

}

# Battlestar Columbia (2.4 GHz, WPA2-EAP)

network={

        eap=TTLS

        group=CCMP

        identity="xxxxxxx"

        key_mgmt=WPA-EAP

        pairwise=CCMP

        password="xxxxxxxx"

        phase2="auth=MSCHAPV2"

        priority=2

        proto=WPA2

        scan_ssid=1

        ssid="Battlestar Columbia"

}

```

wpa_supplicant is running perfectly fine, if I disable completly the control interface. But Gentoo itself is setting "-W" on wpa_supplicant and wants the control interface.

Any Ideas?Last edited by ConiKost on Sat Mar 19, 2016 4:23 pm; edited 1 time in total

----------

## khayyam

 *ConiKost wrote:*   

> 
> 
> ```
> You may have another wpa_supplicant process already running or the file was left by an unclean termination of wpa_supplicant in which case you will need to manually remove this file before starting wpa_supplicant again.
> ```
> ...

 

ConiKost ... do you have both wpa_supplicant and net.wlan0 in the runlevel? If so, you shouldn't ... as you're effectively starting two wpa_supplicant processes. Either allow netifrc to start wpa_supplicant or run /etc/init.d/wpa_supplicant in isolation, or via dhcpcd.

So, using netifrc:

```
modules_wlan0="!plug wpa_supplicant dhcpcd"

wpa_supplicant_wlan0="-Dnl80211 -qq"

config_wlan0="dhcp"
```

... or remove net.wlan0 and add dhcpcd (or whatever dhcp client you use) to the runlevel.

Note that dhcpcd can also start wpa_supplicant if 10-wpa_supplicant is in /lib/dhcpcd/dhcpcd-hooks (see: 2016-01-08-some-dhcpcd-hooks-are-now-examples) ... which, if enabled, can also cause the above error, so similarly remove wpa_supplicant from the runlevel if this is the case.

HTH & best ... khay

----------

## ConiKost

 *khayyam wrote:*   

>  *ConiKost wrote:*   
> 
> ```
> You may have another wpa_supplicant process already running or the file was left by an unclean termination of wpa_supplicant in which case you will need to manually remove this file before starting wpa_supplicant again.
> ```
> ...

 

Hi!

No, wpa_supplicant ist NOT in a runlevel and NOT running. So the message does not apply to me.

I am currently debugging, why wpa_supplicant does not want to start  :Sad: 

I am starting wpa_supplicant over netifrc. But that fails with that error, which I've posted.

At least, I don't think this a problem with wpa_supplicant. I've also discovered, that my logger (metalog) also does not work:

```

# metalog

metalog: Unable to bind a local socket: Invalid argument

metalog: error: Unable to bind sockets

```

So there is something completly wrong with sockets. Could be a kernel option be missing?

----------

## khayyam

 *ConiKost wrote:*   

> So there is something completly wrong with sockets. Could be a kernel option be missing?

 

ConiKost ... possibly, is CONFIG_UNIX (Unix domain sockets) enabled?

best ... khay

----------

## ConiKost

 *khayyam wrote:*   

>  *ConiKost wrote:*   So there is something completly wrong with sockets. Could be a kernel option be missing? 
> 
> ConiKost ... possibly, is CONFIG_UNIX (Unix domain sockets) enabled?
> 
> best ... khay

 

CONFIG_UNIX=y ist set in my kernel config.

----------

## ConiKost

Thats funny.. I've got the cause.

I am using currently -mstructure-size-boundary=32 in my CFLAGS. That one seems to be the cause.

When setting to 8 oder removing it, and recompile metalog/wpa_supplicant, the both start working and don't have any socket problems any more.

I don't have an explanation for this, but I got this option recomended last year by some gcc-folks for linuxARM for better performance.

```

The sizes of all structures and unions are rounded up to a multiple of the number of bits set by this option. Permissible values are 8, 32 and 64. The default value varies for different toolchains. For the COFF targeted toolchain the default value is 8. A value of 64 is only allowed if the underlying ABI supports it.

Specifying a larger number can produce faster, more efficient code, but can also increase the size of the program. Different values are potentially incompatible. Code compiled with one value cannot necessarily expect to work with code or libraries compiled with another value, if they exchange information using structures or unions.

```

At least, I don't think, this is an incompatibility, as my whole system and kernel was compiled without any errors.

Other packages are working perfectly fine. Anyway, the RPi3 is just my dev and play board, so I know the cause  :Wink: 

----------

