Patchwork [bpf] bpf: samples/sockmap detach sock ops program

login
register
mail settings
Submitter Prashant Bhole
Date Feb. 13, 2018, 4:44 a.m.
Message ID <20180213044422.2868-1-bhole_prashant_q7@lab.ntt.co.jp>
Download mbox | patch
Permalink /patch/449087/
State New
Headers show

Comments

Prashant Bhole - Feb. 13, 2018, 4:44 a.m.
samples/sockops program keeps the sock_ops program attached to cgroup.
Fixed this by detaching program before exit.

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
---
 samples/sockmap/sockmap_user.c | 1 +
 1 file changed, 1 insertion(+)
Alexei Starovoitov - Feb. 14, 2018, 1:49 a.m.
On Tue, Feb 13, 2018 at 01:44:22PM +0900, Prashant Bhole wrote:
> samples/sockops program keeps the sock_ops program attached to cgroup.
> Fixed this by detaching program before exit.
> 
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>

Also applied to bpf-next considering that John is planning to move
the whole file into selftests soon.
John Fastabend - Feb. 14, 2018, 2:27 a.m.
On 02/13/2018 05:49 PM, Alexei Starovoitov wrote:
> On Tue, Feb 13, 2018 at 01:44:22PM +0900, Prashant Bhole wrote:
>> samples/sockops program keeps the sock_ops program attached to cgroup.
>> Fixed this by detaching program before exit.
>>
>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> 
> Also applied to bpf-next considering that John is planning to move
> the whole file into selftests soon.
> 

Thanks for the fix here as well.

Acked-by: John Fastabend <john.fastabend@gmail.com>

Patch

diff --git a/samples/sockmap/sockmap_user.c b/samples/sockmap/sockmap_user.c
index 7c25c0c112bc..95a54a89a532 100644
--- a/samples/sockmap/sockmap_user.c
+++ b/samples/sockmap/sockmap_user.c
@@ -566,6 +566,7 @@  int main(int argc, char **argv)
 	else
 		fprintf(stderr, "unknown test\n");
 out:
+	bpf_prog_detach2(prog_fd[2], cg_fd, BPF_CGROUP_SOCK_OPS);
 	close(s1);
 	close(s2);
 	close(p1);