From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH iproute2-next 8/9] utils: Introduce and use print_name_and_link() to print name@link Date: Tue, 6 Feb 2018 22:14:04 -0700 Message-ID: <7996fb02-c31f-4fce-17c5-f1875298f453@gmail.com> References: <1517860174-18333-1-git-send-email-serhe.popovych@gmail.com> <1517860174-18333-9-git-send-email-serhe.popovych@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Serhey Popovych , netdev@vger.kernel.org Return-path: Received: from mail-it0-f47.google.com ([209.85.214.47]:35844 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750715AbeBGFOH (ORCPT ); Wed, 7 Feb 2018 00:14:07 -0500 Received: by mail-it0-f47.google.com with SMTP id n206so716141itg.1 for ; Tue, 06 Feb 2018 21:14:07 -0800 (PST) In-Reply-To: <1517860174-18333-9-git-send-email-serhe.popovych@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 2/5/18 12:49 PM, Serhey Popovych wrote: > There is at least three places implementing same things: two in > ipaddress.c print_linkinfo() & print_linkinfo_brief() and one in > bridge/link.c. > > They are diverge from each other very little: bridge/link.c does not > support JSON output at the moment and print_linkinfo_brief() does not > handle IFLA_LINK_NETNS case. > > Introduce and use print_name_and_link() routine to handle name@link > output in all possible variations; respect IFLA_LINK_NETNS attribute to > handle case when link is in different namespace; use ll_idx_n2a() for > interface name instead of "" to share logic with other code (e.g. > ll_name_to_index() and ll_index_to_name()) supporting such template. > > Signed-off-by: Serhey Popovych > --- > bridge/link.c | 13 +++---------- > include/utils.h | 4 ++++ > ip/ipaddress.c | 44 ++------------------------------------------ > lib/utils.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 58 insertions(+), 52 deletions(-) > This patch is causing a diff on my system: # ip -br add sh > /tmp/1 # ip/ip -br add sh > /tmp/2 # diff /tmp/1 /tmp/2 8c8 < veth-out@br3 UP fe80::18a8:89ff:fee7:55c5/64 --- > veth-out@if7 UP fe80::18a8:89ff:fee7:55c5/64 So the current ip resolves ifindex 7 to br3: # ip li sh dev br3 7: br3: mtu 1500 qdisc noqueue master vrf3 state UP mode DEFAULT group default qlen 1000 where your patch causes if%d to be printed.