Blob Blame History Raw
From 1a9c12f737e86a7905cd123f364af053dc0c7491 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Fri, 28 Jun 2019 14:12:36 +0200
Subject: [PATCH] ip vrf: use hook to change VRF in the child

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1719759
Upstream Status: iproute2.git commit d81d4ba15d74a

commit d81d4ba15d74a51f23f61a2ddb792689e5db95f0
Author: Matteo Croce <mcroce@redhat.com>
Date:   Tue Jun 18 16:49:34 2019 +0200

    ip vrf: use hook to change VRF in the child

    On vrf exec, reset the VRF associations in the child process, via the
    new hook added to cmd_exec(). In this way, the parent doesn't have to
    reset the VRF associations before spawning other processes.

    Signed-off-by: Matteo Croce <mcroce@redhat.com>
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/ipvrf.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ip/ipvrf.c b/ip/ipvrf.c
index c93ff71b39070..aba8639501139 100644
--- a/ip/ipvrf.c
+++ b/ip/ipvrf.c
@@ -441,6 +441,13 @@ out:
 	return rc;
 }
 
+static int do_switch(void *arg)
+{
+	char *vrf = arg;
+
+	return vrf_switch(vrf);
+}
+
 static int ipvrf_exec(int argc, char **argv)
 {
 	if (argc < 1) {
@@ -452,10 +459,7 @@ static int ipvrf_exec(int argc, char **argv)
 		return -1;
 	}
 
-	if (vrf_switch(argv[0]))
-		return -1;
-
-	return -cmd_exec(argv[1], argv + 1, !!batch_mode, NULL, NULL);
+	return -cmd_exec(argv[1], argv + 1, !!batch_mode, do_switch, argv[0]);
 }
 
 /* reset VRF association of current process to default VRF;
-- 
2.20.1