@@ -78,7 +78,8 @@ static int test_foo_bar(void)
78
78
if (join_cgroup (FOO ))
79
79
goto err ;
80
80
81
- if (bpf_prog_attach (drop_prog , foo , BPF_CGROUP_INET_EGRESS , 1 )) {
81
+ if (bpf_prog_attach (drop_prog , foo , BPF_CGROUP_INET_EGRESS ,
82
+ BPF_F_ALLOW_OVERRIDE )) {
82
83
log_err ("Attaching prog to /foo" );
83
84
goto err ;
84
85
}
@@ -97,7 +98,8 @@ static int test_foo_bar(void)
97
98
printf ("Attached DROP prog. This ping in cgroup /foo/bar should fail...\n" );
98
99
assert (system (PING_CMD ) != 0 );
99
100
100
- if (bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS , 1 )) {
101
+ if (bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS ,
102
+ BPF_F_ALLOW_OVERRIDE )) {
101
103
log_err ("Attaching prog to /foo/bar" );
102
104
goto err ;
103
105
}
@@ -114,7 +116,8 @@ static int test_foo_bar(void)
114
116
"This ping in cgroup /foo/bar should fail...\n" );
115
117
assert (system (PING_CMD ) != 0 );
116
118
117
- if (bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS , 1 )) {
119
+ if (bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS ,
120
+ BPF_F_ALLOW_OVERRIDE )) {
118
121
log_err ("Attaching prog to /foo/bar" );
119
122
goto err ;
120
123
}
@@ -128,7 +131,8 @@ static int test_foo_bar(void)
128
131
"This ping in cgroup /foo/bar should pass...\n" );
129
132
assert (system (PING_CMD ) == 0 );
130
133
131
- if (bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS , 1 )) {
134
+ if (bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS ,
135
+ BPF_F_ALLOW_OVERRIDE )) {
132
136
log_err ("Attaching prog to /foo/bar" );
133
137
goto err ;
134
138
}
@@ -161,13 +165,15 @@ static int test_foo_bar(void)
161
165
goto err ;
162
166
}
163
167
164
- if (!bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS , 1 )) {
168
+ if (!bpf_prog_attach (allow_prog , bar , BPF_CGROUP_INET_EGRESS ,
169
+ BPF_F_ALLOW_OVERRIDE )) {
165
170
errno = 0 ;
166
171
log_err ("Unexpected success attaching overridable prog to /foo/bar" );
167
172
goto err ;
168
173
}
169
174
170
- if (!bpf_prog_attach (allow_prog , foo , BPF_CGROUP_INET_EGRESS , 1 )) {
175
+ if (!bpf_prog_attach (allow_prog , foo , BPF_CGROUP_INET_EGRESS ,
176
+ BPF_F_ALLOW_OVERRIDE )) {
171
177
errno = 0 ;
172
178
log_err ("Unexpected success attaching overridable prog to /foo" );
173
179
goto err ;
@@ -273,27 +279,33 @@ static int test_multiprog(void)
273
279
if (join_cgroup ("/cg1/cg2/cg3/cg4/cg5" ))
274
280
goto err ;
275
281
276
- if (bpf_prog_attach (allow_prog [0 ], cg1 , BPF_CGROUP_INET_EGRESS , 2 )) {
282
+ if (bpf_prog_attach (allow_prog [0 ], cg1 , BPF_CGROUP_INET_EGRESS ,
283
+ BPF_F_ALLOW_MULTI )) {
277
284
log_err ("Attaching prog to cg1" );
278
285
goto err ;
279
286
}
280
- if (!bpf_prog_attach (allow_prog [0 ], cg1 , BPF_CGROUP_INET_EGRESS , 2 )) {
287
+ if (!bpf_prog_attach (allow_prog [0 ], cg1 , BPF_CGROUP_INET_EGRESS ,
288
+ BPF_F_ALLOW_MULTI )) {
281
289
log_err ("Unexpected success attaching the same prog to cg1" );
282
290
goto err ;
283
291
}
284
- if (bpf_prog_attach (allow_prog [1 ], cg1 , BPF_CGROUP_INET_EGRESS , 2 )) {
292
+ if (bpf_prog_attach (allow_prog [1 ], cg1 , BPF_CGROUP_INET_EGRESS ,
293
+ BPF_F_ALLOW_MULTI )) {
285
294
log_err ("Attaching prog2 to cg1" );
286
295
goto err ;
287
296
}
288
- if (bpf_prog_attach (allow_prog [2 ], cg2 , BPF_CGROUP_INET_EGRESS , 1 )) {
297
+ if (bpf_prog_attach (allow_prog [2 ], cg2 , BPF_CGROUP_INET_EGRESS ,
298
+ BPF_F_ALLOW_OVERRIDE )) {
289
299
log_err ("Attaching prog to cg2" );
290
300
goto err ;
291
301
}
292
- if (bpf_prog_attach (allow_prog [3 ], cg3 , BPF_CGROUP_INET_EGRESS , 2 )) {
302
+ if (bpf_prog_attach (allow_prog [3 ], cg3 , BPF_CGROUP_INET_EGRESS ,
303
+ BPF_F_ALLOW_MULTI )) {
293
304
log_err ("Attaching prog to cg3" );
294
305
goto err ;
295
306
}
296
- if (bpf_prog_attach (allow_prog [4 ], cg4 , BPF_CGROUP_INET_EGRESS , 1 )) {
307
+ if (bpf_prog_attach (allow_prog [4 ], cg4 , BPF_CGROUP_INET_EGRESS ,
308
+ BPF_F_ALLOW_OVERRIDE )) {
297
309
log_err ("Attaching prog to cg4" );
298
310
goto err ;
299
311
}
0 commit comments