From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Fastabend Subject: Re: [bpf PATCH 3/3] bpf: test_maps, only support ESTABLISHED socks Date: Mon, 17 Sep 2018 21:38:05 -0700 Message-ID: References: <20180917172946.21218.66049.stgit@john-Precision-Tower-5810> <20180917173200.21218.51219.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: edumazet@google.com, Alexei Starovoitov , Daniel Borkmann , netdev To: Y Song Return-path: Received: from mail-it0-f66.google.com ([209.85.214.66]:38495 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbeIRKJG (ORCPT ); Tue, 18 Sep 2018 06:09:06 -0400 Received: by mail-it0-f66.google.com with SMTP id p129-v6so1363351ite.3 for ; Mon, 17 Sep 2018 21:38:21 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 09/17/2018 02:21 PM, Y Song wrote: > On Mon, Sep 17, 2018 at 10:33 AM John Fastabend > wrote: >> >> Ensure that sockets added to a sock{map|hash} that is not in the >> ESTABLISHED state is rejected. >> >> Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") >> Signed-off-by: John Fastabend >> --- >> tools/testing/selftests/bpf/test_maps.c | 10 +++++++--- >> 1 file changed, 7 insertions(+), 3 deletions(-) >> >> diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c >> index 6f54f84..0f2090f 100644 >> --- a/tools/testing/selftests/bpf/test_maps.c >> +++ b/tools/testing/selftests/bpf/test_maps.c >> @@ -580,7 +580,11 @@ static void test_sockmap(int tasks, void *data) >> /* Test update without programs */ >> for (i = 0; i < 6; i++) { >> err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY); >> - if (err) { >> + if (i < 2 && !err) { >> + printf("Allowed update sockmap '%i:%i' not in ESTABLISHED\n", >> + i, sfd[i]); >> + goto out_sockmap; >> + } else if (i > 1 && err) { > > Just a nit. Maybe "i >= 2" since it will be more clear since it is > opposite of "i < 2"? > Seems reasonable changed in v3 to 'i >= 2'. Thanks.