From patchwork Thu Sep 13 18:12:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 969484 X-Patchwork-Delegate: davem@davemloft.net 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=quarantine dis=none) header.from=arista.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=arista.com header.i=@arista.com header.b="ukcDJmv6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42B6Rv5Xsjz9sB4 for ; Fri, 14 Sep 2018 04:21:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbeIMXcU (ORCPT ); Thu, 13 Sep 2018 19:32:20 -0400 Received: from smtp.aristanetworks.com ([54.193.82.35]:35070 "EHLO uscaw2-clmxp01.aristanetworks.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726821AbeIMXcT (ORCPT ); Thu, 13 Sep 2018 19:32:19 -0400 X-Greylist: delayed 475 seconds by postgrey-1.27 at vger.kernel.org; Thu, 13 Sep 2018 19:32:19 EDT Received: from uscaw2-clmxp01.aristanetworks.com (localhost [127.0.0.1]) by uscaw2-clmxp01.aristanetworks.com (Postfix) with ESMTP id 302C12100D19; Thu, 13 Sep 2018 11:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1536862427; bh=xOs7cJzjGBrnvFCCH2zvU9p/c12nncn75wSd7aLpT8k=; h=From:To:Cc:Subject:Date; b=ukcDJmv6zRNwieOS3S66zg8ws344DnwOKC/2pdbleCfoWv4tdhKl+blnQXnaxp+Gr g07QtgqW0SOBrJASekre3+whjJbe/FkMqMZKOTPTrk9d0kWErezoMSrgoLlwfsCeql o95LyIhCjY4gABOU4/m1USuLFeYPwVs+fU8vOHi2mPufx8MxtLO8ml+qvTr80kE2mn 3i+UXSBtQSO7DctVmPrcFhyZaJ8K18Eq7FCgnBmpxEwaV1LkfWvr31ToXG/5TuwNDn /HF9ex1zuy7ihRNrBASKb4uuzZOG/Dl5srKrQD6cslsQDSxWiKBDkrC8Lz6CEQJzHi hYxXFNI6dwEvA== Received: from vasilykh-thinkpad-x1.sjc.aristanetworks.com (unknown [10.80.8.45]) by uscaw2-clmxp01.aristanetworks.com (Postfix) with ESMTP id A2C3330EAA2C; Thu, 13 Sep 2018 11:13:46 -0700 (PDT) From: Vasily Khoruzhick To: "David S. Miller" , Roopa Prabhu , Alexey Dobriyan , Eric Dumazet , Stephen Hemminger , Jim Westfall , Wolfgang Bumiller , Vasily Khoruzhick , Kees Cook , Ihar Hrachyshka , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sergei Shtylyov Cc: Vasily Khoruzhick Subject: [PATCH v3] neighbour: confirm neigh entries when ARP packet is received Date: Thu, 13 Sep 2018 11:12:03 -0700 Message-Id: <20180913181203.4207-1-vasilykh@arista.com> X-Mailer: git-send-email 2.18.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Update 'confirmed' timestamp when ARP packet is received. It shouldn't affect locktime logic and anyway entry can be confirmed by any higher-layer protocol. Thus it makes sense to confirm it when ARP packet is received. Fixes: 77d7123342 ("neighbour: update neigh timestamps iff update is effective") Signed-off-by: Vasily Khoruzhick --- v2: - update comment to match new code. v3: - fix wording in commit message, make 'Fixes' tag one line, remove extra new line between 'Fixes' and 'Signed-off-by'. net/core/neighbour.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index aa19d86937af..91592fceeaad 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1180,6 +1180,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, lladdr = neigh->ha; } + /* Update confirmed timestamp for neighbour entry after we + * received ARP packet even if it doesn't change IP to MAC binding. + */ + if (new & NUD_CONNECTED) + neigh->confirmed = jiffies; + /* If entry was valid and address is not changed, do not change entry state, if new one is STALE. */ @@ -1201,15 +1207,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, } } - /* Update timestamps only once we know we will make a change to the + /* Update timestamp only once we know we will make a change to the * neighbour entry. Otherwise we risk to move the locktime window with * noop updates and ignore relevant ARP updates. */ - if (new != old || lladdr != neigh->ha) { - if (new & NUD_CONNECTED) - neigh->confirmed = jiffies; + if (new != old || lladdr != neigh->ha) neigh->updated = jiffies; - } if (new != old) { neigh_del_timer(neigh);