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);
/*----------------------------------------------------------------------------*/
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)
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;
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;
}
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;
}
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;
}
/* 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);
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 {
/*----------------------------------------------------------------------------*/
-/* 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)
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)
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:
#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"
}
/* 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;
}
/* 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;
(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;