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

mail settings
Date Dec. 5, 2018, 11:34 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/673621/
State New
Headers show

Comments - Dec. 5, 2018, 11:34 p.m.
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

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

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;