lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86c79df5-5b5e-a996-41d1-48b7aa960c02@iogearbox.net>
Date:   Thu, 11 Jan 2018 02:25:27 +0100
From:   Daniel Borkmann <daniel@...earbox.net>
To:     John Fastabend <john.fastabend@...il.com>, borkmann@...earbox.net,
        ast@...nel.org
Cc:     netdev@...r.kernel.org
Subject: Re: [bpf-next PATCH v2 1/7] bpf: refactor sockmap sample program
 update for arg parsing

On 01/10/2018 07:39 PM, 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@...il.com>
> ---
>  samples/sockmap/sockmap_user.c |  142 +++++++++++++++++++++++++++++-----------
>  1 file changed, 103 insertions(+), 39 deletions(-)
[...]
>  
>  	/* Accept Connecrtions */
> @@ -149,23 +177,32 @@ static int sockmap_test_sockets(int rate, int dot)
>  		goto out;
>  	}
>  
> -	max_fd = p2;
> -	timeout.tv_sec = 10;
> -	timeout.tv_usec = 0;
> -
>  	printf("connected sockets: c1 <-> p1, c2 <-> p2\n");
>  	printf("cgroups binding: c1(%i) <-> s1(%i) - - - c2(%i) <-> s2(%i)\n",
>  		c1, s1, c2, s2);
> +out:
> +	return err;

Maybe rather than setting err and goto out where we now just return
err anyway, return from those places directly.

> +}
> +
> +static int forever_ping_pong(int rate, int verbose)
> +{
> +	struct timeval timeout;
> +	char buf[1024] = {0};
> +	int sc;
> +
> +	timeout.tv_sec = 10;
> +	timeout.tv_usec = 0;
>  
>  	/* Ping/Pong data from client to server */
>  	sc = send(c1, buf, sizeof(buf), 0);
>  	if (sc < 0) {
>  		perror("send failed()\n");
> -		goto out;
> +		return sc;
>  	}
>  
>  	do {
> -		int s, rc, i;
> +		int s, rc, i, max_fd = p2;
> +		fd_set w;
>  
>  		/* FD sets */
>  		FD_ZERO(&w);
[...]
> -	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);
> +	return err;
>  }
>  
>  void running_handler(int a)
>  {
>  	running = 0;
> +	printf("\n");

Do we need this out of the sighandler instead of e.g. main loop when
we break out?

>  }
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