Results 1 to 3 of 3

Thread: Update the init script for multiple nics?

Hybrid View

  1. #1
    Junior Member registered user
    Join Date
    Jan 2008
    Posts
    20

    Update the init script for multiple nics?

    I had a weird issue show up the other day. I am using Knoppix 6.7.0 to do PXE booting. I cannot use 6.7.1 at this time, so I do not know if this is fixed there.

    Client -> Knoppix 6.7
    Server -> Fedora 14. PXE files from Knoppix 6.7 CD.

    problem:
    Have an old machine with onboard 1 Gig nic, and pci 10/100 nic. Ethernet cord is plugged into onboard nic, boots, gets IP, TFTP Starts, select the kernel and go. Kernel loads, gets to the udhcp part of getting an IP. Times out.

    Playing with it, I re-started the process, and when udhcp was trying to get an ip, I moved the ethernet cord to the 10/100 pci nic. Knoppix found an ip and completed booting.

    Investigating further, it comes to show that the pci 10/100 board was grabbing eth0, and not the onboard Nic!

    Further investigation shows that the kernels attempt to load drivers in parallel, and that the ethX numbering scheme is based in part, on driver load order. Therefore, I can't really force that, and I'm also in an environment of lots of machines, so it's not like I can do a simple fix for 1 and be done.

    I then unpacked the minirt.gz and examined the init script. The issue is in the DHCP loop, it calls ifconfig up ethX. If ifconfig returns a non zero number, it is supposed to continue. For some reason, (driver? ifconfig bug?) calling ifconfig on eth0 (with no cord) results in a "ok" response.

    I have seen ifconfig up seem to "work" before on nics without a cord. So i suspect that it's not safe to depend on the return from it. I decided to change the init code to instead check for the presence of the cable using the /sys/class/net/ethX/operstate file.

    Works like a charm. I wanted to share the issue here, along with the code I did to change it, and see about putting that into future versions. I don't know how easy it will be to reproduce this, i saw it happen 18 times out of several hundred machines.

    note: my logic checks for the word "down" in the operstate file. I do not check for up, as there are a couple of other possible values, which may indicate there is a cord there. but it's always down when its down.

    I also check for the existence of the file, as ifconfig does not even raise an error doing "up" on a non-existent interface, like eth2. maybe ifconfig just needs to be upgraded, it seems pretty dumb.

    I just did ifconfig --version, and for Knoppix 6.7, it shows net-tools: 1.60 and ifconfig 1.42 (2001-04-13)

    Anyway, the fix:
    open init, search for DHCP and replace that part with this:


    Code:
    DHCP=""
     # How many network cards should we probe for?
     for i in 0 1 2 3; do
      ifconfig "eth$i" up >/dev/null 2>&1 || continue
      sleep 2
      if [ -f /sys/class/net/eth$i/operstate ]; then
              if grep -Fq "down" /sys/class/net/eth$i/operstate
              then
                continue
              fi
      else
        continue
      fi
     
      message "${CRE}${BLUE}DHCP Broadcasting for IP address (${MAGENTA}eth$i${BLUE})... ${NORMAL}"
      if [ -n "$HOSTNAME" ]; then
       udhcpc -i eth$i -H $HOSTNAME && DHCP="eth$i"
      else
       udhcpc -i eth$i && DHCP="eth$i"
      fi
      [ -n "$DHCP" ] && break
      message "${RED}No answer from network.${NORMAL}"
     done

  2. #2
    Junior Member registered user
    Join Date
    Jan 2008
    Posts
    20
    maybe we should move this to the remastering forum or something.

    But I am now seeing an issue "sometimes" with single card nics. Seems that the driver is slow to load or something? I sleep 4 seconds, but it still says cable is "down" and then like 5 seconds later a message pops up from the driver about TX and RX speeds. and by then the operstate is up.

    Guh...

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Keeger,
    Can you let me know which file I need to update the init code? I have a same issues and I need this fix soon.

    thanks
    kevinn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Dell PowerEdge R730 Server 2x E5-2660 V3 - 20 Cores H730 32GB RAM No HDD picture

Dell PowerEdge R730 Server 2x E5-2660 V3 - 20 Cores H730 32GB RAM No HDD

$297.99



DELL PowerEdge R630 8SFF Server 2x E5-2690v4 2.6GHz =28 Cores 128GB H730 4xRJ45 picture

DELL PowerEdge R630 8SFF Server 2x E5-2690v4 2.6GHz =28 Cores 128GB H730 4xRJ45

$412.00



Dell Poweredge T330 E3-1270 v5 3.6GHz 16gb H330 4xTrays 2x495w SRV2016 picture

Dell Poweredge T330 E3-1270 v5 3.6GHz 16gb H330 4xTrays 2x495w SRV2016

$234.99



Dell PowerEdge R820 Server 4x E5-4650 V2 - 40 Cores H710P 256GB RAM 8x 600GB SAS picture

Dell PowerEdge R820 Server 4x E5-4650 V2 - 40 Cores H710P 256GB RAM 8x 600GB SAS

$492.99



Supermicro 4U 36 Bay TRUNAS Storage Server Xeon 20 Core 3Ghz 256GB X540 10GBaseT picture

Supermicro 4U 36 Bay TRUNAS Storage Server Xeon 20 Core 3Ghz 256GB X540 10GBaseT

$588.00



HYVE ZEUS V1 1U SERVER 2x XEON 8 CORE E5-2650V2 2.6GHz 32GB RAM RAIL NO HDD picture

HYVE ZEUS V1 1U SERVER 2x XEON 8 CORE E5-2650V2 2.6GHz 32GB RAM RAIL NO HDD

$132.00



HP Proliant MicroServer Gen8 XeonDC 2.3GHz NO HD 8GB DDR3 No Cover/Caddies picture

HP Proliant MicroServer Gen8 XeonDC 2.3GHz NO HD 8GB DDR3 No Cover/Caddies

$79.99



Dell R730XD 24xSFF Server 2x HS, 2x 1100W, H730, Enterprise- Wholesale Custom picture

Dell R730XD 24xSFF Server 2x HS, 2x 1100W, H730, Enterprise- Wholesale Custom

$265.00



Dell PowerEdge R740xd Server - 2 Xeon Scalable CPUs, 32GB-768GB RAM, 24SFF HDD picture

Dell PowerEdge R740xd Server - 2 Xeon Scalable CPUs, 32GB-768GB RAM, 24SFF HDD

$4297.00



HP DL80 Gen9 12 LFF Bay 2x E5-2650v4 2.2GHz =24 Cores 32GB P840AR PCIe 2xRJ45 picture

HP DL80 Gen9 12 LFF Bay 2x E5-2650v4 2.2GHz =24 Cores 32GB P840AR PCIe 2xRJ45

$225.00