From be54d7449aebd657e378016a1228ec1b006936cc Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 1 Feb 2017 13:03:53 -0200 Subject: [PATCH] ldpd: fix a bug in the explicit-null command Be more clever and update the label of the connected routes just once upon a configuration change. This is not only more efficient but also fixes a bug where no labels were updated when we didn't have any neighbors. Signed-off-by: Renato Westphal --- ldpd/lde.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index 0aa422c23a..91b2b1727f 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -1266,8 +1266,8 @@ lde_change_egress_label(int af, int was_implicit) struct fec *f; struct fec_node *fn; + /* explicitly withdraw all null labels */ RB_FOREACH(ln, nbr_tree, &lde_nbrs) { - /* explicit withdraw */ if (was_implicit) lde_send_labelwithdraw(ln, NULL, MPLS_LABEL_IMPLNULL, NULL); @@ -1279,33 +1279,34 @@ lde_change_egress_label(int af, int was_implicit) lde_send_labelwithdraw(ln, NULL, MPLS_LABEL_IPV6NULL, NULL); } + } - /* advertise new label of connected prefixes */ - RB_FOREACH(f, fec_tree, &ft) { - fn = (struct fec_node *)f; - if (fn->local_label > MPLS_LABEL_RESERVED_MAX) - continue; - - switch (af) { - case AF_INET: - if (fn->fec.type != FEC_TYPE_IPV4) - continue; - break; - case AF_INET6: - if (fn->fec.type != FEC_TYPE_IPV6) - continue; - break; - default: - fatalx("lde_change_egress_label: unknown af"); - } + /* update label of connected routes */ + RB_FOREACH(f, fec_tree, &ft) { + fn = (struct fec_node *)f; + if (fn->local_label > MPLS_LABEL_RESERVED_MAX) + continue; - fn->local_label = egress_label(fn->fec.type); - lde_send_labelmapping(ln, fn, 0); + switch (af) { + case AF_INET: + if (fn->fec.type != FEC_TYPE_IPV4) + continue; + break; + case AF_INET6: + if (fn->fec.type != FEC_TYPE_IPV6) + continue; + break; + default: + fatalx("lde_change_egress_label: unknown af"); } + fn->local_label = egress_label(fn->fec.type); + RB_FOREACH(ln, nbr_tree, &lde_nbrs) + lde_send_labelmapping(ln, fn, 0); + } + RB_FOREACH(ln, nbr_tree, &lde_nbrs) lde_imsg_compose_ldpe(IMSG_MAPPING_ADD_END, ln->peerid, 0, NULL, 0); - } } static int -- 2.39.5