*: 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>
This commit is contained in:
Igor Ryzhov 2022-01-24 00:07:20 +03:00
parent 9e84443aca
commit 788a036fdb
11 changed files with 37 additions and 46 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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
*/

View File

@ -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),

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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"]

View File

@ -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;
}