]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: IS-IS-SR preparation for master 4/5
authorOlivier Dugeon <olivier.dugeon@orange.com>
Mon, 4 May 2020 16:26:21 +0000 (18:26 +0200)
committerOlivier Dugeon <olivier.dugeon@orange.com>
Thu, 14 May 2020 14:36:43 +0000 (16:36 +0200)
 * Regroup fonctions to install label for Prefix and Adjacency SID
 * Change 'replace_semantics' variable name by 'make_before_break' in
   sr_prefix_reinstall() function and adjust comments
 * Call directly lsp_regenerate_schedule() from isis_nb_config.c when MSD
   is updated

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
isisd/isis_nb_config.c
isisd/isis_sr.c
isisd/isis_sr.h
isisd/isis_zebra.c
isisd/isis_zebra.h

index ec3b7baa3101370c0cba52fe79d0afad055e3bfb..a649e896facdcc4affff4c1ae874d46402e8c404 100644 (file)
@@ -1521,7 +1521,9 @@ int isis_instance_segment_routing_msd_node_msd_modify(
 
        area = nb_running_get_entry(args->dnode, NULL, true);
        area->srdb.config.msd = yang_dnode_get_uint8(args->dnode, NULL);
-       isis_sr_cfg_msd_update(area);
+
+       /* Update and regenerate LSP */
+       lsp_regenerate_schedule(area, area->is_type, 0);
 
        return NB_OK;
 }
@@ -1536,7 +1538,9 @@ int isis_instance_segment_routing_msd_node_msd_destroy(
 
        area = nb_running_get_entry(args->dnode, NULL, true);
        area->srdb.config.msd = 0;
-       isis_sr_cfg_msd_update(area);
+
+       /* Update and regenerate LSP */
+       lsp_regenerate_schedule(area, area->is_type, 0);
 
        return NB_OK;
 }
index 948b8e39c8fd6626f6b6c7ebe7c9227f0263fb80..fc97c0fc984f58fc7aade5ca1b455e883bc02ee8 100644 (file)
@@ -51,8 +51,7 @@
 DEFINE_MTYPE_STATIC(ISISD, ISIS_SR_INFO, "ISIS segment routing information")
 
 static void sr_prefix_uninstall(struct sr_prefix *srp);
-static void sr_prefix_reinstall(struct sr_prefix *srp,
-                                    bool replace_semantics);
+static void sr_prefix_reinstall(struct sr_prefix *srp, bool make_before_break);
 
 /*----------------------------------------------------------------------------*/
 
@@ -138,12 +137,6 @@ int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound,
        return 0;
 }
 
-/* Handle changes in the local MSD configuration. */
-void isis_sr_cfg_msd_update(struct isis_area *area)
-{
-       lsp_regenerate_schedule(area, area->is_type, 0);
-}
-
 /* Handle new Prefix-SID configuration. */
 struct sr_prefix_cfg *isis_sr_cfg_prefix_add(struct isis_area *area,
                                             const struct prefix *prefix)
@@ -368,8 +361,10 @@ static void sr_node_srgb_update(struct isis_area *area, int level,
                                continue;
 
                        /*
-                        * Reinstall all Prefix-SID nexthops using route replace
-                        * semantics.
+                        * The Prefix-SID input label hasn't changed. We could
+                        * re-install all Prefix-SID with "Make Before Break"
+                        * option. Zebra layer will update output label(s) by
+                        * adding new entry before removing the old one(s).
                         */
                        sr_prefix_reinstall(srp, true);
                        break;
@@ -506,7 +501,7 @@ static int sr_prefix_install_local(struct sr_prefix *srp)
        isis_sr_nexthop_update(&srp->u.local.info, MPLS_LABEL_IMPLICIT_NULL);
 
        /* Install Prefix-SID in the forwarding plane. */
-       isis_zebra_install_prefix_sid(srp);
+       isis_zebra_send_prefix_sid(ZEBRA_MPLS_LABELS_REPLACE, srp);
 
        return 0;
 }
@@ -587,7 +582,7 @@ static int sr_prefix_install_remote(struct sr_prefix *srp)
        srp->input_label = input_label;
 
        /* Install Prefix-SID in the forwarding plane. */
-       isis_zebra_install_prefix_sid(srp);
+       isis_zebra_send_prefix_sid(ZEBRA_MPLS_LABELS_REPLACE, srp);
 
        return 0;
 }
@@ -647,7 +642,7 @@ static void sr_prefix_uninstall(struct sr_prefix *srp)
                 srp->sid.value);
 
        /* Uninstall Prefix-SID from the forwarding plane. */
-       isis_zebra_uninstall_prefix_sid(srp);
+       isis_zebra_send_prefix_sid(ZEBRA_MPLS_LABELS_DELETE, srp);
 
        /* Reset internal state. */
        srp->input_label = MPLS_INVALID_LABEL;
