Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
slow ping resonse with ifplugd and config in /etc/conf.d/net
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
philip
Guru
Guru


Joined: 10 Jun 2003
Posts: 535
Location: Sweden

PostPosted: Mon Jun 23, 2014 7:16 pm    Post subject: slow ping resonse with ifplugd and config in /etc/conf.d/net Reply with quote

I just emerged ifplugd and configured /etc/conf.d/net to monitor my wired interface (enp0s25). I want my wireless interface (wlp3s0) to "take over" when my ethernet cable is pulled and vica versa.

/etc/conf.d/net
Code:
# Let ifplugd monitor the wired interface enp0s25
# Config hints can be found in /usr/share/doc/netifrc-0.1/net.example

# The following seems to work - but slow ping response when enabled!
ifplugd_enp0s25="..."
ifplugd_enp0s25="--api-mode=wlan"

# --- Wired ethernet ---

config_enp0s25="dhcp 192.168.1.250/24"

# config_eth0="dhcp" ?

# --- Wireless WiFi ---

#Prefer wpa_supplicant over wireless-tools
modules_wlp3s0="wpa_supplicant"
 

# It is important that we tell wpa_supplicant which driver we should
# be using as it is not very good at guessing that
wpa_supplicant_wlp3s0="-Dnl80211 -d -f /var/log/wpa_supplicant.log"

config_wlp3s0="dhcp"


The atomatic switch to wlan works when I pull the ethernet cable. But a side effect is that response on ping becomes very slow. Normally ping swiftly "tics" ping responses (at least every second). But with the configuration
Code:
ifplugd_enp0s25="..."
ifplugd_enp0s25="--api-mode=wlan"

I get a ping response approx every 5 seconds.

Can anyone explain this? Is there a cure?
_________________
/Phil
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Mon Jun 23, 2014 8:35 pm    Post subject: Re: slow ping resonse with ifplugd and config in /etc/conf.d Reply with quote

philip wrote:
I just emerged ifplugd and configured /etc/conf.d/net to monitor my wired interface (enp0s25). I want my wireless interface (wlp3s0) to "take over" when my ethernet cable is pulled and vica versa.

philip ... well, you're not telling netifrc/openrc that the interface is plugged ...

/etc/conf.d/net
Code:
modules_wlp2s0="!plug wpa_supplicant dhcpcd"
config_wlp2s0="dhcp"
wpa_supplicant_wlp2s0="-Dnl80211 -qq"

modules_enp0s25="plug dhcpcd"
config_enp0s25="dhcp 192.168.1.250/24"
ifplugd_enp0s25="--no-beep"

That should be all that's needed for netifrc ... you would then add something like the following to /etc/ifplugd/ifplugd.action

Code:
case "$2" in
    up)
    if [ "${INITNG}" = "yes" ] ; then
        ARGS="-u net/$1"
    else
        /etc/init.d/net.wlp2s0 --quiet stop
        ARGS="--quiet start"
    fi
    ;;
    down)
    if [ "${INITNG}" = "yes" ] ; then
        ARGS="-d net/$1"
    else
        ARGS="--quiet stop"
        /etc/init.d/net.wlp2s0 --quiet start
    fi
    ;;
[blah, blah]

Then you would remove net.wlp2s0 from the default runlevel, as it should be automatically started by ifplugd if no network cable it detected ...

Code:
# rc-update del net.wlp2s0 default

I don't use ifplugd but the above should work as expected.

BTW, the ping time is probably due to having two devices on the same subnet ...

best ... khay
Back to top
View user's profile Send private message
philip
Guru
Guru


Joined: 10 Jun 2003
Posts: 535
Location: Sweden

PostPosted: Wed Jun 25, 2014 5:32 pm    Post subject: Reply with quote

Thanks again khyyam!

I put in the changes you suggest above. It almost works now. But not quite as expected.

When the ethernet cable i plugged and the WiFi is connected (plugged so to speak), then both interfaces are up

