Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9243387pxu; Mon, 28 Dec 2020 10:15:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTicfjrQ5Dftts1qe7E2+tudLi8VmMh3PCM5gkdsvOA7YSn5Bz/y8QiEo4njfwUBuIrSKQ X-Received: by 2002:a05:6402:366:: with SMTP id s6mr42818992edw.44.1609179304709; Mon, 28 Dec 2020 10:15:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609179304; cv=none; d=google.com; s=arc-20160816; b=epTyDft4o2D9WxC0XYE2uhUls3lykbKq4w/B4LpmAWgfvo8Kaj98s9aCm5ajtfwbBA yH5dyC58oZ2liROMgk7sfWP/y4QTYXJxiniaeSq1BRdUxlOmyAw4HvoJTT81aFeXJ6YE 2mbHvWEWiJJfvCZSHjLJz3un0xtoGWIOx/3U1cHB8Z4ttHyZCUtjB5qVbep2LpVdD7Lf GgZGvLR3EDM0tTGE8HzU/dX0B+sveGFPiHaoTIcuErjq/iSbfI0i9FU1v8dn3DNf1xA1 87hpGGtIbvFrhhskpxNSOR3crpLFYaGfkSG5VDW+P+zkM4O5gVbaOZRxpZlMzFv0PUrk xF7w== 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=vef/R6nxwwgGut/I9jzB8/zWN3bQWvHp+dkjtcw+6CE=; b=qqYbPlH8tdSnS8OJGIbP4ayfdRRaGj1l9nUWiWtqaPvno4LfonabZ9zyAUgUYAj+Kj 40b6f96ROjUdoZlSeiymBVd/e6seLqc7NX1mo/nEqVgUs+c9RE+WopcSTsOXFL4b0eou 6LTWxxELv0D9F0PWxn1jXx1Q72f1rHBYLrXnGDVmLR33IDfyBx5Wz7Dk07eF1ZVZqsCx zxO4ncS0KvlizxXacygOEWRc04mRAx1GIDM5XsS6wA1eFKTrwiN55jyXuNnBdDTTNtpl /iwhXGMHlQjGr3H8p4P/q2tmaR2q1yFf98RQ9f9uSPUAR6VsylDAm5A+a44bdPZsnZXd AFKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2WA0za1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c22si5038953ejd.523.2020.12.28.10.14.42; Mon, 28 Dec 2020 10:15:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2WA0za1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2389647AbgL1N1i (ORCPT + 99 others); Mon, 28 Dec 2020 08:27:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:55016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389292AbgL1N0N (ORCPT ); Mon, 28 Dec 2020 08:26:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2926B208D5; Mon, 28 Dec 2020 13:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161932; bh=lKUKgVhGoxoF78/HQuY7Nq7q2AACJYLhri4h8N3WYHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2WA0za1rOTdrW5MrNKfw5WB/+vA7KgHrWVJqmkHpF1csQiNm5r7rekfZWt2LbasfL iXGCSu1bnJI8eErFI8oOm7NordqnupiIKGSdbCd3QuLcZtU68JsyCzs+yWaABgflZE MkrcprgmbLmPqzvczLvV6eMdN5gKiyon6mPfsbOk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Bernat , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 132/346] net: evaluate net.ipvX.conf.all.ignore_routes_with_linkdown Date: Mon, 28 Dec 2020 13:47:31 +0100 Message-Id: <20201228124926.168774822@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124919.745526410@linuxfoundation.org> References: <20201228124919.745526410@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Bernat [ Upstream commit c0c5a60f0f1311bcf08bbe735122096d6326fb5b ] Introduced in 0eeb075fad73, the "ignore_routes_with_linkdown" sysctl ignores a route whose interface is down. It is provided as a per-interface sysctl. However, while a "all" variant is exposed, it was a noop since it was never evaluated. We use the usual "or" logic for this kind of sysctls. Tested with: ip link add type veth # veth0 + veth1 ip link add type veth # veth1 + veth2 ip link set up dev veth0 ip link set up dev veth1 # link-status paired with veth0 ip link set up dev veth2 ip link set up dev veth3 # link-status paired with veth2 # First available path ip -4 addr add 203.0.113.${uts#H}/24 dev veth0 ip -6 addr add 2001:db8:1::${uts#H}/64 dev veth0 # Second available path ip -4 addr add 192.0.2.${uts#H}/24 dev veth2 ip -6 addr add 2001:db8:2::${uts#H}/64 dev veth2 # More specific route through first path ip -4 route add 198.51.100.0/25 via 203.0.113.254 # via veth0 ip -6 route add 2001:db8:3::/56 via 2001:db8:1::ff # via veth0 # Less specific route through second path ip -4 route add 198.51.100.0/24 via 192.0.2.254 # via veth2 ip -6 route add 2001:db8:3::/48 via 2001:db8:2::ff # via veth2 # H1: enable on "all" # H2: enable on "veth0" for v in ipv4 ipv6; do case $uts in H1) sysctl -qw net.${v}.conf.all.ignore_routes_with_linkdown=1 ;; H2) sysctl -qw net.${v}.conf.veth0.ignore_routes_with_linkdown=1 ;; esac done set -xe # When veth0 is up, best route is through veth0 ip -o route get 198.51.100.1 | grep -Fw veth0 ip -o route get 2001:db8:3::1 | grep -Fw veth0 # When veth0 is down, best route should be through veth2 on H1/H2, # but on veth0 on H2 ip link set down dev veth1 # down veth0 ip route show [ $uts != H3 ] || ip -o route get 198.51.100.1 | grep -Fw veth0 [ $uts != H3 ] || ip -o route get 2001:db8:3::1 | grep -Fw veth0 [ $uts = H3 ] || ip -o route get 198.51.100.1 | grep -Fw veth2 [ $uts = H3 ] || ip -o route get 2001:db8:3::1 | grep -Fw veth2 Without this patch, the two last lines would fail on H1 (the one using the "all" sysctl). With the patch, everything succeeds as expected. Also document the sysctl in `ip-sysctl.rst`. Fixes: 0eeb075fad73 ("net: ipv4 sysctl option to ignore routes when nexthop link is down") Signed-off-by: Vincent Bernat Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- Documentation/networking/ip-sysctl.txt | 3 +++ include/linux/inetdevice.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index 3c617d620b6f8..94d42eb83588b 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -1300,6 +1300,9 @@ igmpv3_unsolicited_report_interval - INTEGER IGMPv3 report retransmit will take place. Default: 1000 (1 seconds) +ignore_routes_with_linkdown - BOOLEAN + Ignore routes whose link is down when performing a FIB lookup. + promote_secondaries - BOOLEAN When a primary IP address is removed from this interface promote a corresponding secondary IP address instead of diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index a64f21a97369a..11adf828edf58 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -126,7 +126,7 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev) IN_DEV_ORCONF((in_dev), ACCEPT_REDIRECTS))) #define IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) \ - IN_DEV_CONF_GET((in_dev), IGNORE_ROUTES_WITH_LINKDOWN) + IN_DEV_ORCONF((in_dev), IGNORE_ROUTES_WITH_LINKDOWN) #define IN_DEV_ARPFILTER(in_dev) IN_DEV_ORCONF((in_dev), ARPFILTER) #define IN_DEV_ARP_ACCEPT(in_dev) IN_DEV_ORCONF((in_dev), ARP_ACCEPT) -- 2.27.0