]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospf6d: assign zebra router-id to ospf6 instance
authorChirag Shah <chirag@cumulusnetworks.com>
Tue, 27 Feb 2018 19:24:16 +0000 (11:24 -0800)
committerChirag Shah <chirag@cumulusnetworks.com>
Thu, 1 Mar 2018 22:19:15 +0000 (14:19 -0800)
Store zebra router-id in global structure.
Before router ospf6 instance created,
zebra router-id callback called.

During ospf6 main execution zebra init happens,
but default instance does not execute until
cli replay 'router ospf6'.
Call ospf6_router_id_change during 'router ospf6'
to assign zebra router id to ospf6 instance.

Ticket:CM-19937
Testing Done:
Assign Loopback /32 (6.6.6.6/32) address,
restart frr with (router ospf6 in frr.conf).
ospf6 default instance assigned 6.6.6.6 router-id.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
ospf6d/ospf6_main.c
ospf6d/ospf6_top.c
ospf6d/ospf6_top.h
ospf6d/ospf6_zebra.c

index 88f03d8f646ec1d0d49b0bdc07e8cd3815e1f280..9580d87cf031c365431bf8a43a68923dd422e77d 100644 (file)
@@ -202,6 +202,9 @@ int main(int argc, char *argv[], char *envp[])
                exit(1);
        }
 
+       /* OSPF6 master init. */
+       ospf6_master_init();
+
        /* thread master */
        master = frr_init();
 
index 25d968fb689e575dc3c5ada7240769ea6f2a2710..28379458d24f585e754fdb7c709e641b44fe8574 100644 (file)
@@ -53,6 +53,8 @@ DEFINE_QOBJ_TYPE(ospf6)
 
 /* global ospf6d variable */
 struct ospf6 *ospf6;
+static struct ospf6_master ospf6_master;
+struct ospf6_master *om6;
 
 static void ospf6_disable(struct ospf6 *o);
 
@@ -230,6 +232,13 @@ static void ospf6_disable(struct ospf6 *o)
        }
 }
 
+void ospf6_master_init(void)
+{
+       memset(&ospf6_master, 0, sizeof(struct ospf6_master));
+
+       om6 = &ospf6_master;
+}
+
 static int ospf6_maxage_remover(struct thread *thread)
 {
        struct ospf6 *o = (struct ospf6 *)THREAD_ARG(thread);
@@ -285,6 +294,17 @@ void ospf6_maxage_remove(struct ospf6 *o)
                                 &o->maxage_remover);
 }
 
+void ospf6_router_id_update(void)
+{
+       if (!ospf6)
+               return;
+
+       if (ospf6->router_id_static != 0)
+               ospf6->router_id = ospf6->router_id_static;
+       else
+               ospf6->router_id = om6->zebra_router_id;
+}
+
 /* start ospf6 */
 DEFUN_NOSH (router_ospf6,
        router_ospf6_cmd,
@@ -292,9 +312,11 @@ DEFUN_NOSH (router_ospf6,
        ROUTER_STR
        OSPF6_STR)
 {
-       if (ospf6 == NULL)
+       if (ospf6 == NULL) {
                ospf6 = ospf6_create();
-
+               if (ospf6->router_id == 0)
+                       ospf6_router_id_update();
+       }
        /* set current ospf point. */
        VTY_PUSH_CONTEXT(OSPF6_NODE, ospf6);
 
index d7a3766b80498676b255c183f66c2d9473a0d16c..3ffcad0564c1bd41fe077ddcfb8063ca728a142f 100644 (file)
 #include "qobj.h"
 #include "routemap.h"
 
+struct ospf6_master {
+
+       uint32_t zebra_router_id;
+};
+
 /* OSPFv3 top level data structure */
 struct ospf6 {
        /* my router id */
@@ -109,10 +114,13 @@ DECLARE_QOBJ_TYPE(ospf6)
 
 /* global pointer for OSPF top data structure */
 extern struct ospf6 *ospf6;
+extern struct ospf6_master *om6;
 
 /* prototypes */
+extern void ospf6_master_init(void);
 extern void ospf6_top_init(void);
 extern void ospf6_delete(struct ospf6 *o);
+extern void ospf6_router_id_update(void);
 
 extern void ospf6_maxage_remove(struct ospf6 *o);
 
index 4fb959b952e63dbf64c0741878e9a7c1058e8587..0decc09a29abe584ff2583dad1962a9653cc1b7b 100644 (file)
@@ -55,13 +55,22 @@ static int ospf6_router_id_update_zebra(int command, struct zclient *zclient,
 
        zebra_router_id_update_read(zclient->ibuf, &router_id);
 
+       om6->zebra_router_id = router_id.u.prefix4.s_addr;
+
        if (o == NULL)
                return 0;
 
        o->router_id_zebra = router_id.u.prefix4;
+       if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
+               char buf[INET_ADDRSTRLEN];
+
+               zlog_debug("%s: zebra router-id %s update",
+                          __PRETTY_FUNCTION__,
+                          inet_ntop(AF_INET, &router_id.u.prefix4,
+                                    buf, INET_ADDRSTRLEN));
+       }
 
-       if (o->router_id == 0)
-               o->router_id = (uint32_t)o->router_id_zebra.s_addr;
+       ospf6_router_id_update();
 
        return 0;
 }