ospfd: VRF aware Router-ID update

Ensure zebra received router-id isolated per vrf instance.
Store zebra received router-id within ospf instance.

Ticket:CM-18657
Reviewed By:
Testing Done:
Validated follwoing sequence
- Create vrf1111
- Create ospf vrf1111 with no router-id
- Assign ip to vrf111
- ospf is assigned zebra assigned router-id which is vrf ip.
- upon remvoing vrf ip, the router-id retained as same until
ospfd restarted.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
Chirag Shah 2017-11-02 07:54:45 -07:00
parent 0ce9f92d86
commit 6021c6c059
4 changed files with 15 additions and 15 deletions

View File

@ -244,7 +244,6 @@ DEFUN (no_router_ospf,
else
return CMD_WARNING;
}
zlog_debug("%s: no router ospf ", __PRETTY_FUNCTION__);
ospf_finish(ospf);
return CMD_SUCCESS;
@ -4151,12 +4150,12 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
if (nbr->state == NSM_Attempt &&
nbr->router_id.s_addr == 0)
strncpy(neigh_str, "neighbor",
INET_ADDRSTRLEN);
strlcpy(neigh_str, "neighbor",
sizeof(neigh_str));
else
strncpy(neigh_str,
strlcpy(neigh_str,
inet_ntoa(nbr->router_id),
INET_ADDRSTRLEN);
sizeof(neigh_str));
json_object_object_get_ex(json, neigh_str,
&json_neigh_array);

View File

@ -63,7 +63,6 @@ struct zclient *zclient = NULL;
/* For registering threads. */
extern struct thread_master *master;
struct in_addr router_id_zebra;
/* Router-id update message from zebra. */
static int ospf_router_id_update_zebra(int command, struct zclient *zclient,
@ -80,13 +79,12 @@ static int ospf_router_id_update_zebra(int command, struct zclient *zclient,
buf, ospf_vrf_id_to_name(vrf_id), vrf_id);
}
router_id_zebra = router_id.u.prefix4;
ospf = ospf_lookup_by_vrf_id(vrf_id);
if (ospf != NULL)
if (ospf != NULL) {
ospf->router_id_zebra = router_id.u.prefix4;
ospf_router_id_update(ospf);
else {
} else {
if (IS_DEBUG_OSPF_EVENT) {
char buf[PREFIX2STR_BUFFER];
@ -1434,12 +1432,14 @@ void ospf_zebra_vrf_register(struct ospf *ospf)
if (!zclient || zclient->sock < 0 || !ospf)
return;
if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) {
if (ospf->vrf_id != VRF_UNKNOWN) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: Register VRF %s id %u",
__PRETTY_FUNCTION__,
ospf_vrf_id_to_name(ospf->vrf_id),
ospf->vrf_id);
/* Deregister for router-id, interfaces,
* redistributed routes. */
zclient_send_reg_requests(zclient, ospf->vrf_id);
}
}
@ -1451,7 +1451,7 @@ void ospf_zebra_vrf_deregister(struct ospf *ospf)
if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: De-Register VRF %s id %u",
zlog_debug("%s: De-Register VRF %s id %u to Zebra.",
__PRETTY_FUNCTION__,
ospf_vrf_id_to_name(ospf->vrf_id),
ospf->vrf_id);

View File

@ -66,7 +66,6 @@ static struct ospf_master ospf_master;
struct ospf_master *om;
extern struct zclient *zclient;
extern struct in_addr router_id_zebra;
static void ospf_remove_vls_through_area(struct ospf *, struct ospf_area *);
@ -117,12 +116,12 @@ void ospf_router_id_update(struct ospf *ospf)
else if (ospf->router_id.s_addr != 0)
router_id = ospf->router_id;
else
router_id = router_id_zebra;
router_id = ospf->router_id_zebra;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("Router-ID[OLD:%s]: Update to %s",
inet_ntoa(ospf->router_id),
inet_ntoa(router_id_old));
inet_ntoa(router_id));
if (!IPV4_ADDR_SAME(&router_id_old, &router_id)) {
@ -2056,6 +2055,7 @@ static int ospf_vrf_enable(struct vrf *vrf)
}
ospf->oi_running = 1;
ospf_zebra_vrf_register(ospf);
ospf_router_id_update(ospf);
}
}

View File

@ -134,6 +134,7 @@ struct ospf {
/* OSPF Router ID. */
struct in_addr router_id; /* Configured automatically. */
struct in_addr router_id_static; /* Configured manually. */
struct in_addr router_id_zebra;
vrf_id_t vrf_id; /* VRF Id */
char *name; /* VRF name */