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 983DBC282C2 for ; Thu, 7 Feb 2019 10:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FCCF218FE for ; Thu, 7 Feb 2019 10:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbfBGKYa (ORCPT ); Thu, 7 Feb 2019 05:24:30 -0500 Received: from orbyte.nwl.cc ([151.80.46.58]:41590 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbfBGKYa (ORCPT ); Thu, 7 Feb 2019 05:24:30 -0500 Received: from localhost ([::1]:54680 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1grgr5-00014E-Jo; Thu, 07 Feb 2019 11:24:27 +0100 From: Phil Sutter To: David Miller Cc: netdev@vger.kernel.org Subject: [net-next PATCH] net: rtnetlink: Support alias interfaces with RTM_GETLINK Date: Thu, 7 Feb 2019 11:24:38 +0100 Message-Id: <20190207102438.21448-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 Align interface name handling regarding alias interfaces in rtnl_getlink() with dev_ioctl() treating SIOCGIFINDEX ioctl calls. The latter function strips any colon suffix before doing the interface lookup, do the same for RTM_GETLINK requests. Signed-off-by: Phil Sutter --- net/core/rtnetlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a51cab95ba64c..aaee4df0ff00c 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3312,8 +3312,10 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr *nlh, return PTR_ERR(tgt_net); } - if (tb[IFLA_IFNAME]) + if (tb[IFLA_IFNAME]) { nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); + *strchrnul(ifname, ':') = '\0'; + } if (tb[IFLA_EXT_MASK]) ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); -- 2.20.1