コード例 #1
0
ファイル: ospf6_spf.c プロジェクト: Addision/LVS
static int
ospf6_spf_calculation_thread (struct thread *t)
{
  struct ospf6_area *oa;
  struct timeval start, end, runtime;

  oa = (struct ospf6_area *) THREAD_ARG (t);
  oa->thread_spf_calculation = NULL;

  if (IS_OSPF6_DEBUG_SPF (PROCESS))
    zlog_debug ("SPF calculation for Area %s", oa->name);
  if (IS_OSPF6_DEBUG_SPF (DATABASE))
    ospf6_spf_log_database (oa);

  /* execute SPF calculation */
  quagga_gettime (QUAGGA_CLK_MONOTONIC, &start);
  ospf6_spf_calculation (oa->ospf6->router_id, oa->spf_table, oa);
  quagga_gettime (QUAGGA_CLK_MONOTONIC, &end);
  timersub (&end, &start, &runtime);

  if (IS_OSPF6_DEBUG_SPF (PROCESS) || IS_OSPF6_DEBUG_SPF (TIME))
    zlog_debug ("SPF runtime: %ld sec %ld usec",
		runtime.tv_sec, runtime.tv_usec);

  ospf6_intra_route_calculation (oa);
  ospf6_intra_brouter_calculation (oa);

  return 0;
}
コード例 #2
0
ファイル: ospf6_top.c プロジェクト: carriercomm/vyatta-quagga
static struct ospf6 *
ospf6_create (void)
{
  struct ospf6 *o;

  o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));

  /* initialize */
  quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
  o->area_list = list_new ();
  o->area_list->cmp = ospf6_area_cmp;
  o->lsdb = ospf6_lsdb_create (o);
  o->lsdb_self = ospf6_lsdb_create (o);
  o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
  o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;

  o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
  o->route_table->scope = o;
  o->route_table->hook_add = ospf6_top_route_hook_add;
  o->route_table->hook_remove = ospf6_top_route_hook_remove;

  o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
  o->brouter_table->scope = o;
  o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
  o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;

  o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
  o->external_table->scope = o;

  o->external_id_table = route_table_init ();

  return o;
}
コード例 #3
0
ファイル: sisisd.c プロジェクト: ecks/sis-is
/* time_t value that is monotonicly increasing
 * and uneffected by adjustments to system clock
 */
time_t sisis_clock (void)
{
  struct timeval tv;

  quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv);
  return tv.tv_sec;
}
コード例 #4
0
ファイル: ospf6_top.c プロジェクト: AT-Corp/quagga-atc
static struct ospf6 *
ospf6_create (void)
{
  struct ospf6 *o;

  o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));

  /* initialize */
  quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
  o->area_list = list_new ();
  o->area_list->cmp = ospf6_area_cmp;
  o->lsdb = ospf6_lsdb_create (o);
  o->lsdb_self = ospf6_lsdb_create (o);
  o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
  o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;

  o->spf_delay = OSPF_SPF_DELAY_DEFAULT;
  o->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
  o->spf_max_holdtime = OSPF_SPF_MAX_HOLDTIME_DEFAULT;
  o->spf_hold_multiplier = 1;

  o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
  o->route_table->scope = o;
  o->route_table->hook_add = ospf6_top_route_hook_add;
  o->route_table->hook_remove = ospf6_top_route_hook_remove;

  o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
  o->brouter_table->scope = o;
  o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
  o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;

  o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
  o->external_table->scope = o;

  o->external_id_table = route_table_init ();

  o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;

  return o;
}
コード例 #5
0
static u_int16_t
neighbor_time_metric_function (struct ospf6_neighbor *on, void *data)
{
  struct ospf6_interface *oi = on->ospf6_if;
  u_int16_t minmetric, maxmetric;
  u_char minstate;
  struct timeval now, dt;
  int err;

  minmetric = oi->cost;
  maxmetric = MIN (USHRT_MAX, minmetric + *(u_int16_t *)data);

  if (oi->type == OSPF6_IFTYPE_MDR)
    minstate = OSPF6_NEIGHBOR_TWOWAY;
  else
    minstate = OSPF6_NEIGHBOR_FULL;

  if (on->state < minstate)
    return maxmetric;

  err = quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
  if (err)
    {
      zlog_err ("%s: quagga_gettime() failed", __func__);
      return minmetric;
    }

  timersub (&now, &on->last_changed, &dt);
  if (dt.tv_sec < 0)
    {
      zlog_err ("%s: time went backwards", __func__);
      return minmetric;
    }

  return MAX (minmetric, maxmetric - dt.tv_sec / oi->hello_interval);
}
コード例 #6
0
int
ospf6_flood_interface_mdr (struct ospf6_neighbor *from,
                           struct ospf6_lsa *lsa, struct ospf6_interface *oi)
{
  struct listnode *node, *nnode;
  struct ospf6_neighbor *on;
  struct ospf6_lsa *req;
  int retrans_added = 0;
  int is_debug = 0;
  struct list *flood_neighbors = list_new ();
  bool flood_lsa = true;

