From patchwork Mon Jan 7 22:55:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 1021654 X-Patchwork-Delegate: dsahern@gmail.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=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="cJAK8yXT"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YW356YdVz9sDT for ; Tue, 8 Jan 2019 09:56:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727043AbfAGW4P (ORCPT ); Mon, 7 Jan 2019 17:56:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:38826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbfAGW4P (ORCPT ); Mon, 7 Jan 2019 17:56:15 -0500 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E7A92183E; Mon, 7 Jan 2019 22:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546901774; bh=/P9o6qUC0slF72onmISviKaR9Nz0ym7Gx6FxSJN7gkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJAK8yXTwnKRYts6QXP472NzzBBJGo5e3C9fQKen88e7UrDP+YCWBFmkb2KyuptdG OsNUPV9MWIxg9SxLqq+Mm9M4Dv5JAqKWNy57hiW9Gcmc7MdgxIhzPuNxPwyaDZ3kRR SbVzEyjVG3K2Hz4G6rxtGg24yktsvQttzIZNDshI= From: David Ahern To: stephen@networkplumber.org Cc: netdev@vger.kernel.org, David Ahern Subject: [PATCH iproute2-next 2/3] ip link: Drop cache entry on name changes Date: Mon, 7 Jan 2019 14:55:51 -0800 Message-Id: <20190107225552.8441-3-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190107225552.8441-1-dsahern@kernel.org> References: <20190107225552.8441-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern If a link's name is changed remove any entry from the link cache. Signed-off-by: David Ahern --- ip/ip_common.h | 3 ++- ip/iplink.c | 10 ++++++++-- ip/iplink_vxcan.c | 3 ++- ip/link_veth.c | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ip/ip_common.h b/ip/ip_common.h index d67575c63c24..ae2b2fb4e314 100644 --- a/ip/ip_common.h +++ b/ip/ip_common.h @@ -123,7 +123,8 @@ struct link_util { struct link_util *get_link_kind(const char *kind); -int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type); +int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type, + bool *name_change); /* iplink_bridge.c */ void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len); diff --git a/ip/iplink.c b/ip/iplink.c index b5519201fef7..65838e2b3fe6 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -573,7 +573,8 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp, return 0; } -int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) +int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type, + bool *name_change) { char *name = NULL; char *dev = NULL; @@ -943,6 +944,8 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) dev = name; else if (!strcmp(name, dev)) name = dev; + else if (name_change) + *name_change = true; if (dev && addr_len) { int halen = nl_get_ll_addr_len(dev); @@ -1030,9 +1033,10 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv) .n.nlmsg_type = cmd, .i.ifi_family = preferred_family, }; + bool name_change = false; int ret; - ret = iplink_parse(argc, argv, &req, &type); + ret = iplink_parse(argc, argv, &req, &type, &name_change); if (ret < 0) return ret; @@ -1082,6 +1086,8 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv) if (rtnl_talk(&rth, &req.n, NULL) < 0) return -2; + else if (name_change) + ll_drop_by_index(req.i.ifi_index); return 0; } diff --git a/ip/iplink_vxcan.c b/ip/iplink_vxcan.c index 8b08c9a70c65..bdd372037836 100644 --- a/ip/iplink_vxcan.c +++ b/ip/iplink_vxcan.c @@ -56,7 +56,8 @@ static int vxcan_parse_opt(struct link_util *lu, int argc, char **argv, n->nlmsg_len += sizeof(struct ifinfomsg); - err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)n, &type); + err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)n, &type, + NULL); if (err < 0) return err; diff --git a/ip/link_veth.c b/ip/link_veth.c index 33e8f2b102e7..ef0bc1948323 100644 --- a/ip/link_veth.c +++ b/ip/link_veth.c @@ -54,7 +54,8 @@ static int veth_parse_opt(struct link_util *lu, int argc, char **argv, n->nlmsg_len += sizeof(struct ifinfomsg); - err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)n, &type); + err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)n, &type, + NULL); if (err < 0) return err;