@@ -666,15 +661,16 @@ static void sr_prefix_uninstall(struct sr_prefix *srp)
 }
 
 /* Reinstall local or remote Prefix-SID. */
-static void sr_prefix_reinstall(struct sr_prefix *srp, bool replace_semantics)
+static inline void sr_prefix_reinstall(struct sr_prefix *srp,
+                                      bool make_before_break)
 {
        /*
-        * Route replace semantics can be used only when we know for sure that
+        * Make Before Break can be used only when we know for sure that
         * the Prefix-SID input label hasn't changed. Otherwise we need to
         * uninstall the Prefix-SID first using the old input label before
         * reinstalling it.
         */
-       if (!replace_semantics)
+       if (!make_before_break)
                sr_prefix_uninstall(srp);
 
        sr_prefix_install(srp);
@@ -960,6 +956,11 @@ static int sr_route_update(struct isis_area *area, struct prefix *prefix,
                return 0;
 
        if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ACTIVE)) {
+               /*
+                * The Prefix-SID input label hasn't changed. We could use the
+                * "Make Before Break" option. Zebra layer will update output
+                * label by adding new label(s) before removing old one(s).
+                */
                sr_prefix_reinstall(srp, true);
                srp->u.remote.rinfo = route_info;
        } else {
@@ -972,36 +973,6 @@ static int sr_route_update(struct isis_area *area, struct prefix *prefix,
 
 /*----------------------------------------------------------------------------*/
 
-/* Install or uninstall (LAN)-Adj-SID. */
-static void sr_adj_sid_install_uninstall(bool install,
-                                        const struct sr_adjacency *sra)
-{
-       struct zapi_labels zl;
-       struct zapi_nexthop *znh;
-       int cmd;
-
-       cmd = install ? ZEBRA_MPLS_LABELS_ADD : ZEBRA_MPLS_LABELS_DELETE;
-
-       sr_debug("  |- %s label %u for interface %s",
-                install ? "Add" : "Delete", sra->nexthop.label,
-                sra->adj->circuit->interface->name);
-
-       memset(&zl, 0, sizeof(zl));
-       zl.type = ZEBRA_LSP_ISIS_SR;
-       zl.local_label = sra->nexthop.label;
-       zl.nexthop_num = 1;
-       znh = &zl.nexthops[0];
-       znh->gate = sra->nexthop.address;
-       znh->type = (sra->nexthop.family == AF_INET)
-                           ? NEXTHOP_TYPE_IPV4_IFINDEX
-                           : NEXTHOP_TYPE_IPV6_IFINDEX;
-       znh->ifindex = sra->adj->circuit->interface->ifindex;
-       znh->label_num = 1;
-       znh->labels[0] = MPLS_LABEL_IMPLICIT_NULL;
-
-       (void)zebra_send_mpls_labels(zclient, cmd, &zl);
-}
-
 /* Add new local Adj-SID. */
 static void sr_adj_sid_add_single(struct isis_adjacency *adj, int family,
                                  bool backup)
@@ -1082,7 +1053,7 @@ static void sr_adj_sid_add_single(struct isis_adjacency *adj, int family,
        listnode_add(area->srdb.adj_sids, sra);
        listnode_add(adj->adj_sids, sra);
 
-       sr_adj_sid_install_uninstall(true, sra);
+       isis_zebra_send_adjacency_sid(ZEBRA_MPLS_LABELS_ADD, sra);
 }
 
 static void sr_adj_sid_add(struct isis_adjacency *adj, int family)
@@ -1099,7 +1070,7 @@ static void sr_adj_sid_del(struct sr_adjacency *sra)
 
        sr_debug("ISIS-Sr (%s): Delete Adjacency SID", area->area_tag);
 
-       sr_adj_sid_install_uninstall(false, sra);
+       isis_zebra_send_adjacency_sid(ZEBRA_MPLS_LABELS_DELETE, sra);
 
        switch (circuit->circ_type) {
        case CIRCUIT_T_BROADCAST:
index 0b84db90ff4f9ed81b8d2d3c9f51afa2a6dc974e..b2e013075483d3f2d8b075b9072623fa7171bb9b 100644 (file)
@@ -240,7 +240,6 @@ struct isis_sr_db {
 /* Prototypes. */
 extern int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound,
                                   uint32_t upper_bound);
-extern void isis_sr_cfg_msd_update(struct isis_area *area);
 extern struct sr_prefix_cfg *
 isis_sr_cfg_prefix_add(struct isis_area *area, const struct prefix *prefix);
 extern void isis_sr_cfg_prefix_del(struct sr_prefix_cfg *pcfg);
index 94ad0ae488f1a029fb2d614870bf2d1c03ce3d72..68f80a3f1f67ab5064595aed2223d0468a900dd5 100644 (file)
@@ -49,6 +49,7 @@
 #include "isisd/isis_lsp.h"
 #include "isisd/isis_route.h"
 #include "isisd/isis_zebra.h"
+#include "isisd/isis_adjacency.h"
 #include "isisd/isis_te.h"
 #include "isisd/isis_sr.h"
 
@@ -254,7 +255,7 @@ void isis_zebra_route_del_route(struct prefix *prefix,
 }
 
 /* Install Prefix-SID in the forwarding plane. */
-void isis_zebra_install_prefix_sid(const struct sr_prefix *srp)
+static void isis_zebra_prefix_install_prefix_sid(const struct sr_prefix *srp)
 {
        struct zapi_labels zl;
        struct zapi_nexthop *znh;
@@ -315,7 +316,7 @@ void isis_zebra_install_prefix_sid(const struct sr_prefix *srp)
 }
 
 /* Uninstall Prefix-SID from the forwarding plane. */
-void isis_zebra_uninstall_prefix_sid(const struct sr_prefix *srp)
+static void isis_zebra_uninstall_prefix_sid(const struct sr_prefix *srp)
 {
        struct zapi_labels zl;
 
@@ -336,6 +337,58 @@ void isis_zebra_uninstall_prefix_sid(const struct sr_prefix *srp)
        (void)zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_DELETE, &zl);
 }
 
+void isis_zebra_send_prefix_sid(int cmd, const struct sr_prefix *srp)
+{
+
+       if (cmd != ZEBRA_MPLS_LABELS_REPLACE
+           && cmd != ZEBRA_MPLS_LABELS_DELETE) {
+               flog_warn(EC_LIB_DEVELOPMENT, "%s: wrong ZEBRA command",
+                         __func__);
+               return;
+       }
+
+       sr_debug("  |- %s label %u for prefix %pFX",
+                cmd == ZEBRA_MPLS_LABELS_REPLACE ? "Update" : "Delete",
+                srp->input_label, &srp->prefix);
+
+       if (cmd == ZEBRA_MPLS_LABELS_REPLACE)
+               isis_zebra_prefix_install_prefix_sid(srp);
+       else
+               isis_zebra_uninstall_prefix_sid(srp);
+}
+
+/* Install or uninstall (LAN)-Adj-SID. */
+void isis_zebra_send_adjacency_sid(int cmd, const struct sr_adjacency *sra)
+{
+       struct zapi_labels zl;
+       struct zapi_nexthop *znh;
+
+       if (cmd != ZEBRA_MPLS_LABELS_ADD && cmd != ZEBRA_MPLS_LABELS_DELETE) {
+               flog_warn(EC_LIB_DEVELOPMENT, "%s: wrong ZEBRA command",
+                         __func__);
+               return;
+       }
+
+       sr_debug("  |- %s label %u for interface %s",
+                cmd == ZEBRA_MPLS_LABELS_ADD ? "Add" : "Delete",
+                sra->nexthop.label, sra->adj->circuit->interface->name);
+
+       memset(&zl, 0, sizeof(zl));
+       zl.type = ZEBRA_LSP_ISIS_SR;
+       zl.local_label = sra->nexthop.label;
+       zl.nexthop_num = 1;
+       znh = &zl.nexthops[0];
+       znh->gate = sra->nexthop.address;
+       znh->type = (sra->nexthop.family == AF_INET)
+                           ? NEXTHOP_TYPE_IPV4_IFINDEX
+                           : NEXTHOP_TYPE_IPV6_IFINDEX;
+       znh->ifindex = sra->adj->circuit->interface->ifindex;
+       znh->label_num = 1;
+       znh->labels[0] = MPLS_LABEL_IMPLICIT_NULL;
+
+       (void)zebra_send_mpls_labels(zclient, cmd, &zl);
+}
+
 static int isis_zebra_read(ZAPI_CALLBACK_ARGS)
 {
        struct zapi_route api;
index cca2b08811fcead86f06d54954a14ebf97046113..b143d34626bd9d7643260837d27c173869e831b6 100644 (file)
@@ -36,6 +36,7 @@ void isis_zebra_stop(void);
 
 struct isis_route_info;
 struct sr_prefix;
+struct sr_adjacency;
 
 void isis_zebra_route_add_route(struct prefix *prefix,
                                struct prefix_ipv6 *src_p,
@@ -43,8 +44,8 @@ void isis_zebra_route_add_route(struct prefix *prefix,
 void isis_zebra_route_del_route(struct prefix *prefix,
                                struct prefix_ipv6 *src_p,
                                struct isis_route_info *route_info);
-void isis_zebra_install_prefix_sid(const struct sr_prefix *srp);
-void isis_zebra_uninstall_prefix_sid(const struct sr_prefix *srp);
+void isis_zebra_send_prefix_sid(int cmd, const struct sr_prefix *srp);
+void isis_zebra_send_adjacency_sid(int cmd, const struct sr_adjacency *sra);
 int isis_distribute_list_update(int routetype);
 void isis_zebra_redistribute_set(afi_t afi, int type);
 void isis_zebra_redistribute_unset(afi_t afi, int type);