From 939fba2741e0645266039e8b5b450fa81cc3b7e7 Mon Sep 17 00:00:00 2001 From: vivek Date: Mon, 18 Apr 2016 18:24:10 +0000 Subject: [PATCH] Quagga: Fix MPLS LSP scheduling to follow nexthop route update Fix LSP scheduling to occur only after routes are processed because the LSP resolution depends on the nexthop route being selected. This is similar to how NHT processing is scheduled. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Reviewed-by: Daniel Walton Ticket: CM-6743 Reviewed By: CCR-3233 Testing Done: Verified the failed test multiple times. --- zebra/connected.c | 25 +++++++++++++------------ zebra/zebra_mpls.c | 1 + zebra/zebra_mpls.h | 28 ++++++++++++++++++++++++++++ zebra/zebra_rib.c | 10 ++++++++++ zebra/zebra_vrf.h | 4 ++++ 5 files changed, 56 insertions(+), 12 deletions(-) diff --git a/zebra/connected.c b/zebra/connected.c index 9737f8deba..55c3792d4f 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -39,6 +39,7 @@ #include "zebra/connected.h" #include "zebra/rtadv.h" #include "zebra/zebra_mpls.h" +#include "zebra/debug.h" /* communicate the withdrawal of a connected address */ static void @@ -218,10 +219,10 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc) /* Schedule LSP forwarding entries for processing, if appropriate. */ if (ifp->vrf_id == VRF_DEFAULT) { - if (IS_ZEBRA_DEBUG_RIB_DETAILED) + if (IS_ZEBRA_DEBUG_MPLS) zlog_debug ("%u: IF %s IPv4 address add/up, scheduling MPLS processing", ifp->vrf_id, ifp->name); - zebra_mpls_lsp_schedule (vrf_info_lookup(ifp->vrf_id)); + mpls_mark_lsps_for_processing (vrf_info_lookup(ifp->vrf_id)); } } @@ -347,10 +348,10 @@ connected_down_ipv4 (struct interface *ifp, struct connected *ifc) /* Schedule LSP forwarding entries for processing, if appropriate. */ if (ifp->vrf_id == VRF_DEFAULT) { - if (IS_ZEBRA_DEBUG_RIB_DETAILED) + if (IS_ZEBRA_DEBUG_MPLS) zlog_debug ("%u: IF %s IPv4 address add/up, scheduling MPLS processing", ifp->vrf_id, ifp->name); - zebra_mpls_lsp_schedule (vrf_info_lookup(ifp->vrf_id)); + mpls_mark_lsps_for_processing (vrf_info_lookup(ifp->vrf_id)); } } @@ -382,10 +383,10 @@ connected_delete_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, /* Schedule LSP forwarding entries for processing, if appropriate. */ if (ifp->vrf_id == VRF_DEFAULT) { - if (IS_ZEBRA_DEBUG_RIB_DETAILED) + if (IS_ZEBRA_DEBUG_MPLS) zlog_debug ("%u: IF %s IPv4 address add/up, scheduling MPLS processing", ifp->vrf_id, ifp->name); - zebra_mpls_lsp_schedule (vrf_info_lookup(ifp->vrf_id)); + mpls_mark_lsps_for_processing (vrf_info_lookup(ifp->vrf_id)); } } @@ -421,10 +422,10 @@ connected_up_ipv6 (struct interface *ifp, struct connected *ifc) /* Schedule LSP forwarding entries for processing, if appropriate. */ if (ifp->vrf_id == VRF_DEFAULT) { - if (IS_ZEBRA_DEBUG_RIB_DETAILED) + if (IS_ZEBRA_DEBUG_MPLS) zlog_debug ("%u: IF %s IPv4 address add/up, scheduling MPLS processing", ifp->vrf_id, ifp->name); - zebra_mpls_lsp_schedule (vrf_info_lookup(ifp->vrf_id)); + mpls_mark_lsps_for_processing (vrf_info_lookup(ifp->vrf_id)); } } @@ -520,10 +521,10 @@ connected_down_ipv6 (struct interface *ifp, struct connected *ifc) /* Schedule LSP forwarding entries for processing, if appropriate. */ if (ifp->vrf_id == VRF_DEFAULT) { - if (IS_ZEBRA_DEBUG_RIB_DETAILED) + if (IS_ZEBRA_DEBUG_MPLS) zlog_debug ("%u: IF %s IPv4 address add/up, scheduling MPLS processing", ifp->vrf_id, ifp->name); - zebra_mpls_lsp_schedule (vrf_info_lookup(ifp->vrf_id)); + mpls_mark_lsps_for_processing (vrf_info_lookup(ifp->vrf_id)); } } @@ -554,10 +555,10 @@ connected_delete_ipv6 (struct interface *ifp, struct in6_addr *address, /* Schedule LSP forwarding entries for processing, if appropriate. */ if (ifp->vrf_id == VRF_DEFAULT) { - if (IS_ZEBRA_DEBUG_RIB_DETAILED) + if (IS_ZEBRA_DEBUG_MPLS) zlog_debug ("%u: IF %s IPv4 address add/up, scheduling MPLS processing", ifp->vrf_id, ifp->name); - zebra_mpls_lsp_schedule (vrf_info_lookup(ifp->vrf_id)); + mpls_mark_lsps_for_processing (vrf_info_lookup(ifp->vrf_id)); } } diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 096f576a4c..edfc08019b 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1554,6 +1554,7 @@ zebra_mpls_init_tables (struct zebra_vrf *zvrf) return; zvrf->slsp_table = hash_create(label_hash, label_cmp); zvrf->lsp_table = hash_create(label_hash, label_cmp); + zvrf->mpls_flags = 0; } /* diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h index 7d1f494142..d25869664c 100644 --- a/zebra/zebra_mpls.h +++ b/zebra/zebra_mpls.h @@ -33,6 +33,7 @@ #include "memory.h" #include "mpls.h" #include "zebra/zserv.h" +#include "zebra/zebra_vrf.h" /* Definitions and macros. */ @@ -280,4 +281,31 @@ nhlfe_type2str(enum lsp_types_t lsp_type) } } +static inline void +mpls_mark_lsps_for_processing(struct zebra_vrf *zvrf) +{ + if (!zvrf) + return; + + zvrf->mpls_flags |= MPLS_FLAG_SCHEDULE_LSPS; +} + +static inline void +mpls_unmark_lsps_for_processing(struct zebra_vrf *zvrf) +{ + if (!zvrf) + return; + + zvrf->mpls_flags &= ~MPLS_FLAG_SCHEDULE_LSPS; +} + +static inline int +mpls_should_lsps_be_processed(struct zebra_vrf *zvrf) +{ + if (!zvrf) + return 0; + + return ((zvrf->mpls_flags & MPLS_FLAG_SCHEDULE_LSPS) ? 1 : 0); +} + #endif /*_ZEBRA_MPLS_H */ diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 910610fc60..601721c6d4 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2033,6 +2033,16 @@ meta_queue_process_complete (struct work_queue *dummy) zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_IMPORT_CHECK_TYPE, NULL); } } + + /* Schedule LSPs for processing, if needed. */ + zvrf = vrf_info_lookup(VRF_DEFAULT); + if (mpls_should_lsps_be_processed(zvrf)) + { + if (IS_ZEBRA_DEBUG_MPLS) + zlog_debug ("%u: Scheduling all LSPs upon RIB completion", zvrf->vrf_id); + zebra_mpls_lsp_schedule (zvrf); + mpls_unmark_lsps_for_processing(zvrf); + } } /* Dispatch the meta queue by picking, processing and unlocking the next RN from diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index 1062c90988..0baddc1b6a 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -80,6 +80,10 @@ struct zebra_vrf /* MPLS label forwarding table */ struct hash *lsp_table; + + /* MPLS processing flags */ + u_int16_t mpls_flags; +#define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) }; extern struct list *zvrf_list; -- 2.39.5