⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ospf_abr.c

📁 router source code for the ospdf.
💻 C
📖 第 1 页 / 共 3 页
字号:
    zlog_info ("ospf_abr_unapprove_translates(): Start");  /* NSSA Translator is not checked, because it may have gone away,     and we would want to flush any residuals anyway */  LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)    if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))      UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_unapprove_translates(): Stop");}#endif /* HAVE_NSSA */voidospf_abr_unapprove_summaries (struct ospf *ospf){  listnode node;  struct ospf_area *area;  struct route_node *rn;  struct ospf_lsa *lsa;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_unapprove_summaries(): Start");  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)	if (ospf_lsa_is_self_originated (ospf, lsa))	  UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);      LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)	if (ospf_lsa_is_self_originated (ospf, lsa))	  UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_unapprove_summaries(): Stop");}voidospf_abr_prepare_aggregates (struct ospf *ospf){  listnode node;  struct route_node *rn;  struct ospf_area_range *range;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_prepare_aggregates(): Start");  for (node = listhead (ospf->areas); node; nextnode (node))    {      struct ospf_area *area = getdata (node);      for (rn = route_top (area->ranges); rn; rn = route_next (rn))	if ((range = rn->info) != NULL)	  {	    range->cost = 0;	    range->specifics = 0;	  }    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_prepare_aggregates(): Stop");}voidospf_abr_announce_aggregates (struct ospf *ospf){  struct ospf_area *area, *ar;  struct ospf_area_range *range;  struct route_node *rn;  struct prefix_ipv4 p;  listnode node, n;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_aggregates(): Start");  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_aggregates(): looking at area %s",		   inet_ntoa (area->area_id));      for (rn = route_top (area->ranges); rn; rn = route_next (rn))	if ((range =  rn->info))	  {	    if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))	      {		if (IS_DEBUG_OSPF_EVENT)		  zlog_info ("ospf_abr_announce_aggregates():"			     " discarding suppress-ranges");		continue;	      }	    p.family = AF_INET;	    p.prefix = range->addr;	    p.prefixlen = range->masklen;	    if (IS_DEBUG_OSPF_EVENT)	      zlog_info ("ospf_abr_announce_aggregates():"			 " this is range: %s/%d",			 inet_ntoa (p.prefix), p.prefixlen);	    if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))	      {		p.family = AF_INET;		p.prefix = range->subst_addr;		p.prefixlen = range->subst_masklen;	      }	    if (range->specifics)	      {		if (IS_DEBUG_OSPF_EVENT)		  zlog_info ("ospf_abr_announce_aggregates(): active range");		for (n = listhead (ospf->areas); n; nextnode (n))		  {		    ar = getdata (n);		    if (ar == area)		      continue;		    /* We do not check nexthops here, because		       intra-area routes can be associated with		       one area only */		    /* backbone routes are not summarized		       when announced into transit areas */		    if (ospf_area_is_transit (ar) &&			OSPF_IS_AREA_BACKBONE (area))		      {			if (IS_DEBUG_OSPF_EVENT)			  zlog_info ("ospf_abr_announce_aggregates(): Skipping "				     "announcement of BB aggregate into"				     " a transit area");			continue; 		      }		    ospf_abr_announce_network_to_area (&p, range->cost, ar);		  }	      }	  }    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_aggregates(): Stop");}#ifdef HAVE_NSSAvoidospf_abr_send_nssa_aggregates (struct ospf *ospf) /* temporarily turned off */{  listnode node; /*, n; */  struct ospf_area *area; /*, *ar; */  struct route_node *rn;  struct ospf_area_range *range;  struct prefix_ipv4 p;  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_send_nssa_aggregates(): Start");  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (! area->NSSATranslator)	continue;      if (IS_DEBUG_OSPF_NSSA)	zlog_info ("ospf_abr_send_nssa_aggregates(): looking at area %s",		   inet_ntoa (area->area_id));      for (rn = route_top (area->ranges); rn; rn = route_next (rn))	{          if (rn->info == NULL)	    continue;	  range = rn->info;          if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))	    {	      if (IS_DEBUG_OSPF_NSSA)		zlog_info ("ospf_abr_send_nssa_aggregates():"			   " discarding suppress-ranges");	      continue;	    }          p.family = AF_INET;          p.prefix = range->addr;          p.prefixlen = range->masklen;	  if (IS_DEBUG_OSPF_NSSA)	    zlog_info ("ospf_abr_send_nssa_aggregates():"		       " this is range: %s/%d",		       inet_ntoa (p.prefix), p.prefixlen);          if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))	    {	      p.family = AF_INET;	      p.prefix = range->subst_addr;	      p.prefixlen = range->subst_masklen;	    }          if (range->specifics)	    {	      if (IS_DEBUG_OSPF_NSSA)		zlog_info ("ospf_abr_send_nssa_aggregates(): active range");	      /* Fetch LSA-Type-7 from aggregate prefix, and then                 translate, Install (as Type-5), Approve, and Flood */	      ospf_abr_translate_nssa_range (&p, range->cost);	    } /* if (range->specifics)*/	} /* all area ranges*/    } /* all areas */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_send_nssa_aggregates(): Stop");}voidospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */{  listnode node;  struct ospf_area *area;  struct prefix_ipv4 p;  if (! IS_OSPF_ABR (ospf))    return;  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_announce_stub_defaults(): Start");  p.family = AF_INET;  p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;  p.prefixlen = 0;  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (IS_DEBUG_OSPF_NSSA)	zlog_info ("ospf_abr_announce_nssa_defaults(): looking at area %s",		   inet_ntoa (area->area_id));      if (area->external_routing != OSPF_AREA_NSSA)	continue;      if (OSPF_IS_AREA_BACKBONE (area))	continue; /* Sanity Check */      /* if (!TranslatorRole continue V 1.0 look for "always" conf */      if (area->NSSATranslator)	{	  if (IS_DEBUG_OSPF_NSSA)	    zlog_info ("ospf_abr_announce_nssa_defaults(): "		       "announcing 0.0.0.0/0 to this nssa");	  /* ospf_abr_announce_nssa_asbr_to_as (&p, area->default_cost, area); */	}    }}#endif /* HAVE_NSSA */voidospf_abr_announce_stub_defaults (struct ospf *ospf){  listnode node;  struct ospf_area *area;  struct prefix_ipv4 p;  if (! IS_OSPF_ABR (ospf))    return;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_stub_defaults(): Start");  p.family = AF_INET;  p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;  p.prefixlen = 0;  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_stub_defaults(): looking at area %s",		   inet_ntoa (area->area_id));#ifdef HAVE_NSSA      if (area->external_routing != OSPF_AREA_STUB)#else /* ! HAVE_NSSA */	if (area->external_routing == OSPF_AREA_DEFAULT)#endif /* HAVE_NSSA */	  continue;      if (OSPF_IS_AREA_BACKBONE (area))	continue; /* Sanity Check */      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_stub_defaults(): "		   "announcing 0.0.0.0/0 to this area");      ospf_abr_announce_network_to_area (&p, area->default_cost, area);    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_stub_defaults(): Stop");}#ifdef HAVE_NSSAintospf_abr_remove_unapproved_translates_apply (struct ospf *ospf,					     struct ospf_lsa *lsa){  if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)      && ! CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))    {      zlog_info ("ospf_abr_remove_unapproved_translates(): "		 "removing unapproved translates, ID: %s",		 inet_ntoa (lsa->data->id));      /* FLUSH THROUGHOUT AS */      ospf_lsa_flush_as (ospf, lsa);      /* DISCARD from LSDB  */    }  return 0;}voidospf_abr_remove_unapproved_translates (struct ospf *ospf){  struct route_node *rn;  struct ospf_lsa *lsa;  /* All AREA PROCESS should have APPROVED necessary LSAs */  /* Remove any left over and not APPROVED */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_remove_unapproved_translates(): Start");  LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)    ospf_abr_remove_unapproved_translates_apply (ospf, lsa);   if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_remove_unapproved_translates(): Stop");}#endif /* HAVE_NSSA */voidospf_abr_remove_unapproved_summaries (struct ospf *ospf){  listnode node;  struct ospf_area *area;  struct route_node *rn;  struct ospf_lsa *lsa;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_remove_unapproved_summaries(): Start");  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_remove_unapproved_summaries(): "		   "looking at area %s", inet_ntoa (area->area_id));      LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)	if (ospf_lsa_is_self_originated (ospf, lsa))	  if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))	    ospf_lsa_flush_area (lsa, area);      LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)	if (ospf_lsa_is_self_originated (ospf, lsa))	  if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))	    ospf_lsa_flush_area (lsa, area);    }   if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_remove_unapproved_summaries(): Stop");}voidospf_abr_manage_discard_routes (struct ospf *ospf){  listnode node;  struct route_node *rn;  struct ospf_area *area;  struct ospf_area_range *range;  for (node = listhead (ospf->areas); node; nextnode (node))    if ((area = node->data) != NULL)      for (rn = route_top (area->ranges); rn; rn = route_next (rn))	if ((range = rn->info) != NULL)	  if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))	    {	      if (range->specifics)		ospf_add_discard_route (ospf->new_table, area,					(struct prefix_ipv4 *) &rn->p);	      else		ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);	    }}#ifdef HAVE_NSSA/* This is the function taking care about ABR NSSA, i.e.  NSSA   Translator, -LSA aggregation and flooding. For all NSSAs   Any SELF-AS-LSA is in the Type-5 LSDB and Type-7 LSDB.  These LSA's   are refreshed from the Type-5 LSDB, installed into the Type-7 LSDB   with the P-bit set.   Any received Type-5s are legal for an ABR, else illegal for IR.   Received Type-7s are installed, by area, with incoming P-bit.  They   are flooded; if the Elected NSSA Translator, then P-bit off.   Additionally, this ABR will place "translated type-7's" into the   Type-5 LSDB in order to keep track of APPROVAL or not.   It will scan through every area, looking for Type-7 LSAs with P-Bit   SET. The Type-7's are either AS-FLOODED & 5-INSTALLED or   AGGREGATED.  Later, the AGGREGATED LSAs are AS-FLOODED &   5-INSTALLED.   5-INSTALLED is into the Type-5 LSDB; Any UNAPPROVED Type-5 LSAs   left over are FLUSHED and DISCARDED.   For External Calculations, any NSSA areas use the Type-7 AREA-LSDB,   any ABR-non-NSSA areas use the Type-5 GLOBAL-LSDB. */voidospf_abr_nssa_task (struct ospf *ospf) /* called only if any_nssa */{  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("Check for NSSA-ABR Tasks():");  if (! IS_OSPF_ABR (ospf))    return;  if (! ospf->anyNSSA)    return;  /* Each area must confirm TranslatorRole */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_nssa_task(): Start");  /* For all Global Entries flagged "local-translate", unset APPROVED */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_nssa_task(): unapprove translates");  ospf_abr_unapprove_translates (ospf);  /* RESET all Ranges in every Area, same as summaries */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_nssa_task(): NSSA initialize aggregates");  /*    ospf_abr_prepare_aggregates ();  TURNED OFF just for now */  /* For all NSSAs, Type-7s, translate to 5's, INSTALL/FLOOD, or     Aggregate as Type-7 */  /* Install or Approve in Type-5 Global LSDB */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_nssa_task(): process translates");  ospf_abr_process_nssa_translates (ospf);  /* Translate/Send any "ranged" aggregates, and also 5-Install and     Approve */  /* Scan Type-7's for aggregates, translate to Type-5's,     Install/Flood/Approve */  if (IS_DEBUG_OSPF_NSSA)    zlog_info("ospf_abr_nssa_task(): send NSSA aggregates");  /*       ospf_abr_send_nssa_aggregates ();  TURNED OFF FOR NOW */  /* Send any NSSA defaults as Type-5 */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_nssa_task(): announce nssa defaults");  ospf_abr_announce_nssa_defaults (ospf);     /* Flush any unapproved previous translates from Global Data Base */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_nssa_task(): remove unapproved translates");  ospf_abr_remove_unapproved_translates (ospf);  ospf_abr_manage_discard_routes (ospf); /* same as normal...discard */  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_nssa_task(): Stop");}#endif /* HAVE_NSSA *//* This is the function taking care about ABR stuff, i.e.   summary-LSA origination and flooding. */voidospf_abr_task (struct ospf *ospf){  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_task(): Start");  if (ospf->new_table == NULL || ospf->new_rtrs == NULL)    {      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_task(): Routing tables are not yet ready");      return;    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_task(): unapprove summaries");  ospf_abr_unapprove_summaries (ospf);  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_task(): prepare aggregates");  ospf_abr_prepare_aggregates (ospf);  if (IS_OSPF_ABR (ospf))    {      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_task(): process network RT");      ospf_abr_process_network_rt (ospf, ospf->new_table);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_task(): process router RT");      ospf_abr_process_router_rt (ospf, ospf->new_rtrs);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_task(): announce aggregates");      ospf_abr_announce_aggregates (ospf);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_task(): announce stub defaults");      ospf_abr_announce_stub_defaults (ospf);    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_task(): remove unapproved summaries");  ospf_abr_remove_unapproved_summaries (ospf);  ospf_abr_manage_discard_routes (ospf);#ifdef HAVE_NSSA  ospf_abr_nssa_task (ospf); /* if nssa-abr, then scan Type-7 LSDB */#endif /* HAVE_NSSA */  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_task(): Stop");}intospf_abr_task_timer (struct thread *thread){  struct ospf *ospf = THREAD_ARG (thread);  ospf->t_abr_task = 0;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("Running ABR task on timer");  ospf_check_abr_status (ospf);  ospf_abr_task (ospf);  return 0;}voidospf_schedule_abr_task (struct ospf *ospf){  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("Scheduling ABR task");  if (ospf->t_abr_task == NULL)    ospf->t_abr_task = thread_add_timer (master, ospf_abr_task_timer,					 ospf, OSPF_ABR_TASK_DELAY);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -