Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 218673 - sys-apps/openrc: config_SSID doesn't work with ssidnet.sh and wpa_supplicant.sh
Summary: sys-apps/openrc: config_SSID doesn't work with ssidnet.sh and wpa_supplicant.sh
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-21 03:14 UTC by kouyu
Modified: 2009-01-04 13:05 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
verbose debug log of wireless service start (wpa_suplicant-start-openrc.txt,36.00 KB, text/plain)
2008-04-23 14:15 UTC, Nicola
Details
Some log files about net.eth2 (lognet.tar.bz2,10.31 KB, application/octet-stream)
2008-04-27 15:51 UTC, kouyu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kouyu 2008-04-21 03:14:59 UTC
This bug is about ssidnet.sh and wpa_supplicant.sh 

In ssidnet.sh, ssidnet_pre_start need variable SSID which should be defined before to convert config_SSID to config_IFACE. 
If you take wpa_supplicant as modules (modules_eth0="wpa_supplicant"), the SSID should be defined by wpa_supplicant_pre_start which is in wpa_supplicant.sh. 

In baselayout1, in wpa_supplicant.sh, at the bottom of wpa_supplicant_pre_start, the SSID is reported for essidnet. See code: 
------------------------------------------------------------
# Only report wireless info for wireless interfaces 
if wpa_supplicant_exists "${iface}" ; then 
   # Set ESSID for essidnet and report 
   ESSID=$(wpa_supplicant_get_essid "${iface}" ) 
   ESSIDVAR=$(bash_variable "${ESSID}") 
   save_options "ESSID" "${ESSID}" 

   local -a status=() 
   eval status=( $(wpa_cli -i"${iface}" status | sed -n -e 's/^\(bssid\|pairwise_cipher\|key_mgmt\)=\([^=]\+\).*/\"\U\2\"/p' | tr '[:lower:]' '[:upper:]') ) 
   einfo "${iface} connected to \"${ESSID//\\\\/\\\\}\" at ${status[0]}" 

   if [[ ${status[2]} == "NONE" ]] ; then 
      if [[ ${status[1]} == "NONE" ]] ; then 
         ewarn "not using any encryption" 
      else 
         veinfo "using ${status[1]}" 
      fi 
   else 
      veinfo "using ${status[2]}/${status[1]}" 
   fi 
   eoutdent 
else 
   einfo "${iface} connected" 
fi 
------------------------------------------------------------
 

And in baselayout1, essidnet_pre_start also would call wireless_get_essid to get ESSID by itself. 
------------------------------------------------------------
local ESSID=$(wireless_get_essid "${iface}") 
------------------------------------------------------------

But in openrc, these related code does not exist in either ssidnet.sh or wpa_supplicant.sh. 
So if you write config like this: 
------------------------------------------------------------
config_NETGEAR="192.168.0.123/24" 
------------------------------------------------------------
It does not work! Have a try.
Comment 1 kouyu 2008-04-21 03:19:25 UTC
openrc I'm using is openrc-0.2.2
Comment 2 Roy Marples 2008-04-21 23:19:45 UTC
I tested this and it works just fine.
Please attach output of the following command

IN_BACKGROUND=true rc-service net.eth0 -- stop
IN_BACKGROUND=true rc-service net.eth0 -- --debug --verbose start

Replace eth0 with the name of the interface running wpa_supplicant.
Comment 3 Nicola 2008-04-22 16:49:30 UTC
i got problems too in upgrading from baselayout-1 to openrc with wpa_supplicant.
it simply doesn't associate.

i'll report what with verbose and debug says, once upgraded again.

Without them it just says: net.wlan0 has started, but is inactive.
Comment 4 Nicola 2008-04-23 14:15:17 UTC
Created attachment 150708 [details]
verbose debug log of wireless service start

in the attachment you can read what i get from "IN_BACKGROUND=true rc-service net.eth0 -- --debug --verbose start"

if i don't use "IN_BACKGROUND=true" but i launch the service as usual, it exits with 1 when trying to backgrounding, and says exactly that net.wlan0 has stated but is inactive.
if i try then "wpa_cli status" it answers me:

Selected interface 'wlan0'
bssid=00:00:00:00:00:00
ssid=
id=0
pairwise_cipher=UNKNOWN
group_cipher=UNKNOWN
key_mgmt=UNKNOWN
wpa_state=ASSOCIATED

