ospf6d: use macro for LSDB walks

... to make it easier to refactor all of the iteration uses.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-07-07 17:23:30 +02:00
parent 736ac221d1
commit 49dd8e3758
10 changed files with 61 additions and 99 deletions

View File

@ -989,13 +989,11 @@ ospf6_abr_examin_brouter (u_int32_t router_id)
return; return;
type = htons (OSPF6_LSTYPE_INTER_ROUTER); type = htons (OSPF6_LSTYPE_INTER_ROUTER);
for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; for (ALL_LSDB_TYPED_ADVRTR(oa->lsdb, type, router_id, lsa))
lsa = ospf6_lsdb_type_router_next (type, router_id, lsa)) ospf6_abr_examin_summary (lsa, oa);
ospf6_abr_examin_summary (lsa, oa);
type = htons (OSPF6_LSTYPE_INTER_PREFIX); type = htons (OSPF6_LSTYPE_INTER_PREFIX);
for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; for (ALL_LSDB_TYPED_ADVRTR(oa->lsdb, type, router_id, lsa))
lsa = ospf6_lsdb_type_router_next (type, router_id, lsa))
ospf6_abr_examin_summary (lsa, oa); ospf6_abr_examin_summary (lsa, oa);
} }
@ -1006,13 +1004,11 @@ ospf6_abr_reimport (struct ospf6_area *oa)
u_int16_t type; u_int16_t type;
type = htons (OSPF6_LSTYPE_INTER_ROUTER); type = htons (OSPF6_LSTYPE_INTER_ROUTER);
for (lsa = ospf6_lsdb_type_head (type, oa->lsdb); lsa; for (ALL_LSDB_TYPED(oa->lsdb, type, lsa))
lsa = ospf6_lsdb_type_next (type, lsa))
ospf6_abr_examin_summary (lsa, oa); ospf6_abr_examin_summary (lsa, oa);
type = htons (OSPF6_LSTYPE_INTER_PREFIX); type = htons (OSPF6_LSTYPE_INTER_PREFIX);
for (lsa = ospf6_lsdb_type_head (type, oa->lsdb); lsa; for (ALL_LSDB_TYPED(oa->lsdb, type, lsa))
lsa = ospf6_lsdb_type_next (type, lsa))
ospf6_abr_examin_summary (lsa, oa); ospf6_abr_examin_summary (lsa, oa);
} }

View File

