ospfd: Display all vrf aware interface config

OSPF interface specific configuration can be done independent
of router ospf [vrf x] global config.
In cases where ospf interface non default vrf configuration
is done prior to 'router ospf vrf x', show running-config
would not display such configuration.

To display configuration now walk all vrfs and interface list
and only display where OSPF configure params are set.

Ticket:CM-18952
Testing Done:
Tried ospf interface specific configuration with VRF,
where router ospf vrf x is not present.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
Chirag Shah 2017-11-27 13:59:19 -08:00
parent d17ea5225b
commit c7fd72d2f7

View File

@ -9637,7 +9637,7 @@ const char *ospf_int_type_str[] = {"unknown", /* should never be used. */
static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
{
struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
struct vrf *vrf = NULL;
struct listnode *node;
struct interface *ifp;
struct crypt_key *ck;
@ -9645,16 +9645,15 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
struct ospf_if_params *params;
int write = 0;
/* Display all VRF aware OSPF interface configuration */
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
FOR_ALL_INTERFACES (vrf, ifp) {
struct vrf *vrf = NULL;
if (memcmp(ifp->name, "VLINK", 5) == 0)
continue;
vrf = vrf_lookup_by_id(ifp->vrf_id);
vty_frame(vty, "!\n");
if (ifp->vrf_id == VRF_DEFAULT || vrf == NULL)
if (ifp->vrf_id == VRF_DEFAULT)
vty_frame(vty, "interface %s\n", ifp->name);
else
vty_frame(vty, "interface %s vrf %s\n",
@ -9670,7 +9669,8 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
/* Interface Network print. */
if (OSPF_IF_PARAM_CONFIGURED(params, type)
&& params->type != OSPF_IFTYPE_LOOPBACK) {
if (params->type != ospf_default_iftype(ifp)) {
if (params->type !=
ospf_default_iftype(ifp)) {
vty_out(vty, " ip ospf network %s",
ospf_int_type_str
[params->type]);
@ -9730,11 +9730,13 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
/* Cryptographic Authentication Key print. */
if (params && params->auth_crypt) {
for (ALL_LIST_ELEMENTS_RO(params->auth_crypt,
for (ALL_LIST_ELEMENTS_RO(
params->auth_crypt,
node, ck)) {
vty_out(vty,
" ip ospf message-digest-key %d md5 %s",
ck->key_id, ck->auth_key);
ck->key_id,
ck->auth_key);
if (params != IF_DEF_PARAMS(ifp))
vty_out(vty, " %s",
inet_ntoa(rn->p.u.prefix4));
@ -9755,7 +9757,8 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
/* Hello Interval print. */
if (OSPF_IF_PARAM_CONFIGURED(params, v_hello)
&& params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) {
&& params->v_hello !=
OSPF_HELLO_INTERVAL_DEFAULT) {
vty_out(vty, " ip ospf hello-interval %u",
params->v_hello);
if (params != IF_DEF_PARAMS(ifp))
@ -9778,7 +9781,8 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
"minimal hello-multiplier %d",
params->fast_hello);
else
vty_out(vty, "%u", params->v_wait);
vty_out(vty, "%u",
params->v_wait);
if (params != IF_DEF_PARAMS(ifp))
vty_out(vty, " %s",
@ -9812,7 +9816,8 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
}
/* Transmit Delay print. */
if (OSPF_IF_PARAM_CONFIGURED(params, transmit_delay)
if (OSPF_IF_PARAM_CONFIGURED(params,
transmit_delay)
&& params->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT) {
vty_out(vty, " ip ospf transmit-delay %u",
@ -9847,11 +9852,13 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
}
/* bfd print. */
if (params->bfd_info)
ospf_bfd_write_config(vty, params);
/* MTU ignore print. */
if (OSPF_IF_PARAM_CONFIGURED(params, mtu_ignore)
&& params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) {
&& params->mtu_ignore !=
OSPF_MTU_IGNORE_DEFAULT) {
if (params->mtu_ignore == 0)
vty_out(vty, " no ip ospf mtu-ignore");
else
@ -9865,7 +9872,8 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
while (1) {
if (rn == NULL)
rn = route_top(IF_OIFS_PARAMS(ifp));
rn = route_top(
IF_OIFS_PARAMS(ifp));
else
rn = route_next(rn);
@ -9881,6 +9889,7 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
vty_endframe(vty, NULL);
}
}
return write;
}
@ -9888,11 +9897,9 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
static int config_write_interface(struct vty *vty)
{
int write = 0;
struct ospf *ospf = NULL;
struct listnode *node = NULL;
struct ospf *ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
/* Traverse all ospf [vrf] instances */
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf))
/* Pass Default ospf instances to display MI-OSPF instance id */
write += config_write_interface_one(vty, ospf);
return write;