[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1481832422-10267-4-git-send-email-dsa@cumulusnetworks.com>
Date: Thu, 15 Dec 2016 12:07:01 -0800
From: David Ahern <dsa@...ulusnetworks.com>
To: netdev@...r.kernel.org, stephen@...workplumber.org
Cc: David Ahern <dsa@...ulusnetworks.com>
Subject: [PATCH iproute2 3/4] 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@...ulusnetworks.com>
---
ip/ipvrf.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/ip/ipvrf.c b/ip/ipvrf.c
index a2669f339691..de2ec5c120cb 100644
--- a/ip/ipvrf.c
+++ b/ip/ipvrf.c
@@ -202,16 +202,15 @@ static int vrf_configure_cgroup(const char *path, int ifindex)
static int vrf_switch(const char *name)
{
char path[PATH_MAX], *mnt, pid[16];
- int ifindex = name_is_vrf(name);
- bool default_vrf = false;
+ int ifindex = 0;
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");
return -1;
}
- default_vrf = true;
}
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"
* to the end of the path
*/
- len = snprintf(path, sizeof(path) - sizeof(CGRP_PROC_FILE), "%s%s/%s",
- mnt, default_vrf ? "" : "/vrf", name);
+ len = snprintf(path, sizeof(path) - sizeof(CGRP_PROC_FILE), "%s/vrf/%s",
+ mnt, ifindex ? name : "");
if (len > sizeof(path) - sizeof(CGRP_PROC_FILE)) {
fprintf(stderr, "Invalid path to cgroup2 mount\n");
goto out;
@@ -233,7 +232,7 @@ static int vrf_switch(const char *name)
goto out;
}
- if (!default_vrf && vrf_configure_cgroup(path, ifindex))
+ if (ifindex && vrf_configure_cgroup(path, ifindex))
goto out;
/*
--
2.1.4
Powered by blists - more mailing lists