mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
zdtm/net/ipv4: split save_and_set and check_and_restore
As changing disable_ipv6 sysctl for some device may change mtu sysctl for it we need to first check mtu, and only then set disable_ipv6. That can be done splitting our functions into two. Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Reviewed-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
701faddc84
commit
cde72cabbd
@ -90,6 +90,22 @@ struct test_conf {
|
||||
char *dir4;
|
||||
} lo, def;
|
||||
|
||||
static int save_conf(FILE *fp, int *conf, int *conf_rand,
|
||||
struct range *range, char *path) {
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Save
|
||||
*/
|
||||
ret = fscanf(fp, "%d", conf);
|
||||
if (ret != 1) {
|
||||
pr_perror("fscanf");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rand_in_small_range(struct range *r) {
|
||||
return lrand48() % (r->max - r->min + 1) + r->min;
|
||||
}
|
||||
@ -113,25 +129,9 @@ static int rand_in_range(struct range *r) {
|
||||
return rand_in_small_range(&small);
|
||||
}
|
||||
|
||||
static int save_and_set(FILE *fp, int *conf, int *conf_rand,
|
||||
static int gen_conf(FILE *fp, int *conf, int *conf_rand,
|
||||
struct range *range, char *path) {
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Save
|
||||
*/
|
||||
ret = fscanf(fp, "%d", conf);
|
||||
if (ret != 1) {
|
||||
pr_perror("fscanf");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fseek(fp, 0, SEEK_SET);
|
||||
if (ret) {
|
||||
pr_perror("fseek");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set random value
|
||||
*/
|
||||
@ -146,7 +146,7 @@ static int save_and_set(FILE *fp, int *conf, int *conf_rand,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_and_restore(FILE *fp, int *conf, int *conf_rand,
|
||||
static int check_conf(FILE *fp, int *conf, int *conf_rand,
|
||||
struct range *range, char *path) {
|
||||
int ret;
|
||||
int val;
|
||||
@ -166,12 +166,12 @@ static int check_and_restore(FILE *fp, int *conf, int *conf_rand,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fseek(fp, 0, SEEK_SET);
|
||||
if (ret) {
|
||||
pr_perror("fseek");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int restore_conf(FILE *fp, int *conf, int *conf_rand,
|
||||
struct range *range, char *path) {
|
||||
int ret;
|
||||
/*
|
||||
* Restore opt
|
||||
*/
|
||||
@ -228,22 +228,34 @@ int main(int argc, char **argv)
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
ret = for_each_option_do(save_and_set, &lo);
|
||||
ret = for_each_option_do(save_conf, &lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(gen_conf, &lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
ret = for_each_option_do(save_and_set, &def);
|
||||
ret = for_each_option_do(save_conf, &def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(gen_conf, &def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
ret = for_each_option_do(check_and_restore, &lo);
|
||||
ret = for_each_option_do(check_conf, &lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(restore_conf, &lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
ret = for_each_option_do(check_and_restore, &def);
|
||||
ret = for_each_option_do(check_conf, &def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(restore_conf, &def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user