/* When an area is unstubified, flood all the external LSAs in the area */
void ospf6_asbr_send_externals_to_area(struct ospf6_area *oa)
{
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
- for (ALL_LSDB(oa->ospf6->lsdb, lsa)) {
+ for (ALL_LSDB(oa->ospf6->lsdb, lsa, lsanext)) {
if (ntohs(lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL) {
zlog_debug("%s: Flooding AS-External LSA %s",
__func__, lsa->name);
uint8_t default_iftype;
struct timeval res, now;
char duration[32];
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
default_iftype = ospf6_default_iftype(ifp);
" %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
oi->lsupdate_list->count, duration,
(oi->thread_send_lsupdate ? "on" : "off"));
- for (ALL_LSDB(oi->lsupdate_list, lsa))
+ for (ALL_LSDB(oi->lsupdate_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
vty_out(vty, " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
oi->lsack_list->count, duration,
(oi->thread_send_lsack ? "on" : "off"));
- for (ALL_LSDB(oi->lsack_list, lsa))
+ for (ALL_LSDB(oi->lsack_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
ospf6_bfd_show_info(vty, oi->bfd_info, 1);
return 0;
void ospf6_lsdb_remove_all(struct ospf6_lsdb *lsdb)
{
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
if (lsdb == NULL)
return;
- for (ALL_LSDB(lsdb, lsa))
+ for (ALL_LSDB(lsdb, lsa, lsanext))
ospf6_lsdb_remove(lsa, lsdb);
}
int ospf6_lsdb_maxage_remover(struct ospf6_lsdb *lsdb)
{
int reschedule = 0;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
- for (ALL_LSDB(lsdb, lsa)) {
+ for (ALL_LSDB(lsdb, lsa, lsanext)) {
if (!OSPF6_LSA_IS_MAXAGE(lsa))
continue;
if (lsa->retrans_count != 0) {
lsa; \
lsa = ospf6_lsdb_next(iterend, lsa)
-#define ALL_LSDB(lsdb, lsa) \
+/*
+ * Since we are locking the lsa in ospf6_lsdb_head
+ * and then unlocking it in lspf6_lsa_lock, when
+ * we cache the next pointer we need to increment
+ * the lock for the lsa so we don't accidently free
+ * it really early.
+ */
+#define ALL_LSDB(lsdb, lsa, lsanext) \
const struct route_node *iterend = \
ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); \
- lsa; \
- lsa = ospf6_lsdb_next(iterend, lsa)
+ (lsa) != NULL &&ospf6_lsa_lock(lsa) \
+ && ((lsanext) = ospf6_lsdb_next(iterend, (lsa)), 1); \
+ ospf6_lsa_unlock(lsa), (lsa) = (lsanext)
extern void ospf6_lsdb_remove_all(struct ospf6_lsdb *lsdb);
extern void ospf6_lsdb_lsa_unlock(struct ospf6_lsa *lsa);
struct ospf6_header *oh;
struct ospf6_dbdesc *dbdesc;
uint8_t *p;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
struct in6_addr *dst;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
/* if this is not initial one, set LSA headers in dbdesc */
p = (uint8_t *)((caddr_t)dbdesc + sizeof(struct ospf6_dbdesc));
if (!CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT)) {
- for (ALL_LSDB(on->dbdesc_list, lsa)) {
+ for (ALL_LSDB(on->dbdesc_list, lsa, lsanext)) {
ospf6_lsa_age_update_to_send(lsa,
on->ospf6_if->transdelay);
int ospf6_dbdesc_send_newone(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
unsigned int size = 0;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
structure)
so that ospf6_send_dbdesc () can send those LSAs */
size = sizeof(struct ospf6_lsa_header) + sizeof(struct ospf6_dbdesc);
- for (ALL_LSDB(on->summary_list, lsa)) {
+ for (ALL_LSDB(on->summary_list, lsa, lsanext)) {
if (size + sizeof(struct ospf6_lsa_header)
> ospf6_packet_max(on->ospf6_if)) {
ospf6_lsdb_lsa_unlock(lsa);
struct ospf6_header *oh;
struct ospf6_lsreq_entry *e;
uint8_t *p;
- struct ospf6_lsa *lsa, *last_req;
+ struct ospf6_lsa *lsa, *lsanext, *last_req;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
on->thread_send_lsreq = (struct thread *)NULL;
/* set Request entries in lsreq */
p = (uint8_t *)((caddr_t)oh + sizeof(struct ospf6_header));
- for (ALL_LSDB(on->request_list, lsa)) {
+ for (ALL_LSDB(on->request_list, lsa, lsanext)) {
/* MTU check */
if (p - sendbuf + sizeof(struct ospf6_lsreq_entry)
> ospf6_packet_max(on->ospf6_if)) {
struct ospf6_lsupdate *lsupdate;
uint8_t *p;
int lsa_cnt;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
on->thread_send_lsupdate = (struct thread *)NULL;
/* lsupdate_list lists those LSA which doesn't need to be
retransmitted. remove those from the list */
- for (ALL_LSDB(on->lsupdate_list, lsa)) {
+ for (ALL_LSDB(on->lsupdate_list, lsa, lsanext)) {
/* MTU check */
if ((p - sendbuf + (unsigned int)OSPF6_LSA_SIZE(lsa->header))
> ospf6_packet_max(on->ospf6_if)) {
p = (uint8_t *)((caddr_t)lsupdate + sizeof(struct ospf6_lsupdate));
lsa_cnt = 0;
- for (ALL_LSDB(on->retrans_list, lsa)) {
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
/* MTU check */
if ((p - sendbuf + (unsigned int)OSPF6_LSA_SIZE(lsa->header))
> ospf6_packet_max(on->ospf6_if)) {
struct ospf6_lsupdate *lsupdate;
uint8_t *p;
int lsa_cnt;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
oi = (struct ospf6_interface *)THREAD_ARG(thread);
oi->thread_send_lsupdate = (struct thread *)NULL;
p = (uint8_t *)((caddr_t)lsupdate + sizeof(struct ospf6_lsupdate));
lsa_cnt = 0;
- for (ALL_LSDB(oi->lsupdate_list, lsa)) {
+ for (ALL_LSDB(oi->lsupdate_list, lsa, lsanext)) {
/* MTU check */
if ((p - sendbuf + ((unsigned int)OSPF6_LSA_SIZE(lsa->header)))
> ospf6_packet_max(oi)) {
struct ospf6_neighbor *on;
struct ospf6_header *oh;
uint8_t *p;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
int lsa_cnt = 0;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
p = (uint8_t *)((caddr_t)oh + sizeof(struct ospf6_header));
- for (ALL_LSDB(on->lsack_list, lsa)) {
+ for (ALL_LSDB(on->lsack_list, lsa, lsanext)) {
/* MTU check */
if (p - sendbuf + sizeof(struct ospf6_lsa_header)
> ospf6_packet_max(on->ospf6_if)) {
struct ospf6_interface *oi;
struct ospf6_header *oh;
uint8_t *p;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
int lsa_cnt = 0;
oi = (struct ospf6_interface *)THREAD_ARG(thread);
p = (uint8_t *)((caddr_t)oh + sizeof(struct ospf6_header));
- for (ALL_LSDB(oi->lsack_list, lsa)) {
+ for (ALL_LSDB(oi->lsack_list, lsa, lsanext)) {
/* MTU check */
if (p - sendbuf + sizeof(struct ospf6_lsa_header)
> ospf6_packet_max(oi)) {
void ospf6_neighbor_delete(struct ospf6_neighbor *on)
{
- struct ospf6_lsa *lsa;
+ 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)) {
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
ospf6_decrement_retrans_count(lsa);
ospf6_lsdb_remove(lsa, on->retrans_list);
}
int negotiation_done(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
/* clear ls-list */
ospf6_lsdb_remove_all(on->summary_list);
ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa)) {
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
ospf6_decrement_retrans_count(lsa);
ospf6_lsdb_remove(lsa, on->retrans_list);
}
/* Interface scoped LSAs */
- for (ALL_LSDB(on->ospf6_if->lsdb, lsa)) {
+ for (ALL_LSDB(on->ospf6_if->lsdb, lsa, lsanext)) {
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
ospf6_increment_retrans_count(lsa);
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
}
/* Area scoped LSAs */
- for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa)) {
+ for (ALL_LSDB(on->ospf6_if->area->lsdb, lsa, lsanext)) {
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
ospf6_increment_retrans_count(lsa);
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
}
/* AS scoped LSAs */
- for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa)) {
+ for (ALL_LSDB(on->ospf6_if->area->ospf6->lsdb, lsa, lsanext)) {
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
ospf6_increment_retrans_count(lsa);
ospf6_lsdb_add(ospf6_lsa_copy(lsa), on->retrans_list);
int adj_ok(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(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)) {
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
ospf6_decrement_retrans_count(lsa);
ospf6_lsdb_remove(lsa, on->retrans_list);
}
int seqnumber_mismatch(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
ospf6_lsdb_remove_all(on->summary_list);
ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa)) {
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
ospf6_decrement_retrans_count(lsa);
ospf6_lsdb_remove(lsa, on->retrans_list);
}
int bad_lsreq(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
ospf6_lsdb_remove_all(on->summary_list);
ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa)) {
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
ospf6_decrement_retrans_count(lsa);
ospf6_lsdb_remove(lsa, on->retrans_list);
}
int oneway_received(struct thread *thread)
{
struct ospf6_neighbor *on;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
on = (struct ospf6_neighbor *)THREAD_ARG(thread);
assert(on);
ospf6_lsdb_remove_all(on->summary_list);
ospf6_lsdb_remove_all(on->request_list);
- for (ALL_LSDB(on->retrans_list, lsa)) {
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
ospf6_decrement_retrans_count(lsa);
ospf6_lsdb_remove(lsa, on->retrans_list);
}
char drouter[16], bdrouter[16];
char linklocal_addr[64], duration[32];
struct timeval now, res;
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
inet_ntop(AF_INET6, &on->linklocal_addr, linklocal_addr,
sizeof(linklocal_addr));
(unsigned long)ntohl(on->dbdesc_seqnum));
vty_out(vty, " Summary-List: %d LSAs\n", on->summary_list->count);
- for (ALL_LSDB(on->summary_list, lsa))
+ for (ALL_LSDB(on->summary_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
vty_out(vty, " Request-List: %d LSAs\n", on->request_list->count);
- for (ALL_LSDB(on->request_list, lsa))
+ for (ALL_LSDB(on->request_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
vty_out(vty, " Retrans-List: %d LSAs\n", on->retrans_list->count);
- for (ALL_LSDB(on->retrans_list, lsa))
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
vty_out(vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
on->dbdesc_list->count, duration,
(on->thread_send_dbdesc ? "on" : "off"));
- for (ALL_LSDB(on->dbdesc_list, lsa))
+ for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
vty_out(vty, " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
on->request_list->count, duration,
(on->thread_send_lsreq ? "on" : "off"));
- for (ALL_LSDB(on->request_list, lsa))
+ for (ALL_LSDB(on->request_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
" %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
on->lsupdate_list->count, duration,
(on->thread_send_lsupdate ? "on" : "off"));
- for (ALL_LSDB(on->lsupdate_list, lsa))
+ for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
vty_out(vty, " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
on->lsack_list->count, duration,
(on->thread_send_lsack ? "on" : "off"));
- for (ALL_LSDB(on->lsack_list, lsa))
+ for (ALL_LSDB(on->lsack_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
ospf6_bfd_show_info(vty, on->bfd_info, 0);
{
uint16_t sum;
uint32_t count;
- struct ospf6_lsa *lsa = NULL;
+ struct ospf6_lsa *lsa = NULL, *lsanext;
/* Check whether the instance identifier is valid */
if (smux_header_generic(v, name, length, exact, var_len, write_method)
case OSPFv3ASSCOPELSACHECKSUMSUM:
if (ospf6) {
sum = 0;
- for (ALL_LSDB(ospf6->lsdb, lsa))
+ for (ALL_LSDB(ospf6->lsdb, lsa, lsanext))
sum += ntohs(lsa->header->checksum);
return SNMP_INTEGER(sum);
}
WriteMethod **write_method)
{
struct ospf6_area *oa, *area = NULL;
- struct ospf6_lsa *lsa = NULL;
+ struct ospf6_lsa *lsa = NULL, *lsanext;
uint32_t area_id = 0;
uint32_t count;
uint16_t sum;
return SNMP_INTEGER(area->lsdb->count);
case OSPFv3AREASCOPELSACKSUMSUM:
sum = 0;
- for (ALL_LSDB(area->lsdb, lsa))
+ for (ALL_LSDB(area->lsdb, lsa, lsanext))
sum += ntohs(lsa->header->checksum);
return SNMP_INTEGER(sum);
case OSPFv3AREASUMMARY:
ifindex_t ifindex = 0;
unsigned int instid = 0;
struct ospf6_interface *oi = NULL;
- struct ospf6_lsa *lsa = NULL;
+ struct ospf6_lsa *lsa = NULL, *lsanext;
struct interface *iif;
struct listnode *i;
struct list *ifslist;
return SNMP_INTEGER(oi->lsdb->count);
case OSPFv3IFLINKLSACKSUMSUM:
sum = 0;
- for (ALL_LSDB(oi->lsdb, lsa))
+ for (ALL_LSDB(oi->lsdb, lsa, lsanext))
sum += ntohs(lsa->header->checksum);
return SNMP_INTEGER(sum);
case OSPFv3IFDEMANDNBRPROBE:
void ospf6_remove_temp_router_lsa(struct ospf6_area *area)
{
- struct ospf6_lsa *lsa = NULL;
+ struct ospf6_lsa *lsa = NULL, *lsanext;
- for (ALL_LSDB(area->temp_router_lsa_lsdb, lsa)) {
+ for (ALL_LSDB(area->temp_router_lsa_lsdb, lsa, lsanext)) {
if (IS_OSPF6_DEBUG_SPF(PROCESS))
zlog_debug(
"%s Remove LSA %s lsa->lock %u lsdb count %u",
"LSDB\n"
"walk entries\n")
{
- struct ospf6_lsa *lsa;
+ struct ospf6_lsa *lsa, *lsanext;
+
unsigned cnt = 0;
- for (ALL_LSDB(lsdb, lsa)) {
+ for (ALL_LSDB(lsdb, lsa, lsanext)) {
lsa_show_oneline(vty, lsa);
cnt++;
}