Commit 6f8bbaa1 authored by Ondrej Zajicek's avatar Ondrej Zajicek
Browse files

Fininshing integrated OSPF.

parent 88a183c6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ event_list global_event_list;
inline void
ev_postpone(event *e)
{
  if (e->n.next)
  if (ev_active(e))
    {
      rem_node(&e->n);
      e->n.next = NULL;
+7 −0
Original line number Diff line number Diff line
@@ -30,4 +30,11 @@ void ev_schedule(event *);
void ev_postpone(event *);
int ev_run_list(event_list *);

static inline int
ev_active(event *e)
{
  return e->n.next != NULL;
}


#endif
+25 −22
Original line number Diff line number Diff line
@@ -212,17 +212,6 @@ ospf_send_dbdes(struct ospf_proto *p, struct ospf_neighbor *n)

  ospf_prepare_dbdes(p, n);
  ospf_do_send_dbdes(p, n);

  if (n->state == NEIGHBOR_EXSTART)
    return;

  /* Master should restart RXMT timer for each DBDES exchange */
  if (n->myimms & DBDES_MS)
    tm_start(n->rxmt_timer, n->ifa->rxmtint);

  if (!(n->myimms & DBDES_MS))
    if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
      ospf_neigh_sm(n, INM_EXDONE);
}

void
@@ -277,13 +266,20 @@ ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_ne
    en = ospf_hash_find(p->gr, lsa_domain, lsa.id, lsa.rt, lsa_type);
    if (!en || (lsa_comp(&lsa, &(en->lsa)) == CMP_NEWER))
    {
      /* This should be splitted to ospf_lsa_lsrq_up() */
      req = ospf_hash_get(n->lsrqh, lsa_domain, lsa.id, lsa.rt, lsa_type);

      if (!SNODE_VALID(req))
	s_add_tail(&n->lsrql, SNODE req);

      if (!SNODE_VALID(n->lsrqi))
	n->lsrqi = req;

      req->lsa = lsa;
      req->lsa_body = LSA_BODY_DUMMY;

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

@@ -306,13 +302,16 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
  u32 rcv_ddseq, rcv_options;
  u16 rcv_iface_mtu;
  u8 rcv_imms;
  uint plen, err_val = 0, err_seqmis = 0;
  uint plen, err_val = 0;

  /* RFC 2328 10.6 */

  plen = ntohs(pkt->length);
  if (plen < ospf_dbdes_hdrlen(p))
    DROP("too short", plen);
  {
    LOG_PKT("Bad DBDES packet from nbr %R on %s - %s (%u)", n->rid, ifa->ifname, "too short", plen);
    return;
  }

  OSPF_PACKET(ospf_dump_dbdes, pkt, "DBDES packet received from nbr %R on %s", n->rid, ifa->ifname);

@@ -366,6 +365,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);
      ospf_neigh_sm(n, INM_NEGDONE);
      ospf_send_dbdes(p, n);
      break;
@@ -381,6 +381,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
      n->ddr = rcv_ddseq - 1;	/* It will be set corectly a few lines down */
      n->imms = rcv_imms;
      ospf_neigh_sm(n, INM_NEGDONE);
      /* Continue to the NEIGHBOR_EXCHANGE case */
    }
    else
    {
@@ -394,9 +395,6 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
	(rcv_ddseq == n->ddr))
      goto duplicate;

    /* Do INM_SEQMIS during packet error */
    err_seqmis = 1;

    if ((rcv_imms & DBDES_MS) != (n->imms & DBDES_MS))
      DROP("MS-bit mismatch", rcv_imms);

@@ -422,9 +420,14 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
	return;

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

      ospf_send_dbdes(p, n);
      tm_start(n->dbdes_timer, n->ifa->rxmtint);
    }
    else
    {
@@ -440,6 +443,9 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
	return;

      ospf_send_dbdes(p, n);

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

@@ -450,8 +456,6 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
	(rcv_ddseq == n->ddr))
      goto duplicate;

    err_seqmis = 1;

    DROP("too late for DD exchange", n->state);

  default:
@@ -471,7 +475,6 @@ drop:
  LOG_PKT("Bad DBDES packet from nbr %R on %s - %s (%u)",
	  n->rid, ifa->ifname, err_dsc, err_val);

  if (err_seqmis)
  ospf_neigh_sm(n, INM_SEQMIS);
  return;
}
+2 −5
Original line number Diff line number Diff line
@@ -304,11 +304,8 @@ ospf_receive_hello(struct ospf_packet *pkt, struct ospf_iface *ifa,
	nn->found = 1;
    }

    // XXXX format
    // "ospf1: New neighbor found: 192.168.1.1/fe80:1234:1234:1234:1234 on eth0";
    // "ospf1: New neighbor found: 192.168.1.1 on eth0 at fe80:1234:1234:1234:1234";
    // "ospf1: Neighbor 192.168.1.1 on eth0 found, IP adress fe80:1234:1234:1234:1234";
    OSPF_TRACE(D_EVENTS, "New neighbor found: %I on %s", faddr, ifa->ifname);
    OSPF_TRACE(D_EVENTS, "New neighbor %R on %s, IP address %I",
	       rcv_rid, ifa->ifname, faddr);

    n = ospf_neighbor_new(ifa);

+33 −0
Original line number Diff line number Diff line
@@ -58,6 +58,12 @@ ifa_bufsize(struct ospf_iface *ifa)
  return MAX(bsize, ifa->tx_length);
}

static inline uint
ifa_flood_queue_size(struct ospf_iface *ifa)
{
  return ifa->tx_length / 24;
}

int
ospf_iface_assure_bufsize(struct ospf_iface *ifa, uint plen)
{
@@ -476,6 +482,9 @@ ospf_iface_add(struct object_lock *lock)

    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->flood_queue_size = ifa_flood_queue_size(ifa);
    ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
  }

  /* Do iface UP, unless there is no link and we use link detection */
@@ -679,6 +688,9 @@ 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->flood_queue_size = ifa_flood_queue_size(ifa);
  ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
}

static void
@@ -693,6 +705,20 @@ ospf_iface_change_timer(timer *tm, uint val)
    tm_start(tm, val);
}

static inline void
ospf_iface_update_flood_queue_size(struct ospf_iface *ifa)
{
  uint old_size = ifa->flood_queue_size;
  uint new_size = ifa_flood_queue_size(ifa);

  if (new_size <= old_size)
    return;

  ifa->flood_queue_size = new_size;
  ifa->flood_queue = mb_realloc(ifa->flood_queue, new_size * sizeof(void *));
  bzero(ifa->flood_queue + old_size, (new_size - old_size) * sizeof(void *));
}

int
ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
{
@@ -739,6 +765,7 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
	       ifname, ifa->rxmtint, new->rxmtint);

    ifa->rxmtint = new->rxmtint;
    /* FIXME: Update neighbors' timers */
  }

  /* POLL TIMER */
@@ -874,6 +901,9 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
    /* ifa cannot be vlink */
    ifa->tx_length = ifa_tx_length(ifa);
    update_buffers = 1;

    if (!ifa->stub)
      ospf_iface_update_flood_queue_size(ifa);
  }

  /* RX BUFFER */
@@ -1211,6 +1241,9 @@ ospf_iface_change_mtu(struct ospf_proto *p, struct ospf_iface *ifa)
    sk_set_rbsize(ifa->sk, bsize);
  if (bsize > ifa->sk->tbsize)
    sk_set_tbsize(ifa->sk, bsize);

  if (!ifa->stub)
    ospf_iface_update_flood_queue_size(ifa);
}

static void
Loading