Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4476135rwb; Tue, 6 Sep 2022 08:04:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5HBiiUUqzOObEpVGAQM9Yb41niVfPUGwQmEVMtShFfegdu49nhvgP4iivET78hYyvHjOBY X-Received: by 2002:a62:2fc6:0:b0:53e:285c:9b7f with SMTP id v189-20020a622fc6000000b0053e285c9b7fmr3417801pfv.58.1662476661462; Tue, 06 Sep 2022 08:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662476661; cv=none; d=google.com; s=arc-20160816; b=ZfzeT4Y/tWpdqBJdCKoXqo6TTi15gLNW9C3nc7s4vLFwN+u5W+pzy2UmHdMXowTNXc OXL3YkGLhTB0UWYgxO9lzBw7MRIReDO+FWEx5ydVe6pZZuJUe0TaDAkVrbkCMybG4fq+ LQV4fK+vDNUTdH1PdqAK4f2vH7/VthmXn4qIUu1asDNx4s/AD0UAmq2XKGwBOtoCRbJE le8AVc728qjZwXgqhxdUovBOR7pIcJ8QRlj6N26828EKKTJY3S1Otzj8pCu1YClVj4fy 2FEIr21mQ7/tRn3ITmexUxNKCWeZPRR1Jj9Ele3S0KTeNaZcczGQTa16kbKU38G/vJSq yVdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=anJUKgLmGd+joKh3LU7Q2DFK4Tj0dSad9YFD4TvX1jk=; b=PYNKlN13GNr+SwcKK+goSzR/xw1Hda5u0CTst/lu2LjXUWG+Db48HBrgCf47unT5If Y5k8J2T/uPJWA2sjSJ3I235e/Y+edoG8cfD8iYqJJrlDD48A0E+TqzYA9MivYnZlIROh NOBJBhsjTDqDc7GK1xdCz5DIh8Rkdh3fR9HBiwG6+OSl7vvdavY846+2ZUbFJ93Jr+NZ oekSD9hupsCIuDFYnheHCeAjYSQr/65w3BgZH+/9zHgXzY6WYpZLribB8C5rYsXvA16K Lnz77jTlwyGNp52hXh7PAaYX7jhZJkqNc/iSZEGgreTHe1YhIwJqT68ZrX7OZttfOixa Oplw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NAapCTsF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020a17090270cc00b00163f5028fe7si9094183plt.365.2022.09.06.08.04.09; Tue, 06 Sep 2022 08:04:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NAapCTsF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237686AbiIFNlX (ORCPT + 99 others); Tue, 6 Sep 2022 09:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233972AbiIFNkO (ORCPT ); Tue, 6 Sep 2022 09:40:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D852B7DF4E; Tue, 6 Sep 2022 06:37:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1785A61554; Tue, 6 Sep 2022 13:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20815C433D6; Tue, 6 Sep 2022 13:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471311; bh=CRt/nAFidu2/Fa+kSY83hNUBSE8UekJvMXGOpiPP4Fo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAapCTsFpZW0XxASrtbqhrduMjEhZPWRsR/KOq82xV7KhEXuaJEtIqX8m/cavKWqQ gDYwgBpylkLW7sT6shztLwyCwajjLADa94UAD9MTT/Glyl7S1+tgRUAxD0te5VmIsH UqoeJlZ1capSOWuZlpNinIpKJXJUj+Si/yu5n0Kk= 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.10 67/80] ip: fix triggering of icmp redirect Date: Tue, 6 Sep 2022 15:31:04 +0200 Message-Id: <20220906132819.883154337@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 @@ -389,7 +389,7 @@ static int __fib_validate_source(struct dev_match = dev_match || (res.type == RTN_LOCAL && dev == net->loopback_dev); if (dev_match) { - ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST; + ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_LINK; return ret; } if (no_addr) @@ -401,7 +401,7 @@ static int __fib_validate_source(struct ret = 0; if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) == 0) { if (res.type == RTN_UNICAST) - ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST; + ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_LINK; } return ret;