[CRIU] [PATCH v3 7/7] restore netns ipv4 conf all/default

Pavel Emelyanov xemul at parallels.com
Wed Oct 8 05:15:21 PDT 2014


On 10/08/2014 11:04 AM, Pavel Tikhomirov wrote:
> 
> On 10/07/2014 03:56 PM, Pavel Emelyanov wrote:
>> On 10/01/2014 02:42 PM, Pavel Tikhomirov wrote:
>>> restore order:
>>> 1. default
>>> 2. all
>>> 3. devices
>>>
>>> Signed-off-by: Pavel Tikhomirov <ptikhomirov at parallels.com>
>>> ---
>>>   net.c | 36 +++++++++++++++++++++++++++++++++++-
>>>   1 file changed, 35 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/net.c b/net.c
>>> index 7a80973..a164795 100644
>>> --- a/net.c
>>> +++ b/net.c
>>> @@ -616,6 +616,38 @@ static inline int restore_iptables(int pid)
>>>   	return ret;
>>>   }
>>>   
>>> +static int restore_netns_conf(int pid)
>>> +{
>>> +	int ret;
>>> +	int fd;
>>> +	NetnsEntry *netns;
>>> +
>>> +	fd = open_image(CR_FD_NETNS, O_RSTR, pid);
>>> +	if (fd < 0) {
>>> +		pr_err("Can not open netns image\n");
>>> +		return -1;
>>> +	}
>>> +
>>> +	ret = pb_read_one(fd, &netns, PB_NETNS);
>>> +	if (ret < 0) {
>>> +		pr_err("Can not read netns object\n");
>>> +		close(fd);
>>> +		return -1;
>>> +	}
>>> +
>>> +	ret = ipv4_conf_op("net/ipv4/conf/default", netns->def_conf, CTL_WRITE);
>>> +	if (ret < 0)
>>> +		goto err;
>>> +	ret = ipv4_conf_op("net/ipv4/conf/all", netns->all_conf, CTL_WRITE);
>>> +err:
>>> +	netns_entry__free_unpacked(netns, NULL);
>>> +	close(fd);
>>> +	if (ret < 0)
>>> +		return -1;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>>   static int mount_ns_sysfs(void)
>>>   {
>>>   	char sys_mount[] = "crtools-sys.XXXXXX";
>>> @@ -690,7 +722,9 @@ int prepare_net_ns(int pid)
>>>   {
>>>   	int ret;
>>>   
>>> -	ret = restore_links(pid);
>>> +	ret = restore_netns_conf(pid);
>>> +	if (!ret)
>>> +		ret = restore_links(pid);
>> Since we restore link confs after default and all we can make
>> an optimisation -- don't restore the device values that match
>> the "default" set. Please implement.
> 
> This is, I think, for devices except "lo", because it is created along 
> with a namespace, right?

For lo we can skip this for now, yes.

>>>   	if (!ret)
>>>   		ret = restore_ifaddr(pid);
>>>   	if (!ret)
>>>
> 



More information about the CRIU mailing list