Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
wifi interface not going down when signal lost
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
Zedsquared
n00b
n00b


Joined: 03 Apr 2008
Posts: 5

PostPosted: Fri May 29, 2015 11:51 pm    Post subject: wifi interface not going down when signal lost Reply with quote

Hi Folks,
I have what is going to be a headless gentoo installation running mostly as a router.
I'm trying to get ifmetric to run whenever the wifi connects and disconnects in order to make wifi be chosen over a 3G connection when in range.
My wireless interface is wlp4s0 and it happily connects to my access point, if I manually run ifmetric I can control which interface gets the default route ok.

in /etc/conf.d/net I have:
Code:

postup()
{
echo "postup running if=" $IFACE >> /var/log/netrb
if [${IFACE}='wlp4s0']; then
echo "changing metric" >> /var/log/netrb
ifmetric ppp0 10
fi
return 0;
}

postdown()
{
echo "postdown running if="$IFACE >> /var/log/netrb
if [${IFACE}='wlp4s0']; then
echo "changing metric" >> /var/log/netrb
ifmetric ppp0 0
fi
return 0;
}



I have a two part problem,

1) If I manually stop the interface I can see the postdown function gets run by the log file but the if statement that checks the interface fails with the error:

/etc/init.d/../conf.d/net: line 24: [wlp4s0=wlp4s0]: command not found

and I never see the "changing metric" message in the log file. I've tried various combinations of syntax I found via googling but can't get it right and my bash-fu is terrible!

[edit] above now solved, see post below..

However:

2) The second problem is that if I switch off the access point then the wireless interface doesn't seem to drop so postdown() never gets run. This needs to be a switchover without intervention as it's going to be tucked away on a vehicle that should use wifi when in the garage and 3G/4G elsewhere.

When the AP is truned off I see a disconnect event from wpa_supplicant but the interface stays up.

Any thoughts, good people?

Cheers,
Robin.


Last edited by Zedsquared on Sat May 30, 2015 1:02 am; edited 1 time in total
Back to top
View user's profile Send private message
Zedsquared
n00b
n00b


Joined: 03 Apr 2008
Posts: 5

PostPosted: Sat May 30, 2015 12:22 am    Post subject: Reply with quote

Ok, part 1 solved, thanks to the lovely people on gentoo IRC, I was missing some vital spaces in the script so the line should read:

Code:
 if [ ${IFACE} = 'wlp4s0' ]; then


it now does the right thing when run, however dropping the wifi signal still does not drop the interface so postdown() doesn't run unless I manually stop the interface.

I'm using ath10k drivers on 4.04 kernel AMD64 if that helps.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3136

PostPosted: Sat May 30, 2015 4:50 pm    Post subject: Reply with quote

Why should droppping signal take your interface down too? Interface and link are not the same things. If you take your interface down, you will not be able to establish a link.
If failing link would take interface down, it would make you unable to get another link. Not what you expect with wifi. In fact, not even what you expect with wires. You pull the wire out, link goes down, you plug in another one, the link goes up.

You're trying to drive a screw with a hammer. There are things that track link status, but postdown() is not one of them. I think dhcpcd can do that for you. I know there are other ways, but never needed it myself
Back to top
View user's profile Send private message
Zedsquared
n00b
n00b


Joined: 03 Apr 2008
Posts: 5

PostPosted: Sat May 30, 2015 11:13 pm    Post subject: Reply with quote

I see what you mean... I thought ifplugd was supposed to work by triggering the interface up and down routines though.
I just need a way of firing some commands when the link goes up or down. I'll check that ifplugd is setup properly when I get back to it on Monday.

Thanks for clarifying my terminology, it will help my questions and searches for this.

Cheers,
Robin.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3136

PostPosted: Sun May 31, 2015 2:37 pm    Post subject: Reply with quote

you can try polling interface with ifconfig

Quote:

IFACE=wlan1
while sleep 1
do if ifconfig ${IFACE} | grep "flags.*RUNNING"
then echo link is up
else echo link is down
fi
done


It seems you can get ifplugd to do that, but it's not what it does by default.
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