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

📄 ospf_abr.c

📁 router source code for the ospdf.
💻 C
📖 第 1 页 / 共 3 页
字号:
      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_network_to_area(): "		   "old summary approved");       SET_FLAG (old->flags, OSPF_LSA_APPROVED);    }  else    {      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_network_to_area(): "		   "creating new summary");      if (old)	{	  set_metric (old, cost);	  lsa = ospf_summary_lsa_refresh (area->ospf, old);	  /* This will flood through area. */	}      else	{	  lsa = ospf_summary_lsa_originate (p, cost, area);	  /* This will flood through area. */	}            SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_network_to_area(): "		   "flooding new version of summary");#ifndef HAVE_NSSA            ospf_flood_through_area (area, NULL, lsa);#endif /* ! HAVE_NSSA */    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_network_to_area(): Stop");}intospf_abr_nexthops_belong_to_area (struct ospf_route *or,				  struct ospf_area *area){  listnode node;  for (node = listhead (or->path); node; nextnode (node))    {      struct ospf_path *path = node->data;      struct ospf_interface *oi = path->oi;      if (oi != NULL)	if (oi->area == area)	  return 1;    }  return 0;}intospf_abr_should_accept (struct prefix *p, struct ospf_area *area){  if (IMPORT_NAME (area))    {      if (IMPORT_LIST (area) == NULL)	IMPORT_LIST (area) = access_list_lookup (AFI_IP, IMPORT_NAME (area));      if (IMPORT_LIST (area))        if (access_list_apply (IMPORT_LIST (area), p) == FILTER_DENY)	  return 0;    }  return 1;}intospf_abr_plist_in_check (struct ospf_area *area, struct ospf_route *or,			 struct prefix *p){  if (PREFIX_NAME_IN (area))    {      if (PREFIX_LIST_IN (area) == NULL)	PREFIX_LIST_IN (area) = prefix_list_lookup (AFI_IP,						    PREFIX_NAME_IN (area));      if (PREFIX_LIST_IN (area))	if (prefix_list_apply (PREFIX_LIST_IN (area), p) != PREFIX_PERMIT)	  return 0;    }  return 1;}intospf_abr_plist_out_check (struct ospf_area *area, struct ospf_route *or,			  struct prefix *p){  if (PREFIX_NAME_OUT (area))    {      if (PREFIX_LIST_OUT (area) == NULL)	PREFIX_LIST_OUT (area) = prefix_list_lookup (AFI_IP,						     PREFIX_NAME_OUT (area));      if (PREFIX_LIST_OUT (area))	if (prefix_list_apply (PREFIX_LIST_OUT (area), p) != PREFIX_PERMIT)	  return 0;    }  return 1;}voidospf_abr_announce_network (struct ospf *ospf,			   struct route_node *n, struct ospf_route *or){  struct ospf_area_range *range;  struct ospf_area *area, *or_area;  struct prefix_ipv4 *p;  listnode node;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_network(): Start");  p = (struct prefix_ipv4 *) &n->p;  or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);   assert (or_area);  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_network(): looking at area %s",		   inet_ntoa (area->area_id));      if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))	continue;      if (ospf_abr_nexthops_belong_to_area (or, area))	continue;      if (!ospf_abr_should_accept (&n->p, area))	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_network(): "		       "prefix %s/%d was denied by import-list",		       inet_ntoa (p->prefix), p->prefixlen);	  continue; 	}      if (!ospf_abr_plist_in_check (area, or, &n->p))	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_network(): "		       "prefix %s/%d was denied by prefix-list",		       inet_ntoa (p->prefix), p->prefixlen);	  continue; 	}      if (area->external_routing != OSPF_AREA_DEFAULT && area->no_summary)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_network(): "		       "area %s is stub and no_summary",		       inet_ntoa (area->area_id));          continue;	}      if (or->path_type == OSPF_PATH_INTER_AREA)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_network(): this is "		       "inter-area route to %s/%d",		       inet_ntoa (p->prefix), p->prefixlen);          if (!OSPF_IS_AREA_BACKBONE (area))	    ospf_abr_announce_network_to_area (p, or->cost, area);	}      if (or->path_type == OSPF_PATH_INTRA_AREA)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_network(): "		       "this is intra-area route to %s/%d",		       inet_ntoa (p->prefix), p->prefixlen);	  if ((range = ospf_area_range_match (or_area, p)) &&              !ospf_area_is_transit (area))	    ospf_abr_update_aggregate (range, or);	  else	    ospf_abr_announce_network_to_area (p, or->cost, area);	}    }}intospf_abr_should_announce (struct ospf *ospf,			  struct prefix *p, struct ospf_route *or){  struct ospf_area *area;  area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);  assert (area);    if (EXPORT_NAME (area))    {      if (EXPORT_LIST (area) == NULL)	EXPORT_LIST (area) = access_list_lookup (AFI_IP, EXPORT_NAME (area));      if (EXPORT_LIST (area))        if (access_list_apply (EXPORT_LIST (area), p) == FILTER_DENY)	  return 0;    }  return 1;}#ifdef HAVE_NSSAvoidospf_abr_process_nssa_translates (struct ospf *ospf){  /* Scan through all NSSA_LSDB records for all areas;  If P-bit is on, translate all Type-7's to 5's and aggregate or  flood install as approved in Type-5 LSDB with XLATE Flag on  later, do same for all aggregates...  At end, DISCARD all  remaining UNAPPROVED Type-5's (Aggregate is for future ) */  listnode node;  struct ospf_area *area;  struct route_node *rn;  struct ospf_lsa *lsa;  if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_process_nssa_translates(): Start");  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (! area->NSSATranslator)	continue; /* skip if not translator */            if (area->external_routing != OSPF_AREA_NSSA)	continue;  /* skip if not Nssa Area */      if (IS_DEBUG_OSPF_NSSA)	zlog_info ("ospf_abr_process_nssa_translates(): "		   "looking at area %s", inet_ntoa (area->area_id));            LSDB_LOOP (NSSA_LSDB (area), rn, lsa)	ospf_abr_translate_nssa (area, lsa);    }   if (IS_DEBUG_OSPF_NSSA)    zlog_info ("ospf_abr_process_nssa_translates(): Stop");}#endif /* HAVE_NSSA */voidospf_abr_process_network_rt (struct ospf *ospf,			     struct route_table *rt){  struct ospf_area *area;  struct ospf_route *or;  struct route_node *rn;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_process_network_rt(): Start");  for (rn = route_top (rt); rn; rn = route_next (rn))    {      if ((or = rn->info) == NULL)	continue;      if (!(area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id)))	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_process_network_rt(): area %s no longer exists",		       inet_ntoa (or->u.std.area_id));	  continue;	}      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_process_network_rt(): this is a route to %s/%d",		   inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);      if (or->path_type >= OSPF_PATH_TYPE1_EXTERNAL)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_process_network_rt(): "		       "this is an External router, skipping");	  continue;	}      if (or->cost >= OSPF_LS_INFINITY)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_process_network_rt():"		       " this route's cost is infinity, skipping");	  continue;	}      if (or->type == OSPF_DESTINATION_DISCARD)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_process_network_rt():"		       " this is a discard entry, skipping");	  continue;	}      if (or->path_type == OSPF_PATH_INTRA_AREA &&	  !ospf_abr_should_announce (ospf, &rn->p, or))	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info("ospf_abr_process_network_rt(): denied by export-list");	  continue;	}      if (or->path_type == OSPF_PATH_INTRA_AREA &&	  !ospf_abr_plist_out_check (area, or, &rn->p))	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info("ospf_abr_process_network_rt(): denied by prefix-list");	  continue;	}      if ((or->path_type == OSPF_PATH_INTER_AREA) &&          !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_process_network_rt():"		       " this is route is not backbone one, skipping");	  continue;	}      if ((ospf->abr_type == OSPF_ABR_CISCO) ||          (ospf->abr_type == OSPF_ABR_IBM))	if (!ospf_act_bb_connection (ospf) &&	    or->path_type != OSPF_PATH_INTRA_AREA)	  {	    if (IS_DEBUG_OSPF_EVENT)	      zlog_info ("ospf_abr_process_network_rt(): ALT ABR: "			 "No BB connection, skip not intra-area routes");	    continue;	  }      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_process_network_rt(): announcing");      ospf_abr_announce_network (ospf, rn, or);    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_process_network_rt(): Stop");}voidospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,			       struct ospf_area *area){  struct ospf_lsa *lsa, *old = NULL;  struct summary_lsa *slsa = NULL;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_rtr_to_area(): Start");  old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_ASBR_SUMMARY_LSA,				   p, area->ospf->router_id);  if (old)    {      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_rtr_to_area(): old summary found");      slsa = (struct summary_lsa *) old->data;      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_network_to_area(): "		   "old metric: %d, new metric: %d",		   GET_METRIC (slsa->metric), cost);    }  if (old && (GET_METRIC (slsa->metric) == cost))    {      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_rtr_to_area(): old summary approved");      SET_FLAG (old->flags, OSPF_LSA_APPROVED);    }  else    {      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_rtr_to_area(): 2.2");             if (old) 	{ 	  set_metric (old, cost);	  lsa = ospf_summary_asbr_lsa_refresh (area->ospf, old);	}      else	lsa = ospf_summary_asbr_lsa_originate (p, cost, area);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_rtr_to_area(): "		   "flooding new version of summary");      /*	zlog_info ("ospf_abr_announce_rtr_to_area(): creating new summary");	lsa = ospf_summary_asbr_lsa (p, cost, area, old); */      SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);      /* ospf_flood_through_area (area, NULL, lsa);*/    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_rtr_to_area(): Stop");}voidospf_abr_announce_rtr (struct ospf *ospf,		       struct prefix_ipv4 *p, struct ospf_route *or){  listnode node;  struct ospf_area *area;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_rtr(): Start");  for (node = listhead (ospf->areas); node; nextnode (node))    {      area = getdata (node);      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_announce_rtr(): looking at area %s",		   inet_ntoa (area->area_id));      if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))	continue;      if (ospf_abr_nexthops_belong_to_area (or, area))	continue;      if (area->external_routing != OSPF_AREA_DEFAULT)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_network(): "		       "area %s doesn't support external routing",		       inet_ntoa(area->area_id));          continue;	}      if (or->path_type == OSPF_PATH_INTER_AREA)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_rtr(): "		       "this is inter-area route to %s", inet_ntoa (p->prefix));          if (!OSPF_IS_AREA_BACKBONE (area))	    ospf_abr_announce_rtr_to_area (p, or->cost, area);	}      if (or->path_type == OSPF_PATH_INTRA_AREA)	{	  if (IS_DEBUG_OSPF_EVENT)	    zlog_info ("ospf_abr_announce_rtr(): "		       "this is intra-area route to %s", inet_ntoa (p->prefix));          ospf_abr_announce_rtr_to_area (p, or->cost, area);	}    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_announce_rtr(): Stop");}voidospf_abr_process_router_rt (struct ospf *ospf, struct route_table *rt){  struct ospf_route *or;  struct route_node *rn;  struct list *l;  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_process_router_rt(): Start");  for (rn = route_top (rt); rn; rn = route_next (rn))    {      listnode node;      char flag = 0;      struct ospf_route *best = NULL;      if (rn->info == NULL)	continue;      l = rn->info;      if (IS_DEBUG_OSPF_EVENT)	zlog_info ("ospf_abr_process_router_rt(): this is a route to %s",		   inet_ntoa (rn->p.u.prefix4));      for (node = listhead (l); node; nextnode (node))	{	  or = getdata (node);	  if (or == NULL)	    continue;	  if (!ospf_area_lookup_by_area_id (ospf, or->u.std.area_id))	    {	      if (IS_DEBUG_OSPF_EVENT)		zlog_info ("ospf_abr_process_router_rt(): area %s no longer exists",			   inet_ntoa (or->u.std.area_id));	      continue;	    }	  if (!CHECK_FLAG (or->u.std.flags, ROUTER_LSA_EXTERNAL))	    {	      if (IS_DEBUG_OSPF_EVENT)		zlog_info ("ospf_abr_process_router_rt(): "			   "This is not an ASBR, skipping");	      continue;	    }	  if (!flag)	    {	      best = ospf_find_asbr_route (ospf, rt,					   (struct prefix_ipv4 *) &rn->p);	      flag = 1;	    }	  	  if (best == NULL)	    continue;		  if (or != best)	    {	      if (IS_DEBUG_OSPF_EVENT)		zlog_info ("ospf_abr_process_router_rt(): "			   "This route is not the best among possible, skipping");	      continue;	    }		  if (or->path_type == OSPF_PATH_INTER_AREA &&	      !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))	    {	      if (IS_DEBUG_OSPF_EVENT)		zlog_info ("ospf_abr_process_router_rt(): "			   "This route is not a backbone one, skipping");	      continue;	    }	  if (or->cost >= OSPF_LS_INFINITY)	    {	      if (IS_DEBUG_OSPF_EVENT)		zlog_info ("ospf_abr_process_router_rt(): "			   "This route has LS_INFINITY metric, skipping");	      continue;	    }	  if (ospf->abr_type == OSPF_ABR_CISCO	      || ospf->abr_type == OSPF_ABR_IBM)	    if (!ospf_act_bb_connection (ospf)		&& or->path_type != OSPF_PATH_INTRA_AREA)	      {		if (IS_DEBUG_OSPF_EVENT)		  zlog_info("ospf_abr_process_network_rt(): ALT ABR: "			    "No BB connection, skip not intra-area routes");		continue;	      }	  ospf_abr_announce_rtr (ospf, (struct prefix_ipv4 *) &rn->p, or);	}    }  if (IS_DEBUG_OSPF_EVENT)    zlog_info ("ospf_abr_process_router_rt(): Stop");}#ifdef HAVE_NSSAvoidospf_abr_unapprove_translates (struct ospf *ospf) /* For NSSA Translations */{  struct ospf_lsa *lsa;  struct route_node *rn;  if (IS_DEBUG_OSPF_NSSA)

⌨️ 快捷键说明

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