]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd, ospfd: update interface_link_params callback to check for change
authorKaren Schoener <karen@voltanet.io>
Thu, 17 Jun 2021 13:26:36 +0000 (09:26 -0400)
committermergify-bot <noreply@mergify.io>
Sat, 24 Jul 2021 17:00:04 +0000 (17:00 +0000)
Adding defensive code to the interface_link_params zebra callback
to check if the link params changed before taking action.

Signed-off-by: Karen Schoener <karen@voltanet.io>
(cherry picked from commit 0b4124c18cb826849f18af58dbc712db7d14b993)

isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
ospfd/ospf_interface.c
ospfd/ospf_zebra.c

index 0142e30b2be63aa647931e852bcc229c76fd6add..2c05cb827797e5c0a377cea98d6d04d968860c4a 100644 (file)
@@ -145,10 +145,11 @@ static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
 static int isis_zebra_link_params(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
+       bool changed = false;
 
-       ifp = zebra_interface_link_params_read(zclient->ibuf, vrf_id);
+       ifp = zebra_interface_link_params_read(zclient->ibuf, vrf_id, &changed);
 
-       if (ifp == NULL)
+       if (ifp == NULL || !changed)
                return 0;
 
        /* Update TE TLV */
index bf4966a5d7776d98a0af4122f2dd299a858086b9..c0ca3460b93121df686a8ad33b9245b52d267991 100644 (file)
@@ -2126,10 +2126,13 @@ stream_failure:
 }
 
 struct interface *zebra_interface_link_params_read(struct stream *s,
-                                                  vrf_id_t vrf_id)
+                                                  vrf_id_t vrf_id,
+                                                  bool *changed)
 {
        struct if_link_params *iflp;
+       struct if_link_params iflp_copy;
        ifindex_t ifindex;
+       bool params_changed = false;
 
        STREAM_GETL(s, ifindex);
 
@@ -2142,12 +2145,23 @@ struct interface *zebra_interface_link_params_read(struct stream *s,
                return NULL;
        }
 
+       if (ifp->link_params == NULL)
+               params_changed = true;
+
        if ((iflp = if_link_params_get(ifp)) == NULL)
                return NULL;
 
+       memcpy(&iflp_copy, iflp, sizeof(iflp_copy));
+
        if (link_params_set_value(s, iflp) != 0)
                goto stream_failure;
 
+       if (memcmp(&iflp_copy, iflp, sizeof(iflp_copy)))
+               params_changed = true;
+
+       if (changed)
+               *changed = params_changed;
+
        return ifp;
 
 stream_failure:
index 8c279165425246212dc6c3996d8a47639372bd82..bb4788bf0bd7415a95cabdb1d336bdba228e04dd 100644 (file)
@@ -1019,7 +1019,8 @@ extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
 extern int zebra_router_id_update_read(struct stream *s, struct prefix *rid);
 
 extern struct interface *zebra_interface_link_params_read(struct stream *s,
-                                                         vrf_id_t vrf_id);
+                                                         vrf_id_t vrf_id,
+                                                         bool *changed);
 extern size_t zebra_interface_link_params_write(struct stream *,
                                                struct interface *);
 extern enum zclient_send_status
index b4e318d1d1d1bef3efcf30a158d0243a3f65e310..b3aba247dfb4f0b399aa9dabc53782ad6506ed36 100644 (file)
@@ -50,6 +50,7 @@
 #include "ospfd/ospf_dump.h"
 #include "ospfd/ospf_ldp_sync.h"
 #include "ospfd/ospf_route.h"
+#include "ospfd/ospf_te.h"
 
 DEFINE_QOBJ_TYPE(ospf_interface);
 DEFINE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd));
@@ -1354,6 +1355,9 @@ static int ospf_ifp_create(struct interface *ifp)
 
        ospf_if_update(ospf, ifp);
 
+       if (HAS_LINK_PARAMS(ifp))
+               ospf_mpls_te_update_if(ifp);
+
        hook_call(ospf_if_update, ifp);
 
        return 0;
@@ -1392,6 +1396,9 @@ static int ospf_ifp_up(struct interface *ifp)
                ospf_if_up(oi);
        }
 
+       if (HAS_LINK_PARAMS(ifp))
+               ospf_mpls_te_update_if(ifp);
+
        return 0;
 }
 
index 5853b506f81959467103f37e85c97917f85222c8..df112edc6804dda1587b15359d11268b2afefc87 100644 (file)
@@ -163,10 +163,11 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
 static int ospf_interface_link_params(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
+       bool changed = false;
 
-       ifp = zebra_interface_link_params_read(zclient->ibuf, vrf_id);
+       ifp = zebra_interface_link_params_read(zclient->ibuf, vrf_id, &changed);
 
-       if (ifp == NULL)
+       if (ifp == NULL || !changed)
                return 0;
 
        /* Update TE TLV */