Project

General

Profile

Actions

Bug #942

closed

S40network should not run dhcp client on eth0 if it is not connected

Added by Hammel almost 2 years ago. Updated over 1 year ago.

Status:
Rejected
Priority:
Immediate
Assignee:
Category:
04 - Root File System
Target version:
Start date:
26 Feb 2023
Due date:
% Done:

10%

Estimated time:
Severity:
02 - High

Description

Will need to test sysfs for connection status.

Actions #1

Updated by Hammel over 1 year ago

  • Priority changed from Urgent to Immediate
  • Severity changed from 01 - Critical to 02 - High
Actions #2

Updated by Hammel over 1 year ago

See piboxd:eth.c

#define ETH0_STATE_PATH   "/sys/class/net/eth0/carrier"

If this is 1 then we can enable dhcp. At least until we put network startup in the background.

Actions #3

Updated by Hammel over 1 year ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10
Actions #4

Updated by Hammel over 1 year ago

This isn't what I expected. The use of Busybox's ifup places starting of dhcp inside the ifup binary embedded in Busybox. So I can't actually check there for the eth port connection.

What I can do is change S40network to not use ifup -a, but rather ifup <interface> and iterate across all interfaces one at a time. It will look something like this.

#!/bin/sh

myfunc()
{
    for ifacep in /sys/class/net/*
    do
        iface="$(basename ${ifacep})" 
        if [ "${iface}" == "lo" ]
        then
            continue
        fi
        if [ ! -e "${ifacep}/wireless" ]
        then
            echo "${iface} is not wireless" 
            carrier=$(cat ${ifacep}/carrier)
            if [ ${carrier} -eq 1 ]
            then
                echo "Do ifup ${iface}" 
            fi
        fi
    done
}

( myfunc ) &

Running the function inside () places it in a subshell, which we then background. This is equivalent of the double fork for a daemon process in C. This allows the S40network script to complete even though network startup is in progress, thus speeding up initial bootup.

It's unclear at this point if any system apps will puke because networking is not up yet. An alternative is to only place each instance of ifup <iface> in the double fork though I'm not sure that will help if some app requires networking to be up before it starts. Given that only piboxd will run at boot time (and launcher) on system builds I don't think this will be much of an issue.

Actions #5

Updated by Hammel over 1 year ago

  • Status changed from In Progress to Rejected

That script doesn't really work, either. If the interface is down'd then there is no carrier value at all (not 0 or 1). So you have to ifconfig <iface> up the interface first just to have a valid value in the carrier (note that the carrier file exists but can't be read if the interface isn't ifconfig up'd). But even that isn't working, possibly because the carrier value doesn't update immediately.

This is all such as hack. I'm going to reject this issue for now, then come back to it when I look at boot time speedups (RM #472).

Actions

Also available in: Atom PDF