[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <902e1164-d4a3-6fae-1f29-8b7433a18710@lab.ntt.co.jp>
Date: Tue, 23 Jan 2018 13:55:30 +0900
From: Prashant Bhole <bhole_prashant_q7@....ntt.co.jp>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Shuah Khan <shuahkh@....samsung.com>, netdev@...r.kernel.org,
John Fastabend <john.fastabend@...il.com>
Subject: Re: [PATCH bpf] bpf: test_maps: cleanup sockmaps when test ends
On 1/23/2018 1:38 PM, Alexei Starovoitov wrote:
> On Tue, Jan 23, 2018 at 01:30:44PM +0900, Prashant Bhole wrote:
>> Bug: BPF programs and maps related to sockmaps test exist in
>> memory even after test_maps ends
>>
>> This patch fixes it by empyting sockmaps when test ends.
>>
>> Fixes: 6f6d33f3b3d0f ("bpf: selftests add sockmap tests")
>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@....ntt.co.jp>
>
> that's a fine workaround and I'm planning to apply this patch
> to bpf-next, but it's not a fix. The sockmap should have cleaned
> itself up.
Ok. Do I need to re-submit it targeted to -bpf-next and without fixes tag?
-Prashant
>
>> ---
>> tools/testing/selftests/bpf/test_maps.c | 16 ++++++++++++----
>> 1 file changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
>> index 040356ecc862..5fb1355f80fc 100644
>> --- a/tools/testing/selftests/bpf/test_maps.c
>> +++ b/tools/testing/selftests/bpf/test_maps.c
>> @@ -463,7 +463,7 @@ static void test_devmap(int task, void *data)
>> #define SOCKMAP_VERDICT_PROG "./sockmap_verdict_prog.o"
>> static void test_sockmap(int tasks, void *data)
>> {
>> - int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc;
>> + int one = 1, map_fd_rx = 0, map_fd_tx = 0, map_fd_break, s, sc, rc;
>> struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break;
>> int ports[] = {50200, 50201, 50202, 50204};
>> int err, i, fd, udp, sfd[6] = {0xdeadbeef};
>> @@ -868,9 +868,12 @@ static void test_sockmap(int tasks, void *data)
>> goto out_sockmap;
>> }
>>
>> - /* Test map close sockets */
>> - for (i = 0; i < 6; i++)
>> + /* Test map close sockets and empty maps */
>> + for (i = 0; i < 6; i++) {
>> + bpf_map_delete_elem(map_fd_tx, &i);
>> + bpf_map_delete_elem(map_fd_rx, &i);
>> close(sfd[i]);
>> + }
>> close(fd);
>> close(map_fd_rx);
>> bpf_object__close(obj);
>> @@ -881,8 +884,13 @@ static void test_sockmap(int tasks, void *data)
>> printf("Failed to create sockmap '%i:%s'!\n", i, strerror(errno));
>> exit(1);
>> out_sockmap:
>> - for (i = 0; i < 6; i++)
>> + for (i = 0; i < 6; i++) {
>> + if (map_fd_tx)
>> + bpf_map_delete_elem(map_fd_tx, &i);
>> + if (map_fd_rx)
>> + bpf_map_delete_elem(map_fd_rx, &i);
>> close(sfd[i]);
>> + }
>> close(fd);
>> exit(1);
>> }
>> --
>> 2.13.6
>>
>>
>
>
Powered by blists - more mailing lists