thank's for the attention Roy :-)
Comment 5 Roy Marples 2008-04-23 14:46:01 UTC
That looks like an error with wpa_supplicant and not openrc, as wpa_cli is reporting that it's associated to an AP, but it's not reporting MAC address or ssid which it should be doing.
Comment 6 Nicola 2008-04-23 15:02:25 UTC
ok, but if it was wpa_supplicant the problem... why it does work with baselayout-1 without any porblem? what's the difference with openrc?

have you already read the attachment, or you think i should try updating wpa_supplicant and pray? :-)

thank's again :-)
Comment 7 Roy Marples 2008-04-23 15:13:28 UTC
Yes I read the attachment. iwgetid didn't return anything, which is just like the wpa_cli output you posted. This implies that it could also be an issue with your network driver.

I use wpa_supplicant fine on ipw2200 (linux, netbsd and freebsd i386) and on rt2500 (netbsd amd64), athereos (freebsd sparc64).
Comment 8 kouyu 2008-04-27 15:51:13 UTC
Created attachment 151148 [details]
Some log files about net.eth2

I did some tests as you wish.

$ uname -a
Linux (hostname) 2.6.24-gentoo-r4 #2 SMP Sat Apr 15 15:51:06 CST 2008 x86_64 Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz GenuineIntel GNU/Linux


My net config is like this:
modules_eth2="wpa_supplicant"
config_eth2="dhcpcd
arping"
config_NETGEAR="dhcpcd"

(eth2 is my wireless interface)

The log net.eth2 prints out when system is booting is this:
net.eth2         | * Bringing up interface eth2
net.eth2         | *   Starting wpa_supplicant on eth2 ...                                                                [ ok ]
net.eth2         | *   dhcpcd ...
net.eth2         | *     Running dhcpcd ...                                                                               [ ok ]
net.eth2         | *     received address 192.168.1.6/24                                                                  [ ok ]
net.eth2         | *   arping ...
net.eth2         | *     Pinging gateways on eth2 for configuration                                                       [ !! ]

If I execute '/etc/init.d/net.eth2 start' manually, the log net.eth2 prints out is the same.

But the last two lines of that log shouldn't have existed. Because config_eth2 should have been replaced with config_NETGEAR by ssidnet_pre_start. net.eth2 should not have `arping', but should have printed an extra line:
net.eth2         | *   Configuring eth2 for SSID NETGEAR ...

But the fact is not what I expect.


Then I did the following steps to generate some logs for you.

1. What lognet5 is
$ /etc/init.d/net.eth2 stop
$ /etc/init.d/net.eth2 start -d -v &>lognet5

In this log:
wpa_supplicant_pre_start: from line 1486 to 1554.
next is ssidnet_pre_start: from line 1557 to 1559. 
In wpa_supplicant_pre_start log, I could not find where SSID is set. So ssidnet_pre_start returned immediately.
( Refer to the first line of function ssidnet_pre_start:
	[ -z "${SSID}" -a -z "${SSIDVAR}" ] && return 0
)

2. What lognet2-background is
$ IN_BACKGROUND=true rc-service net.eth0 -- stop
$ IN_BACKGROUND=true rc-service net.eth0 -- --debug --verbose start &>lognet2-background

In this log:
wpa_supplicant_pre_start: from line 1450 to 1485.
next is ssidnet_pre_start: from line 1488 to 1762.
This time, I found SSID is set in wpa_supplicant_pre_start. wpa_supplicant_pre_start calls _get_ssid to set SSID (refer to line 1472 of this log). So ssidnet_pre_start replaces config_eth2 with config_NETGEAR and prints " *   Configuring eth2 for SSID NETGEAR ..."
Why?  Refer to /lib/rc/net/wpa_supplicant.sh, there is only one place to set SSID, from line 65 to 76:
	# We don't configure wireless if we're being called from
	# the background unless we're not currently running
	if yesno ${IN_BACKGROUND}; then
		if ${wireless} && \
		service_started_daemon "${RC_SVCNAME}" "${wpas}"; then
			SSID=$(_get_ssid "${IFACE}")
			SSIDVAR=$(shell_var "${SSID}")
			service_set_value "SSID" "${SSID}"
			metric=2000
		fi
		return 0
	fi
So, SSID is set only when backgrounding. Why? It is really different from baselayout1.




