ethermultilink: ignore link-status of primary

when link-status on secondary is lost, always switch
back to the primary regardless of if it has a link.

this works around some ethernet driver not setting
link-status consistently and wifi's that might
only indicate a link when connected to an ap.
This commit is contained in:
cinap_lenrek 2023-12-07 14:48:49 +00:00
parent b8604dd760
commit 7137060d85

View file

@ -25,6 +25,7 @@ for(i){
# first interface is the primary # first interface is the primary
primary=$1 primary=$1
shift
net=`{echo $primary | sed 's!/*[^/]*$!!g'} net=`{echo $primary | sed 's!/*[^/]*$!!g'}
test -r $net/arp || missing $net/arp test -r $net/arp || missing $net/arp
@ -32,9 +33,9 @@ test -r $net/arp || missing $net/arp
# now select secondary from the list depending on link status # now select secondary from the list depending on link status
@{ @{
old=/dev/null old=/dev/null
new=$old
while(){ while(){
# interfaces are in increasing priority order # interfaces are in increasing priority order
new=$primary
for(i){ for(i){
if(grep -s 'link: 1' $i/stats) if(grep -s 'link: 1' $i/stats)
new=$i new=$i