[CRIU] [PATCH ] net: Drop @ri test but use known ARRA_SIZE

Andrew Vagin avagin at odin.com
Tue May 5 12:26:03 PDT 2015


On Tue, May 05, 2015 at 05:10:40PM +0300, Cyrill Gorcunov wrote:
> On Tue, May 05, 2015 at 05:04:20PM +0300, Andrew Vagin wrote:
> > > 
> > > 1-3 applied
> > 
> > 00:04:15.713 Test: zdtm/live/static/netns-dev, Result: FAIL
> 
> Andrew, could you please give this one a shot.

Acked-by: Andrew Vagin <avagin at odin.com>

> From e81b3626de082992dbf231b79996dfa329b65a40 Mon Sep 17 00:00:00 2001
> From: Cyrill Gorcunov <gorcunov at openvz.org>
> Date: Tue, 5 May 2015 17:09:26 +0300
> Subject: [PATCH] net: Drop @ri test but use known ARRA_SIZE
> 
> We might miss entry in "ri ? ri - 1" expression when ri = 1.
> Lets use known array size instead.
> 
> For some reason it didn't trigger on my tests earlier.
> 
> Reported-by: Andrew Vagin <avagin at odin.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  net.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/net.c b/net.c
> index fb64d2ebfb62..034793029eb2 100644
> --- a/net.c
> +++ b/net.c
> @@ -79,7 +79,6 @@ static char *devconfs[] = {
>  	"shared_media",
>  	"src_valid_mark",
>  	"tag",
> -	NULL,
>  };
>  
>  #define NET_CONF_PATH "net/ipv4/conf"
> @@ -89,10 +88,10 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
>  {
>  	int i, ri;
>  	int ret;
> -	struct sysctl_req req[ARRAY_SIZE(devconfs) + 1];
> +	struct sysctl_req req[ARRAY_SIZE(devconfs)];
>  	char path[ARRAY_SIZE(devconfs)][MAX_CONF_OPT_PATH];
>  
> -	for (i = 0, ri = 0; devconfs[i]; i++) {
> +	for (i = 0, ri = 0; i < ARRAY_SIZE(devconfs); i++) {
>  		/*
>  		 * If dev conf value is the same as default skip restoring it
>  		 */
> @@ -107,9 +106,8 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
>  		req[ri].type = CTL_32;
>  		ri++;
>  	}
> -	req[ri].name = NULL;
>  
> -	ret = sysctl_op(req, ri ? ri - 1 : 0, op);
> +	ret = sysctl_op(req, ri, op);
>  	if (ret < 0) {
>  		pr_err("Failed to %s %s/<confs>\n", (op == CTL_READ)?"read":"write", tgt);
>  		return -1;
> -- 
> 2.1.0
> 



More information about the CRIU mailing list