ospfd: Add ECMP support to OSPF Segment Routing

* Change sr_prefix structure in ospf_sr.h to add support to ECMP
 * Add new Segment Routing information to ospf_paths in ospf_route.h
 * Backport MPLS label configuration from IS-IS Segment Routing implementation
 * Re-write log message in ospf_sr.c and ospf_ext.c

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
Olivier Dugeon 2020-03-20 11:34:52 +01:00
parent ec91e8a9ee
commit b37eb79c01
5 changed files with 570 additions and 516 deletions

View file

@ -465,12 +465,8 @@ uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index,
return rc; return rc;
if (p != NULL) { if (p != NULL) {
if (IS_DEBUG_OSPF_SR) osr_debug("EXT (%s): Schedule new prefix %pFX with index %u "
zlog_debug( "on interface %s", __func__, p, index, ifp->name);
"EXT (%s): Schedule new prefix %s/%u with "
"index %u on interface %s",
__func__, inet_ntoa(p->prefix), p->prefixlen,
index, ifp->name);
/* Set first Extended Prefix then the Prefix SID information */ /* Set first Extended Prefix then the Prefix SID information */
set_ext_prefix(exti, OSPF_PATH_INTRA_AREA, EXT_TLV_PREF_NFLG, set_ext_prefix(exti, OSPF_PATH_INTRA_AREA, EXT_TLV_PREF_NFLG,
@ -488,9 +484,8 @@ uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index,
exti, REORIGINATE_THIS_LSA); exti, REORIGINATE_THIS_LSA);
} }
} else { } else {
if (IS_DEBUG_OSPF_SR) osr_debug("EXT (%s): Remove prefix for interface %s", __func__,
zlog_debug("EXT (%s): Remove prefix for interface %s", ifp->name);
__func__, ifp->name);
if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) { if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) {
ospf_ext_pref_lsa_schedule(exti, FLUSH_THIS_LSA); ospf_ext_pref_lsa_schedule(exti, FLUSH_THIS_LSA);
@ -513,9 +508,8 @@ void ospf_ext_update_sr(bool enable)
struct listnode *node; struct listnode *node;
struct ext_itf *exti; struct ext_itf *exti;
if (IS_DEBUG_OSPF_SR) osr_debug("EXT (%s): %s Extended LSAs for Segment Routing ", __func__,
zlog_debug("EXT (%s): %s Extended LSAs for Segment Routing ", enable ? "Enable" : "Disable");
__func__, enable ? "Enable" : "Disable");
if (enable) { if (enable) {
OspfEXT.enabled = true; OspfEXT.enabled = true;
@ -629,12 +623,12 @@ static void ospf_ext_ism_change(struct ospf_interface *oi, int old_status)
exti->instance = get_ext_pref_instance_value(); exti->instance = get_ext_pref_instance_value();
exti->area = oi->area; exti->area = oi->area;
zlog_debug("EXT (%s): Set Prefix SID to interface %s ", osr_debug("EXT (%s): Set Prefix SID to interface %s ",
__func__, oi->ifp->name); __func__, oi->ifp->name);
/* Complete SRDB if the interface belongs to a Prefix */ /* Complete SRDB if the interface belongs to a Prefix */
if (OspfEXT.enabled) if (OspfEXT.enabled)
ospf_sr_update_prefix(oi->ifp, oi->address); ospf_sr_update_local_prefix(oi->ifp, oi->address);
} else { } else {
/* Determine if interface is related to Adj. or LAN Adj. SID */ /* Determine if interface is related to Adj. or LAN Adj. SID */
if (oi->state == ISM_DR) if (oi->state == ISM_DR)
@ -650,7 +644,7 @@ static void ospf_ext_ism_change(struct ospf_interface *oi, int old_status)
* Note: Adjacency SID information are completed when ospf * Note: Adjacency SID information are completed when ospf
* adjacency become up see ospf_ext_link_nsm_change() * adjacency become up see ospf_ext_link_nsm_change()
*/ */
zlog_debug("EXT (%s): Set %sAdjacency SID for interface %s ", osr_debug("EXT (%s): Set %sAdjacency SID for interface %s ",
__func__, exti->stype == ADJ_SID ? "" : "LAN-", __func__, exti->stype == ADJ_SID ? "" : "LAN-",
oi->ifp->name); oi->ifp->name);
} }
@ -742,9 +736,7 @@ static void ospf_ext_link_nsm_change(struct ospf_neighbor *nbr, int old_status)
return; return;
} }
if (IS_DEBUG_OSPF_SR) osr_debug("EXT (%s): Complete %sAdjacency SID for interface %s ",
zlog_debug(
"EXT (%s): Complete %sAdjacency SID for interface %s ",
__func__, exti->stype == ADJ_SID ? "" : "LAN-", __func__, exti->stype == ADJ_SID ? "" : "LAN-",
oi->ifp->name); oi->ifp->name);
@ -962,12 +954,10 @@ static struct ospf_lsa *ospf_ext_pref_lsa_new(struct ospf_area *area,
/* Set opaque-LSA header fields. */ /* Set opaque-LSA header fields. */
lsa_header_set(s, options, lsa_type, lsa_id, router_id); lsa_header_set(s, options, lsa_type, lsa_id, router_id);
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) osr_debug(
zlog_debug( "EXT (%s): LSA[Type%u:%pI4]: Create an Opaque-LSA Extended "
"EXT (%s): LSA[Type%u:%s]: Create an Opaque-LSA " "Prefix Opaque LSA instance",
"Extended Prefix Opaque LSA instance", __func__, lsa_type, &lsa_id);
__func__, lsa_type, inet_ntoa(lsa_id));
/* Set opaque-LSA body fields. */ /* Set opaque-LSA body fields. */
ospf_ext_pref_lsa_body_set(s, exti); ospf_ext_pref_lsa_body_set(s, exti);
@ -1022,11 +1012,10 @@ static struct ospf_lsa *ospf_ext_link_lsa_new(struct ospf_area *area,
tmp = SET_OPAQUE_LSID(OPAQUE_TYPE_EXTENDED_LINK_LSA, exti->instance); tmp = SET_OPAQUE_LSID(OPAQUE_TYPE_EXTENDED_LINK_LSA, exti->instance);
lsa_id.s_addr = htonl(tmp); lsa_id.s_addr = htonl(tmp);
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) osr_debug(
zlog_debug( "EXT (%s) LSA[Type%u:%pI4]: Create an Opaque-LSA Extended "
"EXT (%s) LSA[Type%u:%s]: Create an Opaque-LSA " "Link Opaque LSA instance",
"Extended Link Opaque LSA instance", __func__, lsa_type, &lsa_id);
__func__, lsa_type, inet_ntoa(lsa_id));
/* Set opaque-LSA header fields. */ /* Set opaque-LSA header fields. */
lsa_header_set(s, options, lsa_type, lsa_id, area->ospf->router_id); lsa_header_set(s, options, lsa_type, lsa_id, area->ospf->router_id);
@ -1089,17 +1078,13 @@ static int ospf_ext_pref_lsa_originate1(struct ospf_area *area,
/* Flood new LSA through area. */ /* Flood new LSA through area. */
ospf_flood_through_area(area, NULL /*nbr */, new); ospf_flood_through_area(area, NULL /*nbr */, new);
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { osr_debug(
char area_id[INET_ADDRSTRLEN]; "EXT (%s): LSA[Type%u:%pI4]: Originate Opaque-LSA"
"Extended Prefix Opaque LSA: Area(%pI4), Link(%s)",
inet_ntop(AF_INET, &area->area_id, area_id, sizeof(area_id)); __func__, new->data->type, &new->data->id,
zlog_debug( &area->area_id, exti->ifp->name);
"EXT (%s): LSA[Type%u:%s]: Originate Opaque-LSA " if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
"Extended Prefix Opaque LSA: Area(%s), Link(%s)",
__func__, new->data->type, inet_ntoa(new->data->id),
area_id, exti->ifp->name);
ospf_lsa_header_dump(new->data); ospf_lsa_header_dump(new->data);
}
rc = 0; rc = 0;
@ -1141,17 +1126,13 @@ static int ospf_ext_link_lsa_originate1(struct ospf_area *area,
/* Flood new LSA through area. */ /* Flood new LSA through area. */
ospf_flood_through_area(area, NULL /*nbr */, new); ospf_flood_through_area(area, NULL /*nbr */, new);
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { osr_debug(
char area_id[INET_ADDRSTRLEN]; "EXT (%s): LSA[Type%u:%pI4]: Originate Opaque-LSA "
"Extended Link Opaque LSA: Area(%pI4), Link(%s)",
inet_ntop(AF_INET, &area->area_id, area_id, sizeof(area_id)); __func__, new->data->type, &new->data->id,
zlog_debug( &area->area_id, exti->ifp->name);
"EXT (%s): LSA[Type%u:%s]: Originate Opaque-LSA " if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
"Extended Link Opaque LSA: Area(%s), Link(%s)",
__func__, new->data->type, inet_ntoa(new->data->id),
area_id, exti->ifp->name);
ospf_lsa_header_dump(new->data); ospf_lsa_header_dump(new->data);
}
rc = 0; rc = 0;
@ -1168,15 +1149,13 @@ static int ospf_ext_pref_lsa_originate(void *arg)
if (!OspfEXT.enabled) { if (!OspfEXT.enabled) {
zlog_info( zlog_info(
"EXT (%s): Segment Routing " "EXT (%s): Segment Routing functionality is Disabled now",
"functionality is Disabled now",
__func__); __func__);
rc = 0; /* This is not an error case. */ rc = 0; /* This is not an error case. */
return rc; return rc;
} }
if (IS_DEBUG_OSPF_SR) osr_debug("EXT (%s): Start Originate Prefix LSA for area %pI4",
zlog_debug("EXT (%s): Start Originate Prefix LSA for area %s", __func__, &area->area_id);
__func__, inet_ntoa(area->area_id));
/* Check if Extended Prefix Opaque LSA is already engaged */ /* Check if Extended Prefix Opaque LSA is already engaged */
for (ALL_LIST_ELEMENTS_RO(OspfEXT.iflist, node, exti)) { for (ALL_LIST_ELEMENTS_RO(OspfEXT.iflist, node, exti)) {
@ -1206,11 +1185,9 @@ static int ospf_ext_pref_lsa_originate(void *arg)
} }
/* Ok, let's try to originate an LSA */ /* Ok, let's try to originate an LSA */
if (IS_DEBUG_OSPF_SR) osr_debug(
zlog_debug( "EXT (%s): Let's finally re-originate the LSA 7.0.0.%u "
"EXT (%s): Let's finally reoriginate the " "for Itf %s", __func__, exti->instance,
"LSA 7.0.0.%u for Itf %s",
__func__, exti->instance,
exti->ifp ? exti->ifp->name : ""); exti->ifp ? exti->ifp->name : "");
ospf_ext_pref_lsa_originate1(area, exti); ospf_ext_pref_lsa_originate1(area, exti);
} }
@ -1229,8 +1206,7 @@ static int ospf_ext_link_lsa_originate(void *arg)
if (!OspfEXT.enabled) { if (!OspfEXT.enabled) {
zlog_info( zlog_info(
"EXT (%s): Segment Routing " "EXT (%s): Segment Routing functionality is Disabled now",
"functionality is Disabled now",
__func__); __func__);
rc = 0; /* This is not an error case. */ rc = 0; /* This is not an error case. */
return rc; return rc;
@ -1268,13 +1244,11 @@ static int ospf_ext_link_lsa_originate(void *arg)
} }
/* Ok, let's try to originate an LSA */ /* Ok, let's try to originate an LSA */
if (IS_DEBUG_OSPF_SR) osr_debug(
zlog_debug( "EXT (%s): Let's finally reoriginate the LSA 8.0.0.%u "
"EXT (%s): Let's finally reoriginate the " "for Itf %s through the Area %pI4", __func__,
"LSA 8.0.0.%u for Itf %s through the Area %s", exti->instance, exti->ifp ? exti->ifp->name : "-",
__func__, exti->instance, &area->area_id);
exti->ifp ? exti->ifp->name : "-",
inet_ntoa(area->area_id));
ospf_ext_link_lsa_originate1(area, exti); ospf_ext_link_lsa_originate1(area, exti);
} }
@ -1297,8 +1271,7 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)
* It seems a slip among routers in the routing domain. * It seems a slip among routers in the routing domain.
*/ */
zlog_info( zlog_info(
"EXT (%s): Segment Routing functionality is " "EXT (%s): Segment Routing functionality is Disabled",
"Disabled",
__func__); __func__);
/* Flush it anyway. */ /* Flush it anyway. */
lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
@ -1362,12 +1335,11 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)
ospf_flood_through_area(area, NULL /*nbr */, new); ospf_flood_through_area(area, NULL /*nbr */, new);
/* Debug logging. */ /* Debug logging. */
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { osr_debug("EXT (%s): LSA[Type%u:%pI4] Refresh Extended Prefix LSA",
zlog_debug( __func__, new->data->type, &new->data->id);
"EXT (%s): LSA[Type%u:%s] Refresh Extended Prefix LSA", if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
__func__, new->data->type, inet_ntoa(new->data->id));
ospf_lsa_header_dump(new->data); ospf_lsa_header_dump(new->data);
}
return new; return new;
} }
@ -1438,12 +1410,10 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)
ospf_flood_through_area(area, NULL /*nbr */, new); ospf_flood_through_area(area, NULL /*nbr */, new);
/* Debug logging. */ /* Debug logging. */
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { osr_debug("EXT (%s): LSA[Type%u:%pI4]: Refresh Extended Link LSA",
zlog_debug( __func__, new->data->type, &new->data->id);
"EXT (%s): LSA[Type%u:%s]: Refresh Extended Link LSA", if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
__func__, new->data->type, inet_ntoa(new->data->id));
ospf_lsa_header_dump(new->data); ospf_lsa_header_dump(new->data);
}
return new; return new;
} }
@ -1468,7 +1438,7 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,
if (!(CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE))) if (!(CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)))
return; return;
zlog_debug("EXT (%s): Schedule %s%s%s LSA for interface %s", __func__, osr_debug("EXT (%s): Schedule %s%s%s LSA for interface %s", __func__,
opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "", opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "",
opcode == REFRESH_THIS_LSA ? "Refresh" : "", opcode == REFRESH_THIS_LSA ? "Refresh" : "",
opcode == FLUSH_THIS_LSA ? "Flush" : "", opcode == FLUSH_THIS_LSA ? "Flush" : "",
@ -1476,8 +1446,7 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,
/* Verify Area */ /* Verify Area */
if (exti->area == NULL) { if (exti->area == NULL) {
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) osr_debug(
zlog_debug(
"EXT (%s): Area is not yet set. Try to use Backbone Area", "EXT (%s): Area is not yet set. Try to use Backbone Area",
__func__); __func__);
@ -1533,7 +1502,7 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,
if (!(CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE))) if (!(CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)))
return; return;
zlog_debug("EXT (%s): Schedule %s%s%s LSA for interface %s", __func__, osr_debug("EXT (%s): Schedule %s%s%s LSA for interface %s", __func__,
opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "", opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "",
opcode == REFRESH_THIS_LSA ? "Refresh" : "", opcode == REFRESH_THIS_LSA ? "Refresh" : "",
opcode == FLUSH_THIS_LSA ? "Flush" : "", opcode == FLUSH_THIS_LSA ? "Flush" : "",
@ -1541,8 +1510,7 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,
/* Verify Area */ /* Verify Area */
if (exti->area == NULL) { if (exti->area == NULL) {
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) osr_debug(
zlog_debug(
"EXT (%s): Area is not yet set. Try to use Backbone Area", "EXT (%s): Area is not yet set. Try to use Backbone Area",
__func__); __func__);

View file

@ -33,12 +33,24 @@
#define OSPF_PATH_TYPE2_EXTERNAL 4 #define OSPF_PATH_TYPE2_EXTERNAL 4
#define OSPF_PATH_MAX 5 #define OSPF_PATH_MAX 5
/* Segment Routing information to complement ospf_path structure */
struct sr_nexthop_info {
/* Output label associated to this route */
mpls_label_t label_out;
/*
* Pointer to SR Node which is the next hop for this route
* or NULL if next hop is the destination of the prefix
*/
struct sr_node *nexthop;
};
/* OSPF Path. */ /* OSPF Path. */
struct ospf_path { struct ospf_path {
struct in_addr nexthop; struct in_addr nexthop;
struct in_addr adv_router; struct in_addr adv_router;
ifindex_t ifindex; ifindex_t ifindex;
unsigned char unnumbered; unsigned char unnumbered;
struct sr_nexthop_info srni;
}; };
/* Below is the structure linked to every /* Below is the structure linked to every

View file

@ -1369,7 +1369,7 @@ static int ospf_spf_calculate_timer(struct thread *thread)
abr_time = monotime_since(&start_time, NULL); abr_time = monotime_since(&start_time, NULL);
/* Schedule Segment Routing update */ /* Schedule Segment Routing update */
ospf_sr_update_timer_add(ospf); ospf_sr_update_task(ospf);
total_spf_time = total_spf_time =
monotime_since(&spf_start_time, &ospf->ts_spf_duration); monotime_since(&spf_start_time, &ospf->ts_spf_duration);

File diff suppressed because it is too large Load diff

View file

@ -51,6 +51,13 @@
#define SID_INDEX 4 #define SID_INDEX 4
#define SID_INDEX_SIZE(U) (U) #define SID_INDEX_SIZE(U) (U)
/* Macro to log debug message */
#define osr_debug(...) \
do { \
if (IS_DEBUG_OSPF_SR) \
zlog_debug(__VA_ARGS__); \
} while (0)
/* SID/Label Sub TLV - section 2.1 */ /* SID/Label Sub TLV - section 2.1 */
#define SUBTLV_SID_LABEL 1 #define SUBTLV_SID_LABEL 1
#define SUBTLV_SID_LABEL_SIZE 8 #define SUBTLV_SID_LABEL_SIZE 8
@ -180,16 +187,13 @@ struct sr_srgb {
}; };
/* SID type to make difference between loopback interfaces and others */ /* SID type to make difference between loopback interfaces and others */
enum sid_type { PREF_SID, ADJ_SID, LAN_ADJ_SID }; enum sid_type { PREF_SID, LOCAL_SID, ADJ_SID, LAN_ADJ_SID };
/* Structure aggregating all OSPF Segment Routing information for the node */ /* Structure aggregating all OSPF Segment Routing information for the node */
struct ospf_sr_db { struct ospf_sr_db {
/* Status of Segment Routing: enable or disable */ /* Status of Segment Routing: enable or disable */
bool enabled; bool enabled;
/* Ongoing Update following an OSPF SPF */
bool update;
/* Flooding Scope: Area = 10 or AS = 11 */ /* Flooding Scope: Area = 10 or AS = 11 */
uint8_t scope; uint8_t scope;
@ -237,7 +241,6 @@ struct sr_node {
/* Segment Routing - NHLFE info: support IPv4 Only */ /* Segment Routing - NHLFE info: support IPv4 Only */
struct sr_nhlfe { struct sr_nhlfe {
struct prefix_ipv4 prefv4;
struct in_addr nexthop; struct in_addr nexthop;
ifindex_t ifindex; ifindex_t ifindex;
mpls_label_t label_in; mpls_label_t label_in;
@ -251,6 +254,9 @@ struct sr_link {
/* 24-bit Opaque-ID field value according to RFC 7684 specification */ /* 24-bit Opaque-ID field value according to RFC 7684 specification */
uint32_t instance; uint32_t instance;
/* Interface address */
struct in_addr itf_addr;
/* Flags to manage this link parameters. */ /* Flags to manage this link parameters. */
uint8_t flags[2]; uint8_t flags[2];
@ -258,7 +264,7 @@ struct sr_link {
uint32_t sid[2]; uint32_t sid[2];
enum sid_type type; enum sid_type type;
/* SR NHLFE for this link */ /* SR NHLFE (Primary + Backup) for this link */
struct sr_nhlfe nhlfe[2]; struct sr_nhlfe nhlfe[2];
/* Back pointer to SR Node which advertise this Link */ /* Back pointer to SR Node which advertise this Link */
@ -271,6 +277,9 @@ struct sr_prefix {
/* 24-bit Opaque-ID field value according to RFC 7684 specification */ /* 24-bit Opaque-ID field value according to RFC 7684 specification */
uint32_t instance; uint32_t instance;
/* Prefix itself */
struct prefix_ipv4 prefv4;
/* Flags to manage this prefix parameters. */ /* Flags to manage this prefix parameters. */
uint8_t flags; uint8_t flags;
@ -278,17 +287,17 @@ struct sr_prefix {
uint32_t sid; uint32_t sid;
enum sid_type type; enum sid_type type;
/* SR NHLFE for this prefix */ /* Incoming label for this prefix */
mpls_label_t label_in;
/* Back pointer to OSPF Route for remote prefix */
struct ospf_route *or;
/* NHLFE for local prefix */
struct sr_nhlfe nhlfe; struct sr_nhlfe nhlfe;
/* Back pointer to SR Node which advertise this Prefix */ /* Back pointer to SR Node which advertise this Prefix */
struct sr_node *srn; struct sr_node *srn;
/*
* Pointer to SR Node which is the next hop for this Prefix
* or NULL if next hop is the destination of the prefix
*/
struct sr_node *nexthop;
}; };
/* Prototypes definition */ /* Prototypes definition */
@ -306,7 +315,7 @@ extern void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa);
/* Segment Routing configuration functions */ /* Segment Routing configuration functions */
extern uint32_t get_ext_link_label_value(void); extern uint32_t get_ext_link_label_value(void);
extern void ospf_sr_config_write_router(struct vty *vty); extern void ospf_sr_config_write_router(struct vty *vty);
extern void ospf_sr_update_prefix(struct interface *ifp, struct prefix *p); extern void ospf_sr_update_local_prefix(struct interface *ifp, struct prefix *p);
/* Segment Routing re-routing function */ /* Segment Routing re-routing function */
extern void ospf_sr_update_timer_add(struct ospf *ospf); extern void ospf_sr_update_task(struct ospf *ospf);
#endif /* _FRR_OSPF_SR_H */ #endif /* _FRR_OSPF_SR_H */