From patchwork Mon Jan 7 22:55:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 1021653 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="antaF5wn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YW350XLHz9sDP for ; Tue, 8 Jan 2019 09:56:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbfAGW4O (ORCPT ); Mon, 7 Jan 2019 17:56:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:38816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbfAGW4O (ORCPT ); Mon, 7 Jan 2019 17:56:14 -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 EDBE82173C; Mon, 7 Jan 2019 22:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546901774; bh=FHGlYEIdezpwIPdw6mobZ1DDMGW86n0+bZZ9b9dnkOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=antaF5wnLep/y91hCRaS3z9+AaIRIHDP6Gih+wUPJ92cd5Fhyvb5GffrJky5Ri1K5 7wbDNgY0+kNUueL7Av2MHL4HoFx9+YGE1+c4h4703QpkHhc59JuJuNJ3s9Q4HYN8Um hLmyoY5TU4YH5be+J3x5sAWyrpG1h6zAJS/R7b7I= From: David Ahern To: stephen@networkplumber.org Cc: netdev@vger.kernel.org, David Ahern Subject: [PATCH iproute2-next 1/3] ll_map: Add function to remove link cache entry by index Date: Mon, 7 Jan 2019 14:55:50 -0800 Message-Id: <20190107225552.8441-2-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 Add ll_drop_by_index to remove an entry from the link cache. Signed-off-by: David Ahern --- include/ll_map.h | 1 + lib/ll_map.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/ll_map.h b/include/ll_map.h index 511fe00b8567..4de1041e2746 100644 --- a/include/ll_map.h +++ b/include/ll_map.h @@ -9,6 +9,7 @@ unsigned ll_name_to_index(const char *name); const char *ll_index_to_name(unsigned idx); int ll_index_to_type(unsigned idx); int ll_index_to_flags(unsigned idx); +void ll_drop_by_index(unsigned index); unsigned namehash(const char *str); const char *ll_idx_n2a(unsigned int idx); diff --git a/lib/ll_map.c b/lib/ll_map.c index 1ab8ef0758ac..8e8a0b1e9c9d 100644 --- a/lib/ll_map.c +++ b/lib/ll_map.c @@ -210,6 +210,20 @@ unsigned ll_name_to_index(const char *name) return idx; } +void ll_drop_by_index(unsigned index) +{ + struct ll_cache *im; + + im = ll_get_by_index(index); + if (!im) + return; + + hlist_del(&im->idx_hash); + hlist_del(&im->name_hash); + + free(im); +} + void ll_init_map(struct rtnl_handle *rth) { static int initialized;