Bug 3938

Summary: routerstation/mpc8315e: connman startup unused ethernet port when using nfs
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Yi Zhao <yi.zhao>
Component: connectivityAssignee: Mihai Prica <mihai.prica>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: cristian.iorga, meta.mr.watcher, meta.watcher, mihai.prica, Qi.Chen, richard.purdie, sgw, yi.zhao
Version: 1.4   
Target Milestone: 1.5 M5   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
message log none

Description Yi Zhao 2013-02-26 05:47:33 UTC
Image location: http://autobuilder.yoctoproject.org/pub/nightly/20130220-2

Git rev:
master:7d22ef28e64de06b6238d0ef9b664c0bee6efa46

This issue is introduced by patch 9eb88ceb39b7d0b8ddc6487e61ce8edadef10ec4

Currently, we test the routerstaton and mpc8315e via nfs. These 2 boards have more than one ethernet port. The /etc/init.d/connman script ignores the eth0 port, but will start up other eth interfaces. Especially for routerstation, it will set an ip address with the unused eth1 port, even this port doesn't connect a cable.

On routerstation:
################
root@routerstationpro:~# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:00:00:33:46:63  
          inet addr:128.224.165.207  Bcast:128.224.165.255  Mask:255.255.255.0
          inet6 addr: fe80::200:ff:fe33:4663/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:33657 errors:0 dropped:1160 overruns:0 frame:0
          TX packets:9338 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:24614844 (23.4 MiB)  TX bytes:1484561 (1.4 MiB)
          Interrupt:4 

eth1      Link encap:Ethernet  HWaddr 02:00:00:33:46:63  
          inet addr:169.254.184.164  Bcast:169.254.255.255  Mask:255.255.0.0
          inet6 addr: fe80::ff:fe33:4663/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:169 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:47704 (46.5 KiB)
          Interrupt:5 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:100 (100.0 B)  TX bytes:100 (100.0 B)
#############

On mpc8315e
#############
root@mpc8315e-rdb:~# ifconfig 
eth0      Link encap:Ethernet  HWaddr 04:00:00:00:00:0A  
          inet addr:128.224.178.140  Bcast:128.224.179.255  Mask:255.255.254.0
          inet6 addr: fe80::600:ff:fe00:a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41948 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9935 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:24396284 (23.2 MiB)  TX bytes:1581891 (1.5 MiB)
          Base address:0xa000 

eth1      Link encap:Ethernet  HWaddr 04:00:00:00:00:0B  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Base address:0xc000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:100 (100.0 B)  TX bytes:100 (100.0 B)
#############
Comment 1 Cristian Iorga 2013-02-26 10:16:36 UTC
Hello Yi,

Please state the exact issue, because I did not understand the exact issue.
Let me explain:
I have reviewed the commit 9eb88ceb39b7d0b8ddc6487e61ce8edadef10ec4 and it seems OK up to some point.
I don't have how to test that, because we don't have boards with two ethernet interfaces around.
But is seems that the patch will make connman ignore eth0, in order to keep previous settings for eth0.
Now, if at ifconfig, eth1 is the first interface returned, the patch can create trouble indeed.
Can you please run the ifconfig expression from the patch and post the results for routerstation and mpc8315e?
Now, onto the second issue at hand.
I am not familiar enough with connman on how it should deal with disconnected ethernet interfaces. But if eth1 is seen as up by connman (which seems to be the case for eth1, judging by your report), the address set on eth1 is a legit one, as connman will fail to set an address via DHCP and will assign the interface a Zeroconf IP address (starting with 169.254.xxx.xxx), which seems to be the case.
That's why I asked what is the exact issue.
Please help on this one.

