Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36B67C282C2 for ; Thu, 7 Feb 2019 13:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 111A22190C for ; Thu, 7 Feb 2019 13:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726979AbfBGNFS (ORCPT ); Thu, 7 Feb 2019 08:05:18 -0500 Received: from orbyte.nwl.cc ([151.80.46.58]:41992 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbfBGNFS (ORCPT ); Thu, 7 Feb 2019 08:05:18 -0500 Received: from localhost ([::1]:55082 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1grjMi-0002bB-KV; Thu, 07 Feb 2019 14:05:16 +0100 From: Phil Sutter To: Stephen Hemminger Cc: netdev@vger.kernel.org, Roopa Prabhu Subject: [iproute PATCH] ip-link: Fix listing of alias interfaces Date: Thu, 7 Feb 2019 14:05:27 +0100 Message-Id: <20190207130527.9439-1-phil@nwl.cc> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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