0001
0002
0003
0004
0005
0006
0007 #include <errno.h>
0008 #include <linux/bpf.h>
0009 #include <bpf/bpf_helpers.h>
0010
0011 __u32 invocations = 0;
0012 __u32 assertion_error = 0;
0013 __u32 retval_value = 0;
0014 __u32 ctx_retval_value = 0;
0015
0016 SEC("cgroup/getsockopt")
0017 int get_retval(struct bpf_sockopt *ctx)
0018 {
0019 retval_value = bpf_get_retval();
0020 ctx_retval_value = ctx->retval;
0021 __sync_fetch_and_add(&invocations, 1);
0022
0023 return 1;
0024 }
0025
0026 SEC("cgroup/getsockopt")
0027 int set_eisconn(struct bpf_sockopt *ctx)
0028 {
0029 __sync_fetch_and_add(&invocations, 1);
0030
0031 if (bpf_set_retval(-EISCONN))
0032 assertion_error = 1;
0033
0034 return 1;
0035 }
0036
0037 SEC("cgroup/getsockopt")
0038 int clear_retval(struct bpf_sockopt *ctx)
0039 {
0040 __sync_fetch_and_add(&invocations, 1);
0041
0042 ctx->retval = 0;
0043
0044 return 1;
0045 }