From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesper Dangaard Brouer Subject: Re: [bpf-next PATCH 1/7] bpf: refactor sockmap sample program update for arg parsing Date: Tue, 9 Jan 2018 14:30:14 +0100 Message-ID: <20180109143014.26f203f9@redhat.com> References: <20180108180302.13647.13866.stgit@john-Precision-Tower-5810> <20180108180507.13647.62367.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: brouer@redhat.com, ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org To: John Fastabend Return-path: Received: from mx1.redhat.com ([209.132.183.28]:43600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753713AbeAINaZ (ORCPT ); Tue, 9 Jan 2018 08:30:25 -0500 In-Reply-To: <20180108180507.13647.62367.stgit@john-Precision-Tower-5810> Sender: netdev-owner@vger.kernel.org List-ID: 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 :-) Acked-by: Jesper Dangaard Brouer -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer