]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospfd: adaptations to handle vrf alias
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 6 Jun 2018 08:13:44 +0000 (10:13 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 28 Aug 2018 14:23:50 +0000 (16:23 +0200)
Some adaptations are done to handle alias when creationg ospf instance.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
ospfd/ospf_vty.c
ospfd/ospfd.c

index fb9770d09ad9e7842c107a18558f1158ce490d68..39f14a00c3acf850a49ae12bc0c85820624a22c8 100644 (file)
@@ -145,6 +145,8 @@ static struct ospf *ospf_cmd_lookup_ospf(struct vty *vty,
 
        if (argv_find(argv, argc, "vrf", &idx_vrf)) {
                vrf_name = argv[idx_vrf + 1]->arg;
+               if (vrf_name == NULL || strmatch(vrf_name, VRF_DEFAULT_NAME))
+                       vrf_name = NULL;
                if (enable) {
                        /* Allocate VRF aware instance */
                        ospf = ospf_get(*instance, vrf_name);
index 62de94a475dd05df439cfaf24c91ec52558db1fe..d311b4da6b75e32664cb9796779fbfb25e78255e 100644 (file)
@@ -234,12 +234,10 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)
        new->instance = instance;
        new->router_id.s_addr = htonl(0);
        new->router_id_static.s_addr = htonl(0);
-
-       if (name) {
+       if (name && !strmatch(name, VRF_DEFAULT_NAME)) {
                new->vrf_id = VRF_UNKNOWN;
                /* Freed in ospf_finish_final */
                new->name = XSTRDUP(MTYPE_OSPF_TOP, name);
-               vrf = vrf_lookup_by_name(new->name);
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
                                "%s: Create new ospf instance with vrf_name %s vrf_id %u",
@@ -381,6 +379,9 @@ struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
        struct ospf *ospf = NULL;
        struct listnode *node, *nnode;
 
+       if (name == NULL || strmatch(name, VRF_DEFAULT_NAME))
+               return ospf_lookup_by_vrf_id(VRF_DEFAULT);
+
        for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf)) {
                if ((ospf->instance == instance)
                    && ((ospf->name == NULL && name == NULL)
@@ -2078,6 +2079,10 @@ static int ospf_vrf_enable(struct vrf *vrf)
 
        ospf = ospf_lookup_by_name(vrf->name);
        if (ospf) {
+               if (ospf->name && strmatch(vrf->name, VRF_DEFAULT_NAME)) {
+                       XFREE(MTYPE_OSPF_TOP, ospf->name);
+                       ospf->name = NULL;
+               }
                old_vrf_id = ospf->vrf_id;
                /* We have instance configured, link to VRF and make it "up". */
                ospf_vrf_link(ospf, vrf);