# [SOLVED] net.ath0 (madwifi), dhcp, initscript issues

## caplan

Hello Fellow Gentoo'rs!

I have a frustrating issue that I can't figure out on my own and I'm hoping someone here can smack me with a trout and show me the light.

I'm using an IBM T42 (2373-CD8) Thinkpad with Wifi (Atheros and madwifi).  Everything works except I have to start networking manually.

```
T42-Gentoo ~ # lspci | grep -i atheros

02:02.0 Ethernet controller: Atheros Communications, Inc. AR5212 802.11abg NIC (rev 01)

T42-Gentoo ~ # uname -a

Linux T42-Gentoo 2.6.18-gentoo-r3 #1 Mon Dec 4 14:32:22 EST 2006 i686 Intel(R) Pentium(R) M processor 1.60GHz GenuineIntel GNU/Linux

```

I have setup that my net.ath0 init script start as apart of the "default" runlevel.

```
T42-Gentoo ~ # rc-update show

               acpid |      default                  

           alsasound | boot                          

            bootmisc | boot                          

             checkfs | boot                          

           checkroot | boot                          

               clock | boot                          

            coldplug | boot                          

         consolefont | boot                          

               cupsd |      default                  

                dbus |      default                  

              hdparm |      default                  

            hostname | boot                          

             hotplug |      default                  

         ibm-wclient |      default                  

             keymaps | boot                          

               local |      default nonetwork        

          localmount | boot                          

             modules | boot                          

            net.ath0 |      default                  

              net.lo | boot                          

            netmount |      default                  

          ntp-client |      default                  

                ntpd |      default                  

           rmnologin | boot                          

                sshd |      default                  

           syslog-ng |      default                  

             urandom | boot                          

          vixie-cron |      default                  

              vmware |      default                  

                 xdm |      default 

```

The net.ath0 script is a link to net.lo like the Gentoo Handbook tells you to do.

```
T42-Gentoo ~ # ls -la /etc/init.d/ | grep net

lrwxrwxrwx  1 root root     6 Apr 21  2006 net.ath0 -> net.lo

lrwxrwxrwx  1 root root     6 Nov  4 10:14 net.eth0 -> net.lo

-rwxr-xr-x  1 root root 30341 Nov  4 10:14 net.lo

-rwxr-xr-x  1 root root  3046 Nov  4 10:14 netmount

```

What happens is on boot the net.eth0 script tries to start (and depending on whether or not I leave my cable plugged in or not) but fails, and then the net.ath0 script tries to start which if fails as well.

```
 * Starting ath0

 *   Running preup function

wlanconfig: ioctl: Input/output error

 *     preup ath0 failed                                              [ !! ]

 * ERROR:  cannot start netmount as net.ath0 could not start

```

After I'm logged in, to start networking I need to do the following:

```
T42-Gentoo ~ # wlanconfig ath0 destory

T42-Gentoo ~ # /etc/init.d/net.ath0 start

 * Starting ath0

 *   Running preup function                                               [ ok ]

 *   Starting wpa_supplicant on ath0 ...                                  [ ok ]

 *   Starting wpa_cli on ath0 ...                                         [ ok ]

 *     Backgrounding ...

T42-Gentoo ~ # dhcpcd ath0

```

Once I do that I'm half-working.  I can do /etc/init.d/net.ath0 stop/start/restart without issue, but I still have to manually type "dhcpcd ath0" to get an IP.  In addition, even though it starts my /etc/init.d/net.ath0 script never show it never does start:

```
T42-Gentoo ~ # /etc/init.d/net.ath0 status

 * status:  inactive

```

This is frustrating as its stopping other services from running:

```
T42-Gentoo ~ # rc

 * WARNING:  netmount is scheduled to start when net.ath0 has started.

 * WARNING:  ntp-client is scheduled to start when net.ath0 has started.

 * WARNING:  ntpd is scheduled to start when net.ath0 has started.

 * WARNING:  sshd is scheduled to start when net.ath0 has started.

```

I've read about issues with baselayout, could this be a similar problem?  I'm not running anything ~x86 here, just stable released packages...

