Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Default route is lost when power switches from AC to battery
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Kaorukun
n00b
n00b


Joined: 27 Aug 2014
Posts: 5

PostPosted: Thu Aug 27, 2015 12:18 am    Post subject: Default route is lost when power switches from AC to battery Reply with quote

Few days ago I stumbled upon a weird issue where a statically configured default route on my laptop would seemingly randomly disappear. Today I finally discovered what causes it and to my surprise it's something within the power management. Once I disconnect my power cable and switch to battery, my default route is lost.

I'm working on a wired connection and use a static IP configuration:
Code:

my /etc/conf.d/net :

config_eth0="10.105.150.158/16"
routes_eth0="default via 10.105.0.1"


The network works fine and the default route is there after boot or restarting the net.eth0 init script:
Code:

# ip route show                                                                                                                                                     
default via 10.105.0.1 dev eth0  metric 2
10.105.0.0/16 dev eth0  proto kernel  scope link  src 10.105.150.158
127.0.0.0/8 dev lo  scope host
127.0.0.0/8 via 127.0.0.1 dev lo


When I disconnect my power cable and the laptop switches to battery, the default route suddenly disappears, while all the other configuration is still intact. I have to restore it manually or by restarting the interface:
Code:

# ip route show
10.105.0.0/16 dev eth0  proto kernel  scope link  src 10.105.150.158
127.0.0.0/8 dev lo  scope host       
127.0.0.0/8 via 127.0.0.1 dev lo
# ip route add default via 10.105.0.1
# ip route show                                                                                                                                                     
default via 10.105.0.1 dev eth0
10.105.0.0/16 dev eth0  proto kernel  scope link  src 10.105.150.158
127.0.0.0/8 dev lo  scope host
127.0.0.0/8 via 127.0.0.1 dev lo


Note that the network cable is permanently plugged in, and the interface never shuts down or loses the link. Even if I disconnect the network cable the route does not go away. Switching from the battery to AC power also does not cause the route to disappear.

Just to be sure I stopped laptop_mode and powernowd daemons and even removed them from the runlevels - still same behavior.

Any clues what subsystem is responsible for this behavior?

/etc/conf.d/net : http://pastebin.com/sdpfGnYS
emerge --info : http://pastebin.com/thMBKtbq
rc-update show : http://pastebin.com/wc6dcTim
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Thu Aug 27, 2015 6:55 am    Post subject: Reply with quote

so what are you using systemd? eudev? static init? what else? (+ useflags + package version isntalled appreciated)

looks like a broken behaviour of some udev rules or udev ot myself and therefore its important to know what type of box yours is.

or something in /etc misconfigured
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7167

PostPosted: Thu Aug 27, 2015 10:56 am    Post subject: Reply with quote

openrc start service, but once done, it do nothing, if you disconnect a device where a service is attach to it, the service will stay start, as openrc isn't aware the device disappears, there's no need then to restart it.

If you remove the cable, your ip and route will remains, only disabling the route or removing the card will remove the route.
So i think really, the card gets disconnect and reconnect while you switch from power to battery, devmanager may even see it, but devmanager add drivers to device, while it could also trigger another script, i don't think anyone have its net service attach to any network device, it's just when you boot, devmanager coldplug drivers for network, and openrc then see it should start net to provide it.


What you could do is try to force the hotplug, and glad for you, there's a tool that is not really made to hotplug a card, but sense the cable state. Use ifplugd or some tool like that, it will detect the lost or availability of the cable, making it restart the configuration (and so reenabling the route, asking openrc to stop and start the network where the cable state change).

If it's not that, it really mean something is deleting the route then.
Back to top
View user's profile Send private message
Kaorukun
n00b
n00b


Joined: 27 Aug 2014
Posts: 5

PostPosted: Thu Aug 27, 2015 12:42 pm    Post subject: Reply with quote

tw04l124 wrote:
so what are you using systemd? eudev? static init? what else? (+ useflags + package version isntalled appreciated)

looks like a broken behaviour of some udev rules or udev ot myself and therefore its important to know what type of box yours is.

or something in /etc misconfigured


I'm using openrc, udev and ifplugd:

sys-apps/ifplugd-0.28-r9::gentoo USE="-doc (-selinux)"
sys-apps/openrc-0.17::gentoo USE="ncurses netifrc pam unicode -audit -debug -newnet (-prefix) (-selinux) -static-libs -tools"
sys-fs/udev-216::gentoo USE="acl firmware-loader gudev introspection kmod -doc (-selinux) -static-libs"

So far I can see I have no specific ifplugd configuration (/etc/ifplugd/ifplugd.conf), just /etc/ifplugd/ifplugd.action : http://pastebin.com/0x3zTusT

Also I noticed the route removal occurs only when connected using the Ethernet interface, and not with WLAN.
Back to top
View user's profile Send private message
Buffoon
Veteran
Veteran


Joined: 17 Jun 2015
Posts: 1074
Location: EU or US

PostPosted: Thu Aug 27, 2015 1:58 pm    Post subject: Reply with quote

Is your laptop switching to a different runlevel when on battery?
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7167

PostPosted: Thu Aug 27, 2015 3:14 pm    Post subject: Reply with quote

if devmanager reload the device, it should appears in dmesg
if ifplugd detect cable change, it should appears in dmesg

So, if any of the two do anything, it is in your dmesg.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum