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=-5.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 D7BC4C4363D for ; Thu, 24 Sep 2020 14:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75E412311A for ; Thu, 24 Sep 2020 14:41:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PMVgNPzU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728274AbgIXOl4 (ORCPT ); Thu, 24 Sep 2020 10:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728217AbgIXOl4 (ORCPT ); Thu, 24 Sep 2020 10:41:56 -0400 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B4ECC0613CE for ; Thu, 24 Sep 2020 07:41:56 -0700 (PDT) Received: by mail-oo1-xc35.google.com with SMTP id r10so845827oor.5 for ; Thu, 24 Sep 2020 07:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Zk1+q+hZj4nhxSPQHL+w1fjhMNXwWhW4NNOjLHy/5l0=; b=PMVgNPzUwcqPHzbbBcKi87pdFHUn/Qj2j3pBInA96oAWVRiSSsCrMK21rakzh7ICHR aU4J79z4NIOlaVrMRVgY7koSBUxSGs7+MImX9E32Rm8OTuV0J7EoPb6bFptq4XWjn3Dm bHD3AGcRLidAcrImgWJztDSIh/8qVAmY3GCxnm5Uux9Z92SoV87DVMssimRSTJzVyqLo oNiNks30T/mDMsRnvFuuxm5FpjPVmIBlFovYN1+W2rToO3Q1an3AGi+bVAMg/TGuvh5Z CpUQj/47vovbB3ur07iBwzvBRMhn78FQLqXoPdTawEWABd/7XgPuLN0DFZQw2k+uvLAA pGUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Zk1+q+hZj4nhxSPQHL+w1fjhMNXwWhW4NNOjLHy/5l0=; b=uFJ5bjgUD5B06GKYoa7MQZiNhucz7q0IGuyxQEiTIj67O90GSD2o/ZWLVKbKy1jQCQ is9wz0tZNnDh/VzkMyEYaBkd34TMMsk4EYywoJlCziR++qJdWnVgsoT7q03UB6nDEVX3 KvQ2xTREOECsmAQ1pRev5yzB2iczQ9dqbnhXhzbIi53DzLQScd6G/IeGGXtGYBSjFkO4 HNsaJQ3MzNWxtYTl3UUkCUhSQPu+rYa5ou4s7VQ+ByhhlG2SO8X/QZUttinFHZdm7CIe cMzFhgU29VQydlVlco8Guo583ZVMjKVnppW9bYrQuf58mI0MTCb4uqhRGZbNyLIra8rq ZUeA== X-Gm-Message-State: AOAM530k/P83tTMRtgPdBncmCjFjbVStagj0EDUW5SE9lupwh65gIZ9q Yb7qzQzmQf6qjNXQY/sNW/NLpg/cHYjvKw== X-Google-Smtp-Source: ABdhPJxSfThbUHx388AgSIFkjPULfdqBbYnJDceTD5rDrUyN294qJFYUIBXrfu2Tkpwtks6L2Lyjtg== X-Received: by 2002:a4a:bd90:: with SMTP id k16mr3679948oop.16.1600958515568; Thu, 24 Sep 2020 07:41:55 -0700 (PDT) Received: from Davids-MacBook-Pro.local ([2601:282:803:7700:5df2:2ea:febc:9ae2]) by smtp.googlemail.com with ESMTPSA id 187sm676898oie.42.2020.09.24.07.41.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2020 07:41:54 -0700 (PDT) Subject: Re: ip rule iif oif and vrf To: Stephen Suryaputra Cc: netdev@vger.kernel.org References: <20200922131122.GB1601@ICIPI.localdomain> <2bea9311-e6b6-91ea-574a-4aa7838d53ea@gmail.com> <20200923235002.GA25818@ICIPI.localdomain> <20200924134845.GA3688@ICIPI.localdomain> From: David Ahern Message-ID: <97ce9942-2115-ed3a-75ea-8b58aa799ceb@gmail.com> Date: Thu, 24 Sep 2020 08:41:54 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200924134845.GA3688@ICIPI.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 9/24/20 7:48 AM, Stephen Suryaputra wrote: > On Wed, Sep 23, 2020 at 07:47:16PM -0600, David Ahern wrote: >> If I remove the fib rules and add VRF route leaking from core to tenant >> it works. Why is that not an option? Overlapping tenant addresses? > > Exactly. > >> One thought to get around it is adding support for a new FIB rule type >> -- say l3mdev_port. That rule can look at the real ingress device which >> is saved in the skb->cb as IPCB(skb)->iif. > > OK. Just to ensure that the existing ip rule behavior isn't considered a > bug. > > We have multiple options on the table right now. One that can be done > without writing any code is to use an nft prerouting rule to mark > the packet with iif equals the tunnel and use ip rule fwmark to lookup > the right table. > > ip netns exec r0 nft add table ip c2t > ip netns exec r0 nft add chain ip c2t prerouting '{ type filter hook prerouting priority 0; policy accept; }' > ip netns exec r0 nft rule ip c2t prerouting iif gre01 mark set 101 counter > ip netns exec r0 ip rule add fwmark 101 table 10 pref 999 > > ip netns exec r1 nft add table ip c2t > ip netns exec r1 nft add chain ip c2t prerouting '{ type filter hook prerouting priority 0; policy accept; }' > ip netns exec r1 nft rule ip c2t prerouting iif gre10 mark set 101 counter > ip netns exec r1 ip rule add fwmark 101 table 10 pref 999 > > But this doesn't seem to work on my Ubuntu VM with the namespaces > script, i.e. pinging from h0 to h1. The packet doesn't egress r1_v11. It > does work on our target, based on 4.14 kernel. add debugs to net/core/fib_rules.c, fib_rule_match() to see if flowi_mark is getting set properly. There could easily be places that are missed. Or if it works on one setup, but not another compare sysctl settings for net.core and net.ipv4 > > We also notice though in on the target platform that the ip rule fwmark > doesn't seem to change the skb->dev to the vrf of the lookup table. not following that statement. fwmark should be marking the skb, not changing the skb->dev. > E.g., ping from 10.0.0.1 to 11.0.0.1. With net.ipv4.fwmark_reflect set, > the reply is generated but the originating ping application doesn't get > the packet. I suspect it is caused by the socket is bound to the tenant > vrf. I haven't been able to repro this because of the problem with the > nft approach above. > > Thanks, > Stephen. >