[CRIU] [PATCH CRIU 02/14] net/ipv4: suffix configs with "4"
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Wed Mar 30 03:42:20 PDT 2016
criu/net.c:
s/devconfs/devconfs4/
s/def_conf/def_conf4/
s/all_conf/all_conf4/
s/nde->conf/nde->conf4/
s/nde->n_conf/nde->n_conf4/
s/netdev.conf/netdev.conf4/
s/netdev.n_conf/netdev.n_conf4/
images/netdev.proto:
s/conf/conf4/
https://jira.sw.ru/browse/PSBM-30942
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/net.c | 62 ++++++++++++++++++++++++++---------------------------
images/netdev.proto | 6 +++---
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/criu/net.c b/criu/net.c
index 0feddf5..cddbf98 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -61,7 +61,7 @@ int read_ns_sys_file(char *path, char *buf, int len)
return rlen;
}
-static char *devconfs[] = {
+static char *devconfs4[] = {
"accept_local",
"accept_redirects",
"accept_source_route",
@@ -108,22 +108,22 @@ static int ipv4_conf_op(char *tgt, int *conf, int n, int op, NetnsEntry **netns)
{
int i, ri;
int ret, flags = op == CTL_READ ? CTL_FLAGS_OPTIONAL : 0;
- struct sysctl_req req[ARRAY_SIZE(devconfs)];
- char path[ARRAY_SIZE(devconfs)][MAX_CONF_OPT_PATH];
+ struct sysctl_req req[ARRAY_SIZE(devconfs4)];
+ char path[ARRAY_SIZE(devconfs4)][MAX_CONF_OPT_PATH];
- if (n > ARRAY_SIZE(devconfs))
+ if (n > ARRAY_SIZE(devconfs4))
pr_warn("The image contains unknown sysctl-s\n");
- for (i = 0, ri = 0; i < ARRAY_SIZE(devconfs); i++) {
+ for (i = 0, ri = 0; i < ARRAY_SIZE(devconfs4); i++) {
if (i >= n) {
- pr_warn("Skip %s/%s\n", tgt, devconfs[i]);
+ pr_warn("Skip %s/%s\n", tgt, devconfs4[i]);
continue;
}
/*
* If dev conf value is the same as default skip restoring it
*/
- if (netns && conf[i] == (*netns)->def_conf[i]) {
- pr_debug("DEBUG Skip %s/%s, val =%d\n", tgt, devconfs[i], conf[i]);
+ if (netns && conf[i] == (*netns)->def_conf4[i]) {
+ pr_debug("DEBUG Skip %s/%s, val =%d\n", tgt, devconfs4[i], conf[i]);
continue;
}
@@ -132,7 +132,7 @@ static int ipv4_conf_op(char *tgt, int *conf, int n, int op, NetnsEntry **netns)
else if (op == CTL_READ)
conf[i] = DEVCONFS_UNUSED;
- snprintf(path[i], MAX_CONF_OPT_PATH, "%s/%s/%s", NET_CONF_PATH, tgt, devconfs[i]);
+ snprintf(path[i], MAX_CONF_OPT_PATH, "%s/%s/%s", NET_CONF_PATH, tgt, devconfs4[i]);
req[ri].name = path[i];
req[ri].arg = &conf[i];
req[ri].type = CTL_32;
@@ -180,12 +180,12 @@ static int dump_one_netdev(int type, struct ifinfomsg *ifi,
(int)netdev.address.len, netdev.name);
}
- netdev.n_conf = ARRAY_SIZE(devconfs);
- netdev.conf = xmalloc(sizeof(int) * netdev.n_conf);
- if (!netdev.conf)
+ netdev.n_conf4 = ARRAY_SIZE(devconfs4);
+ netdev.conf4 = xmalloc(sizeof(int) * netdev.n_conf4);
+ if (!netdev.conf4)
return -1;
- ret = ipv4_conf_op(netdev.name, netdev.conf, netdev.n_conf, CTL_READ, NULL);
+ ret = ipv4_conf_op(netdev.name, netdev.conf4, netdev.n_conf4, CTL_READ, NULL);
if (ret < 0)
goto err_free;
@@ -194,7 +194,7 @@ static int dump_one_netdev(int type, struct ifinfomsg *ifi,
ret = dump(&netdev, fds);
err_free:
- xfree(netdev.conf);
+ xfree(netdev.conf4);
return ret;
}
@@ -743,7 +743,7 @@ static int restore_links(int pid, NetnsEntry **netns)
goto exit;
}
- if (nde->conf) {
+ if (nde->conf4) {
NetnsEntry **def_netns = netns;
/*
* optimize restore of devices configuration except lo
@@ -752,7 +752,7 @@ static int restore_links(int pid, NetnsEntry **netns)
*/
if (nde->type == ND_TYPE__LOOPBACK)
def_netns = NULL;
- ret = ipv4_conf_op(nde->name, nde->conf, nde->n_conf, CTL_WRITE, def_netns);
+ ret = ipv4_conf_op(nde->name, nde->conf4, nde->n_conf4, CTL_WRITE, def_netns);
}
exit:
net_device_entry__free_unpacked(nde, NULL);
@@ -871,29 +871,29 @@ static int dump_netns_conf(struct cr_imgset *fds)
int ret, n;
NetnsEntry netns = NETNS_ENTRY__INIT;
- netns.n_def_conf = ARRAY_SIZE(devconfs);
- netns.n_all_conf = ARRAY_SIZE(devconfs);
- netns.def_conf = xmalloc(sizeof(int) * netns.n_def_conf);
- if (!netns.def_conf)
+ netns.n_def_conf4 = ARRAY_SIZE(devconfs4);
+ netns.n_all_conf4 = ARRAY_SIZE(devconfs4);
+ netns.def_conf4 = xmalloc(sizeof(int) * netns.n_def_conf4);
+ if (!netns.def_conf4)
return -1;
- netns.all_conf = xmalloc(sizeof(int) * netns.n_all_conf);
- if (!netns.all_conf) {
- xfree(netns.def_conf);
+ netns.all_conf4 = xmalloc(sizeof(int) * netns.n_all_conf4);
+ if (!netns.all_conf4) {
+ xfree(netns.def_conf4);
return -1;
}
- n = netns.n_def_conf;
- ret = ipv4_conf_op("default", netns.def_conf, n, CTL_READ, NULL);
+ n = netns.n_def_conf4;
+ ret = ipv4_conf_op("default", netns.def_conf4, n, CTL_READ, NULL);
if (ret < 0)
goto err_free;
- ret = ipv4_conf_op("all", netns.all_conf, n, CTL_READ, NULL);
+ ret = ipv4_conf_op("all", netns.all_conf4, n, CTL_READ, NULL);
if (ret < 0)
goto err_free;
ret = pb_write_one(img_from_set(fds, CR_FD_NETNS), &netns, PB_NETNS);
err_free:
- xfree(netns.def_conf);
- xfree(netns.all_conf);
+ xfree(netns.def_conf4);
+ xfree(netns.all_conf4);
return ret;
}
@@ -1006,11 +1006,11 @@ static int restore_netns_conf(int pid, NetnsEntry **netns)
return -1;
}
- n = (*netns)->n_def_conf;
- ret = ipv4_conf_op("default", (*netns)->def_conf, n, CTL_WRITE, NULL);
+ n = (*netns)->n_def_conf4;
+ ret = ipv4_conf_op("default", (*netns)->def_conf4, n, CTL_WRITE, NULL);
if (ret)
goto out;
- ret = ipv4_conf_op("all", (*netns)->all_conf, n, CTL_WRITE, NULL);
+ ret = ipv4_conf_op("all", (*netns)->all_conf4, n, CTL_WRITE, NULL);
out:
close_image(img);
return ret;
diff --git a/images/netdev.proto b/images/netdev.proto
index dafa2bd..7d7bb26 100644
--- a/images/netdev.proto
+++ b/images/netdev.proto
@@ -30,10 +30,10 @@ message net_device_entry {
optional bytes address = 7;
- repeated int32 conf = 8;
+ repeated int32 conf4 = 8;
}
message netns_entry {
- repeated int32 def_conf = 1;
- repeated int32 all_conf = 2;
+ repeated int32 def_conf4 = 1;
+ repeated int32 all_conf4 = 2;
}
--
1.9.3
More information about the CRIU
mailing list