From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: [PATCH net-next 6/7] neighbor: Skip the duplicate lookup in neigh_add Date: Wed, 5 Dec 2018 15:34:13 -0800 Message-ID: <20181205233414.1386-7-dsahern@kernel.org> References: <20181205233414.1386-1-dsahern@kernel.org> Cc: davem@davemloft.net, David Ahern To: netdev@vger.kernel.org Return-path: Received: from mail.kernel.org ([198.145.29.99]:53908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728793AbeLEXd2 (ORCPT ); Wed, 5 Dec 2018 18:33:28 -0500 In-Reply-To: <20181205233414.1386-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: From: David Ahern When adding a new neighbor via rtnetlink, neigh_add does a lookup and if the result is NULL calls __neigh_lookup_errno to create a new entry if the NLM_F_CREATE flag is set. But, __neigh_lookup_errno calls neigh_lookup again before neigh_create; the neigh_lookup is redundant. Replace the call to __neigh_lookup_errno with a call to __neigh_create to more efficiently achieve the same result and prepare for the next patch. Signed-off-by: David Ahern --- net/core/neighbour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 53e30c15882d..e324467e9a71 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1785,7 +1785,7 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, goto out; } - neigh = __neigh_lookup_errno(tbl, dst, dev); + neigh = __neigh_create(tbl, dst, dev, true); if (IS_ERR(neigh)) { err = PTR_ERR(neigh); goto out; -- 2.11.0