Patchwork [net-next,6/7] neighbor: Skip the duplicate lookup in neigh_add

login
register
mail settings
Submitter dsahern@kernel.org
Date Dec. 5, 2018, 11:34 p.m.
Message ID <20181205233414.1386-7-dsahern@kernel.org>
Download mbox | patch
Permalink /patch/673621/
State New
Headers show

Comments

dsahern@kernel.org - Dec. 5, 2018, 11:34 p.m.
From: David Ahern <dsahern@gmail.com>

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 <dsahern@gmail.com>
---
 net/core/neighbour.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

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;