[lxc-devel] [PATCH 2/9] network: check result of if_nametoindex().

Serge Hallyn serge.hallyn at ubuntu.com
Fri Sep 19 21:12:36 UTC 2014


Quoting Dongsheng Yang (yangds.fnst at cn.fujitsu.com):
> When we want to get index of a ifname which does not
> exist, we should return a -EINVAL in this case.
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst at cn.fujitsu.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/network.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/lxc/network.c b/src/lxc/network.c
> index ce10d31..909f3fe 100644
> --- a/src/lxc/network.c
> +++ b/src/lxc/network.c
> @@ -144,6 +144,8 @@ int lxc_netdev_move_by_name(const char *ifname, pid_t pid)
>  		return -EINVAL;
>  
>  	index = if_nametoindex(ifname);
> +	if (!index)
> +		return -EINVAL;
>  
>  	return lxc_netdev_move_by_index(index, pid);
>  }
> -- 
> 1.8.4.2
> 


More information about the lxc-devel mailing list