ip vrf: Fix reset to default VRF
Path in vrf_switch for "default" VRF is supposed to be MNT/vrf not MNT/default. Also, default_vrf flag is redundant with ifindex. Remove the flag in favor of ifindex != 0. Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
This commit is contained in:
parent
b5efa59763
commit
2917b4f41a
15
ip/ipvrf.c
15
ip/ipvrf.c
|
|
@ -202,16 +202,15 @@ out:
|
||||||
static int vrf_switch(const char *name)
|
static int vrf_switch(const char *name)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX], *mnt, pid[16];
|
char path[PATH_MAX], *mnt, pid[16];
|
||||||
int ifindex = name_is_vrf(name);
|
int ifindex = 0;
|
||||||
bool default_vrf = false;
|
|
||||||
int rc = -1, len, fd = -1;
|
int rc = -1, len, fd = -1;
|
||||||
|
|
||||||
if (!ifindex) {
|
if (strcmp(name, "default")) {
|
||||||
if (strcmp(name, "default")) {
|
ifindex = name_is_vrf(name);
|
||||||
|
if (!ifindex) {
|
||||||
fprintf(stderr, "Invalid VRF name\n");
|
fprintf(stderr, "Invalid VRF name\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
default_vrf = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mnt = find_cgroup2_mount();
|
mnt = find_cgroup2_mount();
|
||||||
|
|
@ -221,8 +220,8 @@ static int vrf_switch(const char *name)
|
||||||
/* path to cgroup; make sure buffer has room to cat "/cgroup.procs"
|
/* path to cgroup; make sure buffer has room to cat "/cgroup.procs"
|
||||||
* to the end of the path
|
* to the end of the path
|
||||||
*/
|
*/
|
||||||
len = snprintf(path, sizeof(path) - sizeof(CGRP_PROC_FILE), "%s%s/%s",
|
len = snprintf(path, sizeof(path) - sizeof(CGRP_PROC_FILE), "%s/vrf/%s",
|
||||||
mnt, default_vrf ? "" : "/vrf", name);
|
mnt, ifindex ? name : "");
|
||||||
if (len > sizeof(path) - sizeof(CGRP_PROC_FILE)) {
|
if (len > sizeof(path) - sizeof(CGRP_PROC_FILE)) {
|
||||||
fprintf(stderr, "Invalid path to cgroup2 mount\n");
|
fprintf(stderr, "Invalid path to cgroup2 mount\n");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -233,7 +232,7 @@ static int vrf_switch(const char *name)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!default_vrf && vrf_configure_cgroup(path, ifindex))
|
if (ifindex && vrf_configure_cgroup(path, ifindex))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue