]> git.puffer.fish Git - mirror/frr.git/commitdiff
ldpd: detect when route received from zebra hasn't changed
authorRenato Westphal <renato@opensourcerouting.org>
Sat, 5 Dec 2020 20:10:04 +0000 (17:10 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Sat, 9 Jan 2021 00:36:09 +0000 (21:36 -0300)
Add some code to detect when a route received from zebra hasn't
changed and ignore the notification in that case, preventing ldpd
from sending unnecessary label mappings.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ldpd/lde.h
ldpd/lde_lib.c

index 660aeafb34bf309f5a851252dd9252275c3144d2..21769ffe0755c853b7a71014307a1997bbf69ab1 100644 (file)
@@ -129,7 +129,9 @@ struct fec_node {
        uint32_t                 pw_remote_status;
 
        void                    *data;          /* fec specific data */
+       uint8_t                  flags;
 };
+#define F_FEC_NHS_CHANGED      0x01
 
 #define CHUNK_SIZE             64
 struct label_chunk {
index 9db931677dc38072639150dc7dc4919d436cfbe4..d89cbb308fa96d5f8cc6177cc3cabfb7275b37dc 100644 (file)
@@ -339,6 +339,8 @@ lde_kernel_insert(struct fec *fec, int af, union ldpd_addr *nexthop,
 
        fnh = fec_nh_find(fn, af, nexthop, ifindex, route_type, route_instance);
        if (fnh == NULL) {
+               fn->flags |= F_FEC_NHS_CHANGED;
+
                fnh = fec_nh_add(fn, af, nexthop, ifindex, route_type,
                    route_instance);
                /*
@@ -415,11 +417,17 @@ lde_kernel_update(struct fec *fec)
                        } else
                                fnh->flags |= F_FEC_NH_NO_LDP;
                } else {
+                       fn->flags |= F_FEC_NHS_CHANGED;
                        lde_send_delete_klabel(fn, fnh);
                        fec_nh_del(fnh);
                }
        }
 
+       if (!(fn->flags & F_FEC_NHS_CHANGED))
+               /* return earlier if nothing has changed */
+               return;
+       fn->flags &= ~F_FEC_NHS_CHANGED;
+
        if (LIST_EMPTY(&fn->nexthops)) {
                RB_FOREACH(ln, nbr_tree, &lde_nbrs)
                        lde_send_labelwithdraw(ln, fn, NULL, NULL);