Commit 80ff91baa1 for frr
commit 80ff91baa181b35a6b96f0eb6a36433ee21e40cb
Author: Floatato <2264667392@qq.com>
Date: Tue Nov 10 15:16:28 2026 +0800
ospfd: drop MPLS-TE area pointers when an area is freed
MPLS-TE stores the OSPF area on each TE link and later compares
lp->area->area_id from ospf_mpls_te_foreach_area(), including when
`mpls-te on` reoriginates LSAs. ospf_area_free() freed the area without
clearing those links, so the next TE walk read the freed area.
Null every TE link that still points at the area before it is released.
Signed-off-by: Floatato <2264667392@qq.com>
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index de9b2f84b1..4c41301e38 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -234,6 +234,19 @@ static struct mpls_te_link *lookup_linkparams_by_instance(struct ospf_lsa *lsa)
return NULL;
}
+void ospf_mpls_te_area_detach(struct ospf_area *area)
+{
+ struct listnode *node;
+ struct mpls_te_link *lp;
+
+ if (!area || !OspfMplsTE.iflist)
+ return;
+
+ for (ALL_LIST_ELEMENTS_RO(OspfMplsTE.iflist, node, lp))
+ if (lp->area == area)
+ lp->area = NULL;
+}
+
static void ospf_mpls_te_foreach_area(
void (*func)(struct mpls_te_link *lp, enum lsa_opcode sched_opcode),
enum lsa_opcode sched_opcode)
diff --git a/ospfd/ospf_te.h b/ospfd/ospf_te.h
index 8be0b7ecb2..71faa0cf53 100644
--- a/ospfd/ospf_te.h
+++ b/ospfd/ospf_te.h
@@ -409,6 +409,7 @@ struct mpls_te_link {
extern int ospf_mpls_te_init(void);
extern void ospf_mpls_te_term(void);
extern void ospf_mpls_te_finish(void);
+extern void ospf_mpls_te_area_detach(struct ospf_area *area);
extern struct ospf_mpls_te *get_ospf_mpls_te(void);
extern void ospf_mpls_te_update_if(struct interface *ifp);
extern void ospf_mpls_te_lsa_schedule(struct mpls_te_link *lp, enum lsa_opcode opcode);
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 36c297c3b4..31da475933 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -47,6 +47,7 @@
#include "ospfd/ospf_ldp_sync.h"
#include "ospfd/ospf_gr.h"
#include "ospfd/ospf_apiserver.h"
+#include "ospfd/ospf_te.h"
DEFINE_QOBJ_TYPE(ospf);
@@ -1026,6 +1027,9 @@ void ospf_area_lsdb_discard_delete(struct ospf_area *area)
static void ospf_area_free(struct ospf_area *area)
{
+ /* Drop TE links before the area object goes away. */
+ ospf_mpls_te_area_detach(area);
+
ospf_opaque_type10_lsa_term(area);
/* Free LSDBs. */