netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
To: Guillaume Nault <gnault@redhat.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: POSSIBLE BUG: selftests/net/fcnal-test.sh: [FAIL] in vrf "bind - ns-B IPv6 LLA" test
Date: Tue, 6 Jun 2023 08:24:54 +0200	[thread overview]
Message-ID: <a379796a-5cd6-caa7-d11d-5ffa7419b90e@alu.unizg.hr> (raw)
In-Reply-To: <ZHeN3bg28pGFFjJN@debian>

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

  parent reply	other threads:[~2023-06-06  6:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 12:17 POSSIBLE BUG: selftests/net/fcnal-test.sh: [FAIL] in vrf "bind - ns-B IPv6 LLA" test Mirsad Todorovac
2023-05-31 18:11 ` Guillaume Nault
2023-06-02 12:35   ` Mirsad Goran Todorovac
2023-06-06  6:24   ` Mirsad Goran Todorovac [this message]
2023-06-06 13:46     ` Guillaume Nault
2023-06-06 13:57       ` Mirsad Todorovac
2023-06-06 14:11         ` Guillaume Nault
2023-06-06 14:28           ` Mirsad Todorovac
2023-06-06 18:50             ` Guillaume Nault
2023-06-06 19:17               ` Mirsad Goran Todorovac
2023-06-06 19:27                 ` Guillaume Nault
2023-06-06 18:07       ` POSSIBLE BUG: selftests/net/fcnal-test.sh: [FAIL][FIX TESTED] " Mirsad Goran Todorovac
2023-06-06 18:57         ` Guillaume Nault
2023-06-06 22:04           ` Mirsad Goran Todorovac
2023-06-07 16:51             ` Guillaume Nault
2023-06-08  5:37               ` Mirsad Goran Todorovac
2023-06-09 16:13                 ` Guillaume Nault
2023-06-10 18:04                   ` Mirsad Goran Todorovac
2023-06-14  8:47                     ` Guillaume Nault
2023-06-15 20:10                       ` Mirsad Goran Todorovac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a379796a-5cd6-caa7-d11d-5ffa7419b90e@alu.unizg.hr \
    --to=mirsad.todorovac@alu.unizg.hr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gnault@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).