selftests/bpf: fix netdevsim trap_flow_action_cookie read

When read netdevsim trap_flow_action_cookie, we need to init it first,
or we will get "Invalid argument" error.

Fixes: d3cbb907ae ("netdevsim: add ACL trap reporting cookie as a metadata")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Hangbin Liu 2020-07-27 19:04:55 +08:00 committed by David S. Miller
parent 8c0de6e96c
commit 4bbca662df
1 changed files with 3 additions and 0 deletions

View File

@ -318,6 +318,9 @@ class DebugfsDir:
continue
if os.path.isfile(p):
# We need to init trap_flow_action_cookie before read it
if f == "trap_flow_action_cookie":
cmd('echo deadbeef > %s/%s' % (path, f))
_, out = cmd('cat %s/%s' % (path, f))
dfs[f] = out.strip()
elif os.path.isdir(p):