aboutsummaryrefslogtreecommitdiffstats
path: root/samples/bpf/bpf_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'samples/bpf/bpf_load.c')
-rw-r--r--samples/bpf/bpf_load.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index a91c57dd8571..a4be7cfa6519 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -64,6 +64,7 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
64 bool is_perf_event = strncmp(event, "perf_event", 10) == 0; 64 bool is_perf_event = strncmp(event, "perf_event", 10) == 0;
65 bool is_cgroup_skb = strncmp(event, "cgroup/skb", 10) == 0; 65 bool is_cgroup_skb = strncmp(event, "cgroup/skb", 10) == 0;
66 bool is_cgroup_sk = strncmp(event, "cgroup/sock", 11) == 0; 66 bool is_cgroup_sk = strncmp(event, "cgroup/sock", 11) == 0;
67 bool is_sockops = strncmp(event, "sockops", 7) == 0;
67 size_t insns_cnt = size / sizeof(struct bpf_insn); 68 size_t insns_cnt = size / sizeof(struct bpf_insn);
68 enum bpf_prog_type prog_type; 69 enum bpf_prog_type prog_type;
69 char buf[256]; 70 char buf[256];
@@ -89,6 +90,8 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
89 prog_type = BPF_PROG_TYPE_CGROUP_SKB; 90 prog_type = BPF_PROG_TYPE_CGROUP_SKB;
90 } else if (is_cgroup_sk) { 91 } else if (is_cgroup_sk) {
91 prog_type = BPF_PROG_TYPE_CGROUP_SOCK; 92 prog_type = BPF_PROG_TYPE_CGROUP_SOCK;
93 } else if (is_sockops) {
94 prog_type = BPF_PROG_TYPE_SOCK_OPS;
92 } else { 95 } else {
93 printf("Unknown event '%s'\n", event); 96 printf("Unknown event '%s'\n", event);
94 return -1; 97 return -1;
@@ -106,8 +109,11 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
106 if (is_xdp || is_perf_event || is_cgroup_skb || is_cgroup_sk) 109 if (is_xdp || is_perf_event || is_cgroup_skb || is_cgroup_sk)
107 return 0; 110 return 0;
108 111
109 if (is_socket) { 112 if (is_socket || is_sockops) {
110 event += 6; 113 if (is_socket)
114 event += 6;
115 else
116 event += 7;
111 if (*event != '/') 117 if (*event != '/')
112 return 0; 118 return 0;
113 event++; 119 event++;
@@ -560,7 +566,8 @@ static int do_load_bpf_file(const char *path, fixup_map_cb fixup_map)
560 memcmp(shname, "xdp", 3) == 0 || 566 memcmp(shname, "xdp", 3) == 0 ||
561 memcmp(shname, "perf_event", 10) == 0 || 567 memcmp(shname, "perf_event", 10) == 0 ||
562 memcmp(shname, "socket", 6) == 0 || 568 memcmp(shname, "socket", 6) == 0 ||
563 memcmp(shname, "cgroup/", 7) == 0) 569 memcmp(shname, "cgroup/", 7) == 0 ||
570 memcmp(shname, "sockops", 7) == 0)
564 load_and_attach(shname, data->d_buf, data->d_size); 571 load_and_attach(shname, data->d_buf, data->d_size);
565 } 572 }
566 573