Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4763855iob; Mon, 9 May 2022 00:38:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSM6X6aHZ0lH4uOrQpPEKdnmgw2GTUjug6oaAqyfvRfMkeVOCgH17omRulBTMgZdxcGoLh X-Received: by 2002:a05:6a00:711:b0:4fa:daf1:94c1 with SMTP id 17-20020a056a00071100b004fadaf194c1mr14811449pfl.52.1652081915508; Mon, 09 May 2022 00:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652081915; cv=none; d=google.com; s=arc-20160816; b=0FUZXTFoFCt0blgTNutqveisx8vQsQhLSfgfV7B0b37Cbd3Zcr+Ms5W6fmszKFb5E7 rsAyrd0mutedAxaWb5Y5PDJV6pARYAR2SOy+0bVUXrCKt2eUxxUTChF7wnN3QY08BhXr gfeDzx1l2nHF8Wcak5/gPvNnknipFNroz6iexKEELj6AOWkcfyMlGX+UfQqel8DLFcQz nmCMb17UEKDGy612YDrvY5ttu/A8yeVAZkxrDmQhEdDpAdHtUxChL3tGJFGXslwJEBfK I4w5dnt1TnuSlVr66ilq7eFJ5OIZd6ksBjrJv82yBqWBIACtZoApb3LLkUoYhmyKG3cH OpRw== 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=Y1v+J/roHSM1DpT3LZVtnfuQFy2xhXXnfeEbXaOFToI=; b=ZoaBCYaB1ETGIe+0P1e6i//8/G+Dkxa+KLU/Zg7vXKnPlwngV1Bpl9NJh7nPnKG1QP uXbQCXBMmD0TCMYQw3iHZ4zOySYXCvA2JHkwBx2adX9oSJAZlEm7xZneGnZFErszmlA0 TqAQuxklJXxC3Y03EOWG+ETz8YvVsaEczeBSLl2qJC4bn9F4y7ROZrPZLVlcDX15PFtS ah2PVh1Ld490XvX1DAo2jJon/Sjqh0VnzVHn2g+l9ux8CpT89ra5oMzLN525Sb6yGN+6 neJoGnuaIGB/wLP/SqdENhhf4UiDAANG7IUtkgOcBPgB4G1ijnxJBDRF/kqQsteNtU0F eZuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P3qZt5Cp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k9-20020a63ff09000000b003816043f09fsi13892333pgi.660.2022.05.09.00.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 00:38:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P3qZt5Cp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A697E1BDAED; Mon, 9 May 2022 00:34:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359042AbiEDRnk (ORCPT + 99 others); Wed, 4 May 2022 13:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356121AbiEDRJD (ORCPT ); Wed, 4 May 2022 13:09:03 -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 3D181522EE; Wed, 4 May 2022 09:54:53 -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 B4F97B827A4; Wed, 4 May 2022 16:54:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D362C385AA; Wed, 4 May 2022 16:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683291; bh=u9mrsRgfGoMizZbDVPeNz/JA+WQ2trwoY2joYBPE0rY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P3qZt5CpQu1lXvCo9JTOrAyHgt2wdAo+4QbPdLOfnyDojLt1i88tdoRQ7IdRkiB8P PDwRJgUS5PtK0mlLsa8YWlpmKQ3SSCSunp1BJFsv76GXaNLOG4A3yp+x0rYIh0+O0O LkdGJ4+Buev0URPRjIABzqojkJtiqOh4zEa9ZZfw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Willi , David Ahern , Pablo Neira Ayuso Subject: [PATCH 5.15 145/177] netfilter: Update ip6_route_me_harder to consider L3 domain Date: Wed, 4 May 2022 18:45:38 +0200 Message-Id: <20220504153106.263366871@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Martin Willi commit 8ddffdb9442a9d60b4a6e679ac48d7d21403a674 upstream. The commit referenced below fixed packet re-routing if Netfilter mangles a routing key property of a packet and the packet is routed in a VRF L3 domain. The fix, however, addressed IPv4 re-routing, only. This commit applies the same behavior for IPv6. While at it, untangle the nested ternary operator to make the code more readable. Fixes: 6d8b49c3a3a3 ("netfilter: Update ip_route_me_harder to consider L3 domain") Cc: stable@vger.kernel.org Signed-off-by: Martin Willi Reviewed-by: David Ahern Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/ipv6/netfilter.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/net/ipv6/netfilter.c +++ b/net/ipv6/netfilter.c @@ -24,14 +24,13 @@ int ip6_route_me_harder(struct net *net, { const struct ipv6hdr *iph = ipv6_hdr(skb); struct sock *sk = sk_to_full_sk(sk_partial); + struct net_device *dev = skb_dst(skb)->dev; struct flow_keys flkeys; unsigned int hh_len; struct dst_entry *dst; int strict = (ipv6_addr_type(&iph->daddr) & (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL)); struct flowi6 fl6 = { - .flowi6_oif = sk && sk->sk_bound_dev_if ? sk->sk_bound_dev_if : - strict ? skb_dst(skb)->dev->ifindex : 0, .flowi6_mark = skb->mark, .flowi6_uid = sock_net_uid(net, sk), .daddr = iph->daddr, @@ -39,6 +38,13 @@ int ip6_route_me_harder(struct net *net, }; int err; + if (sk && sk->sk_bound_dev_if) + fl6.flowi6_oif = sk->sk_bound_dev_if; + else if (strict) + fl6.flowi6_oif = dev->ifindex; + else + fl6.flowi6_oif = l3mdev_master_ifindex(dev); + fib6_rules_early_flow_dissect(net, skb, &fl6, &flkeys); dst = ip6_route_output(net, sk, &fl6); err = dst->error;