BTW
During read lognet2-background, I found another problem.
wpa_supplicant_pre_start calls _get_ssid to set SSID. But _get_ssid is not the one defined in wpa_supplicant.sh, but the one defined in iwconfig.sh. Because _get_ssid calls iwgetid (should have been wpa_cli) to get SSID. 
The variable 'modules' in net config is set to 'wpa_supplicant' only. To wireless, module wpa_supplicant(wpa_supplicant.sh) and module iwconfig(iwconfig.sh) are exclusive (not complementary at least, I think), so if I don't select iwconfig, why is _get_ssid which is defined in iwconfig.sh called. I thought if I select wpa_supplicant only, those related functions should all belong to wpa_supplicant.sh.

So I did the following tests as well.

I exclude module iwconfig explicitly.
$ sed -i '/^modules_eth2/s/.*/modules_eth2="wpa_supplicant !iwconfig"/g' /etc/conf.d/net

Then, like above:

1. What lognet4-exclude_iwconfig is
$ /etc/init.d/net.eth2 stop
$ /etc/init.d/net.eth2 start -d -v &>lognet4-exclude_iwconfig

2. What lognet3-background-exclude_iwconfig is
$ IN_BACKGROUND=true rc-service net.eth0 -- stop
$ IN_BACKGROUND=true rc-service net.eth0 -- --debug --verbose start &>lognet2-background

