summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2022-01-23 22:07:20 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2022-01-24 12:44:05 +0100
commit788a036fdb57d733371b180d1d295ce6ca72bf5d (patch)
treeda6694b6b0d78fd1b679ba02a7808f0fe01f964f
parentMerge pull request #10398 from patrasar/pim_debug_fix (diff)
downloadfrr-788a036fdb57d733371b180d1d295ce6ca72bf5d.tar.xz
frr-788a036fdb57d733371b180d1d295ce6ca72bf5d.zip
*: do not print vrf name for interface config when using vrf-lite
VRF name should not be printed in the config since 574445ec. The update was done for NB config output but I missed it for regular vty output. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
-rw-r--r--babeld/babel_interface.c4
-rw-r--r--isisd/isis_circuit.c4
-rw-r--r--lib/if.c16
-rw-r--r--lib/if.h2
-rw-r--r--nhrpd/nhrp_vty.c4
-rw-r--r--ospf6d/ospf6_interface.c8
-rw-r--r--ospfd/ospf_vty.c10
-rw-r--r--pbrd/pbr_vty.c8
-rw-r--r--pimd/pim_vty.c9
-rw-r--r--tests/topotests/lib/common_config.py10
-rw-r--r--zebra/interface.c8
11 files changed, 37 insertions, 46 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index e725fbffe..98c5d2119 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -1308,7 +1308,7 @@ interface_config_write (struct vty *vty)
int write = 0;
FOR_ALL_INTERFACES (vrf, ifp) {
- vty_frame (vty, "interface %s\n",ifp->name);
+ if_vty_config_start(vty, ifp);
if (ifp->desc)
vty_out (vty, " description %s\n",ifp->desc);
babel_interface_nfo *babel_ifp = babel_get_if_nfo (ifp);
@@ -1385,7 +1385,7 @@ interface_config_write (struct vty *vty)
write++;
}
}
- vty_endframe (vty, "exit\n!\n");
+ if_vty_config_end(vty);
write++;
}
return write;
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index 0ad6190ba..1b0447226 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -1069,7 +1069,7 @@ static int isis_interface_config_write(struct vty *vty)
FOR_ALL_INTERFACES (vrf, ifp) {
/* IF name */
- vty_frame(vty, "interface %s\n", ifp->name);
+ if_vty_config_start(vty, ifp);
write++;
/* IF desc */
if (ifp->desc) {
@@ -1277,7 +1277,7 @@ static int isis_interface_config_write(struct vty *vty)
write += hook_call(isis_circuit_config_write,
circuit, vty);
} while (0);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return write;
diff --git a/lib/if.c b/lib/if.c
index 99fa83719..158303a38 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -1285,6 +1285,22 @@ static void cli_show_interface_end(struct vty *vty,
vty_out(vty, "exit\n");
}
+void if_vty_config_start(struct vty *vty, struct interface *ifp)
+{
+ vty_frame(vty, "!\n");
+ vty_frame(vty, "interface %s", ifp->name);
+
+ if (vrf_is_backend_netns() && strcmp(ifp->vrf->name, VRF_DEFAULT_NAME))
+ vty_frame(vty, " vrf %s", ifp->vrf->name);
+
+ vty_frame(vty, "\n");
+}
+
+void if_vty_config_end(struct vty *vty)
+{
+ vty_endframe(vty, "exit\n!\n");
+}
+
/*
* XPath: /frr-interface:lib/interface/description
*/
diff --git a/lib/if.h b/lib/if.h
index c8f4d9ab9..53cd01946 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -592,6 +592,8 @@ void if_link_params_free(struct interface *);
/* Northbound. */
struct vty;
+extern void if_vty_config_start(struct vty *vty, struct interface *ifp);
+extern void if_vty_config_end(struct vty *vty);
extern void if_cmd_init(int (*config_write)(struct vty *));
extern void if_cmd_init_default(void);
extern void if_zapi_callbacks(int (*create)(struct interface *ifp),
diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c
index 0dfabcf6a..97290ca84 100644
--- a/nhrpd/nhrp_vty.c
+++ b/nhrpd/nhrp_vty.c
@@ -1150,7 +1150,7 @@ static int interface_config_write(struct vty *vty)
int i;
FOR_ALL_INTERFACES (vrf, ifp) {
- vty_frame(vty, "interface %s\n", ifp->name);
+ if_vty_config_start(vty, ifp);
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
@@ -1221,7 +1221,7 @@ static int interface_config_write(struct vty *vty)
}
}
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return 0;
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index ae9f13bc1..0d9f15d08 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -2522,11 +2522,7 @@ static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
if (oi == NULL)
continue;
- if (vrf->vrf_id == VRF_DEFAULT)
- vty_frame(vty, "interface %s\n", oi->interface->name);
- else
- vty_frame(vty, "interface %s vrf %s\n",
- oi->interface->name, vrf->name);
+ if_vty_config_start(vty, ifp);
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
@@ -2581,7 +2577,7 @@ static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
ospf6_bfd_write_config(vty, oi);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return 0;
}
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 3d0804b01..59fe89a6b 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -11582,12 +11582,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
if (memcmp(ifp->name, "VLINK", 5) == 0)
continue;
- vty_frame(vty, "!\n");
- if (ifp->vrf->vrf_id == VRF_DEFAULT)
- vty_frame(vty, "interface %s\n", ifp->name);
- else
- vty_frame(vty, "interface %s vrf %s\n", ifp->name,
- vrf->name);
+ if_vty_config_start(vty, ifp);
+
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
@@ -11797,7 +11793,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
ospf_opaque_config_write_if(vty, ifp);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return write;
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c
index ebcbbb720..c9ec532bb 100644
--- a/pbrd/pbr_vty.c
+++ b/pbrd/pbr_vty.c
@@ -1197,18 +1197,14 @@ static int pbr_interface_config_write(struct vty *vty)
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
FOR_ALL_INTERFACES (vrf, ifp) {
- if (vrf->vrf_id == VRF_DEFAULT)
- vty_frame(vty, "interface %s\n", ifp->name);
- else
- vty_frame(vty, "interface %s vrf %s\n",
- ifp->name, vrf->name);
+ if_vty_config_start(vty, ifp);
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
pbr_map_write_interfaces(vty, ifp);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
}
diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c
index 81e1ac4e3..8c0132a9a 100644
--- a/pimd/pim_vty.c
+++ b/pimd/pim_vty.c
@@ -302,11 +302,8 @@ int pim_interface_config_write(struct vty *vty)
continue;
/* IF name */
- if (vrf->vrf_id == VRF_DEFAULT)
- vty_frame(vty, "interface %s\n", ifp->name);
- else
- vty_frame(vty, "interface %s vrf %s\n",
- ifp->name, vrf->name);
+ if_vty_config_start(vty, ifp);
+
++writes;
if (ifp->desc) {
@@ -455,7 +452,7 @@ int pim_interface_config_write(struct vty *vty)
pim_bfd_write_config(vty, ifp);
++writes;
}
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
++writes;
}
}
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index c744e5bbb..f538b5a52 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -2083,15 +2083,7 @@ def create_interfaces_cfg(tgen, topo, build=False):
else:
interface_name = data["interface"]
- # Include vrf if present
- if "vrf" in data:
- interface_data.append(
- "interface {} vrf {}".format(
- str(interface_name), str(data["vrf"])
- )
- )
- else:
- interface_data.append("interface {}".format(str(interface_name)))
+ interface_data.append("interface {}".format(str(interface_name)))
if "ipv4" in data:
intf_addr = c_data["links"][destRouterLink]["ipv4"]
diff --git a/zebra/interface.c b/zebra/interface.c
index 534953d90..e4e80ec4e 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -4213,11 +4213,7 @@ static int if_config_write(struct vty *vty)
if_data = ifp->info;
- if (ifp->vrf->vrf_id == VRF_DEFAULT)
- vty_frame(vty, "interface %s\n", ifp->name);
- else
- vty_frame(vty, "interface %s vrf %s\n",
- ifp->name, vrf->name);
+ if_vty_config_start(vty, ifp);
if (if_data) {
if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)
@@ -4283,7 +4279,7 @@ static int if_config_write(struct vty *vty)
zebra_evpn_mh_if_write(vty, ifp);
link_params_config_write(vty, ifp);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return 0;
}