@ -343,8 +343,7 @@ ospf6_asbr_lsentry_add (struct ospf6_route *asbr_entry)
type = htons (OSPF6_LSTYPE_AS_EXTERNAL); type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix); router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix);
for (lsa = ospf6_lsdb_type_router_head (type, router, ospf6->lsdb); lsa; for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, router, lsa))
lsa = ospf6_lsdb_type_router_next (type, router, lsa))
{ {
if (! OSPF6_LSA_IS_MAXAGE (lsa)) if (! OSPF6_LSA_IS_MAXAGE (lsa))
ospf6_asbr_lsa_add (lsa); ospf6_asbr_lsa_add (lsa);
@ -360,8 +359,7 @@ ospf6_asbr_lsentry_remove (struct ospf6_route *asbr_entry)
type = htons (OSPF6_LSTYPE_AS_EXTERNAL); type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix); router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix);
for (lsa = ospf6_lsdb_type_router_head (type, router, ospf6->lsdb); for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, router, lsa))
lsa; lsa = ospf6_lsdb_type_router_next (type, router, lsa))
ospf6_asbr_lsa_remove (lsa); ospf6_asbr_lsa_remove (lsa);
} }
@ -444,8 +442,7 @@ ospf6_asbr_send_externals_to_area (struct ospf6_area *oa)
{ {
struct ospf6_lsa *lsa; struct ospf6_lsa *lsa;
for (lsa = ospf6_lsdb_head (oa->ospf6->lsdb); lsa; for (ALL_LSDB(oa->ospf6->lsdb, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
if (ntohs (lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL) if (ntohs (lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL)
{ {

View File

@ -993,8 +993,7 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp)
oi->lsupdate_list->count, duration, oi->lsupdate_list->count, duration,
(oi->thread_send_lsupdate ? "on" : "off"), (oi->thread_send_lsupdate ? "on" : "off"),
VNL); VNL);
for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; for (ALL_LSDB(oi->lsupdate_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
timerclear (&res); timerclear (&res);
@ -1005,8 +1004,7 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp)
oi->lsack_list->count, duration, oi->lsack_list->count, duration,
(oi->thread_send_lsack ? "on" : "off"), (oi->thread_send_lsack ? "on" : "off"),
VNL); VNL);
for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; for (ALL_LSDB(oi->lsack_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
ospf6_bfd_show_info(vty, oi->bfd_info, 1); ospf6_bfd_show_info(vty, oi->bfd_info, 1);
return 0; return 0;

View File

@ -341,8 +341,7 @@ ospf6_router_lsa_originate (struct thread *thread)
type = ntohs (OSPF6_LSTYPE_ROUTER); type = ntohs (OSPF6_LSTYPE_ROUTER);
router = oa->ospf6->router_id; router = oa->ospf6->router_id;
count = 0; count = 0;
for (lsa = ospf6_lsdb_type_router_head (type, router, oa->lsdb); lsa; for (ALL_LSDB_TYPED_ADVRTR(oa->lsdb, type, router, lsa))
lsa = ospf6_lsdb_type_router_next (type, router, lsa))
{ {
if (ntohl (lsa->header->id) < link_state_id) if (ntohl (lsa->header->id) < link_state_id)
continue; continue;
@ -495,8 +494,7 @@ ospf6_network_lsa_originate (struct thread *thread)
/* Collect the interface's Link-LSAs to describe /* Collect the interface's Link-LSAs to describe
network's optional capabilities */ network's optional capabilities */
type = htons (OSPF6_LSTYPE_LINK); type = htons (OSPF6_LSTYPE_LINK);
for (lsa = ospf6_lsdb_type_head (type, oi->lsdb); lsa; for (ALL_LSDB_TYPED(oi->lsdb, type, lsa))
lsa = ospf6_lsdb_type_next (type, lsa))
{ {
link_lsa = (struct ospf6_link_lsa *) link_lsa = (struct ospf6_link_lsa *)
((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
@ -1096,8 +1094,7 @@ ospf6_intra_prefix_lsa_originate_transit (struct thread *thread)
route_advertise = ospf6_route_table_create (0, 0); route_advertise = ospf6_route_table_create (0, 0);
type = ntohs (OSPF6_LSTYPE_LINK); type = ntohs (OSPF6_LSTYPE_LINK);
for (lsa = ospf6_lsdb_type_head (type, oi->lsdb); lsa; for (ALL_LSDB_TYPED(oi->lsdb, type, lsa))
lsa = ospf6_lsdb_type_next (type, lsa))
{ {
if (OSPF6_LSA_IS_MAXAGE (lsa)) if (OSPF6_LSA_IS_MAXAGE (lsa))
continue; continue;
@ -1429,8 +1426,7 @@ ospf6_intra_route_calculation (struct ospf6_area *oa)
route->flag = OSPF6_ROUTE_REMOVE; route->flag = OSPF6_ROUTE_REMOVE;
type = htons (OSPF6_LSTYPE_INTRA_PREFIX); type = htons (OSPF6_LSTYPE_INTRA_PREFIX);
for (lsa = ospf6_lsdb_type_head (type, oa->lsdb); lsa; for (ALL_LSDB_TYPED(oa->lsdb, type, lsa))
lsa = ospf6_lsdb_type_next (type, lsa))
ospf6_intra_prefix_lsa_add (lsa); ospf6_intra_prefix_lsa_add (lsa);
oa->route_table->hook_add = hook_add; oa->route_table->hook_add = hook_add;

View File

@ -80,8 +80,7 @@ _lsdb_count_assert (struct ospf6_lsdb *lsdb)
{ {
struct ospf6_lsa *debug; struct ospf6_lsa *debug;
unsigned int num = 0; unsigned int num = 0;
for (debug = ospf6_lsdb_head (lsdb); debug; for (ALL_LSDB(lsdb, debug))
debug = ospf6_lsdb_next (debug))
num++; num++;
if (num == lsdb->count) if (num == lsdb->count)
@ -89,8 +88,7 @@ _lsdb_count_assert (struct ospf6_lsdb *lsdb)
zlog_debug ("PANIC !! lsdb[%p]->count = %d, real = %d", zlog_debug ("PANIC !! lsdb[%p]->count = %d, real = %d",
lsdb, lsdb->count, num); lsdb, lsdb->count, num);
for (debug = ospf6_lsdb_head (lsdb); debug; for (ALL_LSDB(lsdb, debug))
debug = ospf6_lsdb_next (debug))
zlog_debug ("%p %p %s lsdb[%p]", debug->prev, debug->next, debug->name, zlog_debug ("%p %p %s lsdb[%p]", debug->prev, debug->next, debug->name,
debug->lsdb); debug->lsdb);
zlog_debug ("DUMP END"); zlog_debug ("DUMP END");
@ -437,7 +435,7 @@ ospf6_lsdb_remove_all (struct ospf6_lsdb *lsdb)
if (lsdb == NULL) if (lsdb == NULL)
return; return;
for (lsa = ospf6_lsdb_head (lsdb); lsa; lsa = ospf6_lsdb_next (lsa)) for (ALL_LSDB(lsdb, lsa))
ospf6_lsdb_remove (lsa, lsdb); ospf6_lsdb_remove (lsa, lsdb);
} }
@ -458,7 +456,7 @@ ospf6_lsdb_maxage_remover (struct ospf6_lsdb *lsdb)
int reschedule = 0; int reschedule = 0;
struct ospf6_lsa *lsa; struct ospf6_lsa *lsa;
for (lsa = ospf6_lsdb_head (lsdb); lsa; lsa = ospf6_lsdb_next (lsa)) for (ALL_LSDB(lsdb, lsa))
{ {
if (! OSPF6_LSA_IS_MAXAGE (lsa)) if (! OSPF6_LSA_IS_MAXAGE (lsa))
continue; continue;
@ -559,8 +557,7 @@ ospf6_new_ls_id (u_int16_t type, u_int32_t adv_router,
/* This routine is curently invoked only for Inter-Prefix LSAs for /* This routine is curently invoked only for Inter-Prefix LSAs for
* non-summarized routes (no area/range). * non-summarized routes (no area/range).
*/ */
for (lsa = ospf6_lsdb_type_router_head (type, adv_router, lsdb); lsa; for (ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa))
lsa = ospf6_lsdb_type_router_next (type, adv_router, lsa))
{ {
tmp_id = ntohl (lsa->header->id); tmp_id = ntohl (lsa->header->id);
if (tmp_id < id) if (tmp_id < id)

View File

@ -50,6 +50,9 @@ extern void ospf6_lsdb_remove (struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
extern struct ospf6_lsa *ospf6_lsdb_head (struct ospf6_lsdb *lsdb); extern struct ospf6_lsa *ospf6_lsdb_head (struct ospf6_lsdb *lsdb);
extern struct ospf6_lsa *ospf6_lsdb_next (struct ospf6_lsa *lsa); extern struct ospf6_lsa *ospf6_lsdb_next (struct ospf6_lsa *lsa);
#define ALL_LSDB(lsdb, lsa) \
lsa = ospf6_lsdb_head(lsdb); lsa; \
lsa = ospf6_lsdb_next(lsa)
extern struct ospf6_lsa *ospf6_lsdb_type_router_head (u_int16_t type, extern struct ospf6_lsa *ospf6_lsdb_type_router_head (u_int16_t type,
u_int32_t adv_router, u_int32_t adv_router,
@ -57,11 +60,17 @@ extern struct ospf6_lsa *ospf6_lsdb_type_router_head (u_int16_t type,
extern struct ospf6_lsa *ospf6_lsdb_type_router_next (u_int16_t type, extern struct ospf6_lsa *ospf6_lsdb_type_router_next (u_int16_t type,
u_int32_t adv_router, u_int32_t adv_router,
struct ospf6_lsa *lsa); struct ospf6_lsa *lsa);
#define ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa) \
lsa = ospf6_lsdb_type_router_head(type, adv_router, lsdb); lsa; \
lsa = ospf6_lsdb_type_router_next(type, adv_router, lsa)
extern struct ospf6_lsa *ospf6_lsdb_type_head (u_int16_t type, extern struct ospf6_lsa *ospf6_lsdb_type_head (u_int16_t type,
struct ospf6_lsdb *lsdb); struct ospf6_lsdb *lsdb);
extern struct ospf6_lsa *ospf6_lsdb_type_next (u_int16_t type, extern struct ospf6_lsa *ospf6_lsdb_type_next (u_int16_t type,
struct ospf6_lsa *lsa); struct ospf6_lsa *lsa);
#define ALL_LSDB_TYPED(lsdb, type, lsa) \
lsa = ospf6_lsdb_type_head(type, lsdb); lsa; \
lsa = ospf6_lsdb_type_next(type, lsa)
extern void ospf6_lsdb_remove_all (struct ospf6_lsdb *lsdb); extern void ospf6_lsdb_remove_all (struct ospf6_lsdb *lsdb);
extern void ospf6_lsdb_lsa_unlock (struct ospf6_lsa *lsa); extern void ospf6_lsdb_lsa_unlock (struct ospf6_lsa *lsa);

View File

@ -1826,8 +1826,7 @@ ospf6_dbdesc_send (struct thread *thread)
p = (u_char *)((caddr_t) dbdesc + sizeof (struct ospf6_dbdesc)); p = (u_char *)((caddr_t) dbdesc + sizeof (struct ospf6_dbdesc));
if (! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT)) if (! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT))
{ {
for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa; for (ALL_LSDB(on->dbdesc_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
ospf6_lsa_age_update_to_send (lsa, on->ospf6_if->transdelay); ospf6_lsa_age_update_to_send (lsa, on->ospf6_if->transdelay);
@ -1870,8 +1869,7 @@ ospf6_dbdesc_send_newone (struct thread *thread)
/* move LSAs from summary_list to dbdesc_list (within neighbor structure) /* move LSAs from summary_list to dbdesc_list (within neighbor structure)
so that ospf6_send_dbdesc () can send those LSAs */ so that ospf6_send_dbdesc () can send those LSAs */
size = sizeof (struct ospf6_lsa_header) + sizeof (struct ospf6_dbdesc); size = sizeof (struct ospf6_lsa_header) + sizeof (struct ospf6_dbdesc);
for (lsa = ospf6_lsdb_head (on->summary_list); lsa; for (ALL_LSDB(on->summary_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
if (size + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if)) if (size + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if))
{ {
@ -1932,8 +1930,7 @@ ospf6_lsreq_send (struct thread *thread)
/* set Request entries in lsreq */ /* set Request entries in lsreq */
p = (u_char *)((caddr_t) oh + sizeof (struct ospf6_header)); p = (u_char *)((caddr_t) oh + sizeof (struct ospf6_header));
for (lsa = ospf6_lsdb_head (on->request_list); lsa; for (ALL_LSDB(on->request_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
/* MTU check */ /* MTU check */
if (p - sendbuf + sizeof (struct ospf6_lsreq_entry) > ospf6_packet_max(on->ospf6_if)) if (p - sendbuf + sizeof (struct ospf6_lsreq_entry) > ospf6_packet_max(on->ospf6_if))
@ -2015,8 +2012,7 @@ ospf6_lsupdate_send_neighbor (struct thread *thread)
/* lsupdate_list lists those LSA which doesn't need to be /* lsupdate_list lists those LSA which doesn't need to be
retransmitted. remove those from the list */ retransmitted. remove those from the list */
for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa; for (ALL_LSDB(on->lsupdate_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
/* MTU check */ /* MTU check */
if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header)) if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header))
@ -2061,8 +2057,7 @@ ospf6_lsupdate_send_neighbor (struct thread *thread)
p = (u_char *)((caddr_t) lsupdate + sizeof (struct ospf6_lsupdate)); p = (u_char *)((caddr_t) lsupdate + sizeof (struct ospf6_lsupdate));
lsa_cnt = 0; lsa_cnt = 0;
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
/* MTU check */ /* MTU check */
if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header)) if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header))
@ -2138,8 +2133,7 @@ ospf6_lsupdate_send_interface (struct thread *thread)
p = (u_char *)((caddr_t) lsupdate + sizeof (struct ospf6_lsupdate)); p = (u_char *)((caddr_t) lsupdate + sizeof (struct ospf6_lsupdate));
lsa_cnt = 0; lsa_cnt = 0;
for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; for (ALL_LSDB(oi->lsupdate_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
/* MTU check */ /* MTU check */
if ( (p - sendbuf + ((unsigned int)OSPF6_LSA_SIZE (lsa->header))) if ( (p - sendbuf + ((unsigned int)OSPF6_LSA_SIZE (lsa->header)))
@ -2213,8 +2207,7 @@ ospf6_lsack_send_neighbor (struct thread *thread)
p = (u_char *)((caddr_t) oh + sizeof (struct ospf6_header)); p = (u_char *)((caddr_t) oh + sizeof (struct ospf6_header));
for (lsa = ospf6_lsdb_head (on->lsack_list); lsa; for (ALL_LSDB(on->lsack_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
/* MTU check */ /* MTU check */
if (p - sendbuf + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if)) if (p - sendbuf + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if))
@ -2281,8 +2274,7 @@ ospf6_lsack_send_interface (struct thread *thread)
p = (u_char *)((caddr_t) oh + sizeof (struct ospf6_header)); p = (u_char *)((caddr_t) oh + sizeof (struct ospf6_header));
for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; for (ALL_LSDB(oi->lsack_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
/* MTU check */ /* MTU check */
if (p - sendbuf + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(oi)) if (p - sendbuf + sizeof (struct ospf6_lsa_header) > ospf6_packet_max(oi))

View File

@ -123,8 +123,7 @@ ospf6_neighbor_delete (struct ospf6_neighbor *on)
ospf6_lsdb_remove_all (on->summary_list); ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list); ospf6_lsdb_remove_all (on->request_list);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
ospf6_decrement_retrans_count (lsa); ospf6_decrement_retrans_count (lsa);
ospf6_lsdb_remove (lsa, on->retrans_list); ospf6_lsdb_remove (lsa, on->retrans_list);
@ -302,16 +301,14 @@ negotiation_done (struct thread *thread)
/* clear ls-list */ /* clear ls-list */
ospf6_lsdb_remove_all (on->summary_list); ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list); ospf6_lsdb_remove_all (on->request_list);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
ospf6_decrement_retrans_count (lsa); ospf6_decrement_retrans_count (lsa);
ospf6_lsdb_remove (lsa, on->retrans_list); ospf6_lsdb_remove (lsa, on->retrans_list);
} }
/* Interface scoped LSAs */ /* Interface scoped LSAs */
for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa; for (ALL_LSDB(on->ospf6_if->lsdb, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
if (OSPF6_LSA_IS_MAXAGE (lsa)) if (OSPF6_LSA_IS_MAXAGE (lsa))
{ {
@ -323,8 +320,7 @@ negotiation_done (struct thread *thread)
} }
/* Area scoped LSAs */ /* Area scoped LSAs */
for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa; for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
if (OSPF6_LSA_IS_MAXAGE (lsa)) if (OSPF6_LSA_IS_MAXAGE (lsa))
{ {
@ -336,8 +332,7 @@ negotiation_done (struct thread *thread)
} }
/* AS scoped LSAs */ /* AS scoped LSAs */
for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa; for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
if (OSPF6_LSA_IS_MAXAGE (lsa)) if (OSPF6_LSA_IS_MAXAGE (lsa))
{ {
@ -472,8 +467,7 @@ adj_ok (struct thread *thread)
OSPF6_NEIGHBOR_EVENT_ADJ_OK); OSPF6_NEIGHBOR_EVENT_ADJ_OK);
ospf6_lsdb_remove_all (on->summary_list); ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list); ospf6_lsdb_remove_all (on->request_list);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
ospf6_decrement_retrans_count (lsa); ospf6_decrement_retrans_count (lsa);
ospf6_lsdb_remove (lsa, on->retrans_list); ospf6_lsdb_remove (lsa, on->retrans_list);
@ -506,8 +500,7 @@ seqnumber_mismatch (struct thread *thread)
ospf6_lsdb_remove_all (on->summary_list); ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list); ospf6_lsdb_remove_all (on->request_list);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
ospf6_decrement_retrans_count (lsa); ospf6_decrement_retrans_count (lsa);
ospf6_lsdb_remove (lsa, on->retrans_list); ospf6_lsdb_remove (lsa, on->retrans_list);
@ -545,8 +538,7 @@ bad_lsreq (struct thread *thread)
ospf6_lsdb_remove_all (on->summary_list); ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list); ospf6_lsdb_remove_all (on->request_list);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
ospf6_decrement_retrans_count (lsa); ospf6_decrement_retrans_count (lsa);
ospf6_lsdb_remove (lsa, on->retrans_list); ospf6_lsdb_remove (lsa, on->retrans_list);
@ -582,8 +574,7 @@ oneway_received (struct thread *thread)
ospf6_lsdb_remove_all (on->summary_list); ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list); ospf6_lsdb_remove_all (on->request_list);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
{ {
ospf6_decrement_retrans_count (lsa); ospf6_decrement_retrans_count (lsa);
ospf6_lsdb_remove (lsa, on->retrans_list); ospf6_lsdb_remove (lsa, on->retrans_list);
@ -756,20 +747,17 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count, vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count,
VNL); VNL);
for (lsa = ospf6_lsdb_head (on->summary_list); lsa; for (ALL_LSDB(on->summary_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count, vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count,
VNL); VNL);
for (lsa = ospf6_lsdb_head (on->request_list); lsa; for (ALL_LSDB(on->request_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count, vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count,
VNL); VNL);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; for (ALL_LSDB(on->retrans_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
timerclear (&res); timerclear (&res);
@ -780,8 +768,7 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
on->dbdesc_list->count, duration, on->dbdesc_list->count, duration,
(on->thread_send_dbdesc ? "on" : "off"), (on->thread_send_dbdesc ? "on" : "off"),
VNL); VNL);
for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa; for (ALL_LSDB(on->dbdesc_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
timerclear (&res); timerclear (&res);
@ -792,8 +779,7 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
on->request_list->count, duration, on->request_list->count, duration,
(on->thread_send_lsreq ? "on" : "off"), (on->thread_send_lsreq ? "on" : "off"),
VNL); VNL);
for (lsa = ospf6_lsdb_head (on->request_list); lsa; for (ALL_LSDB(on->request_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
timerclear (&res); timerclear (&res);
@ -804,8 +790,7 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
on->lsupdate_list->count, duration, on->lsupdate_list->count, duration,
(on->thread_send_lsupdate ? "on" : "off"), (on->thread_send_lsupdate ? "on" : "off"),
VNL); VNL);
for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa; for (ALL_LSDB(on->lsupdate_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
timerclear (&res); timerclear (&res);
@ -816,8 +801,7 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
on->lsack_list->count, duration, on->lsack_list->count, duration,
(on->thread_send_lsack ? "on" : "off"), (on->thread_send_lsack ? "on" : "off"),
VNL); VNL);
for (lsa = ospf6_lsdb_head (on->lsack_list); lsa; for (ALL_LSDB(on->lsack_list, lsa))
lsa = ospf6_lsdb_next (lsa))
vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " %s%s", lsa->name, VNL);
ospf6_bfd_show_info(vty, on->bfd_info, 0); ospf6_bfd_show_info(vty, on->bfd_info, 0);

View File

@ -460,9 +460,8 @@ ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
case OSPFv3ASSCOPELSACHECKSUMSUM: case OSPFv3ASSCOPELSACHECKSUMSUM:
if (ospf6) if (ospf6)
{ {
for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb); sum = 0;
lsa; for (ALL_LSDB(ospf6->lsdb, lsa))
lsa = ospf6_lsdb_next (lsa))
sum += ntohs (lsa->header->checksum); sum += ntohs (lsa->header->checksum);
return SNMP_INTEGER (sum); return SNMP_INTEGER (sum);
} }
@ -474,11 +473,8 @@ ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
case OSPFv3EXTLSACOUNT: case OSPFv3EXTLSACOUNT:
if (ospf6) if (ospf6)
{ {
for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL), count = 0;
ospf6->lsdb); for (ALL_LSDB_TYPED(ospf6->lsdb, htons (OSPF6_LSTYPE_AS_EXTERNAL), lsa))
lsa;
lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL),
lsa))
count += 1; count += 1;
return SNMP_INTEGER (count); return SNMP_INTEGER (count);
} }
@ -590,9 +586,8 @@ ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
case OSPFv3AREASCOPELSACOUNT: case OSPFv3AREASCOPELSACOUNT:
return SNMP_INTEGER (area->lsdb->count); return SNMP_INTEGER (area->lsdb->count);
case OSPFv3AREASCOPELSACKSUMSUM: case OSPFv3AREASCOPELSACKSUMSUM:
for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb); sum = 0;
lsa; for (ALL_LSDB(area->lsdb, lsa))
lsa = ospf6_lsdb_next (lsa))
sum += ntohs (lsa->header->checksum); sum += ntohs (lsa->header->checksum);
return SNMP_INTEGER (sum); return SNMP_INTEGER (sum);
case OSPFv3AREASUMMARY: case OSPFv3AREASUMMARY:
@ -962,9 +957,8 @@ ospfv3IfEntry (struct variable *v, oid *name, size_t *length,
case OSPFv3IFLINKSCOPELSACOUNT: case OSPFv3IFLINKSCOPELSACOUNT:
return SNMP_INTEGER (oi->lsdb->count); return SNMP_INTEGER (oi->lsdb->count);
case OSPFv3IFLINKLSACKSUMSUM: case OSPFv3IFLINKLSACKSUMSUM:
for (sum = 0, lsa = ospf6_lsdb_head (oi->lsdb); sum = 0;
lsa; for (ALL_LSDB(oi->lsdb, lsa))
lsa = ospf6_lsdb_next (lsa))
sum += ntohs (lsa->header->checksum); sum += ntohs (lsa->header->checksum);
return SNMP_INTEGER (sum); return SNMP_INTEGER (sum);
case OSPFv3IFDEMANDNBRPROBE: case OSPFv3IFDEMANDNBRPROBE:

View File

@ -296,8 +296,7 @@ ospf6_nexthop_calc (struct ospf6_vertex *w, struct ospf6_vertex *v,
ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc)); ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc));
i = 0; i = 0;
for (lsa = ospf6_lsdb_type_router_head (type, adv_router, oi->lsdb); lsa; for (ALL_LSDB_TYPED_ADVRTR(oi->lsdb, type, adv_router, lsa))
lsa = ospf6_lsdb_type_router_next (type, adv_router, lsa))
{ {
if (VERTEX_IS_TYPE (ROUTER, v) && if (VERTEX_IS_TYPE (ROUTER, v) &&
htonl (ROUTER_LSDESC_GET_NBR_IFID (lsdesc)) != lsa->header->id) htonl (ROUTER_LSDESC_GET_NBR_IFID (lsdesc)) != lsa->header->id)