Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6689813rwd; Tue, 6 Jun 2023 00:02:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DMOHWWzod1y+nzMJNpk5W9uWnu40q2rXQCsAnIEmtLM0LkylfiH44zEZWAz6y2bwvG8lF X-Received: by 2002:a05:620a:6883:b0:75e:ba28:c5c4 with SMTP id rv3-20020a05620a688300b0075eba28c5c4mr1487210qkn.11.1686034946424; Tue, 06 Jun 2023 00:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686034946; cv=none; d=google.com; s=arc-20160816; b=xPXt+b2w4rOsvL4xbrGWN0AOc+kRsqQBGPW50GFB8U9QgfRxsbEhiT8q0mRIfKup4b Ex8g7K10kTYwjO3CKif8WsLaqE06TeR8g5u1UoqUtwR5Ki/V0VeTlIaFCuCv2FqgdxeI Dq65xMs5y7X11G9OdN6mPk12rVTefg8CakeyDLulqYxNCP3evze8zR/+Y+9if/UsqsYX j7UJqfCs6NlaVehI4PrxzfOv9yNBL0EX+18/dW2emqVx309vXTkt0NQ7cJbe5HAyJAy6 pZdfiRipMaukrR6uo82KLYRtlBhCijhhkk11TcRzPZtZG0WFxmIPdGdeCfPZiszEvLtY trSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:dkim-signature; bh=G0PHu4Zk97AK7M34tB6RKOh8sR/gIcSVSWsjn9b/RT0=; b=Rlh6vnXKJtL7x5fTZOHvG09wp5n9H85AeAM/NEHOjtSrkOQhkXQwyYjyZZgHH58wV6 aZEF+2UoE2/bc1oxLITkEQcQ3ONgB8Q/gj+OE/v62AI0lRwre8ZJPS9qQbDNypnmgJTX dHfK2eSDv0tr3/Ev3rIuDX6Ip4UCj+fBD+09bkdqnibhM2jWyvgn7zQGZCY4jQO3VAfM oPRQjpY+HH1X0jxwHYXDri+zDMEWb6pibZIbieJ5R/GMy6p/fuXVPBYjF/pgRJeBeTXp 4fbvvsRp0YjRF3KkUV8koY0QDVB7VESeysZhvSM2d4XTjQo9BNqxjPV6v1u6TvD+DABj 3SZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=BhtJLtJY; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=aC0wknAH; 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=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z7-20020ae9c107000000b0074acfee9e82si5531924qki.41.2023.06.06.00.02.11; Tue, 06 Jun 2023 00:02:26 -0700 (PDT) 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; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=BhtJLtJY; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=aC0wknAH; 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=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235318AbjFFG1B (ORCPT + 99 others); Tue, 6 Jun 2023 02:27:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234856AbjFFG0m (ORCPT ); Tue, 6 Jun 2023 02:26:42 -0400 Received: from domac.alu.hr (domac.alu.unizg.hr [IPv6:2001:b68:2:2800::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DA2810D3; Mon, 5 Jun 2023 23:25:32 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 96391601A8; Tue, 6 Jun 2023 08:25:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1686032729; bh=rjPsMuGvKZwQ0U+WkOYb2CanbJCvdc78Dm+dRdNT2KU=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=BhtJLtJYjBLaKm3E8xnID9Kmz6Ourd86jqyCoonDdTgWgJ5dGz1BUrEdv7DJpe32e vDKLEi4pk0Nd/cJSVJy08L+xkSkMIbquAMj25pHMQbaYg7TE+JplU1kXZ1onfb7vxA pp4paEut2OGFTIBu26jFKn97J0PuLH1Ms9RfN/HbuZGkhhSVADr71Johk6pWH4sJUH eO0hCeMulqcC0Flj7gR0dtnxcmRcPvmNrHho9e/cXMg8jvTBM+uolxBFEQ1dLg26cP gjdIPugRWPxVDX9RtGGDpk3JEl6ese60uve6NbTH4ZGFcWj6QREJHC81zAEFqnkpXq rYqtzAlEYbLEg== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hvSNORR0uzKf; Tue, 6 Jun 2023 08:25:27 +0200 (CEST) Received: from [192.168.1.6] (unknown [77.237.113.62]) by domac.alu.hr (Postfix) with ESMTPSA id 68353601A7; Tue, 6 Jun 2023 08:24:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1686032727; bh=rjPsMuGvKZwQ0U+WkOYb2CanbJCvdc78Dm+dRdNT2KU=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=aC0wknAHsqPblClIELwQ8CrmFLBikkJqUz03jCU0JPdiRjQJ1aop+CIjeXh++ASy2 I6KJczErPI7HLRI+bfOk3qKU+3u3DIRKKARK+hz8IakUS5pQW74nKqVmeOSbCowXi5 39PA2ZO3BVLvYcNOQRxLwGvjgR/xS/YS2+LTYcfyg2BlngsKSaUh8fEBQXGJYSz+So wBlqjSpYuQ2vNVDfK7d2lITVuwJBtr4vMuS8ztgOq+N7Rq4HBCCogu95FO5PU6Tkqa /w9Y9TZWn5I9YA60bLKmzNhlekpnixy+GJyQcRPhkZ4xLxWQXCtQDMcenrvffkhXxO Mmh7Co1UJKJ/w== Message-ID: Date: Tue, 6 Jun 2023 08:24:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 From: Mirsad Goran Todorovac Subject: Re: POSSIBLE BUG: selftests/net/fcnal-test.sh: [FAIL] in vrf "bind - ns-B IPv6 LLA" test To: Guillaume Nault Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 5/31/23 20:11, Guillaume Nault wrote: > On Wed, May 24, 2023 at 02:17:09PM +0200, Mirsad Todorovac wrote: >> Hi, > > Hi Mirsad, > >> The very recent 6.4-rc3 kernel build with AlmaLinux 8.7 on LENOVO 10TX000VCR >> desktop box fails one test: >> >> [root@host net]# ./fcnal-test.sh >> [...] >> TEST: ping out, vrf device+address bind - ns-B loopback IPv6 [ OK ] >> TEST: ping out, vrf device+address bind - ns-B IPv6 LLA [FAIL] >> TEST: ping in - ns-A IPv6 [ OK ] >> [...] >> Tests passed: 887 >> Tests failed: 1 >> [root@host net]# > > This test also fails on -net. The problem is specific to ping sockets > (same test passes with raw sockets). I believe this test has always > failed since fcnal-test.sh started using net.ipv4.ping_group_range > (commit e71b7f1f44d3 ("selftests: add ping test with ping_group_range > tuned")). > > The executed command is: > > ip netns exec ns-A ip vrf exec red /usr/bin/ping6 -c1 -w1 -I 2001:db8:3::1 fe80::a846:b5ff:fe4c:da4e%eth1 > > So ping6 is executed inside VRF 'red' and sets .sin6_scope_id to 'eth1' > (which is a slave device of VRF 'red'). Therefore, we have > sk->sk_bound_dev_if == 'red' and .sin6_scope_id == 'eth1'. This fails > because ping_v6_sendmsg() expects them to be equal: > > static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) > { > ... > if (__ipv6_addr_needs_scope_id(ipv6_addr_type(daddr))) > oif = u->sin6_scope_id; > ... > if ((__ipv6_addr_needs_scope_id(addr_type) && !oif) || > (addr_type & IPV6_ADDR_MAPPED) || > (oif && sk->sk_bound_dev_if && oif != sk->sk_bound_dev_if)) <-- oif='eth1', but ->sk_bound_dev_if='red' > return -EINVAL; > ... > } > > I believe this condition should be relaxed to allow the case where > ->sk_bound_dev_if is oif's master device (and maybe there are other > VRF cases to also consider). I've tried something like this, but something makes the kernel stuck here: TEST: ping out, blocked by route - ns-B loopback IPv6 [ OK ] TEST: ping out, device bind, blocked by route - ns-B loopback IPv6 [ OK ] TEST: ping in, blocked by route - ns-A loopback IPv6 [ OK ] TEST: ping out, unreachable route - ns-B loopback IPv6 [ OK ] TEST: ping out, device bind, unreachable route - ns-B loopback IPv6 [ OK ] ################################################################# With VRF [hanged process and kernel won't shutdown] The code is: --- net/ipv6/ping.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index c4835dbdfcff..81293e902293 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c @@ -73,6 +73,9 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) struct rt6_info *rt; struct pingfakehdr pfh; struct ipcm6_cookie ipc6; + struct net *net = sock_net(sk); + struct net_device *dev = NULL; + struct net_device *mdev = NULL; err = ping_common_sendmsg(AF_INET6, msg, len, &user_icmph, sizeof(user_icmph)); @@ -111,10 +114,17 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) else if (!oif) oif = np->ucast_oif; + if (oif) { + dev = dev_get_by_index(net, oif); + mdev = netdev_master_upper_dev_get(dev); + } + addr_type = ipv6_addr_type(daddr); if ((__ipv6_addr_needs_scope_id(addr_type) && !oif) || (addr_type & IPV6_ADDR_MAPPED) || - (oif && sk->sk_bound_dev_if && oif != sk->sk_bound_dev_if)) + (oif && sk->sk_bound_dev_if && oif != sk->sk_bound_dev_if && + !(mdev && sk->sk_bound_dev_if && + mdev != dev_get_by_index(net, sk->sk_bound_dev_if)))) return -EINVAL; ipcm6_init_sk(&ipc6, np); I am obviously doing something very stupid. Regards, Mirsad