netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [iproute PATCH] ip-link: Fix listing of alias interfaces
@ 2019-02-07 13:05 Phil Sutter
  2019-02-08  0:24 ` Stephen Hemminger
  2019-02-08 17:56 ` Stephen Hemminger
  0 siblings, 2 replies; 7+ messages in thread
From: Phil Sutter @ 2019-02-07 13:05 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Roopa Prabhu

Commit 50b9950dd9011 ("link dump filter") accidentally broke listing of
links in the old alias interface notation:

| % ip link show eth0:1
| RTNETLINK answers: No such device
| Cannot send link get request: No such device

Prior to the above commit, link lookup was performed via ifindex
returned by if_nametoindex(). The latter uses SIOCGIFINDEX ioctl call
which on kernel side causes the colon-suffix to be dropped before doing
the interface lookup. Netlink API though doesn't care about that at all.
To keep things backward compatible, mimick ioctl API behaviour and drop
the colon-suffix prior to sending the RTM_GETLINK request.

Fixes: 50b9950dd9011 ("link dump filter")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 ip/ipaddress.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 2bc33f3a3b3f2..bc30d326ca0a3 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1974,6 +1974,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 	 * the link device
 	 */
 	if (filter_dev && filter.group == -1 && do_link == 1) {
+		*strchrnul(filter_dev, ':') = '\0';
 		if (iplink_get(filter_dev, RTEXT_FILTER_VF) < 0) {
 			perror("Cannot send link get request");
 			delete_json_obj();
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-02-08 18:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-07 13:05 [iproute PATCH] ip-link: Fix listing of alias interfaces Phil Sutter
2019-02-08  0:24 ` Stephen Hemminger
2019-02-08 10:40   ` Phil Sutter
2019-02-08 12:09     ` Michal Kubecek
2019-02-08 17:50       ` David Ahern
2019-02-08 17:56 ` Stephen Hemminger
2019-02-08 18:04   ` Phil Sutter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).