Comment 0 for bug 1732032

Revision history for this message
bugproxy (bugproxy) wrote :

Attn. Canonical: Please make sure that the existing iproute2 package gets updated with the two referenced patches as the missing information is impacting our standard test suites.

Thanks.

== Comment: #0 - Alton L. Pundt - 2017-03-29 14:37:57 ==
---Problem Description---
ip maddr show and ip maddr show dev enP20p96s0 show different data

---uname output---
Linux roselp1 4.10.0-14-generic #16-Ubuntu SMP Fri Mar 17 15:19:05 UTC 2017 ppc64le ppc64le ppc64le GNU/Linux

Machine Type = 8286-42A

---Steps to Reproduce---
 run these at command line:
root@roselp1:~# ip maddr show
...
10: enP20p96s0
        link 33:33:00:00:00:01
        link 01:00:5e:00:00:01
        link 33:33:ff:6d:d0:d0
        link 01:00:5e:00:00:fc
        link 33:33:00:01:00:03
        inet 224.0.0.252
        inet 224.0.0.1
        inet6 ff02::1:3
        inet6 ff02::1:ff6d:d0d0 users 3
        inet6 ff02::1
        inet6 ff01::1
...

root@roselp1:~# ip maddr show dev enP20p96s0
10: enP20p96s0
        link 33:33:00:00:00:01
        link 01:00:5e:00:00:01
        link 33:33:ff:6d:d0:d0
        link 01:00:5e:00:00:fc
        link 33:33:00:01:00:03
        inet6 ff02::1:3
        inet6 ff02::1:ff6d:d0d0 users 3
        inet6 ff02::1
        inet6 ff01::1

== Comment: #12 - David Z. Dai - 2017-11-13 15:07:32 ==

I found upstream already had patches that fix this problem:

1) https://www.spinics.net/lists/netdev/msg415009.html
commit 530903dd9003492edb0714e937ad4a5d1219e376
Author: Petr Vorel <email address hidden>
Date: Tue Jan 17 00:25:50 2017 +0100

    ip: fix igmp parsing when iface is long

    Entries with long vhost names in /proc/net/igmp have no whitespace
    between name and colon, so sscanf() adds it to vhost and
    'ip maddr show iface' doesn't include inet result.

    Signed-off-by: Petr Vorel <email address hidden>

2) https://www.spinics.net/lists/netdev/msg461479.html
commit 21503ed2af233ffe795926f6641ac84ec1b15bf9
Author: Michal Kubecek <email address hidden>
Date: Thu Oct 19 10:21:08 2017 +0200

    ip maddr: fix filtering by device

    Commit 530903dd9003 ("ip: fix igmp parsing when iface is long") uses
    variable len to keep trailing colon from interface name comparison. This
    variable is local to loop body but we set it in one pass and use it in
    following one(s) so that we are actually using (pseudo)random length for
    comparison. This became apparent since commit b48a1161f5f9 ("ipmaddr: Avoid
    accessing uninitialized data") always initializes len to zero so that the
    name comparison is always true. As a result, "ip maddr show dev eth0" shows
    IPv4 multicast addresses for all interfaces.

    Instead of keeping the length, let's simply replace the trailing colon with
    a null byte. The bonus is that we get correct interface name in ma.name.

    Fixes: 530903dd9003 ("ip: fix igmp parsing when iface is long")
    Signed-off-by: Michal Kubecek <email address hidden>
    Acked-by: Phil Sutter <email address hidden>
    Acked-by: Petr Vorel <email address hidden>

The fix is in the same place, but different way.
This is the current implementation In ip/ipmaddr.c file:
                struct ma_info *ma;

                if (buf[0] != '\t') {
                        size_t len;

                        sscanf(buf, "%d%s", &m.index, m.name);
                        len = strlen(m.name);
                        if (m.name[len - 1] == ':')
                                m.name[len - 1] = '\0';
                        continue;
                }

The existing "ip" command that shows the problem:
[root@coral-sriov-host1 ip]# /usr/sbin/ip maddr show dev enP1p12s0f0 /* <-- We do NOT see the IPv4 maddr */
2: enP1p12s0f0
        link 01:00:5e:00:00:01
        inet6 ff02::1
        inet6 ff01::1

I clone the latest "ip" utility from upstream to the same test box.
[root@coral-sriov-host1 git_iproute2]# git clone https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git

I build the "ip" utility on same test box, which has the above 2 patches included.

[root@coral-sriov-host1 ip]# /root/git_iproute2/iproute2/ip/ip maddr show dev enP1p12s0f0 /* <--- shows correct IPv4 maddr */
2: enP1p12s0f0
        link 01:00:5e:00:00:01
        inet 224.0.0.1 /* <--- */
        inet6 ff02::1
        inet6 ff01::1