Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 395859 - sys-apps/openrc-0.9.4: USB networking fails to stop when device unplugged
Summary: sys-apps/openrc-0.9.4: USB networking fails to stop when device unplugged
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: OpenRC Team
Whiteboard: openrc:oldnet
Depends on:
Blocks: openrc-tracker
  Show dependency tree
Reported: 2011-12-24 01:39 UTC by Arthur D.
Modified: 2013-04-25 23:08 UTC (History)
0 users

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


Note You need to log in before you can comment on or make changes to this bug.
Description Arthur D. 2011-12-24 01:39:33 UTC
When I connect my phone (N900) with usb to PC, network interface called usb0 (renamed from kernel eth1) appears. After some working with it I disconnect the phone from the PC and I get this error message in the log:

Dec 24 03:12:54 supervisor /etc/init.d/net.usb0[6053]: ERROR: net.usb0 failed to stop

When I connect the phone back to PC, the interface net.usb0 is not started. Obviously it is because the interface net.usb0 wasn't stopped successfully when the device was disconnected.

The bug first appeared in openrc-0.9.4
This version worked fine: openrc-0.8.3

Reproducible: Always

Steps to Reproduce:
1. Connect n900 to PC using USB data cable
2. Disconnect n900 from PC
3. Connect n900 to PC again
Actual Results:  
1. Network interface usb0 appears and is started successfully (which is added to br0 bridge interface in my case)
2. Message in log:
ERROR: net.usb0 failed to stop

When I run this command, I get:
/etc/init.d/net.usb0 status
 * status: started

That is wrong, because the interface should go down after the device is disconnected.

3. Network interface usb0 doesn't initialize when connected to PC again after previous disconnect.

The above sequence works only after system reboot. Because once I connect-disconnect the device the network interface is not initialized automatically again.

Expected Results:  
The network interface should appear and disappear every time the hotplug device is connected and disconnected from the PC.

After some digging around I found the root of the problem. It's /lib/rc/net/ script. The point where it fails is vlan_pre_stop() function which is called from /etc/init.d/net.lo, function stop().

Below are the points which need to be fixed, I think.

1) File /etc/init.d/net.lo, line #693:
${module}_pre_stop || exit $?

2) The above line calls script /lib/rc/net/, which fails on line #118:
_exists || return 1

3) _exists() is called from file
grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/dev

This fails probably because the interface was already removed from the kernel (/proc/net/dev) after device was disconnected. So the automatic stop of net.usb0 fails when the device is disconnected from PC.

Below is my networking configuration file.

$ cat /etc/conf.d/net
# To prefer iproute2 over ifconfig (both are installed)

# Add ports to bridge br0
# dynamically add usb0 when the interface comes up

# Configure the ports to null values so dhcp does not get started 

# Give the bridge an address
routes_br0="default via"

# Depend on eth0 and eth1 as they may require extra configuration

# Configure the bridge - "man brctl" for more details
brctl_br0="setfd 0
sethello 10
stp off"

The mandatory symlinks in /etc/init.d/ are:
net.br0 -> net.lo
net.eth0 -> net.lo
net.usb0 -> net.lo

Udev configuration file:
$ cat /etc/udev/rules.d/70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="e0:cb:4e:4e:1c:8f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# USB device 0x0421:0x01c8 (usb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="e0:cb:4e:4e:1c:8e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="usb0"

Plz let me know if there's any additional info you need to fix this.
What I did for now to fix the bug on my system is change in /lib/rc/net/
Line #118:
_exists || return 1
changed to:
_exists || return 0
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2011-12-27 02:01:33 UTC
fixed in commit 5615325