Commit b32d557a authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

OSPF: Update to new timers

Note that recurrent timers are currently limited to ~1 hour.
parent ee528fbd
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -279,8 +279,8 @@ ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_ne
      req->lsa = lsa;
      req->lsa_body = LSA_BODY_DUMMY;

      if (!tm_active(n->lsrq_timer))
	tm_start(n->lsrq_timer, 0);
      if (!tm2_active(n->lsrq_timer))
	tm2_start(n->lsrq_timer, 0);
    }
  }

@@ -366,7 +366,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
      n->options = rcv_options;
      n->myimms &= ~DBDES_MS;
      n->imms = rcv_imms;
      tm_stop(n->dbdes_timer);
      tm2_stop(n->dbdes_timer);
      ospf_neigh_sm(n, INM_NEGDONE);
      ospf_send_dbdes(p, n);
      break;
@@ -422,13 +422,13 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,

      if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
      {
	tm_stop(n->dbdes_timer);
	tm2_stop(n->dbdes_timer);
	ospf_neigh_sm(n, INM_EXDONE);
	break;
      }

      ospf_send_dbdes(p, n);
      tm_start(n->dbdes_timer, n->ifa->rxmtint);
      tm2_start(n->dbdes_timer, n->ifa->rxmtint S);
    }
    else
    {
+14 −14
Original line number Diff line number Diff line
@@ -263,13 +263,13 @@ ospf_iface_down(struct ospf_iface *ifa)
    ospf_neigh_sm(n, INM_KILLNBR);

  if (ifa->hello_timer)
    tm_stop(ifa->hello_timer);
    tm2_stop(ifa->hello_timer);

  if (ifa->poll_timer)
    tm_stop(ifa->poll_timer);
    tm2_stop(ifa->poll_timer);

  if (ifa->wait_timer)
    tm_stop(ifa->wait_timer);
    tm2_stop(ifa->wait_timer);

  ospf_flush2_lsa(p, &ifa->link_lsa);
  ospf_flush2_lsa(p, &ifa->net_lsa);
@@ -396,15 +396,15 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
	{
	  ospf_iface_chstate(ifa, OSPF_IS_WAITING);
	  if (ifa->wait_timer)
	    tm_start(ifa->wait_timer, ifa->waitint);
	    tm2_start(ifa->wait_timer, ifa->waitint S);
	}
      }

      if (ifa->hello_timer)
	tm_start(ifa->hello_timer, ifa->helloint);
	tm2_start(ifa->hello_timer, ifa->helloint S);

      if (ifa->poll_timer)
	tm_start(ifa->poll_timer, ifa->pollint);
	tm2_start(ifa->poll_timer, ifa->pollint S);

      ospf_send_hello(ifa, OHS_HELLO, NULL);
    }
@@ -494,13 +494,13 @@ ospf_iface_add(struct object_lock *lock)

  if (! ifa->stub)
  {
    ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
    ifa->hello_timer = tm2_new_init(ifa->pool, hello_timer_hook, ifa, ifa->helloint S, 0);

    if (ifa->type == OSPF_IT_NBMA)
      ifa->poll_timer = tm_new_set(ifa->pool, poll_timer_hook, ifa, 0, ifa->pollint);
      ifa->poll_timer = tm2_new_init(ifa->pool, poll_timer_hook, ifa, ifa->pollint S, 0);

    if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
      ifa->wait_timer = tm_new_set(ifa->pool, wait_timer_hook, ifa, 0, 0);
      ifa->wait_timer = tm2_new_init(ifa->pool, wait_timer_hook, ifa, 0, 0);

    ifa->flood_queue_size = ifa_flood_queue_size(ifa);
    ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
@@ -703,7 +703,7 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip)

  add_tail(&p->iface_list, NODE ifa);

  ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
  ifa->hello_timer = tm2_new_init(ifa->pool, hello_timer_hook, ifa, ifa->helloint S, 0);

  ifa->flood_queue_size = ifa_flood_queue_size(ifa);
  ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
@@ -717,8 +717,8 @@ ospf_iface_change_timer(timer *tm, uint val)

  tm->recurrent = val S;

  if (tm_active(tm))
    tm_start(tm, val);
  if (tm2_active(tm))
    tm2_start(tm, val S);
}

static inline void
@@ -801,8 +801,8 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
	       ifname, ifa->waitint, new->waitint);

    ifa->waitint = new->waitint;
    if (ifa->wait_timer && ifa->wait_timer->expires)
      tm_start(ifa->wait_timer, ifa->waitint);
    if (ifa->wait_timer && tm2_active(ifa->wait_timer))
      tm2_start(ifa->wait_timer, ifa->waitint S);
  }

  /* DEAD TIMER */