  if (IS_OSPF6_DEBUG_FLOODING ||
      IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
    {
      is_debug++;
      zlog_debug ("Flooding on %s: %s", oi->interface->name, lsa->name);
    }

  /* (1) For each neighbor */
  for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
    {
      if (is_debug)
        zlog_debug ("To neighbor %s", on->name);

      /* (a) if neighbor state < Exchange, examin next */
      // Consider adjacent and (backup) dependent neighbors.
      // Require all bidirectional neighbors to be covered
      if (on->state < OSPF6_NEIGHBOR_TWOWAY)
        {
          if (is_debug)
            zlog_debug ("Neighbor state less than TwoWay, next neighbor");
          continue;
        }

      if (on->state > OSPF6_NEIGHBOR_TWOWAY &&
	  on->state < OSPF6_NEIGHBOR_FULL && !need_adjacency (on))
	{
	  if (is_debug)
	    zlog_debug ("No longer need adjacency with neighbor %s: "
			"scheduling AdjOK?", on->name);
	  ospf6_neighbor_schedule_adjok (on);
	  continue;
	}

      /* (b) if neighbor not yet Full, check request-list */
      if (on->state >= OSPF6_NEIGHBOR_EXCHANGE &&
          on->state != OSPF6_NEIGHBOR_FULL)
        {
          if (is_debug)
            zlog_debug ("Neighbor not yet Full");

          req = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
                                   lsa->header->adv_router, on->request_list);
          if (req == NULL)
            {
              if (is_debug)
                zlog_debug ("Not on request-list for this neighbor");
              /* fall through */
            }
          else
            {
              /* If new LSA less recent, examin next neighbor */
              if (ospf6_lsa_compare (lsa, req) > 0)
                {
                  if (is_debug)
                    zlog_debug ("Requesting is newer, next neighbor");
                  continue;
                }

              /* If the same instance, delete from request-list and
                 examin next neighbor */
              if (ospf6_lsa_compare (lsa, req) == 0)
                {
                  if (is_debug)
                    zlog_debug
                      ("Requesting the same, remove it, next neighbor");
                  ospf6_lsdb_remove (req, on->request_list);
                  continue;
                }

              /* If the new LSA is more recent, delete from request-list */
              if (ospf6_lsa_compare (lsa, req) < 0)
                {
                  if (is_debug)
                    zlog_debug ("Received is newer, remove requesting");
                  ospf6_lsdb_remove (req, on->request_list);
                  /* fall through */
                }
            }
        }

      /* (c) If the new LSA was received from this neighbor,
         examin next neighbor */
      if (from == on)
        {
          if (is_debug)
            zlog_debug ("LSA was received from neighbor %s, next neighbor",
			on->name);
          continue;
        }

      //Ogierv3 Section 6 Par 3
      /* At this point, we are not positive that the neighbor has
         an up-to-date instance of this new LSA */
      /* However, in the MANET case, we need to:
         i) check whether neighbor sent a multicast ACK for it already
         ii) whether I am an active relay for this originator */
      /* Has LSA been acked previously with multicast ack? */
      if (ospf6_mdr_neighbor_has_acked (on, lsa))
        {                       //Don't add LSA to neighbor's retransmission list
          if (is_debug)
            zlog_debug ("Existing multicast ACK from neighbor %s found "
			"for LSA, next neighbor", on->name);
          continue;             // examine next neighbor: neighbor already acked
        }
      /* Here, checking for coverage of this neighbor on the sender's RNL.
         If not present, I add this to the flood_neighbors list.
         If LSA was received as a unicast, however, can't assume that
         neighbor "on" was covered by the transmission, so still need to
         add to flood_neighbors regardless of from->rnl */
      if (from)
        {
          if (!from->mdr.Report2Hop ||
              (!CHECK_FLAG (lsa->flag, OSPF6_LSA_RECVMCAST)) ||
              !ospf6_mdr_lookup_neighbor (from->mdr.rnl, on->router_id))
            {
              listnode_add (flood_neighbors, on);
            }
        }

      // Retransmit only to adjacent neighbors.
      if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
        continue;

      /* (d) add retrans-list, schedule retransmission */
      if (is_debug)
        zlog_debug ("Add retrans-list of this neighbor");
      ospf6_increment_retrans_count (lsa);

      quagga_gettime (QUAGGA_CLK_MONOTONIC, &lsa->rxmt_time);
      ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
      on->thread_send_lsupdate =
        ospf6_send_lsupdate_delayed_msec (master,
                                          ospf6_lsupdate_send_neighbor, on,
                                          oi->rxmt_interval * 1000,
                                          on->thread_send_lsupdate);
      retrans_added++;
    }
  /* (2) examin next interface if not added to retrans-list */
  // MDRs can flood an LSA without adding it to the retrans-list
  if (!from && retrans_added == 0)
    {
      /* this LSA is self-originated but there are no adjacent neighbors */
      flood_lsa = false;
      if (is_debug)
        zlog_debug ("Self-originated LSA and no adjacent neighbors");
    }