```
T42-Gentoo ~ # emerge -s baselayout

Searching...   

[ Results for search key : baselayout ]

[ Applications found : 4 ]

 

*  sys-apps/baselayout

      Latest version available: 1.12.6

      Latest version installed: 1.12.6

      Size of files: 216 kB

      Homepage:      http://www.gentoo.org/

      Description:   Filesystem baselayout and init scripts

      License:       GPL-2

T42-Gentoo ~ # emerge -s madwifi

Searching...   

[ Results for search key : madwifi ]

[ Applications found : 4 ]

 

*  net-wireless/madwifi-ng

      Latest version available: 0.9.2.1

      Latest version installed: 0.9.2.1

      Size of files: 3,395 kB

      Homepage:      http://www.madwifi.org/

      Description:   Next Generation driver for Atheros based IEEE 802.11a/b/g wireless LAN cards

      License:       as-is || ( BSD GPL-2 )

*  net-wireless/madwifi-ng-tools

      Latest version available: 0.9.2

      Latest version installed: 0.9.2

      Size of files: 3,395 kB

      Homepage:      http://www.madwifi.org/

      Description:   Next Generation tools for configuration of Atheros based IEEE 802.11a/b/g wireless LAN cards

      License:       || ( BSD GPL-2 )

T42-Gentoo ~ # emerge -s wireless-tools

Searching...   

[ Results for search key : wireless-tools ]

[ Applications found : 1 ]

 

*  net-wireless/wireless-tools

      Latest version available: 28

      Latest version installed: 28

      Size of files: 248 kB

      Homepage:      http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html

      Description:   A collection of tools to configure IEEE 802.11 wireless LAN cards

      License:       GPL-2

```

My /etc/conf.d/net file:

```
T42-Gentoo ~ # cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_eth0=( "dhcp" )

#config_eth0=( "192.168.0.101/24" )

config_ath0=( "dhcp" )

modules=( "wpa_supplicant" )

wpa_supplicant_ath0="-Dmadwifi"

wpa_timeout_ath0=60

preup() {

        if [ "${IFACE}" == "ath0" ]; then

                /sbin/wlanconfig ath0 create wlandev wifi0 wlanmode sta > /dev/null

                return $?

        fi

        if mii-tool ${IFACE} 2> /dev/null | grep -q 'no link'; then

                ewarn "No link on ${IFACE}, aborting configuration"

                return 1

        fi

        return 0

}

                                                                               predown() {

        if [ "${IFACE}" == "ath0" ]; then

                killall wpa_supplicant

                /sbin/wlanconfig ath0 destroy

                return $?

        fi

        return 0

}

```

Any help would be greatly appreciated!!!

----------

## bunkacid

what version of wpa_supplicant, and dhcpcd do you have installed?

also you should not need that preup/predown portion in your config as wpa_supplicant is automatic when setup in the modules, and has configuration values for the interface.

since you said your connection works manually I'd assume your /etc/wpa_supplicant/wpa_supplicant.conf is in good order.

----------

## caplan

 *bunkacid wrote:*   

> what version of wpa_supplicant, and dhcpcd do you have installed? 

 

I have the following versions:

```
T42-Gentoo ~ # emerge -s wpa_supp

Searching...   

[ Results for search key : wpa_supp ]

[ Applications found : 1 ]

 

*  net-wireless/wpa_supplicant

      Latest version available: 0.5.4

      Latest version installed: 0.5.4

      Size of files: 615 kB

      Homepage:      http://hostap.epitest.fi/wpa_supplicant/

      Description:   IEEE 802.1X/WPA supplicant for secure wireless transfers

      License:       || ( GPL-2 BSD )

T42-Gentoo ~ # emerge -s dhcpcd

Searching...   

[ Results for search key : dhcpcd ]

[ Applications found : 1 ]

 

*  net-misc/dhcpcd

      Latest version available: 2.0.5-r1

      Latest version installed: 2.0.5-r1

      Size of files: 121 kB

      Homepage:      http://developer.berlios.de/projects/dhcpcd/

      Description:   A DHCP client only

      License:       GPL-2

```

And just for kicks, here is my /etc/wpa_supplicant.conf file:

```
T42-Gentoo ~ # cat /etc/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

eapol_version=1

ap_scan=1

fast_reauth=1

network={

        ssid="***********"

        key_mgmt=NONE

        wep_key0=**************************

        wep_tx_keyidx=0

        auth_alg=OPEN

        priority=5

}
```

(One of these days I'll try moving to wpa, but hey I'm in the boonies.)  I'll try removing the preup/predown portion in my /etc/conf.d/net configuration file and report back.

----------

## caplan

 *bunkacid wrote:*   

> also you should not need that preup/predown portion in your config as wpa_supplicant is automatic when setup in the modules, and has configuration values for the interface. 

 

Yup that was the issue.  Rebooted and everything started successfully.  Weird that it would affect the other services so poorly, but hey, a fix is a fix.  Thanks bunkacid, I'm super happy now.    :Very Happy: 

For others, my /etc/conf.d/net file is now as follows:

```
T42-Gentoo ~ # cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_eth0=( "dhcp" )

#config_eth0=( "192.168.0.101/24" )

config_ath0=( "dhcp" )

modules=( "wpa_supplicant" )

wpa_supplicant_ath0="-Dmadwifi"

wpa_timeout_ath0=60

```

----------

## bunkacid

 *caplan wrote:*   

>  Thanks bunkacid, I'm super happy now.    

 

your welcome

----------

