[CRIU] [PATCH CRIU 08/14] restore/net/ipv6: net device and def/all configuration
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Wed Mar 30 03:42:26 PDT 2016
First restore "all" and then "default"(and "dev") as for some ipv6
sysctls setting all can change the latter(forwarding, disable_ipv6)
e.g.:
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6
cat /proc/sys/net/ipv6/conf/default/disable_ipv6
0
As changing disable_ipv6 sysctl for some device may change mtu sysctl
do not optimize mtu's restore.
https://jira.sw.ru/browse/PSBM-30942
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/net.c | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/criu/net.c b/criu/net.c
index a55cfba..b1753d9 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -163,9 +163,11 @@ static int net_conf_op(char *tgt, int *conf, int n, int op, char *proto,
continue;
}
/*
- * If dev conf value is the same as default skip restoring it
+ * If dev conf value is the same as default skip restoring it,
+ * mtu may be changed by disable_ipv6 so we can not skip
+ * it's restore
*/
- if (def_conf && conf[i] == def_conf[i]) {
+ if (def_conf && conf[i] == def_conf[i] && strcmp(devconfs[i], "mtu")) {
pr_debug("DEBUG Skip %s/%s, val =%d\n", tgt, devconfs[i], conf[i]);
continue;
}
@@ -833,6 +835,8 @@ static int restore_links(int pid, NetnsEntry **netns)
}
while (1) {
+ NetnsEntry **def_netns = netns;
+
ret = pb_read_one_eof(img, &nde, PB_NETDEV);
if (ret <= 0)
break;
@@ -843,18 +847,24 @@ static int restore_links(int pid, NetnsEntry **netns)
goto exit;
}
+ /*
+ * optimize restore of devices configuration except lo
+ * lo is created with namespace and before default is set
+ * so we cant optimize its restore
+ */
+ if (nde->type == ND_TYPE__LOOPBACK)
+ def_netns = NULL;
+
if (nde->conf4) {
- NetnsEntry **def_netns = netns;
- /*
- * optimize restore of devices configuration except lo
- * lo is created with namespace and before default is set
- * so we cant optimize its restore
- */
- if (nde->type == ND_TYPE__LOOPBACK)
- def_netns = NULL;
ret = ipv4_conf_op(nde->name, nde->conf4, nde->n_conf4,
CTL_WRITE, nde->mask_unused4, def_netns);
+ if (ret)
+ goto exit;
}
+
+ if (nde->conf6)
+ ret = ipv6_conf_op(nde->name, nde->conf6, nde->n_conf6,
+ CTL_WRITE, nde->mask_unused6, def_netns);
exit:
net_device_entry__free_unpacked(nde, NULL);
if (ret)
@@ -1150,6 +1160,16 @@ static int restore_netns_conf(int pid, NetnsEntry **netns)
goto out;
ret = ipv4_conf_op("all", (*netns)->all_conf4, n,
CTL_WRITE, (*netns)->mask_unused4, NULL);
+
+ if ((*netns)->def_conf6) {
+ n = (*netns)->n_def_conf6;
+ ret = ipv6_conf_op("all", (*netns)->all_conf6, n,
+ CTL_WRITE, (*netns)->mask_unused6, NULL);
+ if (ret)
+ goto out;
+ ret = ipv6_conf_op("default", (*netns)->def_conf6, n,
+ CTL_WRITE, (*netns)->mask_unused6, NULL);
+ }
out:
close_image(img);
return ret;
--
1.9.3
More information about the CRIU
mailing list