]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ldpd: fix a bug in the explicit-null command
authorRenato Westphal <renato@opensourcerouting.org>
Wed, 1 Feb 2017 15:03:53 +0000 (13:03 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Wed, 1 Feb 2017 23:48:54 +0000 (21:48 -0200)
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 <renato@opensourcerouting.org>
ldpd/lde.c

index 0aa422c23a45b208e085c5a7c8055c126bf9a02c..91b2b1727f170addca0544455f2fea9b26c9901c 100644 (file)
@@ -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