]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_mpls.h
OSPFD: Update Segment Routing following reviews
[mirror_frr.git] / zebra / zebra_mpls.h
index c8dab39210ea97cc918a26720d7182f3c3170f6d..9d8ca34f82cbaa4e54d3b9a198994a14eef71bc8 100644 (file)
@@ -37,8 +37,6 @@
 
 /* Definitions and macros. */
 
-#define MPLS_MAX_LABELS 2  /* Maximum # labels that can be pushed. */
-
 #define NHLFE_FAMILY(nhlfe)                                                    \
        (((nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6                          \
          || (nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX)              \
@@ -318,6 +316,12 @@ void mpls_ldp_lsp_uninstall_all(struct hash_backet *backet, void *ctxt);
  */
 void mpls_ldp_ftn_uninstall_all(struct zebra_vrf *zvrf, int afi);
 
+/*
+ * Uninstall all Segment Routing NHLFEs for a particular LSP forwarding entry.
+ * If no other NHLFEs exist, the entry would be deleted.
+ */
+void mpls_sr_lsp_uninstall_all(struct hash_backet *backet, void *ctxt);
+
 #if defined(HAVE_CUMULUS)
 /*
  * Check that the label values used in LSP creation are consistent. The
@@ -410,10 +414,16 @@ void zebra_mpls_vty_init(void);
  */
 static inline u_char lsp_distance(enum lsp_types_t type)
 {
-       if (type == ZEBRA_LSP_STATIC)
+       switch (type) {
+       case ZEBRA_LSP_STATIC:
                return (route_distance(ZEBRA_ROUTE_STATIC));
-
-       return 150;
+       case ZEBRA_LSP_LDP:
+               return (route_distance(ZEBRA_ROUTE_LDP));
+       case ZEBRA_LSP_BGP:
+               return (route_distance(ZEBRA_ROUTE_BGP));
+       default:
+               return 150;
+       }
 }
 
 /*
@@ -432,6 +442,26 @@ static inline enum lsp_types_t lsp_type_from_re_type(int re_type)
        }
 }
 
+/*
+ * Map LSP type to RIB type.
+ */
+static inline int re_type_from_lsp_type(enum lsp_types_t lsp_type)
+{
+       switch (lsp_type) {
+       case ZEBRA_LSP_STATIC:
+               return ZEBRA_ROUTE_STATIC;
+       case ZEBRA_LSP_LDP:
+               return ZEBRA_ROUTE_LDP;
+       case ZEBRA_LSP_BGP:
+               return ZEBRA_ROUTE_BGP;
+       case ZEBRA_LSP_SR:
+               return ZEBRA_ROUTE_OSPF;
+       case ZEBRA_LSP_NONE:
+       default:
+               return ZEBRA_ROUTE_KERNEL;
+       }
+}
+
 /* NHLFE type as printable string. */
 static inline const char *nhlfe_type2str(enum lsp_types_t lsp_type)
 {
@@ -442,6 +472,8 @@ static inline const char *nhlfe_type2str(enum lsp_types_t lsp_type)
                return "LDP";
        case ZEBRA_LSP_BGP:
                return "BGP";
+       case ZEBRA_LSP_SR:
+               return "SR";
        default:
                return "Unknown";
        }