• Roman Gushchin's avatar
    samples/bpf: extend test_cgrp2_attach2 test to use cgroup storage · 28ba0687
    Roman Gushchin authored
    The test_cgrp2_attach test covers bpf cgroup attachment code well,
    so let's re-use it for testing allocation/releasing of cgroup storage.
    
    The extension is pretty straightforward: the bpf program will use
    the cgroup storage to save the number of transmitted bytes.
    
    Expected output:
      $ ./test_cgrp2_attach2
      Attached DROP prog. This ping in cgroup /foo should fail...
      ping: sendmsg: Operation not permitted
      Attached DROP prog. This ping in cgroup /foo/bar should fail...
      ping: sendmsg: Operation not permitted
      Attached PASS prog. This ping in cgroup /foo/bar should pass...
      Detached PASS from /foo/bar while DROP is attached to /foo.
      This ping in cgroup /foo/bar should fail...
      ping: sendmsg: Operation not permitted
      Attached PASS from /foo/bar and detached DROP from /foo.
      This ping in cgroup /foo/bar should pass...
      ### override:PASS
      ### multi:PASS
    Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    28ba0687
test_cgrp2_attach2.c 11.5 KB