In lognet4-exclude_iwconfig, SSID is still not set in anywhere.
In lognet3-background-exclude_iwconfig, I could find SSID is set by _get_ssid called by wpa_supplicant_pre_start. And _get_ssid calls wpa_cli (not iwgetid). That's what I want.
But, if I don't want to use anything belonging to iwconfig, do I have to exclude the module explicitly? I remember in baselayout1 I don't have to.....
Comment 9 Nicola 2008-04-29 15:35:21 UTC
(In reply to comment #7)
> Yes I read the attachment. iwgetid didn't return anything, which is just like
> the wpa_cli output you posted. This implies that it could also be an issue with
> your network driver.
> 
> I use wpa_supplicant fine on ipw2200 (linux, netbsd and freebsd i386) and on
> rt2500 (netbsd amd64), athereos (freebsd sparc64).
> 

well, but i can't understand why this happens just with openrc.. if it was a driver problem, it was not related to just one between openrc and baselayout-1, ain't it right?

so, have you tested it with wext? 

i tried with wpa_supplicant 5.7, 5.10 and 6.3, and even with the most recent version of the iwlwifi driver (using the 2.6.25 kernel) (i'm running a 4965AGN from intel)

the /etc/conf.d/net is simple:

modules_wlan0="wpa_supplicant"
wpa_supplicant_wlan0="-Dwext"
mode_wlan0="managed"
config_wlan0="dhcp"
dhcpcd_wlan0="-t 5"


how do you think i should investigate further on where is the problem?
Comment 10 kouyu 2008-05-06 06:28:19 UTC
Can anyone help this bug please?
Who is in charge?
Too sad...
Comment 11 inode77 2008-05-15 18:27:49 UTC
I have the exact same problem using 2.6.24 kernel, iwl3945 (Thinkpad T60p) and openrc 0.2.4-r1.

Comment 12 inode77 2008-05-15 18:48:11 UTC
OpenRC:
=======
 /etc/init.d/net.wlan start
 * Caching service dependencies ...                                                                                                 [ ok ]
 * Bringing up interface wlan
 *   Running preup ...
 *   Starting wpa_supplicant on wlan ...
ioctl[SIOCSIWAUTH]: Operation not supported                                                                                               [ ok ]uth param 4 value 0x0 -
 *   Starting wpa_cli on wlan ...
Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory
 *   start-stop-daemon: failed to start `/usr/bin/wpa_cli'                                                                          [ !! ]
 * WARNING: net.wlan not under our control, aborting

MANUAL
======

# wpa_supplicant -Dwext -iwlan -c /etc/wpa_supplicant/wpa_supplicant.conf &
[1] 13695

ioctl[SIOCSIWAUTH]: Operation not supported
WEXT auth param 4 value 0x0 - CTRL-EVENT-SCAN-RESULTS
CTRL-EVENT-SCAN-RESULTS
Trying to associate with 00:0b:6b:35:c8:63 (SSID='*WLAN*' freq=2412 MHz)
Associated with 00:0b:6b:35:c8:63
WPA: Key negotiation completed with 00:0b:6b:35:c8:63 [PTK=CCMP GTK=CCMP]
CTRL-EVENT-CONNECTED - Connection to 00:0b:6b:35:c8:63 completed (auth) [id=1 id_str=]
# dhcpcd wlan
Comment 13 Nicola 2008-05-15 21:43:47 UTC
(In reply to comment #12)
>  /etc/init.d/net.wlan start

maybe it should be net.wlan0

try before changing it on how is called your interface
Comment 14 Nicola 2008-05-22 16:14:16 UTC
i did understand my problem: i'm opening a separate bug, because it doesn't match with config_SSID.
Comment 15 Roy Marples 2008-05-27 10:51:12 UTC
OK, I've looked at your log files some more, and have a question :)
Do you roll your own wpa_supplicant or use a Gentoo ebuild?

If the former, install wpa_cli.sh from portage in /etc/wpa_supplicant.
If the latter, what does this show? equery files wpa_supplicant | grep wpa_cli
Comment 16 kouyu 2008-06-06 06:00:27 UTC
Sorry, this time I didn't make response in time.
Since you said you are busy last time, I haven't been concerning with this bug for a long time.

wpa_supplicant in my mechine was installed a long time ago, last year maybe, and I have not updated it yet. 
You are right, maybe this is the problem -- I should update my wpa_supplicant. Exactly speaking, I should downgrade my wpa_supplicant from 0.6.0 to 0.5.10.
I will try when I am home and tell you the result. Thank you.

(In reply to comment #15)
> OK, I've looked at your log files some more, and have a question :)
> Do you roll your own wpa_supplicant or use a Gentoo ebuild?
> 
> If the former, install wpa_cli.sh from portage in /etc/wpa_supplicant.
> If the latter, what does this show? equery files wpa_supplicant | grep wpa_cli
> 

Comment 17 kouyu 2008-06-19 03:10:16 UTC
OK, I think this bug can be resolved.
After I tested, the problem gone.

And I knew the truth: if your gentoo want to use wireless network with wpa_supplicant and openrc(baselayout2), you must update them to the newest version. Because wpa_supplicant.sh in openrc need to use wpa_cli.sh provided by the newest ebuild of wpa_supplicant. 
I.e., wpa_supplicant ebuild provide wpa_cli.sh just for openrc only. So, maybe some other related ebuilds (e.g. dhcpcd) all need to be updated in order to provide scripts required by openrc. I will update right now ...
Comment 18 Roy Marples 2008-06-19 06:51:56 UTC
All baselayout versions that support wpa_supplicant require wpa_cli.sh as supplied by wpa_supplicant.
openrc is not special here
Comment 19 kouyu 2008-09-11 07:09:56 UTC
I have to say:

wpa_cli.sh was not provided by wpa_supplicant package before. First half of last year,I emerged wpa_supplicant-0.6.0(now this version has been being masked for a long time), and then I had never updated wpa_supplicant. And that file, wpa_cli.sh, never appeared in my system.
And baselayout-1, which did not need openrc and which I had been using for a year, could start my wireless network service based on wpa_supplicant properly, correctly without wpa_cli.sh.
Comment 20 kouyu 2008-09-11 07:18:44 UTC
Of course, now with openrc, with baselayout-2, with wpa_cli.sh, I can start my wireless service properly, correctly.

In addion, before with baselayout-1, without wpa_cli.sh, without openrc, I also can start my wireless service properly, correctly, as I mentioned in last comment.

But the difference is now the service is started in background, and before it is started in foreground.
Comment 21 Doug Goldstein (RETIRED) gentoo-dev 2008-10-07 15:45:09 UTC
Looks like this issue is fixed. If there is still an issue, please open a new bug for any new issues.
Comment 22 Piotr Łyczba 2008-12-03 16:29:15 UTC
Hi,
recently I upgrade my baselayout to second version with openrc and i have problem with running net.ath0 with dhcpcd, wpa_supplicant. I have wpa_supplicant 0.6.4 with madwifi flag.

I noticed that: "/etc/init.d/net.ath0 start" gives me no "running dhcpcd..." and "WARNING: net.ath0 has started, but is inactive"
whilst:
IN_BACKGROUND=true /etc/init.d/net.ath0 start works properly.

So, my question is: what should I do if I want to start at booting (with rc) net.ath0 WITH option IN_BACKGROUND=true? Or maybe there's some other issue with my config or maybe it's some bug?