+3 −0
Original line number Diff line number Diff line
@@ -60,4 +60,7 @@ void lsa_parse_sum_rt(struct top_hash_entry *en, int ospf2, u32 *drid, u32 *metr
void lsa_parse_ext(struct top_hash_entry *en, int ospf2, int af, struct ospf_lsa_ext_local *rt);
int lsa_validate(struct ospf_lsa_header *lsa, u32 lsa_type, int ospf2, void *body);

static inline btime lsa_inst_age(struct top_hash_entry *en)
{ return current_time() - en->inst_time; }

#endif /* _BIRD_OSPF_LSALIB_H_ */
+8 −8
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ ospf_lsa_lsrq_down(struct top_hash_entry *req, struct ospf_neighbor *n)

  if (EMPTY_SLIST(n->lsrql))
  {
    tm_stop(n->lsrq_timer);
    tm2_stop(n->lsrq_timer);

    if (n->state == NEIGHBOR_LOADING)
      ospf_neigh_sm(n, INM_LOADDONE);
@@ -136,8 +136,8 @@ ospf_lsa_lsrt_up(struct top_hash_entry *en, struct ospf_neighbor *n)
  ret->lsa = en->lsa;
  ret->lsa_body = LSA_BODY_DUMMY;

  if (!tm_active(n->lsrt_timer))
    tm_start(n->lsrt_timer, n->ifa->rxmtint);
  if (!tm2_active(n->lsrt_timer))
    tm2_start(n->lsrt_timer, n->ifa->rxmtint S);
}

void
@@ -150,7 +150,7 @@ ospf_lsa_lsrt_down_(struct top_hash_entry *en, struct ospf_neighbor *n, struct t
  ospf_hash_delete(n->lsrth, ret);

  if (EMPTY_SLIST(n->lsrtl))
    tm_stop(n->lsrt_timer);
    tm2_stop(n->lsrt_timer);
}

static inline int
@@ -175,8 +175,8 @@ ospf_add_flushed_to_lsrt(struct ospf_proto *p, struct ospf_neighbor *n)
      ospf_lsa_lsrt_up(en, n);

  /* If we found any flushed LSA, we send them ASAP */
  if (tm_active(n->lsrt_timer))
    tm_start(n->lsrt_timer, 0);
  if (tm2_active(n->lsrt_timer))
    tm2_start(n->lsrt_timer, 0);
}

static int ospf_flood_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_list, uint lsa_count, uint lsa_min_count, struct ospf_iface *ifa);
@@ -572,7 +572,7 @@ ospf_receive_lsupd(struct ospf_packet *pkt, struct ospf_iface *ifa,
    {
      /* 13. (5a) - enforce minimum time between updates for received LSAs */
      /* We also use this to ratelimit reactions to received self-originated LSAs */
      if (en && ((now - en->inst_time) < MINLSARRIVAL))
      if (en && (lsa_inst_age(en) < MINLSARRIVAL))
      {
	OSPF_TRACE(D_EVENTS, "Skipping LSA received in less that MinLSArrival");
	continue;
@@ -700,7 +700,7 @@ ospf_receive_lsupd(struct ospf_packet *pkt, struct ospf_iface *ifa,
  if (!EMPTY_SLIST(n->lsrql) && (n->lsrqi == SHEAD(n->lsrql)))
  {
    ospf_send_lsreq(p, n);
    tm_start(n->lsrq_timer, n->ifa->rxmtint);
    tm2_start(n->lsrq_timer, n->ifa->rxmtint S);
  }

  return;
+12 −12
Original line number Diff line number Diff line
@@ -66,10 +66,10 @@ reset_lists(struct ospf_proto *p, struct ospf_neighbor *n)
  ospf_top_free(n->lsrth);
  ospf_reset_lsack_queue(n);

  tm_stop(n->dbdes_timer);
  tm_stop(n->lsrq_timer);
  tm_stop(n->lsrt_timer);
  tm_stop(n->ackd_timer);
  tm2_stop(n->dbdes_timer);
  tm2_stop(n->lsrq_timer);
  tm2_stop(n->lsrt_timer);
  tm2_stop(n->ackd_timer);

  init_lists(p, n);
}
@@ -94,11 +94,11 @@ ospf_neighbor_new(struct ospf_iface *ifa)
  init_list(&n->ackl[ACKL_DIRECT]);
  init_list(&n->ackl[ACKL_DELAY]);

  n->inactim = tm_new_set(pool, inactivity_timer_hook, n, 0, 0);
  n->dbdes_timer = tm_new_set(pool, dbdes_timer_hook, n, 0, ifa->rxmtint);
  n->lsrq_timer = tm_new_set(pool, lsrq_timer_hook, n, 0, ifa->rxmtint);
  n->lsrt_timer = tm_new_set(pool, lsrt_timer_hook, n, 0, ifa->rxmtint);
  n->ackd_timer = tm_new_set(pool, ackd_timer_hook, n, 0, ifa->rxmtint / 2);
  n->inactim = tm2_new_init(pool, inactivity_timer_hook, n, 0, 0);
  n->dbdes_timer = tm2_new_init(pool, dbdes_timer_hook, n, ifa->rxmtint S, 0);
  n->lsrq_timer = tm2_new_init(pool, lsrq_timer_hook, n, ifa->rxmtint S, 0);
  n->lsrt_timer = tm2_new_init(pool, lsrt_timer_hook, n, ifa->rxmtint S, 0);
  n->ackd_timer = tm2_new_init(pool, ackd_timer_hook, n, ifa->rxmtint S / 2, 0);

  return (n);
}
@@ -185,8 +185,8 @@ ospf_neigh_chstate(struct ospf_neighbor *n, u8 state)
    n->dds++;
    n->myimms = DBDES_IMMS;

    tm_start(n->dbdes_timer, 0);
    tm_start(n->ackd_timer, ifa->rxmtint / 2);
    tm2_start(n->dbdes_timer, 0);
    tm2_start(n->ackd_timer, ifa->rxmtint S / 2);
  }

  if (state > NEIGHBOR_EXSTART)
@@ -231,7 +231,7 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
      ospf_neigh_chstate(n, NEIGHBOR_INIT);

    /* Restart inactivity timer */
    tm_start(n->inactim, n->ifa->deadint);
    tm2_start(n->inactim, n->ifa->deadint S);
    break;

  case INM_2WAYREC:
Loading