예제 #1
0
/**gjd : under a interface , calculate the all ip address(include ipv4 and ipv6) num**/
int 
ip_address_count(struct interface* ifp) 
{
   struct connected *c;
   struct listnode *cnode, *cnnode;
   int i = 0;

   #if 0
   for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, c)) 
   {
	//	if ((c->address->family == AF_INET)||(c->address->family == AF_INET6)) 
			
		if ((c->address->family == AF_INET)) 
			++i;
   }
   return i; 
   #endif

   if (ifp->connected)
    {
      for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, c))
		{
/*		  	if(CHECK_FLAG (c->conf, ZEBRA_IFC_CONFIGURED))*/
				if(CHECK_FLAG (c->conf, ZEBRA_IFC_CONFIGURED)||CHECK_FLAG (c->conf, ZEBRA_IFC_REAL))
				i++;
		}
    }
   /*zlog_info("############## i = %d #################\n",i);*/
   return i;
   
}
예제 #2
0
static void
delete_marked_cache_groups()
{
  cache_group* cache_group;
  cache* cache;
  struct listnode *cache_group_node, *cache_node;
  struct listnode *next_node, *next_cache_node;
  for (ALL_LIST_ELEMENTS(cache_group_list, cache_group_node, next_node,
      cache_group))
    {
      for (ALL_LIST_ELEMENTS(cache_group->cache_config_list, cache_node,
          next_cache_node, cache))
        {
          if (cache->delete_flag)
            {
              listnode_delete(cache_group->cache_config_list, cache);
              delete_cache(cache);
            }
        }
      if (listcount(cache_group->cache_config_list) == 0
          || cache_group->delete_flag)
        {
          listnode_delete(cache_group_list, cache_group);
          delete_cache_group(cache_group);
        }
    }
}
static void forward_off(struct pim_upstream *up)
{
  struct listnode      *ifnode;
  struct listnode      *ifnextnode;
  struct listnode      *chnode;
  struct listnode      *chnextnode;
  struct interface     *ifp;
  struct pim_interface *pim_ifp;
  struct pim_ifchannel *ch;

  /* scan all interfaces */
  for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
    pim_ifp = ifp->info;
    if (!pim_ifp)
      continue;

    /* scan per-interface (S,G) state */
    for (ALL_LIST_ELEMENTS(pim_ifp->pim_ifchannel_list, chnode, chnextnode, ch)) {

      if (ch->upstream != up)
	continue;

      pim_forward_stop(ch);

    } /* scan iface channel list */
  } /* scan iflist */
}
/*
  Evaluate JoinDesired(S,G):

  JoinDesired(S,G) is true if there is a downstream (S,G) interface I
  in the set:

  inherited_olist(S,G) =
  joins(S,G) (+) pim_include(S,G) (-) lost_assert(S,G)

  JoinDesired(S,G) may be affected by changes in the following:

  pim_ifp->primary_address
  pim_ifp->pim_dr_addr
  ch->ifassert_winner_metric
  ch->ifassert_winner
  ch->local_ifmembership 
  ch->ifjoin_state
  ch->upstream->rpf.source_nexthop.mrib_metric_preference
  ch->upstream->rpf.source_nexthop.mrib_route_metric
  ch->upstream->rpf.source_nexthop.interface

  See also pim_upstream_update_join_desired() below.
 */
int pim_upstream_evaluate_join_desired(struct pim_upstream *up)
{
  struct listnode      *ifnode;
  struct listnode      *ifnextnode;
  struct listnode      *chnode;
  struct listnode      *chnextnode;
  struct interface     *ifp;
  struct pim_interface *pim_ifp;
  struct pim_ifchannel *ch;

  /* scan all interfaces */
  for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
    pim_ifp = ifp->info;
    if (!pim_ifp)
      continue;

    /* scan per-interface (S,G) state */
    for (ALL_LIST_ELEMENTS(pim_ifp->pim_ifchannel_list, chnode, chnextnode, ch)) {
      if (ch->upstream != up)
	continue;

      if (pim_macro_ch_lost_assert(ch))
	continue; /* keep searching */

      if (pim_macro_chisin_joins_or_include(ch))
	return 1; /* true */
    } /* scan iface channel list */
  } /* scan iflist */

  return 0; /* false */
}
예제 #5
0
파일: zserv.c 프로젝트: MichaelQQ/Quagga-PE
/* Register zebra server interface information.  Send current all
   interface and address information. */
