]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip vrf: Fix reset to default VRF
authorDavid Ahern <dsa@cumulusnetworks.com>
Thu, 15 Dec 2016 20:07:01 +0000 (12:07 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 21 Dec 2016 23:56:39 +0000 (15:56 -0800)
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>
ip/ipvrf.c

index a2669f339691b995bbce59dbde97351db4506f89..de2ec5c120cb4ae789c5fb2688f12cba97abf8e3 100644 (file)
@@ -202,16 +202,15 @@ out:
 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;
 
        /*