Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 515E8C61DA4 for ; Sun, 29 Jan 2023 03:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbjA2DIq (ORCPT ); Sat, 28 Jan 2023 22:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjA2DIm (ORCPT ); Sat, 28 Jan 2023 22:08:42 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1504122A08; Sat, 28 Jan 2023 19:08:41 -0800 (PST) Received: from dggpeml500006.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4P4GP875VWzJqDK; Sun, 29 Jan 2023 11:04:12 +0800 (CST) Received: from [10.174.178.240] (10.174.178.240) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sun, 29 Jan 2023 11:08:38 +0800 To: Network Development , open list CC: Julian Anastasov , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Denis V. Lunev" , Nikolay Aleksandrov , Daniel Borkmann , Zhang Changzhong , YueHaibing From: Zhang Changzhong Subject: [Question] neighbor entry doesn't switch to the STALE state after the reachable timer expires Message-ID: Date: Sun, 29 Jan 2023 11:08:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.240] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, We got the following weird neighbor cache entry on a machine that's been running for over a year: 172.16.1.18 dev bond0 lladdr 0a:0e:0f:01:12:01 ref 1 used 350521/15994171/350520 probes 4 REACHABLE 350520 seconds have elapsed since this entry was last updated, but it is still in the REACHABLE state (base_reachable_time_ms is 30000), preventing lladdr from being updated through probe. After some analysis, we found a scenario that may cause such a neighbor entry: Entry used DELAY_PROBE_TIME expired NUD_STALE ------------> NUD_DELAY ------------------------> NUD_PROBE | | DELAY_PROBE_TIME not expired v NUD_REACHABLE The neigh_timer_handler() use time_before_eq() to compare 'now' with 'neigh->confirmed + NEIGH_VAR(neigh->parms, DELAY_PROBE_TIME)', but time_before_eq() only works if delta < ULONG_MAX/2. This means that if an entry stays in the NUD_STALE state for more than ULONG_MAX/2 ticks, it enters the NUD_RACHABLE state directly when it is used again and cannot be switched to the NUD_STALE state (the timer is set too long). On 64-bit machines, ULONG_MAX/2 ticks are a extremely long time, but in my case (32-bit machine and kernel compiled with CONFIG_HZ=250), ULONG_MAX/2 ticks are about 99.42 days, which is possible in reality. Does anyone have a good idea to solve this problem? Or are there other scenarios that might cause such a neighbor entry? ----- Best Regards, Changzhong Zhang