summaryrefslogtreecommitdiff
path: root/proto/ospf/lsupd.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-06-30 20:12:59 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-06-30 21:30:41 +0200
commit1a2ad348f660b150265f6df759a07de8a2b6de2f (patch)
treed64846d56a79178a34e865440b3b87d970c13fd4 /proto/ospf/lsupd.c
parent8a68316eb96be1fecf91ca395f3321aa99997ad2 (diff)
OSPF: Support for graceful restart
Implement OSPFv2 (RFC 3623) and OSPFv3 (RFC 5187) graceful restart, for both restarting and helper sides. Graceful restart is initiated by 'graceful down' command.
Diffstat (limited to 'proto/ospf/lsupd.c')
-rw-r--r--proto/ospf/lsupd.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c
index 7318b751..fafe4872 100644
--- a/proto/ospf/lsupd.c
+++ b/proto/ospf/lsupd.c
@@ -185,6 +185,13 @@ static int ospf_flood_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_li
static void
ospf_enqueue_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_iface *ifa)
{
+ /* Exception for local Grace-LSA, they are flooded synchronously */
+ if ((en->lsa_type == LSA_T_GR) && (en->lsa.rt == p->router_id))
+ {
+ ospf_flood_lsupd(p, &en, 1, 1, ifa);
+ return;
+ }
+
if (ifa->flood_queue_used == ifa->flood_queue_size)
{
/* If we already have full queue, we send some packets */
@@ -591,8 +598,9 @@ ospf_receive_lsupd(struct ospf_packet *pkt, struct ospf_iface *ifa,
}
/* 13. (5f) - handle self-originated LSAs, see also 13.4. */
- if ((lsa.rt == p->router_id) ||
- (ospf_is_v2(p) && (lsa_type == LSA_T_NET) && ospf_addr_is_local(p, ifa->oa, ipa_from_u32(lsa.id))))
+ if (!p->gr_recovery &&
+ ((lsa.rt == p->router_id) ||
+ (ospf_is_v2(p) && (lsa_type == LSA_T_NET) && ospf_addr_is_local(p, ifa->oa, ipa_from_u32(lsa.id)))))
{
OSPF_TRACE(D_EVENTS, "Received unexpected self-originated LSA");
ospf_advance_lsa(p, en, &lsa, lsa_type, lsa_domain, body);
@@ -629,6 +637,14 @@ ospf_receive_lsupd(struct ospf_packet *pkt, struct ospf_iface *ifa,
if (lsa_type == LSA_T_LINK)
ospf_notify_net_lsa(ifa);
+ /* RFC 3623 3.1 - entering graceful restart helper mode */
+ if (lsa_type == LSA_T_GR)
+ ospf_neigh_notify_grace_lsa(n, en);
+
+ /* Link received pre-restart router LSA */
+ if (p->gr_recovery && (lsa_type == LSA_T_RT) && (lsa.rt == p->router_id))
+ ifa->oa->rt = en;
+
/* 13. (5b) - flood new LSA */
int flood_back = ospf_flood_lsa(p, en, n);