From patchwork Thu Feb 7 13:05:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1038053 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43wJWF30Jpz9s4Z for ; Fri, 8 Feb 2019 00:07:21 +1100 (AEDT) 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 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();