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);
write++;
}
}
- vty_endframe (vty, "exit\n!\n");
+ if_vty_config_end(vty);
write++;
}
return write;
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) {
write += hook_call(isis_circuit_config_write,
circuit, vty);
} while (0);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return write;
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
*/
/* 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),
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);
}
}
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return 0;
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);
ospf6_bfd_write_config(vty, oi);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return 0;
}
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);
ospf_opaque_config_write_if(vty, ifp);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return write;
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);
}
}
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) {
pim_bfd_write_config(vty, ifp);
++writes;
}
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
++writes;
}
}
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"]
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)
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;
}