diff mbox series

[net-next] bpf: re-fix skip write only files in debugfs

Message ID 94ba2eebd8d6c48ca6da8626c9fa37f186d15f92.1572876157.git.daniel@iogearbox.net
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] bpf: re-fix skip write only files in debugfs | expand

Commit Message

Daniel Borkmann Nov. 4, 2019, 2:27 p.m. UTC
Commit 5bc60de50dfe ("selftests: bpf: Don't try to read files without
read permission") got reverted as the fix was not working as expected
and real fix came in via 8101e069418d ("selftests: bpf: Skip write
only files in debugfs"). When bpf-next got merged into net-next, the
test_offload.py had a small conflict. Fix the resolution in ae8a76fb8b5d
iby not reintroducing 5bc60de50dfe again.

Fixes: ae8a76fb8b5d ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Alexei Starovoitov <ast@kernel.org>
---
 [
   Hey Jakub, please take a look at the below merge fix ... still trying
   to figure out why the netdev doesn't appear on my test node when I
   wanted to run the test script, but seems independent of the fix.

   [...]
   [ 1901.270493] netdevsim: probe of netdevsim4 failed with error -17
   [...]

   # ./test_offload.py
   Test destruction of generic XDP...
   Traceback (most recent call last):
    File "./test_offload.py", line 800, in <module>
     simdev = NetdevSimDev()
    File "./test_offload.py", line 355, in __init__
     self.wait_for_netdevs(port_count)
    File "./test_offload.py", line 390, in wait_for_netdevs
     raise Exception("netdevices did not appear within timeout")
   Exception: netdevices did not appear within timeout
 ]

 tools/testing/selftests/bpf/test_offload.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Nov. 4, 2019, 4:27 p.m. UTC | #1
On Mon,  4 Nov 2019 15:27:02 +0100, Daniel Borkmann wrote:
> Commit 5bc60de50dfe ("selftests: bpf: Don't try to read files without
> read permission") got reverted as the fix was not working as expected
> and real fix came in via 8101e069418d ("selftests: bpf: Skip write
> only files in debugfs"). When bpf-next got merged into net-next, the
> test_offload.py had a small conflict. Fix the resolution in ae8a76fb8b5d
> iby not reintroducing 5bc60de50dfe again.
> 
> Fixes: ae8a76fb8b5d ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
> Cc: Alexei Starovoitov <ast@kernel.org>

Ayayay :(

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

>  [
>    Hey Jakub, please take a look at the below merge fix ... still trying
>    to figure out why the netdev doesn't appear on my test node when I
>    wanted to run the test script, but seems independent of the fix.
> 
>    [...]
>    [ 1901.270493] netdevsim: probe of netdevsim4 failed with error -17
>    [...]
> 
>    # ./test_offload.py
>    Test destruction of generic XDP...
>    Traceback (most recent call last):
>     File "./test_offload.py", line 800, in <module>
>      simdev = NetdevSimDev()
>     File "./test_offload.py", line 355, in __init__
>      self.wait_for_netdevs(port_count)
>     File "./test_offload.py", line 390, in wait_for_netdevs
>      raise Exception("netdevices did not appear within timeout")
>    Exception: netdevices did not appear within timeout
>  ]
> 
>  tools/testing/selftests/bpf/test_offload.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
> index fc8a4319c1b2..1afa22c88e42 100755
> --- a/tools/testing/selftests/bpf/test_offload.py
> +++ b/tools/testing/selftests/bpf/test_offload.py
> @@ -314,7 +314,10 @@ def bpftool_prog_load(sample, file_name, maps=[], prog_type="xdp", dev=None,
>                  continue
>  
>              p = os.path.join(path, f)
> -            if os.path.isfile(p) and os.access(p, os.R_OK):
> +            if not os.stat(p).st_mode & stat.S_IRUSR:
> +                continue
> +
> +            if os.path.isfile(p):
>                  _, out = cmd('cat %s/%s' % (path, f))
>                  dfs[f] = out.strip()
>              elif os.path.isdir(p):
David Miller Nov. 4, 2019, 7:37 p.m. UTC | #2
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Mon, 4 Nov 2019 08:27:21 -0800

> On Mon,  4 Nov 2019 15:27:02 +0100, Daniel Borkmann wrote:
>> Commit 5bc60de50dfe ("selftests: bpf: Don't try to read files without
>> read permission") got reverted as the fix was not working as expected
>> and real fix came in via 8101e069418d ("selftests: bpf: Skip write
>> only files in debugfs"). When bpf-next got merged into net-next, the
>> test_offload.py had a small conflict. Fix the resolution in ae8a76fb8b5d
>> iby not reintroducing 5bc60de50dfe again.
>> 
>> Fixes: ae8a76fb8b5d ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next")
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>> Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
>> Cc: Alexei Starovoitov <ast@kernel.org>
> 
> Ayayay :(
> 
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied.
Jakub Kicinski Nov. 5, 2019, 2:45 a.m. UTC | #3
On Mon,  4 Nov 2019 15:27:02 +0100, Daniel Borkmann wrote:
>  [
>    Hey Jakub, please take a look at the below merge fix ... still trying
>    to figure out why the netdev doesn't appear on my test node when I
>    wanted to run the test script, but seems independent of the fix.
> 
>    [...]
>    [ 1901.270493] netdevsim: probe of netdevsim4 failed with error -17
>    [...]
> 
>    # ./test_offload.py
>    Test destruction of generic XDP...
>    Traceback (most recent call last):
>     File "./test_offload.py", line 800, in <module>
>      simdev = NetdevSimDev()
>     File "./test_offload.py", line 355, in __init__
>      self.wait_for_netdevs(port_count)
>     File "./test_offload.py", line 390, in wait_for_netdevs
>      raise Exception("netdevices did not appear within timeout")
>    Exception: netdevices did not appear within timeout
>  ]

I got this fixed, looks like the merged also added back some duplicated
code, surreptitiously.

I'm still debugging another issue with the devlink.sh test which looks
broken.
Jakub Kicinski Nov. 5, 2019, 5:49 a.m. UTC | #4
On Mon, 4 Nov 2019 18:45:50 -0800, Jakub Kicinski wrote:
> On Mon,  4 Nov 2019 15:27:02 +0100, Daniel Borkmann wrote:
> >  [
> >    Hey Jakub, please take a look at the below merge fix ... still trying
> >    to figure out why the netdev doesn't appear on my test node when I
> >    wanted to run the test script, but seems independent of the fix.
> > 
> >    [...]
> >    [ 1901.270493] netdevsim: probe of netdevsim4 failed with error -17
> >    [...]
> > 
> >    # ./test_offload.py
> >    Test destruction of generic XDP...
> >    Traceback (most recent call last):
> >     File "./test_offload.py", line 800, in <module>
> >      simdev = NetdevSimDev()
> >     File "./test_offload.py", line 355, in __init__
> >      self.wait_for_netdevs(port_count)
> >     File "./test_offload.py", line 390, in wait_for_netdevs
> >      raise Exception("netdevices did not appear within timeout")
> >    Exception: netdevices did not appear within timeout
> >  ]  
> 
> I got this fixed, looks like the merged also added back some duplicated
> code, surreptitiously.
> 
> I'm still debugging another issue with the devlink.sh test which looks
> broken.

Looks like the resource tests didn't unwind the state and when health
tests were added they revealed the brokenness. A couple patches to
iproute2 are required to fix that, I'll send all the patches tomorrow.
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
index fc8a4319c1b2..1afa22c88e42 100755
--- a/tools/testing/selftests/bpf/test_offload.py
+++ b/tools/testing/selftests/bpf/test_offload.py
@@ -314,7 +314,10 @@  def bpftool_prog_load(sample, file_name, maps=[], prog_type="xdp", dev=None,
                 continue
 
             p = os.path.join(path, f)
-            if os.path.isfile(p) and os.access(p, os.R_OK):
+            if not os.stat(p).st_mode & stat.S_IRUSR:
+                continue
+
+            if os.path.isfile(p):
                 _, out = cmd('cat %s/%s' % (path, f))
                 dfs[f] = out.strip()
             elif os.path.isdir(p):