Regards,
Cristian
Comment 2 Yi Zhao 2013-02-26 12:35:15 UTC
(In reply to comment #1)
> Hello Yi,
> 
> Please state the exact issue, because I did not understand the exact issue.
> Let me explain:
> I have reviewed the commit 9eb88ceb39b7d0b8ddc6487e61ce8edadef10ec4 and it
> seems OK up to some point.
> I don't have how to test that, because we don't have boards with two
> ethernet interfaces around.
> But is seems that the patch will make connman ignore eth0, in order to keep
> previous settings for eth0.
> Now, if at ifconfig, eth1 is the first interface returned, the patch can
> create trouble indeed.
> Can you please run the ifconfig expression from the patch and post the
> results for routerstation and mpc8315e?

After the system boot up, run the command would get the following message:
#################
root@routerstationpro:~# ifconfig | grep eth | sed -e "s/\(eth[0-9]\)\(.*\)/\1/"
eth0
eth1
root@routerstationpro:~# 
#################

#################
root@mpc8315e-rdb:~#  ifconfig | grep eth | sed -e "s/\(eth[0-9]\)\(.*\)/\1/"
eth0
eth1
root@mpc8315e-rdb:~#
#################

> Now, onto the second issue at hand.
> I am not familiar enough with connman on how it should deal with
> disconnected ethernet interfaces. But if eth1 is seen as up by connman
> (which seems to be the case for eth1, judging by your report), the address
> set on eth1 is a legit one, as connman will fail to set an address via DHCP
> and will assign the interface a Zeroconf IP address (starting with
> 169.254.xxx.xxx), which seems to be the case.
> That's why I asked what is the exact issue.
> Please help on this one.

I found on routerstation, if eth1 is set with an ip address, I can not ping or ssh to the target via eth0. I must ifconfig down eth1, then it works.  

For mpc8315e, although the eth1 is also up, but there is no ip address with it. I can ping or ssh to it via eth0.  

> 
> Regards,
> Cristian
Comment 3 Yi Zhao 2013-02-26 12:38:19 UTC
Here is the route message on routerstation:
###############
root@routerstationpro:~# route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         *               0.0.0.0         U     0      0        0 eth1
default         128.224.165.1   0.0.0.0         UG    0      0        0 eth0
128.224.165.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
root@routerstationpro:~# 
root@routerstationpro:~# 
root@routerstationpro:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 eth1
0.0.0.0         128.224.165.1   0.0.0.0         UG    0      0        0 eth0
128.224.165.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
root@routerstationpro:~#
###############


After eth1 is down, the route message :
###############
root@routerstationpro:~# ifconfig eth1 down
eth1: link down
root@routerstationpro:~# ADDRCONF(NETDEV_UP): eth1: link is not ready

root@routerstationpro:~# route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         128.224.165.1   0.0.0.0         UG    0      0        0 eth0
128.224.165.0   *               255.255.255.0   U     0      0        0 eth0
root@routerstationpro:~# 
root@routerstationpro:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         128.224.165.1   0.0.0.0         UG    0      0        0 eth0
128.224.165.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
root@routerstationpro:~# 
################
Comment 4 Cristian Iorga 2013-03-01 16:59:15 UTC
The routing tables don't look right. All interfaces have metric 0.
Yi, how are those routing tables generated? Are there any changes done to the BSPs?
Comment 5 Yi Zhao 2013-03-08 10:15:05 UTC
(In reply to comment #4)
> The routing tables don't look right. All interfaces have metric 0.
> Yi, how are those routing tables generated? Are there any changes done to
> the BSPs?

The route of eth1 is set by conman, I can find the log in /var/log/messages:
###################
238 Mar  6 00:29:43 routerstationpro daemon.info connmand[178]: eth1 {add} address 169.254.184.164/16 label eth1 family 2
239 Mar  6 00:29:43 routerstationpro daemon.info connmand[178]: eth1 {add} route 169.254.0.0 gw 0.0.0.0 scope 253 <LINK>
240 Mar  6 00:29:43 routerstationpro daemon.info connmand[178]: eth1 {add} route 0.0.0.0 gw 0.0.0.0 scope 253 <LINK>
241 Mar  6 00:29:43 routerstationpro daemon.err connmand[178]: Setting default interface route failed (File exists)
#####################

The rote of eth0 is set by cmdline when booting from red-boot:
###########
root@routerstationpro:~# cat /proc/cmdline 
  console=ttyS0,115200 root=/dev/nfs rw nfsroot=128.224.178.20:/export/pxeboot/vlm-boards/19255/rootfs ip=128.224.178.127:128.224.178.20:128.224.178.1:255.255.254.0::eth0:off board=UBNT-RSPRO ethaddr=00.00.00.00.46.61
###########

It looks there are 2 default gws in route table:
#################
root@routerstationpro:~# route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         *               0.0.0.0         U     0      0        0 eth1
default         128.224.178.1   0.0.0.0         UG    0      0        0 eth0
128.224.178.0   *               255.255.254.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
##################

But the default dev is eth1:
###################
root@routerstationpro:~# ip route
default dev eth1 
default via 128.224.178.1 dev eth0 
128.224.178.0/23 dev eth0  src 128.224.178.127 
169.254.0.0/16 dev eth1  src 169.254.184.164 
root@routerstationpro:~# 
####################

So when I connect the remote target, it will try to route from eth1. The traceroute shows the following message:
##################
root@routerstationpro:~# traceroute 128.224.162.212
traceroute to 128.224.162.212 (128.224.162.212), 30 hops max, 38 byte packets
 1  routerstationpro.local (169.254.184.164)  2991.308 ms !H  2994.546 ms !H  2999.787 ms !H
root@routerstationpro:~#
#################


There aren't any changes for the system. This issue happens after the patch 9eb88ceb39b7d0b8ddc6487e61ce8edadef10ec4 applying.
Comment 6 Cristian Iorga 2013-03-15 11:03:39 UTC
Hello Yi,

As I said previously, it is quite hard for me to reproduce this issue.
Yi, if I will send you some patches to test, can you help me with testing?
That's one thing.

The second would be:
For this board, how eth0 network interface gets its IP address?

Static IP via bootloader (kernel command line parameters)?
Or DHCP? Or another way (please describe)?

I might have a proper fix now that connman supports ethernet provisioning.

Regards,
Cristian
Comment 7 Yi Zhao 2013-03-18 07:56:57 UTC
(In reply to comment #6)
> Hello Yi,
> 
> As I said previously, it is quite hard for me to reproduce this issue.
> Yi, if I will send you some patches to test, can you help me with testing?
> That's one thing.

It's ok for me.

> 
> The second would be:
> For this board, how eth0 network interface gets its IP address?
> 
> Static IP via bootloader (kernel command line parameters)?
> Or DHCP? Or another way (please describe)?
> 

The static ip of eth0 is set in kernel command line by bootloader

> I might have a proper fix now that connman supports ethernet provisioning.
> 
> Regards,
> Cristian
Comment 8 Cristian Iorga 2013-03-18 11:16:57 UTC
Hello.

At this point, I don't have a complete fix to this issue.

My line of action would be to do something similar to what I implemented to qemu machines that use connman to take care of networking.

However, I recently found out that my solution does not work with systemd, so a redesign is needed.

Regards,
Cristian
Comment 9 Cristian Iorga 2013-04-02 05:59:27 UTC
Redesign for systemd init system is complete, waiting for review and integration.
Comment 10 Cristian Iorga 2013-04-10 08:33:34 UTC
Implementation started.
Comment 11 Richard Purdie 2013-04-11 13:51:17 UTC
Retarget to 1.5, too invasive for 1.4
Comment 12 Cristian Iorga 2013-04-11 13:56:22 UTC
In order to choose the right technical solution, this needs to be discussed with the connman authors.
Comment 13 Cristian Iorga 2013-09-03 13:45:57 UTC
Hello Yi,

What's the status of this issue?
I am getting back working at it after a long hiatus.
What's the Yocto image that are qorking with?
Is core-image-sato?

Can you also please attach a complete /var/log/messages for the routerstation board?
Comment 14 Cristian Iorga 2013-09-03 13:52:32 UTC
Hello Yi,
Also, for routerstation, please let me know how is eth1 brought up (if anything special is done).
Comment 15 Cristian Iorga 2013-09-03 14:41:20 UTC
Hy Yi.
Can you also please re-test this issue and report the outcome?
Comment 16 Yi Zhao 2013-09-04 07:13:07 UTC
Created attachment 1455 [details]
message log
Comment 17 Yi Zhao 2013-09-04 07:15:04 UTC
(In reply to comment #13)
> Hello Yi,
> 

Hi Cristian,

> What's the status of this issue?

This issue still exists.


> I am getting back working at it after a long hiatus.
> What's the Yocto image that are qorking with?
> Is core-image-sato?
> 

It is core-image-sato-sdk. 

> Can you also please attach a complete /var/log/messages for the
> routerstation board?

I attached the full message log.
Comment 18 Yi Zhao 2013-09-04 07:57:13 UTC
(In reply to comment #14)
> Hello Yi,
> Also, for routerstation, please let me know how is eth1 brought up (if
> anything special is done).

The eth1 is brought up by connmand.
Here is the reason:

The start function in /etc/init.d/connman:
################
do_start() {
    EXTRA_PARAM=""
    if test $nfsroot -eq 1 ; then
        ethn=`ifconfig | grep eth | sed -e "s/\(eth[0-9]\)\(.*\)/\1/"`
        EXTRA_PARAM="-I $ethn"
    fi  
    if [ -f /usr/lib/connman/wired-setup ] ; then
        . /usr/lib/connman/wired-setup
    fi  
    $DAEMON $EXTRA_PARAM
}
################

When the board boot up, the kernel detects eth0 and eth1 on the board. So the $ethn should be "eth0 eth1" (It is a nfs boot).  The "$DAEMON $EXTRA_PARAM" extends to "/usr/sbin/connmand -I eth0 eth1". But this is not a legal argument. The eth1 will be ignored with -I option. Then the eth1 still setup by connmand. If we want to ignore both eth0 and eth1, it should be "$DAEMON -I eth0,eth1"

This issue is introduced by commit 9eb88ceb39b7d0b8ddc6487e61ce8edadef10ec4. And the author also said: it might not work if using more than one eth interface. But it's better than not using connman with nfs at all.
Comment 19 Mihai Prica 2013-09-05 15:46:34 UTC
Hello Yi,

I've talked with Cristi about the problem and we found the following:

1) For connman to ignore both the interfaces a comma should be used. However only the details for the eth0 interfaces are sent through the cmdline. Considering this, eth0 should be the only one ignored. A fix can be done to ignore only the interfaces that are specified in the cmdline.

2) From the log, it is quite clear that the eth1 interface link is up. 

Sep  4 15:00:03 routerstationpro user.info kernel: eth1: link up (1000Mbps/Full duplex)
Sep  4 15:00:03 routerstationpro daemon.info connmand[403]: eth1 {add} route ff00:: gw :: scope 0 <UNIVERSE>
Sep  4 15:00:03 routerstationpro daemon.info connmand[403]: eth1 {add} route fe80:: gw :: scope 0 <UNIVERSE>
Sep  4 15:00:03 routerstationpro daemon.info connmand[403]: eth1 {update} flags 102467 <UP,RUNNING,LOWER_UP>
Sep  4 15:00:03 routerstationpro daemon.info connmand[403]: eth1 {newlink} index 3 address 02:00:00:00:46:61 mtu 1500
Sep  4 15:00:03 routerstationpro daemon.info connmand[403]: eth1 {newlink} index 3 operstate 6 <UP>
Sep  4 15:00:03 routerstationpro user.info kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready

connman intercepts the newlink signal and assigns the interface a zeroconf IP because it doesn't have DHCP or a static IP. So this is the expected behavior. A possible solution would be to include a custom script in your BSP that handles this behavior and ignore eth1.

3) From the log it seems like the eth1 interface is in an internal switch:

Sep  4 15:00:02 routerstationpro user.info kernel: eth1: Atheros AG71xx at 0xba000000, irq 5
Sep  4 15:00:02 routerstationpro user.info kernel: eth1: Atheros AR8316 switch driver attached.
Sep  4 15:00:02 routerstationpro user.info kernel: ar8316: Using port 4 as PHY
Sep  4 15:00:02 routerstationpro user.info kernel: ag71xx ag71xx.1 eth1: connected to PHY at ag71xx-mdio.0:00 [uid=004dd041, driver=Atheros AR8216/AR8236/AR8316]

This is a possible reason for which the interface is up.

Considering all of this, I can implement the fix specified at 1), but that won't solve the problems with the routes. The real problem is that the eth1 interface link is up eventough it's unused, but this is not because to connman.
Comment 20 Mihai Prica 2013-09-06 15:06:43 UTC
Jukka Rissanen has sent a fix for the problem that I described in my other post with the incorrect ignoring of the interfaces.

See http://lists.openembedded.org/pipermail/openembedded-core/2013-September/083958.html for details.
Comment 21 Mihai Prica 2013-09-16 10:58:10 UTC
Jukka Rissanen's patch has been merged to master: http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=c73487302270a7c2d3bbbb191ce1dd63ee2016dc