diff options
| author | Christian Hopps <chopps@labn.net> | 2022-01-08 16:57:10 -0500 |
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2022-06-02 16:37:16 -0400 |
| commit | 5349121b4c6ea2126be87bcbe6400a8f10ea99fc (patch) | |
| tree | 4863a63656b2f3d7ff45f0b6eac69dfe5d030163 /ospfd/ospf_apiserver.c | |
| parent | d86760acad1225dac16776e4cb7366d9b345825c (diff) | |
ospfd: api: fix recovery of LSA after restart of api client
Prior to this fix, restarting the client just failed b/c the code tried to
"refresh" the existing LSA being added, except that code checked for meta-data
to exist, which was deleted when the client disconnected previously (or had
never connected and the LSA state was picked up from the network).
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'ospfd/ospf_apiserver.c')
| -rw-r--r-- | ospfd/ospf_apiserver.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index 259ba2a3f1..4015566b10 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -1627,9 +1627,9 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv, /* Determine if LSA is new or an update for an existing one. */ old = ospf_lsdb_lookup(lsdb, new); - if (!old) { + if (!old || !ospf_opaque_is_owned(old)) { /* New LSA install in LSDB. */ - rc = ospf_apiserver_originate1(new); + rc = ospf_apiserver_originate1(new, old); } else { /* * Keep the new LSA instance in the "waiting place" until the @@ -1696,17 +1696,33 @@ void ospf_apiserver_flood_opaque_lsa(struct ospf_lsa *lsa) } } -int ospf_apiserver_originate1(struct ospf_lsa *lsa) +int ospf_apiserver_originate1(struct ospf_lsa *lsa, struct ospf_lsa *old) { struct ospf *ospf; ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); assert(ospf); + if (old) { + /* + * An old LSA exists that we didn't originate it in this + * session. Dump it, but increment past it's seqnum. + */ + assert(!ospf_opaque_is_owned(old)); + if (IS_LSA_MAX_SEQ(old)) { + flog_warn( + EC_OSPF_LSA_INSTALL_FAILURE, + "ospf_apiserver_originate1: old LSA at maxseq"); + return -1; + } + lsa->data->ls_seqnum = lsa_seqnum_increment(old); + ospf_discard_from_db(ospf, old->lsdb, old); + } + /* Install this LSA into LSDB. */ if (ospf_lsa_install(ospf, lsa->oi, lsa) == NULL) { flog_warn(EC_OSPF_LSA_INSTALL_FAILURE, - "ospf_apiserver_originate1: ospf_lsa_install failed"); + "%s: ospf_lsa_install failed", __func__); return -1; } |
