From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Fastabend Subject: Re: [bpf-next PATCH 1/7] bpf: refactor sockmap sample program update for arg parsing Date: Tue, 9 Jan 2018 08:10:13 -0800 Message-ID: <054a9fd0-2d62-0448-45da-605f9546c4e7@gmail.com> References: <20180108180302.13647.13866.stgit@john-Precision-Tower-5810> <20180108180507.13647.62367.stgit@john-Precision-Tower-5810> <20180109143014.26f203f9@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org To: Jesper Dangaard Brouer Return-path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:33343 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932862AbeAIQLM (ORCPT ); Tue, 9 Jan 2018 11:11:12 -0500 Received: by mail-pf0-f196.google.com with SMTP id y89so8864752pfk.0 for ; Tue, 09 Jan 2018 08:11:12 -0800 (PST) In-Reply-To: <20180109143014.26f203f9@redhat.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 01/09/2018 05:30 AM, Jesper Dangaard Brouer wrote: > On Mon, 08 Jan 2018 10:05:07 -0800 > John Fastabend wrote: > >> sockmap sample program takes arguments from cmd line but it reads them >> in using offsets into the array. Because we want to add more arguments >> in the future lets do proper argument handling. >> >> Also refactor code to pull apart sock init and ping/pong test. This >> allows us to add new tests in the future. >> >> Signed-off-by: John Fastabend >> --- >> samples/sockmap/sockmap_user.c | 142 +++++++++++++++++++++++++++++----------- >> 1 file changed, 103 insertions(+), 39 deletions(-) >> >> diff --git a/samples/sockmap/sockmap_user.c b/samples/sockmap/sockmap_user.c >> index 7cc9d22..5cbe7a5 100644 >> --- a/samples/sockmap/sockmap_user.c >> +++ b/samples/sockmap/sockmap_user.c >> @@ -35,6 +35,8 @@ >> #include >> #include >> >> +#include >> + >> #include "../bpf/bpf_load.h" >> #include "../bpf/bpf_util.h" >> #include "../bpf/libbpf.h" >> @@ -46,15 +48,39 @@ >> #define S1_PORT 10000 >> #define S2_PORT 10001 >> >> -static int sockmap_test_sockets(int rate, int dot) >> +/* global sockets */ >> +int s1, s2, c1, c2, p1, p2; >> + >> +static const struct option long_options[] = { >> + {"help", no_argument, NULL, 'h' }, >> + {"cgroup", required_argument, NULL, 'c' }, >> + {"rate", required_argument, NULL, 'r' }, >> + {"verbose", no_argument, NULL, 'v' }, >> + {0, 0, NULL, 0 } >> +}; >> + >> +static void usage(char *argv[]) >> +{ >> + int i; >> + >> + printf(" Usage: %s --cgroup \n", argv[0]); >> + printf(" options:\n"); >> + for (i = 0; long_options[i].name != 0; i++) { >> + printf(" --%-12s", long_options[i].name); >> + if (long_options[i].flag != NULL) >> + printf(" flag (internal value:%d)\n", >> + *long_options[i].flag); >> + else >> + printf(" -%c\n", long_options[i].val); >> + } >> + printf("\n"); >> +} >> + > > I love that you are using --long-options :-) Yep, saw it being used in xdp_rxq_info_user.c > > Acked-by: Jesper Dangaard Brouer >