Code:
# ifconfig enp0s25 && ifconfig wlp3s0
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 0.0.14.40  netmask 0.0.0.0  broadcast 255.255.255.255
        inet6 fe80::56ee:75ff:fe07:8c8e  prefixlen 64  scopeid 0x20<link>
        ether 54:ee:75:07:8c:8e  txqueuelen 1000  (Ethernet)
        RX packets 1267  bytes 82214 (80.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 680 (680.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf0500000-f0520000 

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.210  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::7e7a:91ff:fea3:2f5a  prefixlen 64  scopeid 0x20<link>
        ether 7c:7a:91:a3:2f:5a  txqueuelen 1000  (Ethernet)
        RX packets 2028  bytes 522585 (510.3 KiB)
        RX errors 0  dropped 541  overruns 0  frame 0
        TX packets 1457  bytes 189244 (184.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


and

Code:
# ifplugstatus
enp0s25: link beat detected
wlp3s0: link beat detected


Ping works swiftly and is probably transmited over the Wifi i/f'

When I pull the ethernet cable, then

# ifconfig enp0s25 && ifconfig wlp3s0
Code:
enp0s25: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 0.0.14.40  netmask 0.0.0.0  broadcast 255.255.255.255
        inet6 fe80::56ee:75ff:fe07:8c8e  prefixlen 64  scopeid 0x20<link>
        ether 54:ee:75:07:8c:8e  txqueuelen 1000  (Ethernet)
        RX packets 1460  bytes 94566 (92.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 680 (680.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf0500000-f0520000 

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.210  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::7e7a:91ff:fea3:2f5a  prefixlen 64  scopeid 0x20<link>
        ether 7c:7a:91:a3:2f:5a  txqueuelen 1000  (Ethernet)
        RX packets 2147  bytes 536390 (523.8 KiB)
        RX errors 0  dropped 620  overruns 0  frame 0
        TX packets 1470  bytes 190415 (185.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


The wired ethernet i/f enp0s25 is still up, but

# ifplugstatus
Code:
enp0s25: unplugged
wlp3s0: link beat detected
enp0s20u4: unplugged
lo: link beat detected
sit0: unplugged


In other words the enp0s25 i/f is still up but is detected as unplugged.

The ping goes on seamlessly, still over the WiFi i/f.

Shouldn't the wired i/f enp0s25 go down when the wireless i/f wlp3s0 up when the ethernet cable is pulled. And vice versa when the eth cable is put back in again?
_________________
/Phil
Back to top
View user's profile Send private message
philip
Guru
Guru


Joined: 10 Jun 2003
Posts: 535
Location: Sweden

PostPosted: Wed Jun 25, 2014 6:01 pm    Post subject: Reply with quote

I doscovered an error by me

I had in /etc/conf.d/net
Code:
ifplugd_enp0s25="--no--beep"

which is wrong syntax and should be
Code:
ifplugd_enp0s25="--no-beep"


But stil the wired enp0s25 i/f is not brought down and up as I pull and plug the ethernet cable....

My configuration looks like this now

# cat /etc/conf.d/net
Code:
#  Let ifplugd monitor the wired interface enp0s25
# Config hints can be found in /usr/share/doc/netifrc-0.1/net.example
# Tell netifrc/openrc when the enp0s25 is plugged


# --- Wireless WiFi ---

# Prefer wpa_supplicant over wireless-tools
modules_wlp3s0="!plug wpa_supplicant dhcpcd"

config_wlp3s0="dhcp"
 
# Tell wpa_supplicant which driver to be used, which logfile to use
# and that extra verbose output should be made to the logfile (-qq)

wpa_supplicant_wlp3s0="-Dnl80211 -d -f /var/log/wpa_supplicant.log -qq"


# --- Wired ethernet ---

modules_enp0s25="plug dhcpcd"

config_enp0s25="dhcp 192.168.1.250/24"

ifplugd_enp0s25="--no-beep"


and

# cat /etc/ifplugd/ifplugd.action
Code:
#!/bin/sh
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#
# Gentoo-specific ifplugd.action
#
# This file gets called by ifplugd when it wants to bring an interface
# up or down.
#

if grep -q initng /proc/1/cmdline
then
    EXEC="/sbin/ngc"
    INITNG="yes"
else
    EXEC="/etc/init.d/net.$1"
    INITNG="no"
fi

case "$2" in
    up)
        if [ "${INITNG}" = "yes" ]
        then
            ARGS="-u net/$1"
        else
            /etc/init.d/net.wlp3s0 --quiet stop
            ARGS="--quiet start"
        fi
        ;;
    down)
        if [ "${INITNG}" = "yes" ]
        then
            ARGS="-d net/$1"
        else
            ARGS="--quiet stop"
            /etc/init.d/net.wlp3s0 --quiet start
        fi
        ;;
    *)
        echo "$0: wrong arguments" >&2
        echo "Call with <interface> <up|down>" >&2
        exit 1
        ;;
esac

export IN_BACKGROUND=true

if [ -x "${EXEC}" ]
then
    ${EXEC} ${ARGS}
    exit 0
else
    logger -t ifplugd.action "Error: Couldn't configure $1, no ${EXEC} !"
    exit 1
fi

# vim: set ts=4

_________________
/Phil
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Wed Jun 25, 2014 7:16 pm    Post subject: Reply with quote

phil ...

I'm not entirely sure why that's happening, and as I don't have ifplugd installed its difficult for me to check. I suspect that ifplugd is trying to manage both interfaces, please try the following:

/etc/conf.d/net
Code:
ifplugd_enp0s25="--no--beep --iface=enp0s25"

/etc/ifplugd/ifplugd.conf (if it exists ... otherwise don't worry about it) ..
Code:
INTERFACES="enp0s25"

Also, but unrelated ... the '-d' option for wpa_supplicant turns on debug (similarly with '-dd' and '-ddd'), and the '-qq' makes the output 'quiet', so having both, and providing a log, isn't advisable ... just turn on debug/logging as and when needed ... otherwise use the following:

Code:
wpa_supplicant_wlp3s0="-Dnl80211 -qq"

best ... khay
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