From nobody Mon Sep 8 08:59:04 2025 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 8CAB8ECAAD8 for ; Tue, 13 Sep 2022 17:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233590AbiIMRsa (ORCPT ); Tue, 13 Sep 2022 13:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233525AbiIMRr7 (ORCPT ); Tue, 13 Sep 2022 13:47:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A35F80F40; Tue, 13 Sep 2022 09:45:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7B863B80F96; Tue, 13 Sep 2022 14:28:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2861C433C1; Tue, 13 Sep 2022 14:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079308; bh=/WwQQQWZw4Ocl4rtG/ztMzhyCaIJYCvo4vCXiqY1XGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uc8bqbV8aUEzSHURr2/A8CaCypkvMCYlftdy+Q0K/HmGJ93Dxt6CKlNzEOOvINjCU UaZi0x/XSNav9HyVvLugWMXUViv3p4ZO2cYGrFf3AeGjPblliAuOFo5jig4CdrFU/9 H7iCfCC3/bKxCOu3PnAgezrDjRPQ3eTQT3Dws2sw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Heng Qi , Nicolas Dichtel , David Ahern , Jakub Kicinski Subject: [PATCH 5.4 057/108] ip: fix triggering of icmp redirect Date: Tue, 13 Sep 2022 16:06:28 +0200 Message-Id: <20220913140356.077233760@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140353.549108748@linuxfoundation.org> References: <20220913140353.549108748@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nicolas Dichtel commit eb55dc09b5dd040232d5de32812cc83001a23da6 upstream. __mkroute_input() uses fib_validate_source() to trigger an icmp redirect. My understanding is that fib_validate_source() is used to know if the src address and the gateway address are on the same link. For that, fib_validate_source() returns 1 (same link) or 0 (not the same network). __mkroute_input() is the only user of these positive values, all other callers only look if the returned value is negative. Since the below patch, fib_validate_source() didn't return anymore 1 when both addresses are on the same network, because the route lookup returns RT_SCOPE_LINK instead of RT_SCOPE_HOST. But this is, in fact, right. Let's adapat the test to return 1 again when both addresses are on the same link. CC: stable@vger.kernel.org Fixes: 747c14307214 ("ip: fix dflt addr selection for connected nexthop") Reported-by: kernel test robot Reported-by: Heng Qi Signed-off-by: Nicolas Dichtel Reviewed-by: David Ahern Link: https://lore.kernel.org/r/20220829100121.3821-1-nicolas.dichtel@6wind= .com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/fib_frontend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -399,7 +399,7 @@ static int __fib_validate_source(struct dev_match =3D dev_match || (res.type =3D=3D RTN_LOCAL && dev =3D=3D net->loopback_dev); if (dev_match) { - ret =3D FIB_RES_NHC(res)->nhc_scope >=3D RT_SCOPE_HOST; + ret =3D FIB_RES_NHC(res)->nhc_scope >=3D RT_SCOPE_LINK; return ret; } if (no_addr) @@ -411,7 +411,7 @@ static int __fib_validate_source(struct ret =3D 0; if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) =3D=3D 0) { if (res.type =3D=3D RTN_UNICAST) - ret =3D FIB_RES_NHC(res)->nhc_scope >=3D RT_SCOPE_HOST; + ret =3D FIB_RES_NHC(res)->nhc_scope >=3D RT_SCOPE_LINK; } return ret;