#include "zebra/zebra_router.h"
#include "zebra/redistribute.h"
#include "zebra/debug.h"
-#include "zebra/zebra_memory.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_mpls.h"
#include "zebra/zebra_srte.h"
#include "zebra/zebra_errors.h"
-DEFINE_MTYPE_STATIC(ZEBRA, LSP, "MPLS LSP object")
-DEFINE_MTYPE_STATIC(ZEBRA, FEC, "MPLS FEC object")
-DEFINE_MTYPE_STATIC(ZEBRA, NHLFE, "MPLS nexthop object")
+DEFINE_MTYPE_STATIC(ZEBRA, LSP, "MPLS LSP object");
+DEFINE_MTYPE_STATIC(ZEBRA, FEC, "MPLS FEC object");
+DEFINE_MTYPE_STATIC(ZEBRA, NHLFE, "MPLS nexthop object");
int mpls_enabled;
zebra_fec_t *fec;
uint32_t old_label, new_label;
int af;
- char buf[BUFSIZ];
for (af = AFI_IP; af < AFI_MAX; af++) {
if (zvrf->fec_table[af] == NULL)
|| fec->label_index == MPLS_INVALID_LABEL_INDEX)
continue;
- if (IS_ZEBRA_DEBUG_MPLS)
- prefix2str(&rn->p, buf, BUFSIZ);
-
/* Save old label, determine new label. */
old_label = fec->label;
new_label =
if (IS_ZEBRA_DEBUG_MPLS)
zlog_debug(
- "Update fec %s new label %u upon label block",
- buf, new_label);
+ "Update fec %pRN new label %u upon label block",
+ rn, new_label);
fec->label = new_label;
fec_update_clients(fec);
char buf[BUFSIZ];
rn = fec->rn;
- prefix2str(&rn->p, buf, BUFSIZ);
- vty_out(vty, "%s\n", buf);
+ vty_out(vty, "%pRN\n", rn);
vty_out(vty, " Label: %s", label2str(fec->label, buf, BUFSIZ));
if (fec->label_index != MPLS_INVALID_LABEL_INDEX)
vty_out(vty, ", Label Index: %u", fec->label_index);
zebra_lsp_t *lsp;
lsp = (zebra_lsp_t *)bucket->data;
+
+ /* In the common flow, this is used when external events occur. For
+ * LSPs with backup nhlfes, we'll assume that the forwarding
+ * plane will use the backups to handle these events, until the
+ * owning protocol can react.
+ */
+ if (ctxt == NULL) {
+ /* Skip LSPs with backups */
+ if (nhlfe_list_first(&lsp->backup_nhlfe_list) != NULL) {
+ if (IS_ZEBRA_DEBUG_MPLS_DETAIL)
+ zlog_debug("%s: skip LSP in-label %u",
+ __func__, lsp->ile.in_label);
+ return;
+ }
+ }
+
(void)lsp_processq_add(lsp);
}
int start_count = 0, end_count = 0; /* Installed counts */
bool changed_p = false;
bool is_debug = (IS_ZEBRA_DEBUG_DPLANE | IS_ZEBRA_DEBUG_MPLS);
+ enum zebra_sr_policy_update_label_mode update_mode;
if (is_debug)
zlog_debug("LSP dplane notif, in-label %u",
if (end_count > 0) {
SET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
+ /* SR-TE update too */
+ if (start_count == 0)
+ update_mode = ZEBRA_SR_POLICY_LABEL_CREATED;
+ else
+ update_mode = ZEBRA_SR_POLICY_LABEL_UPDATED;
+ zebra_sr_policy_label_update(lsp->ile.in_label, update_mode);
+
if (changed_p)
dplane_lsp_notif_update(lsp, DPLANE_OP_LSP_UPDATE, ctx);
} else {
+ /* SR-TE update too */
+ zebra_sr_policy_label_update(lsp->ile.in_label,
+ ZEBRA_SR_POLICY_LABEL_REMOVED);
+
UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
clear_nhlfe_installed(lsp);
}
{
struct route_table *table;
zebra_fec_t *fec;
- char buf[BUFSIZ];
bool new_client;
bool label_change = false;
uint32_t old_label;
if (!table)
return -1;
- if (IS_ZEBRA_DEBUG_MPLS)
- prefix2str(p, buf, BUFSIZ);
-
if (label != MPLS_INVALID_LABEL && have_label_index) {
flog_err(
EC_ZEBRA_FEC_LABEL_INDEX_LABEL_CONFLICT,
- "Rejecting FEC register for %s with both label %u and Label Index %u specified, client %s",
- buf, label, label_index,
+ "Rejecting FEC register for %pFX with both label %u and Label Index %u specified, client %s",
+ p, label, label_index,
zebra_route_string(client->proto));
return -1;
}
if (!fec) {
flog_err(
EC_ZEBRA_FEC_ADD_FAILED,
- "Failed to add FEC %s upon register, client %s",
- buf, zebra_route_string(client->proto));
+ "Failed to add FEC %pFX upon register, client %s",
+ p, zebra_route_string(client->proto));
return -1;
}
listnode_add(fec->client_list, client);
if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("FEC %s label%s %u %s by client %s%s", buf,
+ zlog_debug("FEC %pFX label%s %u %s by client %s%s", p,
have_label_index ? " index" : "",
have_label_index ? label_index : label,
new_client ? "registered" : "updated",
{
struct route_table *table;
zebra_fec_t *fec;
- char buf[BUFSIZ];
table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))];
if (!table)
return -1;
- if (IS_ZEBRA_DEBUG_MPLS)
- prefix2str(p, buf, BUFSIZ);
-
fec = fec_find(table, p);
if (!fec) {
flog_err(EC_ZEBRA_FEC_RM_FAILED,
listnode_delete(fec->client_list, client);
if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("FEC %s unregistered by client %s", buf,
+ zlog_debug("FEC %pFX unregistered by client %s", p,
zebra_route_string(client->proto));
/* If not a configured entry, delete the FEC if no other clients. Before
{
struct route_table *table;
zebra_fec_t *fec;
- char buf[BUFSIZ];
mpls_label_t old_label;
int ret = 0;
if (!table)
return -1;
- if (IS_ZEBRA_DEBUG_MPLS)
- prefix2str(p, buf, BUFSIZ);
-
/* Update existing FEC or create a new one. */
fec = fec_find(table, p);
if (!fec) {
}
if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Add fec %s label %u", buf, in_label);
+ zlog_debug("Add fec %pFX label %u", p, in_label);
} else {
fec->flags |= FEC_FLAG_CONFIGURED;
if (fec->label == in_label)
/* Label change, update clients. */
old_label = fec->label;
if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Update fec %s new label %u", buf, in_label);
+ zlog_debug("Update fec %pFX new label %u", p, in_label);
fec->label = in_label;
fec_update_clients(fec);
struct route_table *table;
zebra_fec_t *fec;
mpls_label_t old_label;
- char buf[BUFSIZ];
table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))];
if (!table)
fec = fec_find(table, p);
if (!fec) {
- prefix2str(p, buf, BUFSIZ);
flog_err(EC_ZEBRA_FEC_RM_FAILED,
- "Failed to find FEC %s upon delete", buf);
+ "Failed to find FEC %pFX upon delete", p);
return -1;
}
*/
void zebra_mpls_init_tables(struct zebra_vrf *zvrf)
{
+ char buffer[80];
+
if (!zvrf)
return;
- zvrf->slsp_table =
- hash_create(label_hash, label_cmp, "ZEBRA SLSP table");
- zvrf->lsp_table = hash_create(label_hash, label_cmp, "ZEBRA LSP table");
+
+ snprintf(buffer, sizeof(buffer), "ZEBRA SLSP table: %s",
+ zvrf->vrf->name);
+ zvrf->slsp_table = hash_create_size(8, label_hash, label_cmp, buffer);
+
+ snprintf(buffer, sizeof(buffer), "ZEBRA LSP table: %s",
+ zvrf->vrf->name);
+ zvrf->lsp_table = hash_create_size(8, label_hash, label_cmp, buffer);
zvrf->fec_table[AFI_IP] = route_table_init();
zvrf->fec_table[AFI_IP6] = route_table_init();
zvrf->mpls_flags = 0;