This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5718: ip address is lost after eth0 is down

Part Number: AM5718

Tool/software: Linux

I have a AM5718 custom board. 

PDK Ver: ti-processor-sdk-linux-rt-am57xx-evm-05.02.00.10

 

Q. Why is the IP address gone when the link down of eth0?

I want to keep the IP address even if the link is down.

~# ifconfig eth0 192.168.123.50 up
~# ifconfig
eth0      Link encap:Ethernet  HWaddr 3C:A3:08:FE:65:DC
          inet addr:192.168.123.50  Bcast:192.168.123.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:12509 errors:0 dropped:0 overruns:0 frame:0
          TX packets:322 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:937677 (915.7 KiB)  TX bytes:32309 (31.5 KiB)
          Interrupt:88
~#
~# cpsw 48484000.ethernet eth0: Link is Down
~# ifconfig
eth0      Link encap:Ethernet  HWaddr 3C:A3:08:FE:65:DC
          inet6 addr: fe80::3ea3:8ff:fefe:65dc%775872/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1861 errors:0 dropped:0 overruns:0 frame:0
          TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:129879 (126.8 KiB)  TX bytes:11319 (11.0 KiB)
          Interrupt:88

  • Hi,
    I am not sure I am following your question. An IP address only has relevance when the port is up. In your example you assigned an IP address statically on port bring up. Does you network have a DHCP server? Could you please describe why you need the IP address if the link is down?
    Best Regards,
    Schuyler
  • If the Ethernet link is down/up,
    The IP address will be lost and communication will not be possible.

    Ethernet links can be downed by noise.
    However, if the link is up again, you must maintain the existing communication, and IP Address must not be lost.

    Best Regards,
    John

  • Hi,

    It sounds like you want to set a static IP address on the board so the would board boots similar to your ifconfig command.

    There are a couple of ways to ensure that the port gets the same IP address. One way is to configure the DHCP server to provide the same IP address based on the MAC address during the DHCP sequence as the port initializes. The other way is to set a static IP in the file system so the port initializes with the same IP address. The problem with the second approach is that you have ensure each board is setup uniquely so that there are not an IP address collisions. The first method only the server needs to be updated.

    Best Regards,
    Schuyler
  • Hi,

    I want to try the first method.
    Please explain how to do it.

    Best Regards,
    John
  • Hi,

    There are too many DCHP routers to give an exact set of steps. If you are using a home router or can use one in your development setup you will want to use the address reservation feature or something like it. You want to reserve an IP address assignment to the MAC address of your device. This is a very common technique and you should be able to find plenty of examples by searching for "assigning fixed ip addresses to devices on a home network". This example will serve to demonstrate how IP addressing can be statically done at the network level. I need to add that this is beyond the scope of TI support, but hopefully the above recommendation helps.

    Best Regards,

    Schuyler 

  • I can't use DHCP or fix the IP in the Filesystem script since users must be able to change IP addresses on Linux apps and the IP addresses must be maintained under any circumstances.

    Therefore, I want to know how to keep IP even if eth0's Link is down.

    Best Regards,

    John

  • Hi,

    Unfortunately this request is beyond the scope of TI support since this is now more of an application level type of problem. I can recommend that you may have to have the app that updates the file system resource with the static address selected.  Here is a link to example on setting a static IP address in a SystemD based file system, your application can probably modify this file when entering an IP address. This example also assumes that you will be using a SystemD based file system like the TI PSDKL.

    Link to setting a static IP address in a SystemD based file system

    Please be aware that user entered IP addresses can be troublesome since the network setup is relying on users to enter unique IP addresses in the product.

    Best Regards,

    Schuyler

  • I don't understand why I think this is an application problem.

    Symptoms of the IP address being lost are being performed in a specific script or service in Filesystem.

    Then, I think this is not an application problem.
    I think it is sufficiently resolvable in the BSP (Board support package).

    If the TI exceeds the support range,
    I'll change the question.

    Q. Where is the script or service file that clears the IP when the link is down?

     

    Best Regards,

    John

  • Hi,

    TI will respectfully disagree about this question being a support package topic. TI only supports what was written by TI which is the Linux drivers for the peripherals that are on the AM5718, not the entire Linux kernel or in this case the network stack or services which are above the CPSW driver.  The IP addresses are not stored in the CPSW driver but higher in the network stack in the kernel. 

    To answer your question on the services that are called on a link close operation is that I don't know. I do know that when the interface goes down to either link loss or a user command there are several tear down operations that occur in the driver such as release of resources like buffer memory, DMA channels/queues and HW tear down. I imagine the network stack also has some tear down operations too. 

    There are probably several methods to assign a static IP address to meet your requirements and are dependent on the user space in use (SystemD, SysVinit, Busybox etc). These user spaces can automatically acquire or statically assign IP addresses for network interfaces. This example from the previous post shows how to assign a static ip address. Your application would edit this file based on user input with the ip address required.  This file would be read by SystemD on interface init and would use the data to assign the address. The SystemD community may have a better example than this one for assigning a static IP address.

     /etc/systemd/network/01-eth-static.network. 

    ---- File contents -----
    [Match]
    Name=eth0

    [Network]
    Address=192.168.1.100    
    ----- EOF -----------

    Best Regards,

    Schuyler