]> git.puffer.fish Git - mirror/frr.git/commitdiff
ldpd: fixing host-only configuration filter. 6109/head
authorlynne <lynne@voltanet.io>
Sun, 29 Mar 2020 17:47:36 +0000 (13:47 -0400)
committerlynne <lynne@voltanet.io>
Wed, 1 Apr 2020 17:14:58 +0000 (13:14 -0400)
There is configuration in LDP to only create labels for
host-routes.   If the user remove this configuration the code
was not readvertising non-host routes to it's LDP neighbors.
The issue is the same in reverse also.  If the user adds this
configuration on an active LDP session the non-host routes were
not withdrawn.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
ldpd/lde.c
ldpd/lde.h
ldpd/ldpd.c

index 64c12e0df51a9fa5f01a31e5cb7108b33555ca42..d4113a78690e233109c53103818aaa2c6f6fd2ba 100644 (file)
@@ -1637,6 +1637,56 @@ lde_change_egress_label(int af)
                    NULL, 0);
 }
 
+void
+lde_change_host_label(int af)
+{
+       struct lde_nbr  *ln;
+       struct fec      *f;
+       struct fec_node *fn;
+       uint32_t         new_label;
+
+       RB_FOREACH(f, fec_tree, &ft) {
+               fn = (struct fec_node *)f;
+
+               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_host_label: unknown af");
+               }
+
+               /*
+                * If the local label has changed to NO_LABEL, send a label
+                * withdraw to all peers.
+                * If the local label has changed and it's different from
+                * NO_LABEL, send a label mapping to all peers advertising
+                * the new label.
+                * If the local label hasn't changed, do nothing
+                */
+               new_label = lde_update_label(fn);
+               if (fn->local_label != new_label) {
+                       if (new_label == NO_LABEL)
+                               RB_FOREACH(ln, nbr_tree, &lde_nbrs)
+                                       lde_send_labelwithdraw(ln, fn,
+                                           NULL, NULL);
+
+                       fn->local_label = new_label;
+                       if (fn->local_label != NO_LABEL)
+                               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
 lde_address_add(struct lde_nbr *ln, struct lde_addr *lde_addr)
 {
index a099f8d2860b74aba2db3d51c916797a9524c3e4..36196a3d081a053025b39b42e495577585d45e36 100644 (file)
@@ -183,6 +183,7 @@ void                 lde_req_del(struct lde_nbr *, struct lde_req *, int);
 struct lde_wdraw *lde_wdraw_add(struct lde_nbr *, struct fec_node *);
 void            lde_wdraw_del(struct lde_nbr *, struct lde_wdraw *);
 void            lde_change_egress_label(int);
+void            lde_change_host_label(int);
 struct lde_addr        *lde_address_find(struct lde_nbr *, int,
                    union ldpd_addr *);
 
index 0f9f055d02544cc7a4010f5c87c4ee11a2e70dfb..741c8c4655a229dea5777befa3da38f5c85cb9f6 100644 (file)
@@ -1319,6 +1319,7 @@ merge_af(int af, struct ldpd_af_conf *af_conf, struct ldpd_af_conf *xa)
        int              stop_init_backoff = 0;
        int              remove_dynamic_tnbrs = 0;
        int              change_egress_label = 0;
+       int              change_host_label = 0;
        int              reset_nbrs_ipv4 = 0;
        int              reset_nbrs = 0;
        int              update_sockets = 0;
@@ -1349,6 +1350,12 @@ merge_af(int af, struct ldpd_af_conf *af_conf, struct ldpd_af_conf *xa)
        if ((af_conf->flags & F_LDPD_AF_EXPNULL) !=
            (xa->flags & F_LDPD_AF_EXPNULL))
                change_egress_label = 1;
+
+       /* changing config of host only fec filtering */
+       if ((af_conf->flags & F_LDPD_AF_ALLOCHOSTONLY)
+           != (xa->flags & F_LDPD_AF_ALLOCHOSTONLY))
+               change_host_label = 1;
+
        af_conf->flags = xa->flags;
 
        /* update the transport address */
@@ -1358,6 +1365,10 @@ merge_af(int af, struct ldpd_af_conf *af_conf, struct ldpd_af_conf *xa)
        }
 
        /* update ACLs */
+       if (strcmp(af_conf->acl_label_allocate_for,
+           xa->acl_label_allocate_for))
+               change_host_label = 1;
+
        if (strcmp(af_conf->acl_label_advertise_to,
            xa->acl_label_advertise_to) ||
            strcmp(af_conf->acl_label_advertise_for,
@@ -1391,6 +1402,8 @@ merge_af(int af, struct ldpd_af_conf *af_conf, struct ldpd_af_conf *xa)
        case PROC_LDE_ENGINE:
                if (change_egress_label)
                        lde_change_egress_label(af);
+               if (change_host_label)
+                       lde_change_host_label(af);
                break;
        case PROC_LDP_ENGINE:
                if (stop_init_backoff)