diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/log.c | 2 | ||||
| -rw-r--r-- | lib/mpls.h | 9 | ||||
| -rw-r--r-- | lib/nexthop.c | 14 | ||||
| -rw-r--r-- | lib/nexthop.h | 5 | ||||
| -rw-r--r-- | lib/zebra.h | 2 |
5 files changed, 26 insertions, 6 deletions
@@ -939,6 +939,8 @@ static const struct zebra_desc_table command_types[] = { DESC_ENTRY (ZEBRA_INTERFACE_ENABLE_RADV), DESC_ENTRY (ZEBRA_INTERFACE_DISABLE_RADV), DESC_ENTRY (ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB), + DESC_ENTRY (ZEBRA_MPLS_LABELS_ADD), + DESC_ENTRY (ZEBRA_MPLS_LABELS_DELETE), }; #undef DESC_ENTRY diff --git a/lib/mpls.h b/lib/mpls.h index 5a67b915d1..1f77aaa536 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -75,8 +75,17 @@ typedef unsigned int mpls_lse_t; /* MPLS label value as a 32-bit (mostly we only care about the label value). */ typedef unsigned int mpls_label_t; +#define MPLS_NO_LABEL 0xFFFFFFFF #define MPLS_INVALID_LABEL 0xFFFFFFFF +/* LSP types. */ +enum lsp_types_t +{ + ZEBRA_LSP_NONE = 0, /* No LSP. */ + ZEBRA_LSP_STATIC = 1, /* Static LSP. */ + ZEBRA_LSP_LDP = 2 /* LDP LSP. */ +}; + /* Functions for basic label operations. */ /* Encode a label stack entry from fields; convert to network byte-order as diff --git a/lib/nexthop.c b/lib/nexthop.c index 8e775b68be..01771e253c 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -130,8 +130,8 @@ copy_nexthops (struct nexthop **tnh, struct nexthop *nh) memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr)); memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr)); if (nh->nh_label) - nexthop_add_labels (nexthop, nh->nh_label->num_labels, - &nh->nh_label->label[0]); + nexthop_add_labels (nexthop, nh->nh_label_type, + nh->nh_label->num_labels, &nh->nh_label->label[0]); nexthop_add(tnh, nexthop); if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE)) @@ -164,12 +164,13 @@ nexthops_free (struct nexthop *nexthop) /* Update nexthop with label information. */ void -nexthop_add_labels (struct nexthop *nexthop, u_int8_t num_labels, - mpls_label_t *label) +nexthop_add_labels (struct nexthop *nexthop, enum lsp_types_t type, + u_int8_t num_labels, mpls_label_t *label) { struct nexthop_label *nh_label; int i; + nexthop->nh_label_type = type; nh_label = XCALLOC (MTYPE_NH_LABEL, sizeof (struct nexthop_label)); nh_label->num_labels = num_labels; for (i = 0; i < num_labels; i++) @@ -182,7 +183,10 @@ void nexthop_del_labels (struct nexthop *nexthop) { if (nexthop->nh_label) - XFREE (MTYPE_NH_LABEL, nexthop->nh_label); + { + XFREE (MTYPE_NH_LABEL, nexthop->nh_label); + nexthop->nh_label_type = ZEBRA_LSP_NONE; + } } const char * diff --git a/lib/nexthop.h b/lib/nexthop.h index c06dfe0e25..e66e0eee20 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -85,6 +85,9 @@ struct nexthop * Only one level of recursive resolution is currently supported. */ struct nexthop *resolved; + /* Type of label(s), if any */ + enum lsp_types_t nh_label_type; + /* Label(s) associated with this nexthop. */ struct nexthop_label *nh_label; }; @@ -109,7 +112,7 @@ void copy_nexthops (struct nexthop **tnh, struct nexthop *nh); void nexthop_free (struct nexthop *nexthop); void nexthops_free (struct nexthop *nexthop); -void nexthop_add_labels (struct nexthop *, u_int8_t, mpls_label_t *); +void nexthop_add_labels (struct nexthop *, enum lsp_types_t, u_int8_t, mpls_label_t *); void nexthop_del_labels (struct nexthop *); extern const char *nexthop_type_to_str (enum nexthop_types_t nh_type); diff --git a/lib/zebra.h b/lib/zebra.h index d7a441c2e9..da069d1dfa 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -422,6 +422,8 @@ typedef enum { ZEBRA_INTERFACE_DISABLE_RADV, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, ZEBRA_INTERFACE_LINK_PARAMS, + ZEBRA_MPLS_LABELS_ADD, + ZEBRA_MPLS_LABELS_DELETE, } zebra_message_types_t; /* Marker value used in new Zserv, in the byte location corresponding |
