Commit a7a7372a authored by Ondrej Zajicek's avatar Ondrej Zajicek
Browse files

Temporary integrated OSPF commit.

parent 70945cb6
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -22,10 +22,11 @@
 * or some other non-shareable resource, it asks the core to lock it and it doesn't
 * use the resource until it's notified that it has acquired the lock.
 *
 * Object locks are represented by &object_lock structures which are in turn a kind of
 * resource. Lockable resources are uniquely determined by resource type
 * Object locks are represented by &object_lock structures which are in turn a
 * kind of resource. Lockable resources are uniquely determined by resource type
 * (%OBJLOCK_UDP for a UDP port etc.), IP address (usually a broadcast or
 * multicast address the port is bound to), port number and interface.
 * multicast address the port is bound to), port number, interface and optional
 * instance ID.
 */

#undef LOCAL_DEBUG
@@ -45,6 +46,7 @@ olock_same(struct object_lock *x, struct object_lock *y)
    x->type == y->type &&
    x->iface == y->iface &&
    x->port == y->port &&
    x->inst == y->inst &&
    ipa_equal(x->addr, y->addr);
}

@@ -88,7 +90,7 @@ olock_dump(resource *r)
  struct object_lock *l = (struct object_lock *) r;
  static char *olock_states[] = { "free", "locked", "waiting", "event" };

  debug("(%d:%s:%I:%d) [%s]\n", l->type, (l->iface ? l->iface->name : "?"), l->addr, l->port, olock_states[l->state]);
  debug("(%d:%s:%I:%d:%d) [%s]\n", l->type, (l->iface ? l->iface->name : "?"), l->addr, l->port, l->inst, olock_states[l->state]);
  if (!EMPTY_LIST(l->waiters))
    debug(" [wanted]\n");
}
+3 −2
Original line number Diff line number Diff line
@@ -26,9 +26,10 @@
struct object_lock {
  resource r;
  ip_addr addr;		/* Identification of a object: IP address */
  unsigned int type;	/* ... object type (OBJLOCK_xxx) */
  uint type;		/* ... object type (OBJLOCK_xxx) */
  uint port;		/* ... port number */
  uint inst;		/* ... instance ID */
  struct iface *iface;	/* ... interface */
  unsigned int port;	/* ... port number */
  void (*hook)(struct object_lock *);	/* Called when the lock succeeds */
  void *data;		/* User data */
  /* ... internal to lock manager, don't touch ... */
+8 −11
Original line number Diff line number Diff line
@@ -200,15 +200,11 @@ ospf_do_send_dbdes(struct ospf_proto *p, struct ospf_neighbor *n)
 * of the buffer.
 */
void
ospf_send_dbdes(struct ospf_neighbor *n, int next)
ospf_send_dbdes(struct ospf_proto *p, struct ospf_neighbor *n, int next)
{
  struct ospf_iface *ifa = n->ifa;
  struct ospf_area *oa = ifa->oa;
  struct ospf_proto *p = oa->po;

  /* RFC 2328 10.8 */

  if (oa->rt == NULL)
  if (n->ifa->oa->rt == NULL)
    return;

  switch (n->state)
@@ -312,6 +308,7 @@ ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_ne
	s_add_tail(&n->lsrql, SNODE req);

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

@@ -394,7 +391,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
      n->imms = rcv_imms;
      OSPF_TRACE(D_PACKETS, "I'm slave to %I", n->ip);
      ospf_neigh_sm(n, INM_NEGDONE);
      ospf_send_dbdes(n, 1);
      ospf_send_dbdes(p, n, 1);
      break;
    }

@@ -426,7 +423,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
      if (!(n->myimms & DBDES_MS))
      {
	/* Slave should retransmit dbdes packet */
	ospf_send_dbdes(n, 0);
	ospf_send_dbdes(p, n, 0);
      }
      return;
    }
@@ -472,7 +469,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
      if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
	ospf_neigh_sm(n, INM_EXDONE);
      else
	ospf_send_dbdes(n, 1);
	ospf_send_dbdes(p, n, 1);
    }
    else
    {
@@ -489,7 +486,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
      if (ospf_process_dbdes(p, pkt, n) < 0)
	return;

      ospf_send_dbdes(n, 1);
      ospf_send_dbdes(p, n, 1);
    }
    break;

@@ -504,7 +501,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
      if (!(n->myimms & DBDES_MS))
      {
	/* Slave should retransmit dbdes packet */
	ospf_send_dbdes(n, 0);
	ospf_send_dbdes(p, n, 0);
      }
      return;
    }
+1 −1
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ ospf_receive_hello(struct ospf_packet *pkt, struct ospf_iface *ifa,
  /* Check consistency of existing neighbor entry */
  if (n)
  {
    unsigned t = ifa->type;
    uint t = ifa->type;
    if (ospf_is_v2(p) && ((t == OSPF_IT_BCAST) || (t == OSPF_IT_NBMA) || (t == OSPF_IT_PTMP)))
    {
      /* Neighbor identified by IP address; Router ID may change */
+5 −12
Original line number Diff line number Diff line
@@ -620,18 +620,11 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i

  add_tail(&oa->po->iface_list, NODE ifa);

  /*
   * In some cases we allow more ospf_ifaces on one physical iface.
   * In OSPFv2, if they use different IP address prefix.
   * In OSPFv3, if they use different instance_id.
   * Therefore, we store such info to lock->addr field.
   */

  // XXXX review
  struct object_lock *lock = olock_new(pool);
  lock->addr = ospf_is_v2(p) ? ifa->addr->prefix : _MI6(0,0,0,ifa->instance_id);
  lock->addr = ospf_is_v2(p) ? ifa->addr->prefix : IPA_NONE;
  lock->type = OBJLOCK_IP;
  lock->port = OSPF_PROTO;
  lock->inst = ifa->instance_id;
  lock->iface = iface;
  lock->data = ifa;
  lock->hook = ospf_iface_add;
@@ -997,7 +990,7 @@ ospf_walk_matching_iface_patts(struct ospf_proto *p, struct ospf_mip_walk *s)
	BIT32_SET(s->ignore, id);

	/* If we already found it in previous areas, ignore it and add warning */
	if (!BIT32_TEST(s->active, id))
	if (BIT32_TEST(s->active, id))
	  { s->warn = 1; continue; }

	BIT32_SET(s->active, id);
@@ -1046,7 +1039,7 @@ ospf_ifa_notify2(struct proto *P, uint flags, struct ifa *a)
  {
    struct ospf_mip_walk s = { .iface = a->iface, .a = a };
    while (ospf_walk_matching_iface_patts(p, &s))
      ospf_iface_new(s.oa, s.a, s.ip);
      ospf_iface_new(s.oa, a, s.ip);
  }

  if (flags & IF_CHANGE_DOWN)
@@ -1078,7 +1071,7 @@ ospf_ifa_notify3(struct proto *P, uint flags, struct ifa *a)
    {
      struct ospf_mip_walk s = { .iface = a->iface };
      while (ospf_walk_matching_iface_patts(p, &s))
	ospf_iface_new(s.oa, s.a, s.ip);
	ospf_iface_new(s.oa, a, s.ip);
    }

    if (flags & IF_CHANGE_DOWN)
Loading