From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: Re: [PATCH iproute2-next 8/9] utils: Introduce and use print_name_and_link() to print name@link Date: Wed, 7 Feb 2018 09:36:55 +0200 Message-ID: <4b5094fc-7cf7-74a2-4d54-1dd9fe60c77b@gmail.com> References: <1517860174-18333-1-git-send-email-serhe.popovych@gmail.com> <1517860174-18333-9-git-send-email-serhe.popovych@gmail.com> <7996fb02-c31f-4fce-17c5-f1875298f453@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="60OdVEioTm7hjj5iomARRHikq3GhEVWEP" To: David Ahern , netdev@vger.kernel.org Return-path: Received: from mail-lf0-f65.google.com ([209.85.215.65]:35736 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750777AbeBGHhD (ORCPT ); Wed, 7 Feb 2018 02:37:03 -0500 Received: by mail-lf0-f65.google.com with SMTP id a204so6436220lfa.2 for ; Tue, 06 Feb 2018 23:37:03 -0800 (PST) In-Reply-To: <7996fb02-c31f-4fce-17c5-f1875298f453@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --60OdVEioTm7hjj5iomARRHikq3GhEVWEP Content-Type: multipart/mixed; boundary="G0IWpXYDzYncL0v1v7rtGToOThiPRizRU"; protected-headers="v1" From: Serhey Popovych To: David Ahern , netdev@vger.kernel.org Message-ID: <4b5094fc-7cf7-74a2-4d54-1dd9fe60c77b@gmail.com> Subject: Re: [PATCH iproute2-next 8/9] utils: Introduce and use print_name_and_link() to print name@link References: <1517860174-18333-1-git-send-email-serhe.popovych@gmail.com> <1517860174-18333-9-git-send-email-serhe.popovych@gmail.com> <7996fb02-c31f-4fce-17c5-f1875298f453@gmail.com> In-Reply-To: <7996fb02-c31f-4fce-17c5-f1875298f453@gmail.com> --G0IWpXYDzYncL0v1v7rtGToOThiPRizRU Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable David Ahern wrote: > 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 t= o >> 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(-) >> >=20 > This patch is causing a diff on my system: >=20 > # 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 >=20 > So the current ip resolves ifindex 7 to br3: >=20 > # ip li sh dev br3 > 7: br3: mtu 1500 qdisc noqueue master= > vrf3 state UP mode DEFAULT group default qlen 1000 >=20 > where your patch causes if%d to be printed. >=20 That's interesting. I guess output comes from ll_idx_n2a() in this change when both IFLA_LINK and IFLA_LINK_NETNS is seen. My guess about this case is following: 1) veth-out is of "veth" rtnl kind. (ip -d li sh dev veth-out). 2) according to drivers/net/veth.c veth_get_iflink() and veth_get_link_net() IFLA_LINK and IFLA_LINK_NETNS are taken from peer device. 3) seeing @br3 in current ip output looks confusing according to (2) as veth do not link to something other than it's peer that is in different network namespace. =46rom (3) I guess @br3 is incorrect value and caused by missing IFLA_LINK_NETNS handling in old print_linkinfo_brief(): it always calls ll_index_to_name(). Could you provide some more details about your setup if above guess is wrong. Especially following ones: 1) ip -d li sh dev veth-out (get the rtnl kind) 2) ip -d li sh dev br3 (get the rtnl kind) 3) uname -r or cat /proc/version --G0IWpXYDzYncL0v1v7rtGToOThiPRizRU-- --60OdVEioTm7hjj5iomARRHikq3GhEVWEP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBAgAGBQJaeqybAAoJEBTawMmQ61bBtAYH/1gq9MX1TJTpO1HQ6vSb9llL vzsSmNsSp+wMu01ZIo78kgg5Cufa9fYJ1M7OtQpjAULqOk4v4DnjeEeuQfu4guTH 3ZHOT33f4TstKI8i0HLxMNN9AZRzcMDo1KinKjNjf1gU6ICYWG/VAQdLObu75jji JthshjwgT6OMSKM7YxTU1IrLm6H7At/NBIoVDp72B6ChL+j+TsvV6EHGohnPvXKO BipoEMiOabCdDTE7GWxZc0cv1l9M2ziXagJnf2MK3TQMWtpZ3vxBgptZpu2Kq+6u T8SUtKve0OheU05AlTmcdSXExYjvRqoA16TSOOGKJX2UM1jfMYTT/NOieBqRmg4= =EF51 -----END PGP SIGNATURE----- --60OdVEioTm7hjj5iomARRHikq3GhEVWEP--