]> git.proxmox.com Git - mirror_frr.git/blobdiff - isisd/isis_te.c
Merge pull request #12698 from Orange-OpenSource/isisd
[mirror_frr.git] / isisd / isis_te.c
index 95a1dc989f22263fc9b3e021e289cfdcbce02757..4e180ead6189cd6a935e51abc8e08d2dae116127 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * IS-IS Rout(e)ing protocol - isis_te.c
  *
@@ -6,29 +7,13 @@
  * Author: Olivier Dugeon <olivier.dugeon@orange.com>
  *
  * Copyright (C) 2014 - 2019 Orange Labs http://www.orange.com
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
 #include <math.h>
 
 #include "linklist.h"
-#include "thread.h"
+#include "frrevent.h"
 #include "vty.h"
 #include "stream.h"
 #include "memory.h"
@@ -765,6 +750,11 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv,
                attr->standard.admin_group = tlvs->adm_group;
                SET_FLAG(attr->flags, LS_ATTR_ADM_GRP);
        }
+       if (CHECK_FLAG(tlvs->status, EXT_EXTEND_ADM_GRP)) {
+               admin_group_copy(&attr->ext_admin_group,
+                                &tlvs->ext_admin_group);
+               SET_FLAG(attr->flags, LS_ATTR_EXT_ADM_GRP);
+       }
        if (CHECK_FLAG(tlvs->status, EXT_LLRI)) {
                attr->standard.local_id = tlvs->local_llri;
                attr->standard.remote_id = tlvs->remote_llri;
@@ -913,7 +903,7 @@ static int lsp_to_edge_cb(const uint8_t *id, uint32_t metric, bool old_metric,
        struct ls_edge *edge, *dst;
        struct ls_attributes *attr;
 
-       te_debug("  |- Process Extended IS for %s", sysid_print(id));
+       te_debug("  |- Process Extended IS for %pSY", id);
 
        /* Check parameters */
        if (old_metric || !args || !tlvs)
@@ -1085,16 +1075,29 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric,
        }
        if (!std)
                prefix_copy(&p, prefix);
-       else
+       else {
+               /* Remove old subnet if any before prefix adjustment */
+               subnet = ls_find_subnet(args->ted, prefix);
+               if (subnet) {
+                       if (args->export) {
+                               subnet->status = DELETE;
+                               isis_te_export(LS_MSG_TYPE_PREFIX, subnet);
+                       }
+                       te_debug("   |- Remove subnet with prefix %pFX",
+                                &subnet->key);
+                       ls_subnet_del_all(args->ted, subnet);
+               }
                te_debug("   |- Adjust prefix %pFX with local address to: %pFX",
                         prefix, &p);
+       }
 
        /* Search existing Subnet in TED ... */
-       subnet = ls_find_subnet(args->ted, p);
+       subnet = ls_find_subnet(args->ted, &p);
        /* ... and create a new Subnet if not found */
        if (!subnet) {
-               ls_pref = ls_prefix_new(vertex->node->adv, p);
+               ls_pref = ls_prefix_new(vertex->node->adv, &p);
                subnet = ls_subnet_add(args->ted, ls_pref);
+               /* Stop processing if we are unable to create a new subnet */
                if (!subnet)
                        return LSP_ITER_CONTINUE;
        }
@@ -1177,14 +1180,14 @@ static void isis_te_parse_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp)
 
        ted = mta->ted;
 
-       te_debug("ISIS-TE(%s): Parse LSP %s", lsp->area->area_tag,
-                sysid_print(lsp->hdr.lsp_id));
+       te_debug("ISIS-TE(%s): Parse LSP %pSY", lsp->area->area_tag,
+                lsp->hdr.lsp_id);
 
        /* First parse LSP to obtain the corresponding Vertex */
        vertex = lsp_to_vertex(ted, lsp);
        if (!vertex) {
-               zlog_warn("Unable to build Vertex from LSP %s. Abort!",
-                         sysid_print(lsp->hdr.lsp_id));
+               zlog_warn("Unable to build Vertex from LSP %pSY. Abort!",
+                         lsp->hdr.lsp_id);
                return;
        }
 
@@ -1248,8 +1251,8 @@ static void isis_te_delete_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp)
        if (!IS_MPLS_TE(mta) || !mta->ted || !lsp)
                return;
 
-       te_debug("ISIS-TE(%s): Delete Link State TED objects from LSP %s",
-                lsp->area->area_tag, sysid_print(lsp->hdr.lsp_id));
+       te_debug("ISIS-TE(%s): Delete Link State TED objects from LSP %pSY",
+                lsp->area->area_tag, lsp->hdr.lsp_id);
 
        /* Compute Link State Node ID from IS-IS sysID ... */
        if (lsp->level == ISIS_LEVEL1)
@@ -1832,7 +1835,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
                                return CMD_WARNING_CONFIG_FAILED;
                        }
                        /* Get the Subnet from the Link State Database */
-                       subnet = ls_find_subnet(ted, pref);
+                       subnet = ls_find_subnet(ted, &pref);
                        if (!subnet) {
                                vty_out(vty, "No subnet found for ID %pFX\n",
                                        &pref);
@@ -1845,7 +1848,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
                                return CMD_WARNING_CONFIG_FAILED;
                        }
                        /* Get the Subnet from the Link State Database */
-                       subnet = ls_find_subnet(ted, pref);
+                       subnet = ls_find_subnet(ted, &pref);
                        if (!subnet) {
                                vty_out(vty, "No subnet found for ID %pFX\n",
                                        &pref);