From 826cfad3a9f5e52d41a4ff995a35cd995f4ce396 Mon Sep 17 00:00:00 2001 From: Mobashshera Rasool Date: Mon, 14 Nov 2022 21:00:55 -0800 Subject: [PATCH] ospfd: Fix RFC conformance test cases 25.19 and 27.6 Steps to reproduce: -------------------------- 1. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-A on DIface-0 with DUT as DR. 2. ANVL: Listen (for up to 2 * seconds) on DIface-0. 3. DUT: Send packet. 4. ANVL: Verify that the received packet contains a Network- LSA for network N1 originated by DUT, and the LS Sequence Number is set to . 5. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-B on DIface-0 with DUT as DR. 6. ANVL: Listen (for up to 2 * seconds) on DIface-0. 7. DUT: Send packet. 8. ANVL: Verify that the received packet contains a new instance of the Network-LSA for network N1 originated by DUT, and the LS Sequence Number is set to ( + 1). Both the test cases were failing while verifying the initial sequence number for network LSA. This is because currently OSPF does not reset its LSA sequence number when it is going down. Signed-off-by: Mobashshera Rasool (cherry picked from commit ca5997cd018ec66534285130d02de168a3a4ed5c) --- lib/libospf.h | 1 + ospfd/ospf_lsa.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/libospf.h b/lib/libospf.h index c8ada9d3c5..161c7635d8 100644 --- a/lib/libospf.h +++ b/lib/libospf.h @@ -52,6 +52,7 @@ extern "C" { #define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */ #define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001U #define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffffU +#define OSPF_INVALID_SEQUENCE_NUMBER 0x80000000U /* OSPF Interface Types */ #define OSPF_IFTYPE_NONE 0 diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 8d05cebcdc..e20235b967 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -3565,6 +3565,7 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf) struct ospf_interface *oi; struct ospf_lsa *lsa; struct route_node *rn; + struct ospf_if_params *oip; int need_to_flush_ase = 0; ospf->inst_shutdown = 1; @@ -3597,6 +3598,12 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf) ospf_lsa_flush_area(oi->network_lsa_self, area); ospf_lsa_unlock(&oi->network_lsa_self); oi->network_lsa_self = NULL; + + oip = ospf_lookup_if_params( + oi->ifp, oi->address->u.prefix4); + if (oip) + oip->network_lsa_seqnum = htonl( + OSPF_INVALID_SEQUENCE_NUMBER); } if (oi->type != OSPF_IFTYPE_VIRTUALLINK -- 2.39.5