  //Ogierv3 Section 6 - Remove (3) and (4)

  //Ogierv3 Section 6 - Replace (5)
  //Ogierv3 Forwarding Procedure bullet(a)
  if (from && oi->mdr.mdr_level == OSPF6_MDR)
    {
      //Flood the LSA unless all neighbors are already covered
      if (flood_neighbors->count == 0)
	{
	  flood_lsa = false;
	  if (is_debug)
	    zlog_debug ("All neighbors covered");
	}
      else if (oi->mdr.nonflooding_mdr)
        {
          // Non-flooding MDR acts like a BMDR.
          for (ALL_LIST_ELEMENTS (flood_neighbors, node, nnode, on))
            ospf6_backupwait_lsa_add (lsa, on);
          flood_lsa = false;
	  if (is_debug)
	    zlog_debug ("Router is a non-flooding MDR");
        }
    }
  //Ogierv3 Forwarding Procedure bullet(c)
  else if (from && oi->mdr.mdr_level == OSPF6_BMDR)
コード例 #7
0
/* RFC 2328 12.4.3. Summary-LSAs */
void
ospf6_abr_originate_summary_to_area (struct ospf6_route *route,
                                     struct ospf6_area *area)
{
  struct ospf6_lsa *lsa, *old = NULL;
  struct ospf6_interface *oi;
  struct ospf6_route *summary, *range = NULL;
  struct ospf6_area *route_area;
  char buffer[OSPF6_MAX_LSASIZE];
  struct ospf6_lsa_header *lsa_header;
  caddr_t p;
  struct ospf6_inter_prefix_lsa *prefix_lsa;
  struct ospf6_inter_router_lsa *router_lsa;
  struct ospf6_route_table *summary_table = NULL;
  u_int16_t type;
  char buf[64];
  int is_debug = 0;

