]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: install MPLS LSPs with appropriate protocol type
authorRenato Westphal <renato@opensourcerouting.org>
Sat, 16 Sep 2017 00:25:32 +0000 (21:25 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Thu, 21 Sep 2017 16:27:50 +0000 (13:27 -0300)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
zebra/rt_netlink.c
zebra/zebra_mpls.h

index 7c43c38f4281abe05518bac8db2ce4ad694c1d27..344a204fde8c6d0caaa4a30a6baa3589761399b2 100644 (file)
@@ -2349,6 +2349,7 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp)
        unsigned int nexthop_num;
        const char *routedesc;
        struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
+       int route_type;
 
        struct {
                struct nlmsghdr n;
@@ -2382,9 +2383,11 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp)
                }
        }
 
-       if (nexthop_num == 0) // unexpected
+       if (nexthop_num == 0 || !lsp->best_nhlfe) // unexpected
                return 0;
 
+       route_type = re_type_from_lsp_type(lsp->best_nhlfe->type);
+
        req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
        req.n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST;
        req.n.nlmsg_type = cmd;
@@ -2393,7 +2396,7 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp)
        req.r.rtm_family = AF_MPLS;
        req.r.rtm_table = RT_TABLE_MAIN;
        req.r.rtm_dst_len = MPLS_LABEL_LEN_BITS;
-       req.r.rtm_protocol = RTPROT_ZEBRA;
+       req.r.rtm_protocol = zebra2proto(route_type);
        req.r.rtm_scope = RT_SCOPE_UNIVERSE;
        req.r.rtm_type = RTN_UNICAST;
 
index 51279798a42b9997c9b4a7704331a50ef805d9da..22c771c34809aa86706180a480c00056d40b4b1b 100644 (file)
@@ -436,6 +436,24 @@ 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_NONE:
+       default:
+               return ZEBRA_ROUTE_KERNEL;
+       }
+}
+
 /* NHLFE type as printable string. */
 static inline const char *nhlfe_type2str(enum lsp_types_t lsp_type)
 {