From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Westfall Subject: [PATCH 1/2] net: Allow neigh contructor functions ability to modify the primary_key Date: Sat, 13 Jan 2018 16:00:18 -0800 Message-ID: <20180114000018.GG740@surrealistic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: netdev@vger.kernel.org Return-path: Received: from whipper.surrealistic.net ([50.251.204.81]:48406 "EHLO whipper.surrealistic.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754504AbeANAAT (ORCPT ); Sat, 13 Jan 2018 19:00:19 -0500 Received: from localhost (whipper.surrealistic.net [local]) by whipper.surrealistic.net (OpenSMTPD) with ESMTPA id 8d23a23e for ; Sun, 14 Jan 2018 00:00:18 +0000 (UTC) Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: Use n->primary_key instead of pkey to account for the possibility that a neigh constructor function may have modified the primary_key value. Signed-off-by: Jim Westfall --- net/core/neighbour.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index d1f5fe986edd..7f831711b6e0 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -532,7 +532,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey, if (atomic_read(&tbl->entries) > (1 << nht->hash_shift)) nht = neigh_hash_grow(tbl, nht->hash_shift + 1); - hash_val = tbl->hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); + hash_val = tbl->hash(n->primary_key, dev, nht->hash_rnd) >> (32 - nht->hash_shift); if (n->parms->dead) { rc = ERR_PTR(-EINVAL); @@ -544,7 +544,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey, n1 != NULL; n1 = rcu_dereference_protected(n1->next, lockdep_is_held(&tbl->lock))) { - if (dev == n1->dev && !memcmp(n1->primary_key, pkey, key_len)) { + if (dev == n1->dev && !memcmp(n1->primary_key, n->primary_key, key_len)) { if (want_ref) neigh_hold(n1); rc = n1;