ip netns: Reset vrf to default VRF on namespace switch
A vrf is local to a namespace. Drop any VRF association before trying to exec a command in the new namespace. Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
This commit is contained in:
parent
2917b4f41a
commit
ee9369a05f
|
|
@ -58,6 +58,7 @@ int do_tcp_metrics(int argc, char **argv);
|
|||
int do_ipnetconf(int argc, char **argv);
|
||||
int do_iptoken(int argc, char **argv);
|
||||
int do_ipvrf(int argc, char **argv);
|
||||
void vrf_reset(void);
|
||||
|
||||
int iplink_get(unsigned int flags, char *name, __u32 filt_mask);
|
||||
|
||||
|
|
|
|||
|
|
@ -387,6 +387,11 @@ static int netns_exec(int argc, char **argv)
|
|||
if (netns_switch(argv[0]))
|
||||
return -1;
|
||||
|
||||
/* we just changed namespaces. clear any vrf association
|
||||
* with prior namespace before exec'ing command
|
||||
*/
|
||||
vrf_reset();
|
||||
|
||||
/* ip must return the status of the child,
|
||||
* but do_cmd() will add a minus to this,
|
||||
* so let's add another one here to cancel it.
|
||||
|
|
|
|||
14
ip/ipvrf.c
14
ip/ipvrf.c
|
|
@ -277,6 +277,20 @@ static int ipvrf_exec(int argc, char **argv)
|
|||
return -cmd_exec(argv[1], argv + 1, !!batch_mode);
|
||||
}
|
||||
|
||||
/* reset VRF association of current process to default VRF;
|
||||
* used by netns_exec
|
||||
*/
|
||||
void vrf_reset(void)
|
||||
{
|
||||
char vrf[32];
|
||||
|
||||
if (vrf_identify(getpid(), vrf, sizeof(vrf)) ||
|
||||
(vrf[0] == '\0'))
|
||||
return;
|
||||
|
||||
vrf_switch("default");
|
||||
}
|
||||
|
||||
int do_ipvrf(int argc, char **argv)
|
||||
{
|
||||
if (argc == 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue