]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: VRF aware Router-ID update 1400/head
authorChirag Shah <chirag@cumulusnetworks.com>
Thu, 2 Nov 2017 14:54:45 +0000 (07:54 -0700)
committerChirag Shah <chirag@cumulusnetworks.com>
Mon, 6 Nov 2017 21:15:41 +0000 (13:15 -0800)
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>
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
ospfd/ospfd.c
ospfd/ospfd.h

index cfbe7a459a221771b8c2d80f8b1f99a85c1b8b65..a49143873e5120b56af2a19d29672d4aacbdf6d8 100644 (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);
index 76fa6fa6dd76980b34d7658c5b4838a2fa08ccc0..d7fe0edcbf354a1dc305e3ca63099bba90ba8ba0 100644 (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);
index 3771f946309d3073eafbb13741859e1fab0245f9..b0646495a581cd87ed269b5cd01dcf0347369889 100644 (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);
                }
        }
index 4c5bb756f6e759731f33af69e76a785e294af44c..df318cf2c0aa0e276b5ae2aad1655b257fa48304 100644 (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 */