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 to >> handle case when link is in different namespace; use ll_idx_n2a() for >> interface name instead of "<nil>" 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 <serhe.popov...@gmail.com> >> --- >> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master > vrf3 state UP mode DEFAULT group default qlen 1000 > > where your patch causes if%d to be printed. >
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. From (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
signature.asc
Description: OpenPGP digital signature