From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDF94C282C2 for ; Wed, 13 Feb 2019 18:46:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B98EE20835 for ; Wed, 13 Feb 2019 18:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550083605; bh=gzVnmnmzdM/kzCjwvKbx+hK6zO61rF2m5sxJBh30GcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aVIy+zeg3CiP5Q9JaYd1goY76/VFNfCbbmJBEYs47yQ8ix41Fbuh6TFoDaPh3xEf9 g+JO96S4DY0LNmo75+8wDOkn6rMfpiQEtEcGqtqy1ijCaB7Rqv8H561Z8FPjeT1B1Q rKe0bei/b59+UWSpKRvgFI7Tkc0NF1FaJdYrI+3E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406502AbfBMSqp (ORCPT ); Wed, 13 Feb 2019 13:46:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:45184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406486AbfBMSqi (ORCPT ); Wed, 13 Feb 2019 13:46:38 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2ED8F20811; Wed, 13 Feb 2019 18:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550083597; bh=gzVnmnmzdM/kzCjwvKbx+hK6zO61rF2m5sxJBh30GcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MVL25ECvrJVOVDO1Gexl5W0ArVi2w+HudoeWlGMJssRQk8QsCSEhzpDnFA6ENzykc WXzbGo53GpGYvmM8CknF9LxNqIUExvUBZKA1UW9v1M0Gg85GYFvBNouq4Mpbn7PmML AxpSbcawKOimUBYAeuUGPCRa4YS8+GkmgHTjfwPs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benedict Wong , Steffen Klassert Subject: [PATCH 4.20 44/50] xfrm: Make set-mark default behavior backward compatible Date: Wed, 13 Feb 2019 19:38:49 +0100 Message-Id: <20190213183659.167323266@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213183655.747168774@linuxfoundation.org> References: <20190213183655.747168774@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benedict Wong commit e2612cd496e7b465711d219ea6118893d7253f52 upstream. Fixes 9b42c1f179a6, which changed the default route lookup behavior for tunnel mode SAs in the outbound direction to use the skb mark, whereas previously mark=0 was used if the output mark was unspecified. In mark-based routing schemes such as Android’s, this change in default behavior causes routing loops or lookup failures. This patch restores the default behavior of using a 0 mark while still incorporating the skb mark if the SET_MARK (and SET_MARK_MASK) is specified. Tested with additions to Android's kernel unit test suite: https://android-review.googlesource.com/c/kernel/tests/+/860150 Fixes: 9b42c1f179a6 ("xfrm: Extend the output_mark to support input direction and masking") Signed-off-by: Benedict Wong Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/xfrm/xfrm_policy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -1628,7 +1628,10 @@ static struct dst_entry *xfrm_bundle_cre dst_copy_metrics(dst1, dst); if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { - __u32 mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]); + __u32 mark = 0; + + if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m) + mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]); family = xfrm[i]->props.family; dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif,