Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724902pxb; Tue, 2 Feb 2021 16:47:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUHyXT5EvsYlf4UAchGalQp5bYDf+lihQyCwChs6qCTo2NbHl6em+hFu0ioGCIf2jYjrK4 X-Received: by 2002:a17:906:15c7:: with SMTP id l7mr638422ejd.226.1612313261871; Tue, 02 Feb 2021 16:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313261; cv=none; d=google.com; s=arc-20160816; b=iZ6WvXP2LuKOiXVa07t/YjktJumnRbajve1pghQBaHj+xVfTZJ2fEIsA4Mk9V7L2bI lbkqtMq3PuhN7rFxt+122GIqTGRfzOqmUFD0o5aUt1nRRfjdSkqbsAKKUr+a9+jqtml4 fxsOd7FVLYeBV6HbRBXfYz3mftC+pT3T9tJVFIxUeGori3i4HxUFBz9IbW7bs75EHLSF A6eMqqBg8TSFY6t/helL7mKoox9ijBr05HNaMK4YHP1kCpupkGykcLA/Yk/84ppfkZ8D wEbGNiLZQrDLDFD+ksREZXpPuQ3nD3R55tCccRYJA63S6FY9L0cUo5s0YKXVGZfsVTTG kuIQ== 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=FemeNoKOsyGlscmNMvFXRnblsDoixe3EhPYZ/1D0NhA=; b=C5Acu2uk5Wi9kD7CcQvLbzB0pxErgq5TWbGz+dLIu2L6mY+O42A4RXU3ICx1iU2C5U cTFTzYKb6ZoGw8gSZXA8S1m1FiiZduQiqCgwJbOfJShpfmPuXsHRTM+AFFOc44dBgK84 sgg7Swzmx7WDiI/NljRPHz+uPRZ8eJ3wZio2uk3gLW7Esc4h/34Ju5NTX4Fdf2B3N18F DNwlG7qqtD+vgGWgmd83nFOtftx0vPIdke+yrpQvMI9CcPv+JNidJX0y/8167lydWdDV mtnGdnCXkIrQsuk+le9gVU0Vr1NQv8fQIIyvLocl7EJi90WonaPYNysEukWe11hOmb/y LdyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QtMGVJOE; 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 bc7si223920edb.41.2021.02.02.16.47.17; Tue, 02 Feb 2021 16:47:41 -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=QtMGVJOE; 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 S239898AbhBBTnL (ORCPT + 99 others); Tue, 2 Feb 2021 14:43:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:40788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233285AbhBBNxl (ORCPT ); Tue, 2 Feb 2021 08:53:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EC01964FCC; Tue, 2 Feb 2021 13:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273449; bh=tQ/V8Pgt9hEUqKKULNEDAVcjUSpt+lU7tBqP3fhxx5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QtMGVJOE3jCtJrDWgwXufLMnJsJPpWc3jtpa+mjiUyrHrRH496mw2Cqf9AiP/Df8P nnfHrtG6WDd8hI2Av/nGCo8gQ/r7n88Y2g6XZVA18BY2dGnm9OQifzxxuJ+AsmLmuP gqUNVC06Jv+aHPySH812m8/DTWeyyxFQrA0HH0LQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eyal Birger , Steffen Klassert , Sasha Levin Subject: [PATCH 5.10 079/142] xfrm: fix disable_xfrm sysctl when used on xfrm interfaces Date: Tue, 2 Feb 2021 14:37:22 +0100 Message-Id: <20210202133000.966644502@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@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: Eyal Birger [ Upstream commit 9f8550e4bd9d78a8436c2061ad2530215f875376 ] The disable_xfrm flag signals that xfrm should not be performed during routing towards a device before reaching device xmit. For xfrm interfaces this is usually desired as they perform the outbound policy lookup as part of their xmit using their if_id. Before this change enabling this flag on xfrm interfaces prevented them from xmitting as xfrm_lookup_with_ifid() would not perform a policy lookup in case the original dst had the DST_NOXFRM flag. This optimization is incorrect when the lookup is done by the xfrm interface xmit logic. Fix by performing policy lookup when invoked by xfrmi as if_id != 0. Similarly it's unlikely for the 'no policy exists on net' check to yield any performance benefits when invoked from xfrmi. Fixes: f203b76d7809 ("xfrm: Add virtual xfrm interfaces") Signed-off-by: Eyal Birger Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_policy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index d622c2548d229..2f84136af48ab 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -3078,8 +3078,8 @@ struct dst_entry *xfrm_lookup_with_ifid(struct net *net, xflo.flags = flags; /* To accelerate a bit... */ - if ((dst_orig->flags & DST_NOXFRM) || - !net->xfrm.policy_count[XFRM_POLICY_OUT]) + if (!if_id && ((dst_orig->flags & DST_NOXFRM) || + !net->xfrm.policy_count[XFRM_POLICY_OUT])) goto nopol; xdst = xfrm_bundle_lookup(net, fl, family, dir, &xflo, if_id); -- 2.27.0