From patchwork Tue Sep 25 09:36:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UGV0ciBQw61zYcWZ?= X-Patchwork-Id: 186747 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id F13F72C008A for ; Tue, 25 Sep 2012 19:37:07 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753674Ab2IYJhA (ORCPT ); Tue, 25 Sep 2012 05:37:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26392 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752136Ab2IYJg7 (ORCPT ); Tue, 25 Sep 2012 05:36:59 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8P9axQi000866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Sep 2012 05:36:59 -0400 Received: from dhcp-0-146.brq.redhat.com (dhcp-25-104.brq.redhat.com [10.34.25.104]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8P9auhL021216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Sep 2012 05:36:58 -0400 Received: from dhcp-0-146.brq.redhat.com (localhost.localdomain [127.0.0.1]) by dhcp-0-146.brq.redhat.com (8.14.5/8.14.5) with ESMTP id q8P9at4f020122; Tue, 25 Sep 2012 11:36:55 +0200 Received: (from petr@localhost) by dhcp-0-146.brq.redhat.com (8.14.5/8.14.5/Submit) id q8P9atpE020121; Tue, 25 Sep 2012 11:36:55 +0200 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= To: Cc: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Subject: [PATCH] List interfaces without net address by default Date: Tue, 25 Sep 2012 11:36:39 +0200 Message-Id: <1348565799-20080-1-git-send-email-ppisar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This fixes regression in iproute2-3.5.1 when `ip addr show' skipped interfaces without network layer address. Wrong output: 1: lo: mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:50:54:00:0f:03 brd ff:ff:ff:ff:ff:ff inet 10.34.25.198/23 brd 10.34.25.255 scope global eth0 inet6 2620:52:0:2219:250:54ff:fe00:f03/64 scope global dynamic valid_lft 2591919sec preferred_lft 604719sec inet6 fe80::250:54ff:fe00:f03/64 scope link valid_lft forever preferred_lft forever Expected output: 1: lo: mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:50:54:00:0f:03 brd ff:ff:ff:ff:ff:ff inet 10.34.25.198/23 brd 10.34.25.255 scope global eth0 inet6 2620:52:0:2219:250:54ff:fe00:f03/64 scope global dynamic valid_lft 2591896sec preferred_lft 604696sec inet6 fe80::250:54ff:fe00:f03/64 scope link valid_lft forever preferred_lft forever 5: veth1: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 8a:ec:35:34:1f:a8 brd ff:ff:ff:ff:ff:ff 6: veth0: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 2e:97:ef:77:40:82 brd ff:ff:ff:ff:ff:ff Signed-off-by: Petr Písař --- ip/ipaddress.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 69a63b3..4382ab5 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -785,6 +785,7 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) lp = &linfo->head; while ( (l = *lp) != NULL) { int ok = 0; + int missing_net_address = 1; struct ifinfomsg *ifi = NLMSG_DATA(&l->h); struct nlmsg_list *a; @@ -792,8 +793,10 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) struct nlmsghdr *n = &a->h; struct ifaddrmsg *ifa = NLMSG_DATA(n); - if (ifa->ifa_index != ifi->ifi_index || - (filter.family && filter.family != ifa->ifa_family)) + if (ifa->ifa_index != ifi->ifi_index) + continue; + missing_net_address = 0; + if (filter.family && filter.family != ifa->ifa_family) continue; if ((filter.scope^ifa->ifa_scope)&filter.scopemask) continue; @@ -828,6 +831,9 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo) ok = 1; break; } + if (missing_net_address && + (filter.family == AF_UNSPEC || filter.family == AF_PACKET)) + ok = 1; if (!ok) { *lp = l->next; free(l);