Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1068780pxp; Wed, 9 Mar 2022 20:19:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyg3is76d2vsJqHaXEpgbLbXeIczMaxyaHL/4aox/oOBzAcM6q1RgpvKSBmCJzsPrcDVLWA X-Received: by 2002:a63:6987:0:b0:380:117f:b4d6 with SMTP id e129-20020a636987000000b00380117fb4d6mr2481542pgc.618.1646885986205; Wed, 09 Mar 2022 20:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646885986; cv=none; d=google.com; s=arc-20160816; b=wlKpRyRFmMjjp5W+QeE6Mmu5XYZcdNFpvEdIetYFQFQ82DwiJL61hM3LrhCl5Nijud OSyqnclpIQ35BQOM6qdBWsgzRbt6sgXcNhzryGUJehAAT/NBTZhJgaXsNTlF83MoIbFR I7W8+IVm/hUIdN4zDc8ddWXkHw75t7NKMi9vEpsv7brf2Z62M8yvBi2q717ssbQPMBu/ fBUhyDHuggEQaeltSTEOVudr62r93M3G1EtoNxwY4/BSNv++p4iR7PdzQZTAv4Tsd/re ybzE596ykLgChXkC7Io1Jw1P34Y/d6PbmhM6XiIkZlybAYbQuP4h0XVNJQFMc/NRffzP nIRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=CLYcWg/E1WptTxIOcFEusxNg2r7FZ7HtW2ixompz6uc=; b=zDIKZ8h7RhuEI0hNXdqaLWywKOpya4je2Ro54lIPsMY0Z96CPrpnwhqXBIcI+8cl7n MyspyKKdcaOG2nhnjTLP0UFjidMP3hRJpjGnzOIWS7eNHfvnQTqBWFQ5db89le/It+4e HNn4kKklo6rDIq1ZA6PUFh6VQCzOdqVKvMU3K3HV4GCh575Et193wuykLqZivwOxf3Ju qVktwD5c66xwCg1llUCYLgcJTw9fQ3da5PPvOUYsraPJq8AP5fOtTiKYGai5EYRO0ELg L9/q/m2NK7+GogAswf2Ml5k7kXlvvX+Ttb/VeZ3OV+na7KH9gGErxg44gCADnu6m20bH 4ioA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a17090a9bc200b001bf71a5a3fcsi788763pjw.175.2022.03.09.20.19.24; Wed, 09 Mar 2022 20:19:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239216AbiCJDV0 (ORCPT + 99 others); Wed, 9 Mar 2022 22:21:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237642AbiCJDVY (ORCPT ); Wed, 9 Mar 2022 22:21:24 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54278120EB8; Wed, 9 Mar 2022 19:20:24 -0800 (PST) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KDZ2D2Tlzz1GCLX; Thu, 10 Mar 2022 11:15:32 +0800 (CST) Received: from [10.174.179.200] (10.174.179.200) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 10 Mar 2022 11:20:21 +0800 Subject: Re: IPv4 saddr do not match with selected output device in double default gateways scene To: David Ahern , David Miller , , Jakub Kicinski , netdev , CC: Linux Kernel Mailing List References: <58c15089-f1c7-675e-db4b-b6dfdad4b497@huawei.com> <0f97539a-439f-d584-9ba3-f4bd5a302bc0@kernel.org> From: "Ziyang Xuan (William)" Message-ID: <86c61138-c82c-a403-664c-a61d651008b0@huawei.com> Date: Thu, 10 Mar 2022 11:20:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <0f97539a-439f-d584-9ba3-f4bd5a302bc0@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.200] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 > On 3/7/22 11:41 PM, Ziyang Xuan (William) wrote: >> Create VLAN devices and add default gateways with following commands: >> >> # ip link add link eth2 dev eth2.71 type vlan id 71 >> # ip link add link eth2 dev eth2.72 type vlan id 72 >> # ip addr add 192.168.71.41/24 dev eth2.71 >> # ip addr add 192.168.72.41/24 dev eth2.72 >> # ip link set eth2.71 up >> # ip link set eth2.72 up >> # route add -net default gw 192.168.71.1 dev eth2.71 >> # route add -net default gw 192.168.72.1 dev eth2.72 >> > > ... > >> We can find that IPv4 saddr "192.168.72.41" do not match with selected VLAN device "eth2.71". >> >> I tracked the related processes, and found that user space program uses connect() firstly, then sends UDP packet. >> > > ... > >> Deep tracking, it because fa->fa_default has changed in fib_select_default() after first __ip_route_output_key() process, >> and a new fib_nh is selected in fib_select_default() within the second __ip_route_output_key() process but not update flowi4. >> So the phenomenon described at the beginning happens. >> >> Does it a kernel bug or a user problem? If it is a kernel bug, is there any good solution? > > That is a known problem with multipath routes. > . > Does the community have a plan to address it?