Re: [bpf-next PATCH v3 1/7] bpf: refactor sockmap sample program update for arg parsing

Martin KaFai Lau
2018-01-13T07:19:50Z

On Thu, Jan 11, 2018 at 09:06:17PM -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 <john.fastabend@gmail.com>
One nit below.

Acked-by: Martin KaFai Lau <kafai@fb.com>

> ---
[ ... ]
> @@ -280,12 +333,21 @@ int main(int argc, char **argv)
> return err;
> }
>
> - err = sockmap_test_sockets(rate, dot);
> + err = sockmap_init_sockets();
> if (err) {
> fprintf(stderr, "ERROR: test socket failed: %d\n", err);
> - return err;
> + goto out;
> }
> - return 0;
> +
> + err = forever_ping_pong(rate, verbose);
> +out:
> + close(s1);
> + close(s2);
> + close(p1);
> + close(p2);
> + close(c1);
> + close(c2);
close(cg_fd);

> + return err;
> }
>
> void running_handler(int a)
>