From 141e5d9dd265e78d4ed6d259f3c7b591602e24b8 Mon Sep 17 00:00:00 2001 From: "James R. Leu" Date: Sun, 17 Aug 2003 16:32:23 -0600 Subject: [PATCH] Updated label mapping to better support the new fec -> nh relationship [git-p4: depot-paths = "//depot/ldp-portable/": change = 390] --- ldp/ldp_label_mapping.c | 149 ++++++++++++++++++++++++------------------------ ldp/ldp_nexthop.c | 2 +- 2 files changed, 75 insertions(+), 76 deletions(-) diff --git a/ldp/ldp_label_mapping.c b/ldp/ldp_label_mapping.c index 25f3393..2f1bfbf 100644 --- a/ldp/ldp_label_mapping.c +++ b/ldp/ldp_label_mapping.c @@ -40,9 +40,10 @@ mpls_return_enum ldp_label_mapping_with_xc(ldp_global * g, ldp_session * s, ldp_fec * f, ldp_attr ** us_attr, ldp_attr * ds_attr) { - mpls_return_enum result; + mpls_return_enum result = MPLS_SUCCESS; mpls_bool propogating = MPLS_BOOL_TRUE; mpls_bool egress = MPLS_BOOL_TRUE; + mspl_bool created = MPLS_BOOL_FALSE; MPLS_ASSERT(us_attr); @@ -50,6 +51,7 @@ mpls_return_enum ldp_label_mapping_with_xc(ldp_global * g, ldp_session * s, if (!((*us_attr) = ldp_attr_create(&f->info))) { return MPLS_FAILURE; } + created = MPLS_BOOL_TRUE; } if (!ds_attr) { propogating = MPLS_BOOL_FALSE; @@ -59,25 +61,30 @@ mpls_return_enum ldp_label_mapping_with_xc(ldp_global * g, ldp_session * s, Prepare_Label_Mapping_Attributes(g, s, &f->info, ds_attr, (*us_attr), propogating, MPLS_BOOL_TRUE, egress); - if (ldp_attr_insert_upstream2(g, s, (*us_attr), f) != MPLS_SUCCESS) { - ldp_attr_delete(*us_attr); - return MPLS_FATAL; + result = ldp_label_mapping_send(g, s, (*us_attr), ds_attr); + if (result != MPLS_SUCCESS) { + if (created == MPLS_BOOL_TRUE) { + ldp_attr_delete(*us_attr); + } + return result; } - if (ldp_label_mapping_send(g, s, (*us_attr), ds_attr) != MPLS_SUCCESS) { - ldp_attr_delete(*us_attr); - return MPLS_FATAL; + if (created == MPLS_BOOL_TRUE) { + result = ldp_attr_insert_upstream2(g, s, (*us_attr), f); + if (result != MPLS_SUCCESS) { + ldp_attr_delete(*us_attr); + return result; + } } - if (ds_attr && ds_attr->outlabel) { + if (ds_attr && ds_attr->outlabel && created == MPLS_BOOL_TRUE) { LDP_TRACE_LOG(g->user_data, MPLS_TRACE_STATE_ALL, LDP_TRACE_FLAG_BINDING, "Cross Connect Added\n"); result = ldp_inlabel_add_outlabel(g,(*us_attr)->inlabel,ds_attr->outlabel); if (result != MPLS_SUCCESS) { - ldp_label_withdraw_send(g, s, (*us_attr), LDP_NOTIF_NONE); - return MPLS_FATAL; + return result; } } return MPLS_SUCCESS; @@ -635,7 +642,7 @@ mpls_return_enum ldp_label_mapping_process(ldp_global * g, ldp_session * s, ldp_outlabel *out = NULL; mpls_bool requested = MPLS_BOOL_FALSE; - ldp_attr *update = NULL; + ldp_attr *existing = NULL; mpls_bool need_request = MPLS_BOOL_FALSE; LDP_ENTER(g->user_data, "ldp_label_mapping_process"); @@ -726,7 +733,7 @@ LMp_9: * this mapping matches an existing mapping, but it * could contain updated attributes */ - update = ds_temp; + existing = ds_temp; break; } else { /* @@ -740,13 +747,27 @@ LMp_9: ds_temp = MPLS_LIST_NEXT(ds_list, ds_temp, _fs); } } + if (existing) { + ldp_attr2ldp_attr(ds_attr, existing, LDP_ATTR_HOPCOUNT | LDP_ATTR_PATH | + LDP_ATTR_MSGID | LDP_ATTR_LSPID | LDP_ATTR_TRAFFIC); + ds_attr = existing; + /* + * no need to free ds_attr, since it was not added to the tree it + * will be deleted when we exit ldp_label_mapping_process(), see + * ldp_state_process(). + */ + } + /* + * from this point on.... if this is an updated mapping then ds_attr + * is the existing mapping which has now been update, else ds_attr + * is the new mapping + */ LMp_11: /* - * update ONLY has a value for updated label mapping + * existing ONLY has a value for updated label mapping */ - /* LMp.11 */ - nh = ldp_nexthop_for_fec_session(f,s); + nh = ldp_nexthop_for_fec_session(f,s); /* LMp.11 */ /* * the following departs from the procedure, it allows for filtering @@ -759,12 +780,9 @@ LMp_11: /* * policy has rejected it, store it away */ - if (update) { - ldp_attr2ldp_attr(ds_attr, update, LDP_ATTR_HOPCOUNT | LDP_ATTR_PATH | - LDP_ATTR_MSGID | LDP_ATTR_LSPID | LDP_ATTR_TRAFFIC); - /* JLEU free ds_attr? */ - update->filtered = MPLS_BOOL_TRUE; - if (update->outlabel && update->outlabel->switching == MPLS_BOOL_TRUE) { + if (existing) { + ds_attr->filtered = MPLS_BOOL_TRUE; + if (ds_attr->outlabel && ds_attr->outlabel->switching == MPLS_BOOL_TRUE) { /* the mapping has been filtered, but the original wasn't? */ MPLS_ASSERT(0); } @@ -777,11 +795,10 @@ LMp_11: goto LMp_33; } - /* LMp.12 */ - if ((!f) || (!nh)) { + if (!nh) { /* LMp.12 */ /* - * if we don't know about the route, or we don't have a next hop session, - * or the next hop session isn't the one who sent us the mapping .... + * if we did not find a nh hop for this FEC that corresponded to the + * MsgSource then the MsgSource is not a nexthop for the FEC */ if (g->label_retention_mode == LDP_RETENTION_CONSERVATIVE) { /* LMp.13C */ LDP_PRINT(g->user_data, "LMp.13C conservative\n"); @@ -795,11 +812,7 @@ LMp_11: ds_attr->fecTlv.fecElArray[0].addressEl.address, ds_attr->fecTlv.fecElArray[0].addressEl.preLen, ds_attr->state); - if (update) { - ldp_attr2ldp_attr(ds_attr, update, LDP_ATTR_HOPCOUNT | LDP_ATTR_PATH | - LDP_ATTR_MSGID | LDP_ATTR_LSPID | LDP_ATTR_TRAFFIC); - /* JLEU free ds_attr? */ - } else { + if (!existing) { /* LMp.13L */ if (ldp_attr_insert_downstream(g, s, ds_attr) != MPLS_SUCCESS) { retval = MPLS_FAILURE; @@ -815,11 +828,11 @@ LMp_11: * only once. We could arrive here multiple times due to updates, * only install it the first time */ - if ((!update) || (!update->outlabel)) { + if ((!existing) || (!existing->outlabel)) { /* * we haven't installed it yet. - * Either new (!update), or a result of a "Detect FEC Nexthop Change" - * and we had this mapping in our database (!update->outlabel)) + * Either new (!existing), or a result of a "Detect FEC Nexthop Change" + * and we had this mapping in our database (!existing->outlabel)) */ if (!(out = ldp_outlabel_create_complete(g, s, ds_attr, nh))) { @@ -875,7 +888,7 @@ LMp_11: Prepare_Label_Mapping_Attributes(g, s, &f->info, ds_attr, &dumb_attr, MPLS_BOOL_TRUE, MPLS_BOOL_TRUE, MPLS_BOOL_FALSE); - if (!update) { + if (!existing) { /* * this is the first time we've seen this mapping, add it to the database. * all future updates will modify this entry in place @@ -887,57 +900,43 @@ LMp_11: } } -#if 0 - if (update) { - /* - * this is an update, propogate update to all member of this LSP - */ - us_temp = MPLS_LIST_HEAD(&ds_attr->us_attr_root); - while (us_temp) { - us_temp = MPLS_LIST_NEXT(&ds_attr->us_attr_root, us_temp, _ds_attr); - } - } -#endif - peer = MPLS_LIST_HEAD(&g->session); - while (peer) { /* LMp.17 */ + while (peer) { /* LMp.17 */ - if (peer->state != LDP_STATE_OPERATIONAL || - peer->index == s->index) { - /* peer equals msg source */ + if (peer->state != LDP_STATE_OPERATIONAL) { goto next_peer; } - /* check to see if a upstream mapping has been xc'd to this - * downstream mapping for this session. If so we need to propogate - * the attr changes (if any) + /* + * it is just as easy to walk the list of all upstream attr for this + * peer as it is to the individual check to see if we have sent a + * label mapping for this FEC LSP */ - us_temp = MPLS_LIST_HEAD(&ds_attr->us_attr_root); - while (us_temp) { - if (us_temp->session->index == peer->index) { - break; - } - us_temp = MPLS_LIST_NEXT(&ds_attr->us_attr_root, us_temp, _ds_attr); - } - if (us_temp) { /* LMp.18 */ - /* LMp.22 - 27 */ - if ((us_list = ldp_attr_find_upstream_all2(g, peer, f))) { - us_temp = MPLS_LIST_HEAD(us_list); - while (us_temp) { - if (us_temp->state == LDP_LSP_STATE_MAP_SENT) { - /* LMp.23 */ - if (ldp_attr_is_equal(us_temp, &dumb_attr, - LDP_ATTR_HOPCOUNT | LDP_ATTR_PATH) != MPLS_BOOL_TRUE) { - if (ldp_label_mapping_with_xc(g, us_temp->session, f, &us_temp, - ds_attr) != MPLS_SUCCESS) { /* LMp.24-26 */ - retval = MPLS_FAILURE; - goto LMp_33; - } + /* LMp.22 - 27 */ + if ((us_list = ldp_attr_find_upstream_all2(g, peer, f))) { /* LMp.23 */ + us_temp = MPLS_LIST_HEAD(us_list); + while (us_temp) { + /* + * if we have sent a label mapping for the FEC and that label mapping + * was an done in independent mode or it is part of an existing + * recieved label mapping + */ + /* LMp.18 */ + if ((us_temp->state == LDP_LSP_STATE_MAP_SENT) && + ((!existing) || (existing->index == us_temp->ds_attr->index))) { + /* are the recieved attrs the same as the ones we've already sent */ + if (ldp_attr_is_equal(us_temp, &dumb_attr, + LDP_ATTR_HOPCOUNT | LDP_ATTR_PATH) != MPLS_BOOL_TRUE) { + /* send an updated label mapping */ + if (ldp_label_mapping_with_xc(g, us_temp->session, f, &us_temp, + ds_attr) != MPLS_SUCCESS) { /* LMp.24-26 */ + retval = MPLS_FAILURE; + goto LMp_33; } } - us_temp = MPLS_LIST_NEXT(us_list, us_temp, _fs); } + us_temp = MPLS_LIST_NEXT(us_list, us_temp, _fs); } } diff --git a/ldp/ldp_nexthop.c b/ldp/ldp_nexthop.c index 545f866..637650c 100644 --- a/ldp/ldp_nexthop.c +++ b/ldp/ldp_nexthop.c @@ -35,7 +35,7 @@ ldp_nexthop *ldp_nexthop_for_fec_session(ldp_fec *fec, ldp_session *s) ldp_session *sp; while (nh) { sp = ldp_session_for_nexthop(nh); - if (s->index == sp->index) { + if (sp && (sp->index == s->index)) { return nh; } nh = MPLS_LIST_NEXT(&fec->nh_root, nh, _fec); -- 2.11.4.GIT