  if (route->type == OSPF6_DEST_TYPE_ROUTER)
    {
      if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_ROUTER))
        {
          is_debug++;
          inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)),
                     buf, sizeof (buf));
          zlog_debug ("Originating summary in area %s for ASBR %s",
		      area->name, buf);
        }
      summary_table = area->summary_router;
    }
  else
    {
      if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_PREFIX))
        {
          is_debug++;
          prefix2str (&route->prefix, buf, sizeof (buf));
          zlog_debug ("Originating summary in area %s for %s",
		      area->name, buf);
        }
      summary_table = area->summary_prefix;
    }

  summary = ospf6_route_lookup (&route->prefix, summary_table);
  if (summary)
    old = ospf6_lsdb_lookup (summary->path.origin.type,
                             summary->path.origin.id,
                             area->ospf6->router_id, area->lsdb);

  /* if this route has just removed, remove corresponding LSA */
  if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE))
    {
      if (is_debug)
        zlog_debug ("The route has just removed, purge previous LSA");
      if (summary)
        ospf6_route_remove (summary, summary_table);
      if (old)
        ospf6_lsa_purge (old);
      return;
    }

  /* Only destination type network, range or ASBR are considered */
  if (route->type != OSPF6_DEST_TYPE_NETWORK &&
      route->type != OSPF6_DEST_TYPE_RANGE &&
      (route->type != OSPF6_DEST_TYPE_ROUTER ||
       ! CHECK_FLAG (route->path.router_bits, OSPF6_ROUTER_BIT_E)))
    {
      if (is_debug)
        zlog_debug ("Route type is none of network, range nor ASBR, withdraw");
      if (summary)
        ospf6_route_remove (summary, summary_table);
      if (old)
        ospf6_lsa_purge (old);
      return;
    }

  /* AS External routes are never considered */
  if (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
      route->path.type == OSPF6_PATH_TYPE_EXTERNAL2)
    {
      if (is_debug)
        zlog_debug ("Path type is external, withdraw");
      if (summary)
        ospf6_route_remove (summary, summary_table);
      if (old)
        ospf6_lsa_purge (old);
      return;
    }

  /* do not generate if the path's area is the same as target area */
  if (route->path.area_id == area->area_id)
    {
      if (is_debug)
        zlog_debug ("The route is in the area itself, ignore");
      if (summary)
        ospf6_route_remove (summary, summary_table);
      if (old)
        ospf6_lsa_purge (old);
      return;
    }

  /* do not generate if the nexthops belongs to the target area */
  oi = ospf6_interface_lookup_by_ifindex (route->nexthop[0].ifindex);
  if (oi && oi->area && oi->area == area)
    {
      if (is_debug)
        zlog_debug ("The route's nexthop is in the same area, ignore");
      if (summary)
        ospf6_route_remove (summary, summary_table);
      if (old)
        ospf6_lsa_purge (old);
      return;
    }

  /* do not generate if the route cost is greater or equal to LSInfinity */
  if (route->path.cost >= OSPF_LS_INFINITY)
    {
      if (is_debug)
        zlog_debug ("The cost exceeds LSInfinity, withdraw");
      if (summary)
        ospf6_route_remove (summary, summary_table);
      if (old)
        ospf6_lsa_purge (old);
      return;
    }

  /* if this is a route to ASBR */
  if (route->type == OSPF6_DEST_TYPE_ROUTER)
    {
      /* Only the prefered best path is considered */
      if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_BEST))
        {
          if (is_debug)
            zlog_debug ("This is the secondary path to the ASBR, ignore");
          if (summary)
            ospf6_route_remove (summary, summary_table);
          if (old)
            ospf6_lsa_purge (old);
          return;
        }

      /* Do not generate if the area is stub */
      /* XXX */
    }

  /* if this is an intra-area route, this may be suppressed by aggregation */
  if (route->type == OSPF6_DEST_TYPE_NETWORK &&
      route->path.type == OSPF6_PATH_TYPE_INTRA)
    {
      /* search for configured address range for the route's area */
      route_area = ospf6_area_lookup (route->path.area_id, area->ospf6);
      assert (route_area);
      range = ospf6_route_lookup_bestmatch (&route->prefix,
                                            route_area->range_table);

      /* ranges are ignored when originate backbone routes to transit area.
         Otherwise, if ranges are configured, the route is suppressed. */
      if (range && ! CHECK_FLAG (range->flag, OSPF6_ROUTE_REMOVE) &&
          (route->path.area_id != OSPF_AREA_BACKBONE ||
           ! IS_AREA_TRANSIT (area)))
        {
          if (is_debug)
            {
              prefix2str (&range->prefix, buf, sizeof (buf));
              zlog_debug ("Suppressed by range %s of area %s",
                         buf, route_area->name);
            }

          if (summary)
            ospf6_route_remove (summary, summary_table);
          if (old)
            ospf6_lsa_purge (old);
          return;
        }
    }

  /* If this is a configured address range */
  if (route->type == OSPF6_DEST_TYPE_RANGE)
    {
      /* If DoNotAdvertise is set */
      if (CHECK_FLAG (route->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE))
        {
          if (is_debug)
            zlog_debug ("This is the range with DoNotAdvertise set. ignore");
          if (summary)
            ospf6_route_remove (summary, summary_table);
          if (old)
            ospf6_lsa_purge (old);
          return;
        }

      /* Whether the route have active longer prefix */
      if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_ACTIVE_SUMMARY))
        {
          if (is_debug)
            zlog_debug ("The range is not active. withdraw");
          if (summary)
            ospf6_route_remove (summary, summary_table);
          if (old)
            ospf6_lsa_purge (old);
          return;
        }
    }

  /* Check export list */
  if (EXPORT_NAME (area))
    {
      if (EXPORT_LIST (area) == NULL)
        EXPORT_LIST (area) =
          access_list_lookup (AFI_IP6, EXPORT_NAME (area));

      if (EXPORT_LIST (area))
        if (access_list_apply (EXPORT_LIST (area),
                               &route->prefix) == FILTER_DENY)
          {
            if (is_debug)
              {
                inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)),
                           buf, sizeof(buf));
                zlog_debug ("prefix %s was denied by export list", buf);
              }
            return;
          }
    }

  /* Check filter-list */
  if (PREFIX_NAME_OUT (area))
    {
      if (PREFIX_LIST_OUT (area) == NULL)
        PREFIX_LIST_OUT (area) =
          prefix_list_lookup(AFI_IP6, PREFIX_NAME_OUT (area));

      if (PREFIX_LIST_OUT (area))
         if (prefix_list_apply (PREFIX_LIST_OUT (area), 
                                &route->prefix) != PREFIX_PERMIT) 
           {
             if (is_debug)
               {
                 inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)),
                            buf, sizeof (buf));
                 zlog_debug ("prefix %s was denied by filter-list out", buf);
               }
             return;
           }
    }

  /* the route is going to be originated. store it in area's summary_table */
  if (summary == NULL)
    {
      summary = ospf6_route_copy (route);
      if (route->type == OSPF6_DEST_TYPE_NETWORK ||
          route->type == OSPF6_DEST_TYPE_RANGE)
        summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_PREFIX);
      else
        summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_ROUTER);
      summary->path.origin.adv_router = area->ospf6->router_id;
      summary->path.origin.id =
        ospf6_new_ls_id (summary->path.origin.type,
                         summary->path.origin.adv_router, area->lsdb);
      summary = ospf6_route_add (summary, summary_table);
    }
  else
    {
      summary->type = route->type;
      quagga_gettime (QUAGGA_CLK_MONOTONIC, &summary->changed);
    }

  summary->path.router_bits = route->path.router_bits;
  summary->path.options[0] = route->path.options[0];
  summary->path.options[1] = route->path.options[1];
  summary->path.options[2] = route->path.options[2];
  summary->path.prefix_options = route->path.prefix_options;
  summary->path.area_id = area->area_id;
  summary->path.type = OSPF6_PATH_TYPE_INTER;
  summary->path.cost = route->path.cost;
  summary->nexthop[0] = route->nexthop[0];

  /* prepare buffer */
  memset (buffer, 0, sizeof (buffer));
  lsa_header = (struct ospf6_lsa_header *) buffer;

  if (route->type == OSPF6_DEST_TYPE_ROUTER)
    {
      router_lsa = (struct ospf6_inter_router_lsa *)
        ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
      p = (caddr_t) router_lsa + sizeof (struct ospf6_inter_router_lsa);

      /* Fill Inter-Area-Router-LSA */
      router_lsa->options[0] = route->path.options[0];
      router_lsa->options[1] = route->path.options[1];
      router_lsa->options[2] = route->path.options[2];
      OSPF6_ABR_SUMMARY_METRIC_SET (router_lsa, route->path.cost);
      router_lsa->router_id = ADV_ROUTER_IN_PREFIX (&route->prefix);
      type = htons (OSPF6_LSTYPE_INTER_ROUTER);
    }
  else
    {
      prefix_lsa = (struct ospf6_inter_prefix_lsa *)
        ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
      p = (caddr_t) prefix_lsa + sizeof (struct ospf6_inter_prefix_lsa);

      /* Fill Inter-Area-Prefix-LSA */
      OSPF6_ABR_SUMMARY_METRIC_SET (prefix_lsa, route->path.cost);
      prefix_lsa->prefix.prefix_length = route->prefix.prefixlen;
      prefix_lsa->prefix.prefix_options = route->path.prefix_options;

      /* set Prefix */
      memcpy (p, &route->prefix.u.prefix6,
              OSPF6_PREFIX_SPACE (route->prefix.prefixlen));
      ospf6_prefix_apply_mask (&prefix_lsa->prefix);
      p += OSPF6_PREFIX_SPACE (route->prefix.prefixlen);
      type = htons (OSPF6_LSTYPE_INTER_PREFIX);
    }

  /* Fill LSA Header */
  lsa_header->age = 0;
  lsa_header->type = type;
  lsa_header->id = summary->path.origin.id;
  lsa_header->adv_router = area->ospf6->router_id;
  lsa_header->seqnum =
    ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
                         lsa_header->adv_router, area->lsdb);
  lsa_header->length = htons ((caddr_t) p - (caddr_t) lsa_header);

  /* LSA checksum */
  ospf6_lsa_checksum (lsa_header);

  /* create LSA */
  lsa = ospf6_lsa_create (lsa_header);

  /* Originate */
  ospf6_lsa_originate_area (lsa, area);
}
コード例 #8
0
/* show specified interface structure */
static int
ospf6_interface_show (struct vty *vty, struct interface *ifp)
{
    struct ospf6_interface *oi;
    struct connected *c;
    struct prefix *p;
    struct listnode *i;
    char strbuf[64], drouter[32], bdrouter[32];
    const char *updown[3] = {"down", "up", NULL};
    const char *type;
    struct timeval res, now;
    char duration[32];
    struct ospf6_lsa *lsa;

    /* check physical interface type */
    if (if_is_loopback (ifp))
        type = "LOOPBACK";
    else if (if_is_broadcast (ifp))
        type = "BROADCAST";
    else if (if_is_pointopoint (ifp))
        type = "POINTOPOINT";
    else
        type = "UNKNOWN";

    vty_out (vty, "%s is %s, type %s%s",
             ifp->name, updown[if_is_up (ifp)], type,
             VNL);
    vty_out (vty, "  Interface ID: %d%s", ifp->ifindex, VNL);

    if (ifp->info == NULL)
    {
        vty_out (vty, "   OSPF not enabled on this interface%s", VNL);
        return 0;
    }
    else
        oi = (struct ospf6_interface *) ifp->info;

    vty_out (vty, "  Internet Address:%s", VNL);

    for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
    {
        p = c->address;
        prefix2str (p, strbuf, sizeof (strbuf));
        switch (p->family)
        {
        case AF_INET:
            vty_out (vty, "    inet : %s%s", strbuf,
                     VNL);
            break;
        case AF_INET6:
            vty_out (vty, "    inet6: %s%s", strbuf,
                     VNL);
            break;
        default:
            vty_out (vty, "    ???  : %s%s", strbuf,
                     VNL);
            break;
        }
    }

    if (oi->area)
    {
        vty_out (vty, "  Instance ID %d, Interface MTU %d (autodetect: %d)%s",
                 oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
        vty_out (vty, "  MTU mismatch detection: %s%s", oi->mtu_ignore ?
                 "disabled" : "enabled", VNL);
        inet_ntop (AF_INET, &oi->area->area_id,
                   strbuf, sizeof (strbuf));
        vty_out (vty, "  Area ID %s, Cost %hu%s", strbuf, oi->cost,
                 VNL);
    }
    else
        vty_out (vty, "  Not Attached to Area%s", VNL);

    vty_out (vty, "  State %s, Transmit Delay %d sec, Priority %d%s",
             ospf6_interface_state_str[oi->state],
             oi->transdelay, oi->priority,
             VNL);
    vty_out (vty, "  Timer intervals configured:%s", VNL);
    vty_out (vty, "   Hello %d, Dead %d, Retransmit %d%s",
             oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
             VNL);

    inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
    inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
    vty_out (vty, "  DR: %s BDR: %s%s", drouter, bdrouter, VNL);

    vty_out (vty, "  Number of I/F scoped LSAs is %u%s",
             oi->lsdb->count, VNL);

    quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);

    timerclear (&res);
    if (oi->thread_send_lsupdate)
        timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
    timerstring (&res, duration, sizeof (duration));
    vty_out (vty, "    %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
             oi->lsupdate_list->count, duration,
             (oi->thread_send_lsupdate ? "on" : "off"),
             VNL);
    for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
            lsa = ospf6_lsdb_next (lsa))
        vty_out (vty, "      %s%s", lsa->name, VNL);

    timerclear (&res);
    if (oi->thread_send_lsack)
        timersub (&oi->thread_send_lsack->u.sands, &now, &res);
    timerstring (&res, duration, sizeof (duration));
    vty_out (vty, "    %d Pending LSAs for LSAck in Time %s [thread %s]%s",
             oi->lsack_list->count, duration,
             (oi->thread_send_lsack ? "on" : "off"),
             VNL);
    for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
            lsa = ospf6_lsdb_next (lsa))
        vty_out (vty, "      %s%s", lsa->name, VNL);

    return 0;
}
コード例 #9
0
int main(int argc, char **argv)
{
  struct prng *prng;
  int i;
  struct thread **timers;
  struct timeval tv_start, tv_lap, tv_stop;
  unsigned long t_schedule, t_remove;

  master = thread_master_create();
  prng = prng_new(0);
  timers = calloc(SCHEDULE_TIMERS, sizeof(*timers));

  /* create thread structures so they won't be allocated during the
   * time measurement */
  for (i = 0; i < SCHEDULE_TIMERS; i++)
    timers[i] = thread_add_timer_msec(master, dummy_func, NULL, 0);
  for (i = 0; i < SCHEDULE_TIMERS; i++)
    thread_cancel(timers[i]);

  quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv_start);

  for (i = 0; i < SCHEDULE_TIMERS; i++)
    {
      long interval_msec;

      interval_msec = prng_rand(prng) % (100 * SCHEDULE_TIMERS);
      timers[i] = thread_add_timer_msec(master, dummy_func,
                                        NULL, interval_msec);
    }

  quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv_lap);

  for (i = 0; i < REMOVE_TIMERS; i++)
    {
      int index;

      index = prng_rand(prng) % SCHEDULE_TIMERS;
      if (timers[index])
        thread_cancel(timers[index]);
      timers[index] = NULL;
    }

  quagga_gettime(QUAGGA_CLK_MONOTONIC, &tv_stop);

  t_schedule = 1000 * (tv_lap.tv_sec - tv_start.tv_sec);
  t_schedule += (tv_lap.tv_usec - tv_start.tv_usec) / 1000;

  t_remove = 1000 * (tv_stop.tv_sec - tv_lap.tv_sec);
  t_remove += (tv_stop.tv_usec - tv_lap.tv_usec) / 1000;

  printf("Scheduling %d random timers took %ld.%03ld seconds.\n",
         SCHEDULE_TIMERS, t_schedule/1000, t_schedule%1000);
  printf("Removing %d random timers took %ld.%03ld seconds.\n",
         REMOVE_TIMERS, t_remove/1000, t_remove%1000);
  fflush(stdout);

  free(timers);
  thread_master_free(master);
  prng_free(prng);
  return 0;
}
コード例 #10
0
ファイル: ospf6_spf.c プロジェクト: ColinBS/quagga-rtrlib
static int
ospf6_spf_calculation_thread (struct thread *t)
{
  struct ospf6_area *oa;
  struct ospf6 *ospf6;
  struct timeval start, end, runtime;
  struct listnode *node;
  struct ospf6_route *route;
  int areas_processed = 0;
  char rbuf[32];

  ospf6 = (struct ospf6 *)THREAD_ARG (t);
  ospf6->t_spf_calc = NULL;

  /* execute SPF calculation */
  quagga_gettime (QUAGGA_CLK_MONOTONIC, &start);

  for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa))
    {

      if (oa == ospf6->backbone)
	continue;

      if (IS_OSPF6_DEBUG_SPF (PROCESS))
	zlog_debug ("SPF calculation for Area %s", oa->name);
      if (IS_OSPF6_DEBUG_SPF (DATABASE))
	ospf6_spf_log_database (oa);

      ospf6_spf_calculation (ospf6->router_id, oa->spf_table, oa);
      ospf6_intra_route_calculation (oa);
      ospf6_intra_brouter_calculation (oa);

      areas_processed++;
    }

  if (ospf6->backbone)
    {
      if (IS_OSPF6_DEBUG_SPF (PROCESS))
	zlog_debug ("SPF calculation for Backbone area %s",
		    ospf6->backbone->name);
      if (IS_OSPF6_DEBUG_SPF (DATABASE))
	ospf6_spf_log_database(ospf6->backbone);

      ospf6_spf_calculation(ospf6->router_id, ospf6->backbone->spf_table,
			    ospf6->backbone);
      ospf6_intra_route_calculation(ospf6->backbone);
      ospf6_intra_brouter_calculation(ospf6->backbone);
      areas_processed++;
    }

  /* Redo summaries if required */
  for (route = ospf6_route_head (ospf6->route_table); route;
       route = ospf6_route_next (route))
    ospf6_abr_originate_summary(route);

  quagga_gettime (QUAGGA_CLK_MONOTONIC, &end);
  timersub (&end, &start, &runtime);

  ospf6->ts_spf_duration = runtime;

  ospf6_spf_reason_string(ospf6->spf_reason, rbuf, sizeof(rbuf));

  if (IS_OSPF6_DEBUG_SPF (PROCESS) || IS_OSPF6_DEBUG_SPF (TIME))
    zlog_debug ("SPF runtime: %lld sec %lld usec",
		(long long)runtime.tv_sec, (long long)runtime.tv_usec);

  zlog_info("SPF processing: # Areas: %d, SPF runtime: %lld sec %lld usec, "
	    "Reason: %s\n", areas_processed,
	    (long long)runtime.tv_sec, (long long)runtime.tv_usec,
	    rbuf);
  ospf6->last_spf_reason = ospf6->spf_reason;
  ospf6_reset_spf_reason(ospf6);
  return 0;
}