Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune "flags" regex for ip and ifconfig output + add test case #43

Open
claireyywang opened this issue Oct 29, 2019 · 7 comments
Open

Tune "flags" regex for ip and ifconfig output + add test case #43

claireyywang opened this issue Oct 29, 2019 · 7 comments

Comments

@claireyywang
Copy link

Currently the flags are only parsed in ifconfig command pattern. It would be nice to have that in ip too since ifconfig is deprecated. Thanks!

@benjaoming
Copy link
Collaborator

Hi @claireyywang - thanks for filing the issue! A PR is most welcome.

I think there's already test data for this purpose. The behavior can be implemented and already existing unit tests can be expanded to cover flags.

@shr-project
Copy link

shr-project commented Jun 16, 2020

And even with ifconfig command it doesn't work with some versions of net-tools

e.g.

ifconfig --version
net-tools 1.60
ifconfig 1.42 (2001-04-13)

with this format:

root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02  
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

doesn't parse the flags, while net-tools 1.60+git20180626.aebd88e-1ubuntu1 in ubuntu works with this format:

# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
ifconfig --version
net-tools 2.10-alpha

works

The format was probably changed in:
https://sourceforge.net/p/net-tools/code/ci/eb04ef31571f6c707eacaba6846feeebfab518e6
which unfortunately doesn't mention anything about format change in commit message and considering state of net-tools package in various distributions it's hard to tell which distributions have this included, e.g. debian probably included it since:

net-tools (1.60+git20150829.73cef8a-1) unstable; urgency=medium

  * After 14 years without an upstream release, I am producing a new package
    based on today's upstream repository.
    Closes: #391495, #486448, #323261, #260587, #545328, #511395.
  * Remove many patches now merged upstream, delete unmaintainable and
    undocumented local changes, and update the rest.

 -- Martín Ferrari <tincho@debian.org>  Mon, 07 Sep 2015 01:54:07 +0000

shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jun 16, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
@benjaoming
Copy link
Collaborator

benjaoming commented Jun 16, 2020

@shr-project the first example (that's the broken one, right) has a test case written:

LINUX2 = """
eth0 Link encap:Ethernet HWaddr 1a:2b:3c:4d:5e:6f
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::4240:36ff:fe38:a121/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4041381 errors:0 dropped:0 overruns:0 frame:0
TX packets:3851783 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1123058554 (1.0 GiB) TX bytes:737462074 (703.2 MiB)
Interrupt:24
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:126491 errors:0 dropped:0 overruns:0 frame:0
TX packets:126491 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:43170341 (41.1 MiB) TX bytes:43170341 (41.1 MiB)
"""

...but upon further investigation it seems like the test case doesn't check if the flags were found:

def test_linux2(self):
ifcfg.distro = 'Linux'
ifcfg.Parser = LinuxParser
parser = ifcfg.get_parser(ifconfig=ifconfig_out.LINUX2)
interfaces = parser.interfaces
self.assertEqual(len(interfaces.keys()), 2)
eq_(interfaces['eth0']['ether'], '1a:2b:3c:4d:5e:6f')
eq_(interfaces['eth0']['inet'], '192.168.0.1')
eq_(interfaces['eth0']['broadcast'], '192.168.0.255')
eq_(interfaces['eth0']['netmask'], '255.255.255.0')

@benjaoming benjaoming changed the title add flags regex to ip command Tune "flags" regex for ip and ifconfig output + add test case Jun 16, 2020
@shr-project
Copy link

shr-project commented Jun 16, 2020

Sorry about the spam from meta-ros commits (it's useful to mention related issue ticket in commit message and in many cases I didn't want to trigger notification from the other side, but github is just too clever).

Anyway, I've also sent patch to OpenEmbedded (where I've seen the issue first) to update the ifconfig format to match what debian/ubuntu currently use:
https://lists.openembedded.org/g/openembedded-core/message/139567
now python-ifcfg works fine for me and ros is happily finding those flags.