static int
zread_interface_add (struct zserv *client, u_short length)
{
  struct listnode *ifnode, *ifnnode;
  struct listnode *cnode, *cnnode;
  struct interface *ifp;
  struct connected *c;

  /* Interface information is needed. */
  client->ifinfo = 1;

  for (ALL_LIST_ELEMENTS (iflist, ifnode, ifnnode, ifp))
    {
      /* Skip pseudo interface. */
      if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
	continue;

      if (zsend_interface_add (client, ifp) < 0)
        return -1;

      for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, c))
	{
	  if (CHECK_FLAG (c->conf, ZEBRA_IFC_REAL) &&
	      (zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, 
				        ifp, c) < 0))
	    return -1;
	}
    }
  return 0;
}
static void pim_upstream_update_assert_tracking_desired(struct pim_upstream *up)
{
  struct listnode      *ifnode;
  struct listnode      *ifnextnode;
  struct listnode      *chnode;
  struct listnode      *chnextnode;
  struct interface     *ifp;
  struct pim_interface *pim_ifp;
  struct pim_ifchannel *ch;

  /* scan all interfaces */
  for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
    pim_ifp = ifp->info;
    if (!pim_ifp)
      continue;

    /* scan per-interface (S,G) state */
    for (ALL_LIST_ELEMENTS(pim_ifp->pim_ifchannel_list, chnode, chnextnode, ch)) {

      if (ch->upstream != up)
	continue;

      pim_ifchannel_update_assert_tracking_desired(ch);

    } /* scan iface channel list */
  } /* scan iflist */
}
예제 #7
0
/* Restore an interface to its pre UP state
   Used from ism_interface_down only */
void
ospf_if_cleanup (struct ospf_interface *oi)
{
  struct route_node *rn;
  struct listnode *node, *nnode;
  struct ospf_neighbor *nbr;
  struct ospf_nbr_nbma *nbr_nbma;
  struct ospf_lsa *lsa;

  /* oi->nbrs and oi->nbr_nbma should be deleted on InterfaceDown event */
  /* delete all static neighbors attached to this interface */
  for (ALL_LIST_ELEMENTS (oi->nbr_nbma, node, nnode, nbr_nbma))
    {
      OSPF_POLL_TIMER_OFF (nbr_nbma->t_poll);

      if (nbr_nbma->nbr)
	{
	  nbr_nbma->nbr->nbr_nbma = NULL;
	  nbr_nbma->nbr = NULL;
	}

      nbr_nbma->oi = NULL;
      
      listnode_delete (oi->nbr_nbma, nbr_nbma);
    }

  /* send Neighbor event KillNbr to all associated neighbors. */
  for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
    if ((nbr = rn->info) != NULL)
      if (nbr != oi->nbr_self)
	OSPF_NSM_EVENT_EXECUTE (nbr, NSM_KillNbr);

  /* Cleanup Link State Acknowlegdment list. */
  for (ALL_LIST_ELEMENTS (oi->ls_ack, node, nnode, lsa))
    ospf_lsa_unlock (&lsa); /* oi->ls_ack */
  list_delete_all_node (oi->ls_ack);

  oi->crypt_seqnum = 0;
  
  /* Empty link state update queue */
  ospf_ls_upd_queue_empty (oi);
  
  /* Reset pseudo neighbor. */
  ospf_nbr_delete (oi->nbr_self);
  oi->nbr_self = ospf_nbr_new (oi);
  ospf_nbr_add_self (oi);
  
  ospf_lsa_unlock (&oi->network_lsa_self);
  oi->network_lsa_self = NULL;
  OSPF_TIMER_OFF (oi->t_network_lsa_self);
#ifdef HAVE_GRACEFUL_RESTART
  THREAD_TIMER_OFF(oi->t_opaque_lsa_refresh);
  oi->v_opaque_lsa_count = 0 ;
#endif
}
예제 #8
0
/* Display configuration to file pointer. */
void
vtysh_config_dump (FILE *fp)
{
  struct listnode *node, *nnode;
  struct listnode *mnode, *mnnode;
  struct config *config;
  struct list *master;
  char *line;
  unsigned int i;

  for (ALL_LIST_ELEMENTS (config_top, node, nnode, line))
    {
      fprintf (fp, "%s\n", line);
      fflush (fp);
    }
  fprintf (fp, "!\n");
  fflush (fp);

  for (i = 0; i < vector_active (configvec); i++)
    if ((master = vector_slot (configvec, i)) != NULL)
      {
	for (ALL_LIST_ELEMENTS (master, node, nnode, config))
	  {
	    fprintf (fp, "%s\n", config->name);
	    fflush (fp);

	    for (ALL_LIST_ELEMENTS (config->line, mnode, mnnode, line))
	      {
		fprintf  (fp, "%s\n", line);
		fflush (fp);
	      }
	    if (! NO_DELIMITER (i))
	      {
		fprintf (fp, "!\n");
		fflush (fp);
	      }
	  }
	if (NO_DELIMITER (i))
	  {
	    fprintf (fp, "!\n");
	    fflush (fp);
	  }
      }

  for (i = 0; i < vector_active (configvec); i++)
    if ((master = vector_slot (configvec, i)) != NULL)
      {
	list_delete (master);
	vector_slot (configvec, i) = NULL;
      }
  list_delete_all_node (config_top);
}
예제 #9
0
static int
bgp_interface_down (int command, struct zclient *zclient, zebra_size_t length)
{
  struct stream *s;
  struct interface *ifp;
  struct connected *c;
  struct listnode *node, *nnode;

  s = zclient->ibuf;
  ifp = zebra_interface_state_read (s);
  if (! ifp)
    return 0;

  if (BGP_DEBUG(zebra, ZEBRA))
    zlog_debug("Zebra rcvd: interface %s down", ifp->name);

  for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
    bgp_connected_delete (c);

  /* Fast external-failover (Currently IPv4 only) */
  {
    struct listnode *mnode;
    struct bgp *bgp;
    struct peer *peer;
    struct interface *peer_if;

    for (ALL_LIST_ELEMENTS_RO (bm->bgp, mnode, bgp))
      {
	if (CHECK_FLAG (bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER))
	  continue;

	for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
	  {
	    if (peer->ttl != 1)
	      continue;

	    if (peer->su.sa.sa_family == AF_INET)
	      peer_if = if_lookup_by_ipv4 (&peer->su.sin.sin_addr);
	    else
	      continue;

	    if (ifp == peer_if)
	      BGP_EVENT_ADD (peer, BGP_Stop);
	  }
      }
  }

  return 0;
}
예제 #10
0
int eigrp_nbr_count_get(void){

	struct eigrp_interface *iface;
	struct listnode *node, *node2, *nnode2;
	struct eigrp_neighbor *nbr;
	struct eigrp *eigrp = eigrp_lookup();
	u_int32_t counter;

	if (eigrp == NULL)
	  {
	    zlog_debug("EIGRP Routing Process not enabled");
	    return 0;
	  }

	counter=0;
	for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, iface))
	  {
	    for (ALL_LIST_ELEMENTS(iface->nbrs, node2, nnode2, nbr))
	      {
	        if (nbr->state == EIGRP_NEIGHBOR_UP){
	          counter++;
	        }
	      }
	  }
	return counter;
}
예제 #11
0
파일: ospf6_spf.c 프로젝트: Addision/LVS
void
ospf6_spf_display_subtree (struct vty *vty, const char *prefix, int rest,
                           struct ospf6_vertex *v)
{
  struct listnode *node, *nnode;
  struct ospf6_vertex *c;
  char *next_prefix;
  int len;
  int restnum;

  /* "prefix" is the space prefix of the display line */
  vty_out (vty, "%s+-%s [%d]%s", prefix, v->name, v->cost, VNL);

  len = strlen (prefix) + 4;
  next_prefix = (char *) malloc (len);
  if (next_prefix == NULL)
    {
      vty_out (vty, "malloc failed%s", VNL);
      return;
    }
  snprintf (next_prefix, len, "%s%s", prefix, (rest ? "|  " : "   "));

  restnum = listcount (v->child_list);
  for (ALL_LIST_ELEMENTS (v->child_list, node, nnode, c))
    {
      restnum--;
      ospf6_spf_display_subtree (vty, next_prefix, restnum, c);
    }

  free (next_prefix);
}
예제 #12
0
static void igmp_group_delete(struct igmp_group *group)
{
  struct listnode *src_node;
  struct listnode *src_nextnode;
  struct igmp_source *src;

  if (PIM_DEBUG_IGMP_TRACE) {
    char group_str[100];
    pim_inet4_dump("<group?>", group->group_addr, group_str, sizeof(group_str));
    zlog_debug("Deleting IGMP group %s from socket %d interface %s",
	       group_str,
	       group->group_igmp_sock->fd,
	       group->group_igmp_sock->interface->name);
  }

  for (ALL_LIST_ELEMENTS(group->group_source_list, src_node, src_nextnode, src)) {
    igmp_source_delete(src);
  }

  if (group->t_group_query_retransmit_timer) {
    THREAD_OFF(group->t_group_query_retransmit_timer);
    zassert(!group->t_group_query_retransmit_timer);
  }

  group_timer_off(group);
  listnode_delete(group->group_igmp_sock->igmp_group_list, group);
  igmp_group_free(group);
}
예제 #13
0
파일: bgp_zebra.c 프로젝트: DorChen/quagga
/* Router-id update message from zebra. */
static int
bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length)
{
  struct prefix router_id;
  struct listnode *node, *nnode;
  struct bgp *bgp;

  zebra_router_id_update_read(zclient->ibuf,&router_id);

  if (BGP_DEBUG(zebra, ZEBRA))
    {
      char buf[128];
      prefix2str(&router_id, buf, sizeof(buf));
      zlog_debug("Zebra rcvd: router id update %s", buf);
    }

  router_id_zebra = router_id.u.prefix4;

  for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
    {
      if (!bgp->router_id_static.s_addr)
        bgp_router_id_set (bgp, &router_id.u.prefix4);
    }

  return 0;
}
예제 #14
0
파일: svz_sisis.c 프로젝트: ecks/sis-is
void
clear_checksum_streams (uint16_t checksum)
{
  struct listnode * node, * nnode;
  struct sisis_listener * listener;

  for(ALL_LIST_ELEMENTS (sm->listen_sockets, node, nnode, listener))
  {
     if(stream_get_getp(listener->chksum_stream) < stream_get_endp(listener->chksum_stream))
     {
       uint16_t checksum_head = stream_getw(listener->chksum_stream);
       if(checksum_head != checksum)
       {
         stream_putw(listener->chksum_stream, checksum_head);
         uint16_t next_checksum = stream_peekw(listener->chksum_stream);
         while(next_checksum != checksum_head)
         {
           next_checksum = stream_getw(listener->chksum_stream);
           if(next_checksum != checksum)
             stream_putw(listener->chksum_stream, next_checksum);
         }
       }
     }
  }
}
예제 #15
0
void
eigrp_update_send_all (struct eigrp *eigrp, struct eigrp_interface *exception)
{

  struct eigrp_interface *iface;
  struct listnode *node, *node2, *nnode2;
  struct eigrp_prefix_entry *pe;

  for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, iface))
    {
      if (iface != exception)
        {
          eigrp_update_send(iface);
        }
    }

  for (ALL_LIST_ELEMENTS(eigrp->topology_changes_internalIPV4, node2, nnode2, pe))
    {
      if(pe->req_action & EIGRP_FSM_NEED_UPDATE)
        {
          pe->req_action &= ~EIGRP_FSM_NEED_UPDATE;
          listnode_delete(eigrp->topology_changes_internalIPV4, pe);
          zlog_debug("UPDATE COUNT: %d", eigrp->topology_changes_internalIPV4->count);
        }
    }
}
예제 #16
0
/**Only for real interface first time register rpa table .not include ipv6 address: fe80: xx**/
int 
ip_address_count_except_fe80(struct interface* ifp) 
{
   struct connected *c;
   struct listnode *cnode, *cnnode;
   int i = 0;

   if (ifp->connected)
    {
      for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, c))
		{
			if(CHECK_FLAG (c->conf, ZEBRA_IFC_CONFIGURED)||CHECK_FLAG (c->conf, ZEBRA_IFC_REAL))
			{
				if((c->address->family == AF_INET6) 
					&&(IPV6_ADDR_FE80(c->address->u.prefix6.in6_u.u6_addr16[0])))
					continue;
				else
					i++;
				}
				
		}
    }
   
  /* zlog_info("############## i = %d #################\n",i);*/
   return i;
   
}
예제 #17
0
int
interface_down (struct thread *thread)
{
  struct ospf6_interface *oi;
  struct listnode *node, *nnode;
  struct ospf6_neighbor *on;

  oi = (struct ospf6_interface *) THREAD_ARG (thread);
  assert (oi && oi->interface);

  if (IS_OSPF6_DEBUG_INTERFACE)
    zlog_debug ("Interface Event %s: [InterfaceDown]",
		oi->interface->name);

  /* Leave AllSPFRouters */
  if (oi->state > OSPF6_INTERFACE_DOWN)
    ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);

  ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);

  for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
    ospf6_neighbor_delete (on);
  
  list_delete_all_node (oi->neighbor_list);

  return 0;
}
예제 #18
0
u_int32_t
eigrp_query_send_all (struct eigrp *eigrp)
{
  struct eigrp_interface *iface;
  struct listnode *node, *node2, *nnode2;
  struct eigrp_neighbor *nbr;
  struct eigrp_prefix_entry *pe;
  u_int32_t counter;

  if (eigrp == NULL)
    {
      zlog_debug("EIGRP Routing Process not enabled");
      return 0;
    }

  counter=0;
  for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, iface))
    {
      eigrp_send_query(iface);
      counter++;
    }

  for (ALL_LIST_ELEMENTS(eigrp->topology_changes_internalIPV4, node2, nnode2, pe))
    {
      if(pe->req_action & EIGRP_FSM_NEED_QUERY)
        {
          pe->req_action &= ~EIGRP_FSM_NEED_QUERY;
          listnode_delete(eigrp->topology_changes_internalIPV4, pe);
        }
    }

  return counter;
}
예제 #19
0
파일: sv_sisis.c 프로젝트: ecks/sis-is
unsigned int
are_checksums_same (void)
{
  int same = 0;
  struct listnode * node, * nnode;
  struct sisis_listener * listener;
  struct sisis_listener * listener_swp = (struct sisis_listener *)listgetdata(listhead(sm->listen_sockets));
  u_int16_t chsum_swp = listener_swp->chksum;

  for(ALL_LIST_ELEMENTS (sm->listen_sockets, node, nnode, listener))
  {
    zlog_debug("checksum: %d\n", listener->chksum);
    if(listener->chksum == chsum_swp)
    {
      same = 1;
      chsum_swp = listener->chksum;
    }
    else
    {
      return 0;
     }
  }

  return same;
}
/* Check wether the interface has at least a connected prefix that
 * is within the ripng_enable_network table. */
static int
rip_enable_network_lookup_if (struct interface *ifp)
{
  struct listnode *node, *nnode;
  struct connected *connected;
  struct prefix_ipv4 address;

  for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
    {
      struct prefix *p; 
      struct route_node *node;

      p = connected->address;

      if (p->family == AF_INET)
        {
          address.family = AF_INET;
          address.prefix = p->u.prefix4;
          address.prefixlen = IPV4_MAX_BITLEN;
          
          node = route_node_match (rip_enable_network,
                                   (struct prefix *)&address);
          if (node)
            {
              route_unlock_node (node);
              return 1;
            }
        }
    }
  return -1;
}
예제 #21
0
void
ospf6_abr_disable_area (struct ospf6_area *area)
{
  struct ospf6_area *oa;
  struct ospf6_route *ro;
  struct ospf6_lsa *old;
  struct listnode *node, *nnode;

  /* Withdraw all summary prefixes previously originated */
  for (ro = ospf6_route_head (area->summary_prefix); ro;
       ro = ospf6_route_next (ro))
    {
      old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id,
                               area->ospf6->router_id, area->lsdb);
      if (old)
        ospf6_lsa_purge (old);
      ospf6_route_remove (ro, area->summary_prefix);
    }

  /* Withdraw all summary router-routes previously originated */
  for (ro = ospf6_route_head (area->summary_router); ro;
       ro = ospf6_route_next (ro))
    {
      old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id,
                               area->ospf6->router_id, area->lsdb);
      if (old)
        ospf6_lsa_purge (old);
      ospf6_route_remove (ro, area->summary_router);
    }

  /* Schedule Router-LSA for each area (ABR status may change) */
  for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa))
    /* update B bit for each area */
    OSPF6_ROUTER_LSA_SCHEDULE (oa);
}
예제 #22
0
void
ospf6_abr_enable_area (struct ospf6_area *area)
{
  struct ospf6_area *oa;
  struct ospf6_route *ro;
  struct listnode *node, *nnode;

  for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa))
    {
      /* update B bit for each area */
      OSPF6_ROUTER_LSA_SCHEDULE (oa);

      /* install other area's configured address range */
      if (oa != area)
        {
          for (ro = ospf6_route_head (oa->range_table); ro;
               ro = ospf6_route_next (ro))
            {
              if (CHECK_FLAG (ro->flag, OSPF6_ROUTE_ACTIVE_SUMMARY))
                ospf6_abr_originate_summary_to_area (ro, area);
            }
        }
    }

  /* install calculated routes to border routers */
  for (ro = ospf6_route_head (area->ospf6->brouter_table); ro;
       ro = ospf6_route_next (ro))
    ospf6_abr_originate_summary_to_area (ro, area);

  /* install calculated routes to network (may be rejected by ranges) */
  for (ro = ospf6_route_head (area->ospf6->route_table); ro;
       ro = ospf6_route_next (ro))
    ospf6_abr_originate_summary_to_area (ro, area);
}
예제 #23
0
파일: ospf6_area.c 프로젝트: Addision/LVS
void
ospf6_area_delete (struct ospf6_area *oa)
{
  struct listnode *n, *nnode;
  struct ospf6_interface *oi;

  ospf6_route_table_delete (oa->range_table);
  ospf6_route_table_delete (oa->summary_prefix);
  ospf6_route_table_delete (oa->summary_router);

  /* ospf6 interface list */
  for (ALL_LIST_ELEMENTS (oa->if_list, n, nnode, oi))
    {
      ospf6_interface_delete (oi);
    }
  list_delete (oa->if_list);

  ospf6_lsdb_delete (oa->lsdb);
  ospf6_lsdb_delete (oa->lsdb_self);

  ospf6_spf_table_finish (oa->spf_table);
  ospf6_route_table_delete (oa->spf_table);
  ospf6_route_table_delete (oa->route_table);

  THREAD_OFF (oa->thread_spf_calculation);
  THREAD_OFF (oa->thread_route_calculation);

  listnode_delete (oa->ospf6->area_list, oa);
  oa->ospf6 = NULL;

  /* free area */
  XFREE (MTYPE_OSPF6_AREA, oa);
}
예제 #24
0
void
ospf6_delete (struct ospf6 *o)
{
  struct listnode *node, *nnode;
  struct ospf6_area *oa;

  ospf6_disable (ospf6);

  for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
    ospf6_area_delete (oa);
  list_delete (o->area_list);

  ospf6_lsdb_delete (o->lsdb);
  ospf6_lsdb_delete (o->lsdb_self);

  ospf6_route_table_delete (o->route_table);
  ospf6_route_table_delete (o->brouter_table);

  ospf6_route_table_delete (o->external_table);
  route_table_finish (o->external_id_table);

  XFREE (MTYPE_OSPF6_TOP, o);
  /* TODO Fix this */
  ospf6 = NULL;
}
예제 #25
0
/* Interface goes down.  We have to manage different behavior of based
   OS. */
void
if_down (struct interface *ifp)
{
  struct listnode *node;
  struct listnode *next;
  struct connected *ifc;
  struct prefix *p;

  /* Notify to the protocol daemons. */
  zebra_interface_down_update (ifp);

  /* Delete connected routes from the kernel. */
  if (ifp->connected)
    {
      for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
	{
	  p = ifc->address;

	  if (p->family == AF_INET)
	    connected_down_ipv4 (ifp, ifc);
#ifdef HAVE_IPV6
	  else if (p->family == AF_INET6)
	    connected_down_ipv6 (ifp, ifc);
#endif /* HAVE_IPV6 */
	}
    }

  /* Examine all static routes which direct to the interface. */
  rib_update ();
}
예제 #26
0
static int
ripng_if_down (struct interface *ifp)
{
  struct route_node *rp;
  struct ripng_info *rinfo;
  struct ripng_interface *ri;
  struct list *list = NULL;
  struct listnode *listnode = NULL, *nextnode = NULL;

  if (ripng)
    for (rp = route_top (ripng->table); rp; rp = route_next (rp))
      if ((list = rp->info) != NULL)
        for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo))
          if (rinfo->ifindex == ifp->ifindex)
            ripng_ecmp_delete (rinfo);

  ri = ifp->info;
  
  if (ri->running)
   {
     if (IS_RIPNG_DEBUG_EVENT)
       zlog_debug ("turn off %s", ifp->name);

     /* Leave from multicast group. */
     ripng_multicast_leave (ifp);

     ri->running = 0;
   }

  return 0;
}
예제 #27
0
/*
*  check if interface with given address is configured and
*  return it if yes.  special treatment for PtP networks.
*/
struct ospf_interface *
ospf_if_is_configured (struct ospf *ospf, struct in_addr *address)
{
  struct listnode *node, *nnode;
  struct ospf_interface *oi;
  struct prefix_ipv4 addr;

  addr.family = AF_INET;
  addr.prefix = *address;
  addr.prefixlen = IPV4_MAX_PREFIXLEN;

  for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
    if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
      {
        if (oi->type == OSPF_IFTYPE_POINTOPOINT)
	  {
	    /* special leniency: match if addr is anywhere on peer subnet */
	    if (prefix_match(CONNECTED_PREFIX(oi->connected),
			     (struct prefix *)&addr))
	      return oi;
	  }
        else
	  {
	    if (IPV4_ADDR_SAME (address, &oi->address->u.prefix4))
	      return oi;
	  }
      }
  return NULL;
}
예제 #28
0
static void
ripng_connect_set (struct interface *ifp, int set)
{
  struct listnode *node, *nnode;
  struct connected *connected;
  struct prefix_ipv6 address;

  for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
    {
      struct prefix *p;
      p = connected->address;

      if (p->family != AF_INET6)
        continue;

      address.family = AF_INET6;
      address.prefix = p->u.prefix6;
      address.prefixlen = p->prefixlen;
      apply_mask_ipv6 (&address);

      if (set) {
        /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
        if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) ||
            (ripng_enable_network_lookup2(connected) >= 0))
          ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
                                  &address, connected->ifp->ifindex, NULL);
      } else {
        ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
                                   &address, connected->ifp->ifindex);
        if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT))
          ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_REDISTRIBUTE,
                                  &address, connected->ifp->ifindex, NULL);
      }
    }
}
예제 #29
0
파일: ospf6_top.c 프로젝트: ton31337/frr
void ospf6_delete(struct ospf6 *o)
{
	struct listnode *node, *nnode;
	struct ospf6_area *oa;

	QOBJ_UNREG(o);

	ospf6_flush_self_originated_lsas_now();
	ospf6_disable(ospf6);

	for (ALL_LIST_ELEMENTS(o->area_list, node, nnode, oa))
		ospf6_area_delete(oa);


	list_delete(&o->area_list);

	ospf6_lsdb_delete(o->lsdb);
	ospf6_lsdb_delete(o->lsdb_self);

	ospf6_route_table_delete(o->route_table);
	ospf6_route_table_delete(o->brouter_table);

	ospf6_route_table_delete(o->external_table);
	route_table_finish(o->external_id_table);

	ospf6_distance_reset(o);
	route_table_finish(o->distance_table);

	XFREE(MTYPE_OSPF6_TOP, o);
}
예제 #30
0
static void scan_upstream_rpf_cache()
{
  struct listnode     *up_node;
  struct listnode     *up_nextnode;
  struct pim_upstream *up;

  for (ALL_LIST_ELEMENTS(qpim_upstream_list, up_node, up_nextnode, up)) {
    struct in_addr      old_rpf_addr;
    enum pim_rpf_result rpf_result;

    rpf_result = pim_rpf_update(up, &old_rpf_addr);
    if (rpf_result == PIM_RPF_FAILURE)
      continue;

    if (rpf_result == PIM_RPF_CHANGED) {
      
      if (up->join_state == PIM_UPSTREAM_JOINED) {
	
	/*
	  RFC 4601: 4.5.7.  Sending (S,G) Join/Prune Messages
	  
	  Transitions from Joined State
	  
	  RPF'(S,G) changes not due to an Assert
	  
	  The upstream (S,G) state machine remains in Joined
	  state. Send Join(S,G) to the new upstream neighbor, which is
	  the new value of RPF'(S,G).  Send Prune(S,G) to the old
	  upstream neighbor, which is the old value of RPF'(S,G).  Set
	  the Join Timer (JT) to expire after t_periodic seconds.
	*/

    
	/* send Prune(S,G) to the old upstream neighbor */
	pim_joinprune_send(up->rpf.source_nexthop.interface,
			   old_rpf_addr,
			   up->source_addr,
			   up->group_addr,
			   0 /* prune */);
	
	/* send Join(S,G) to the current upstream neighbor */
	pim_joinprune_send(up->rpf.source_nexthop.interface,
			   up->rpf.rpf_addr,
			   up->source_addr,
			   up->group_addr,
			   1 /* join */);

	pim_upstream_join_timer_restart(up);
      } /* up->join_state == PIM_UPSTREAM_JOINED */

      /* FIXME can join_desired actually be changed by pim_rpf_update()
	 returning PIM_RPF_CHANGED ? */
      pim_upstream_update_join_desired(up);

    } /* PIM_RPF_CHANGED */

  } /* for (qpim_upstream_list) */
  
}