summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_neighbor.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_neighbor.c')
-rw-r--r--ospf6d/ospf6_neighbor.c65
1 files changed, 23 insertions, 42 deletions
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 439b94c9af..a4ba1fb569 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -106,6 +106,23 @@ struct ospf6_neighbor *ospf6_area_neighbor_lookup(struct ospf6_area *area,
return NULL;
}
+static void ospf6_neighbor_clear_ls_lists(struct ospf6_neighbor *on)
+{
+ struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsanext;
+
+ ospf6_lsdb_remove_all(on->summary_list);
+ if (on->last_ls_req) {
+ ospf6_lsa_unlock(on->last_ls_req);
+ on->last_ls_req = NULL;
+ }
+ ospf6_lsdb_remove_all(on->request_list);
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
+ ospf6_decrement_retrans_count(lsa);
+ ospf6_lsdb_remove(lsa, on->retrans_list);
+ }
+}
+
/* create ospf6_neighbor */
struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
struct ospf6_interface *oi)
@@ -147,14 +164,7 @@ struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
void ospf6_neighbor_delete(struct ospf6_neighbor *on)
{
- struct ospf6_lsa *lsa, *lsanext;
-
- ospf6_lsdb_remove_all(on->summary_list);
- ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
- ospf6_decrement_retrans_count(lsa);
- ospf6_lsdb_remove(lsa, on->retrans_list);
- }
+ ospf6_neighbor_clear_ls_lists(on);
ospf6_lsdb_remove_all(on->dbdesc_list);
ospf6_lsdb_remove_all(on->lsupdate_list);
@@ -339,12 +349,7 @@ void negotiation_done(struct thread *thread)
zlog_debug("Neighbor Event %s: *NegotiationDone*", on->name);
/* clear ls-list */
- ospf6_lsdb_remove_all(on->summary_list);
- ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
- ospf6_decrement_retrans_count(lsa);
- ospf6_lsdb_remove(lsa, on->retrans_list);
- }
+ ospf6_neighbor_clear_ls_lists(on);
/* Interface scoped LSAs */
for (ALL_LSDB(on->ospf6_if->lsdb, lsa, lsanext)) {
@@ -464,7 +469,6 @@ void loading_done(struct thread *thread)
void adj_ok(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
@@ -486,19 +490,13 @@ void adj_ok(struct thread *thread)
} else if (on->state >= OSPF6_NEIGHBOR_EXSTART && !need_adjacency(on)) {
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on,
OSPF6_NEIGHBOR_EVENT_ADJ_OK);
- ospf6_lsdb_remove_all(on->summary_list);
- ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
- ospf6_decrement_retrans_count(lsa);
- ospf6_lsdb_remove(lsa, on->retrans_list);
- }
+ ospf6_neighbor_clear_ls_lists(on);
}
}
void seqnumber_mismatch(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
@@ -515,12 +513,7 @@ void seqnumber_mismatch(struct thread *thread)
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
- ospf6_lsdb_remove_all(on->summary_list);
- ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
- ospf6_decrement_retrans_count(lsa);
- ospf6_lsdb_remove(lsa, on->retrans_list);
- }
+ ospf6_neighbor_clear_ls_lists(on);
THREAD_OFF(on->thread_send_dbdesc);
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
@@ -532,7 +525,6 @@ void seqnumber_mismatch(struct thread *thread)
void bad_lsreq(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
@@ -549,12 +541,7 @@ void bad_lsreq(struct thread *thread)
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
- ospf6_lsdb_remove_all(on->summary_list);
- ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
- ospf6_decrement_retrans_count(lsa);
- ospf6_lsdb_remove(lsa, on->retrans_list);
- }
+ ospf6_neighbor_clear_ls_lists(on);
THREAD_OFF(on->thread_send_dbdesc);
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
@@ -567,7 +554,6 @@ void bad_lsreq(struct thread *thread)
void oneway_received(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
@@ -582,12 +568,7 @@ void oneway_received(struct thread *thread)
OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
- ospf6_lsdb_remove_all(on->summary_list);
- ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
- ospf6_decrement_retrans_count(lsa);
- ospf6_lsdb_remove(lsa, on->retrans_list);
- }
+ ospf6_neighbor_clear_ls_lists(on);
THREAD_OFF(on->thread_send_dbdesc);
THREAD_OFF(on->thread_send_lsreq);