If you can extend the regex to cover older ifconfig (which will probably work on busybox's version of ifconfig as well) then it would be still nice for other people I guess (especially as you already have a test data for it).

Thanks

halstead pushed a commit to openembedded/openembedded-core that referenced this issue Jun 16, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Jun 17, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
github-actions bot pushed a commit to hexagon-geo-surv/poky that referenced this issue Jun 17, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

(From OE-Core rev: dacfd695061b186240a85f8ffc43e6636c56e1fb)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Jun 26, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit dacfd69)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
kraj pushed a commit to YoeDistro/poky-old that referenced this issue Jun 26, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

(From OE-Core rev: 71c8667fca681a5977ed2b825b14306930707f2d)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit dacfd695061b186240a85f8ffc43e6636c56e1fb)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 1, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…fg, python3-netifaces

* ros2 doctor still fails with:

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: No loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Only loopback IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: No multicast IP address is found.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  but that is still slightly better than

    root@qemux86-64:~# ros2 doctor
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Failed to import ifcfg. Use `python -m pip install ifcfg` to install needed package.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: ERROR: ifcfg is not imported. Unable to run network check.
    /usr/lib/python3.8/site-packages/ros2doctor/api/format.py: 76: UserWarning: Fail to call PlatformCheck class functions.

    1/2 checks failed

    Failed modules: network

  I'll check why it doesn't parse ifconfig correctly, it could be the
  busybox version of ifconfig using different format
  lrwxrwxrwx    1 root     root          19 Jun 16 07:10 /sbin/ifconfig -> /bin/busybox.nosuid

  root@qemux86-64:~# ifconfig
  eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
            inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
            inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:5 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:426 (426.0 B)  TX bytes:1350142 (1.2 MiB)

  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:65536  Metric:1
            RX packets:4076 errors:0 dropped:0 overruns:0 frame:0
            TX packets:4076 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:734356 (717.1 KiB)  TX bytes:734356 (717.1 KiB)

  while in docker with proper net-tools:
  root@dafcbbf25ff2:/# dpkg -S /sbin/ifconfig
  net-tools: /sbin/ifconfig

  root@dafcbbf25ff2:/# ifconfig
  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
          inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
          ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
          RX packets 39299  bytes 89614740 (89.6 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 33767  bytes 3807354 (3.8 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
          inet 127.0.0.1  netmask 255.0.0.0
          loop  txqueuelen 1000  (Local Loopback)
          RX packets 5658  bytes 1294220 (1.2 MB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 5658  bytes 1294220 (1.2 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  see those flags which ros2doctor is using to find loopback and
  multicast in:
  https://github.com/ros2/ros2cli/blob/a7541b9b339e2a338a4d9ff2ff96c2ed0ce03236/ros2doctor/ros2doctor/api/network.py#L42

  I've added comment in:
  ftao/python-ifcfg#43

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
shr-project added a commit to shr-project/meta-ros that referenced this issue Jul 3, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
chaitu236 pushed a commit to chaitu236/openembedded-core that referenced this issue Aug 10, 2020
…rmat as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit dacfd69)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
@benjaoming
Copy link
Collaborator

In #61, @dre1902 has implemented a very simple approach to parsing and storing flags from ip. It's not platform transparent, but does it work well enough for you cases?

@shr-project
Copy link

@benjaoming
Thanks for update, I've reverted the change in net-tools to reproduce this issue again and backported the change from #61 to python-ifcfg-0.21. Unfortunately it still doesn't parse correctly:

root@qemux86-64:~# grep -B 3 flags= /usr/lib/python3.8/site-packages/ifcfg/parser.py
    @classmethod
    def get_patterns(cls):
        return [
            r'(?P<device>^[-a-zA-Z0-9:\.]+): flags=(?P<flags>.*) mtu (?P<mtu>\d+)',
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02  
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:496 (496.0 B)  TX bytes:15914 (15.5 KiB)

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:65536  Metric:1
          RX packets:340 errors:0 dropped:0 overruns:0 frame:0
          TX packets:340 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:22124 (21.6 KiB)  TX bytes:22124 (21.6 KiB
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "add",
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "broadcast": "192.168.7.255",
        "mtu": "1500",
        "rxbytes": "496",
        "txbytes": "18864"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "add",
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "mtu": "65536",
        "rxbytes": "25540",
        "txbytes": "25540"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": "00-00-00-00-30-30-30-00-00-00-00-00-00-00-00-00",
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "mtu": "1480",
        "rxbytes": "0",
        "txbytes": "0"
    }
}

the old format from net-tools's ifconfig as well as busybox's (as in v1.33.0) ifconfig doesn't have 'flags=' at all, the flags are listed only on this line:

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

For my case (https://github.com/ros/meta-ros) I've just backported the format change to net-tools for python-ifcfg to parse the flags correctly, I don't know how many distributions still ship older net-tools especially now with new upstream release 2.10 (from 2021-01-07) which includes the format change from 2003 https://sourceforge.net/p/net-tools/code/ci/eb04ef31571f6c707eacaba6846feeebfab518e6

@benjaoming
Copy link
Collaborator

@shr-project thanks for testing. IIRC (don't have time to verify it ATM) then ifconfig is used if it exists. I guess on second thought that since the new behavior only works for systems that only have the ip command.

daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
…config format as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

(From OE-Core rev: dacfd695061b186240a85f8ffc43e6636c56e1fb)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
…config format as debian/ubuntu

* this is needed for python3-ifcfg to parse it correctly
  ftao/python-ifcfg#43
* backport this single patch, so it can be backported to dunfell
  then for master we should upgrade to new snapshot from debian
  which includes other fixes and improvements as well
* this is already part of net-tools_1.60-26.diff from debian we're using
  but it's first added there and then removed
  $ grep 'sprintf(flags' net-tools_1.60-26.diff
  ++    sprintf(flags, "flags=%d<", ptr->flags);
  +-    sprintf(flags, "flags=%d<", ptr->flags);

* before:
root@qemux86-64:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:02
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:496 (496.0 B)  TX bytes:42832 (41.8 KiB)

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:65536  Metric:1
          RX packets:846 errors:0 dropped:0 overruns:0 frame:0
          TX packets:846 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53364 (52.1 KiB)  TX bytes:53364 (52.1 KiB)

* after:

root@qemux86-64:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.7.2  netmask 255.255.255.0  broadcast 192.168.7.255
        inet6 fe80::5054:ff:fe12:3402  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:12:34:02  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2140 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* for comparison ubuntu-20.04 in docker:

root@dafcbbf25ff2:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 39299  bytes 89614740 (89.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33767  bytes 3807354 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5658  bytes 1294220 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5658  bytes 1294220 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

* python3-ifcfg now parses flags correctly:
root@qemux86-64:~# python3 -m ifcfg.cli | python3 -m json.tool
{
    "eth0": {
        "inet": "192.168.7.2",
        "inet4": [
            "192.168.7.2"
        ],
        "ether": "52:54:00:12:34:02",
        "inet6": [
            "fe80::5054:ff:fe12:3402"
        ],
        "netmask": "255.255.255.0",
        "device": "eth0",
        "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST> ",
        "mtu": "1500",
        "broadcast": "192.168.7.255"
    },
    "lo": {
        "inet": "127.0.0.1",
        "inet4": [
            "127.0.0.1"
        ],
        "ether": null,
        "inet6": [
            "::1"
        ],
        "netmask": "255.0.0.0",
        "device": "lo",
        "flags": "73<UP,LOOPBACK,RUNNING> ",
        "mtu": "65536"
    },
    "sit0": {
        "inet": null,
        "inet4": [],
        "ether": null,
        "inet6": [],
        "netmask": null,
        "device": "sit0",
        "flags": "128<NOARP> ",
        "mtu": "1480"
    }
}

(From OE-Core rev: dacfd695061b186240a85f8ffc43e6636c56e1fb)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants