ospf_abr.c 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914
  1. /*
  2. * OSPF ABR functions.
  3. * Copyright (C) 1999, 2000 Alex Zinin, Toshiaki Takada
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2, or (at your option) any
  10. * later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  19. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. * 02111-1307, USA.
  21. */
  22. #include <zebra.h>
  23. #include "thread.h"
  24. #include "memory.h"
  25. #include "linklist.h"
  26. #include "prefix.h"
  27. #include "if.h"
  28. #include "table.h"
  29. #include "vty.h"
  30. #include "filter.h"
  31. #include "plist.h"
  32. #include "log.h"
  33. #include "ospfd/ospfd.h"
  34. #include "ospfd/ospf_interface.h"
  35. #include "ospfd/ospf_ism.h"
  36. #include "ospfd/ospf_asbr.h"
  37. #include "ospfd/ospf_lsa.h"
  38. #include "ospfd/ospf_lsdb.h"
  39. #include "ospfd/ospf_neighbor.h"
  40. #include "ospfd/ospf_nsm.h"
  41. #include "ospfd/ospf_spf.h"
  42. #include "ospfd/ospf_route.h"
  43. #include "ospfd/ospf_ia.h"
  44. #include "ospfd/ospf_flood.h"
  45. #include "ospfd/ospf_abr.h"
  46. #include "ospfd/ospf_ase.h"
  47. #include "ospfd/ospf_zebra.h"
  48. #include "ospfd/ospf_dump.h"
  49. struct ospf_area_range *
  50. ospf_area_range_new (struct prefix_ipv4 *p)
  51. {
  52. struct ospf_area_range *range;
  53. range = XCALLOC (MTYPE_OSPF_AREA_RANGE, sizeof (struct ospf_area_range));
  54. range->addr = p->prefix;
  55. range->masklen = p->prefixlen;
  56. range->cost_config = OSPF_AREA_RANGE_COST_UNSPEC;
  57. return range;
  58. }
  59. void
  60. ospf_area_range_free (struct ospf_area_range *range)
  61. {
  62. XFREE (MTYPE_OSPF_AREA_RANGE, range);
  63. }
  64. void
  65. ospf_area_range_add (struct ospf_area *area, struct ospf_area_range *range)
  66. {
  67. struct route_node *rn;
  68. struct prefix_ipv4 p;
  69. p.family = AF_INET;
  70. p.prefixlen = range->masklen;
  71. p.prefix = range->addr;
  72. rn = route_node_get (area->ranges, (struct prefix *)&p);
  73. if (rn->info)
  74. route_unlock_node (rn);
  75. else
  76. rn->info = range;
  77. }
  78. void
  79. ospf_area_range_delete (struct ospf_area *area, struct ospf_area_range *range)
  80. {
  81. struct route_node *rn;
  82. struct prefix_ipv4 p;
  83. p.family = AF_INET;
  84. p.prefixlen = range->masklen;
  85. p.prefix = range->addr;
  86. rn = route_node_lookup (area->ranges, (struct prefix *)&p);
  87. if (rn)
  88. {
  89. ospf_area_range_free (rn->info);
  90. rn->info = NULL;
  91. route_unlock_node (rn);
  92. route_unlock_node (rn);
  93. }
  94. }
  95. struct ospf_area_range *
  96. ospf_area_range_lookup (struct ospf_area *area, struct prefix_ipv4 *p)
  97. {
  98. struct route_node *rn;
  99. rn = route_node_lookup (area->ranges, (struct prefix *)p);
  100. if (rn)
  101. {
  102. route_unlock_node (rn);
  103. return rn->info;
  104. }
  105. return NULL;
  106. }
  107. struct ospf_area_range *
  108. ospf_area_range_lookup_next (struct ospf_area *area,
  109. struct in_addr *range_net,
  110. int first)
  111. {
  112. struct route_node *rn;
  113. struct prefix_ipv4 p;
  114. struct ospf_area_range *find;
  115. p.family = AF_INET;
  116. p.prefixlen = IPV4_MAX_BITLEN;
  117. p.prefix = *range_net;
  118. if (first)
  119. rn = route_top (area->ranges);
  120. else
  121. {
  122. rn = route_node_get (area->ranges, (struct prefix *) &p);
  123. rn = route_next (rn);
  124. }
  125. for (; rn; rn = route_next (rn))
  126. if (rn->info)
  127. break;
  128. if (rn && rn->info)
  129. {
  130. find = rn->info;
  131. *range_net = rn->p.u.prefix4;
  132. route_unlock_node (rn);
  133. return find;
  134. }
  135. return NULL;
  136. }
  137. struct ospf_area_range *
  138. ospf_area_range_match (struct ospf_area *area, struct prefix_ipv4 *p)
  139. {
  140. struct route_node *node;
  141. node = route_node_match (area->ranges, (struct prefix *) p);
  142. if (node)
  143. {
  144. route_unlock_node (node);
  145. return node->info;
  146. }
  147. return NULL;
  148. }
  149. struct ospf_area_range *
  150. ospf_area_range_match_any (struct ospf *ospf, struct prefix_ipv4 *p)
  151. {
  152. struct ospf_area_range *range;
  153. listnode node;
  154. for (node = listhead (ospf->areas); node; nextnode (node))
  155. if ((range = ospf_area_range_match (node->data, p)))
  156. return range;
  157. return NULL;
  158. }
  159. int
  160. ospf_area_range_active (struct ospf_area_range *range)
  161. {
  162. return range->specifics;
  163. }
  164. int
  165. ospf_area_actively_attached (struct ospf_area *area)
  166. {
  167. return area->act_ints;
  168. }
  169. int
  170. ospf_area_range_set (struct ospf *ospf, struct in_addr area_id,
  171. struct prefix_ipv4 *p, int advertise)
  172. {
  173. struct ospf_area *area;
  174. struct ospf_area_range *range;
  175. int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
  176. area = ospf_area_get (ospf, area_id, ret);
  177. if (area == NULL)
  178. return 0;
  179. range = ospf_area_range_lookup (area, p);
  180. if (range != NULL)
  181. {
  182. if ((CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)
  183. && !CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE))
  184. || (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)
  185. && CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE)))
  186. ospf_schedule_abr_task (ospf);
  187. }
  188. else
  189. {
  190. range = ospf_area_range_new (p);
  191. ospf_area_range_add (area, range);
  192. ospf_schedule_abr_task (ospf);
  193. }
  194. if (CHECK_FLAG (advertise, OSPF_AREA_RANGE_ADVERTISE))
  195. SET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE);
  196. else
  197. UNSET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE);
  198. return 1;
  199. }
  200. int
  201. ospf_area_range_cost_set (struct ospf *ospf, struct in_addr area_id,
  202. struct prefix_ipv4 *p, u_int32_t cost)
  203. {
  204. struct ospf_area *area;
  205. struct ospf_area_range *range;
  206. int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
  207. area = ospf_area_get (ospf, area_id, ret);
  208. if (area == NULL)
  209. return 0;
  210. range = ospf_area_range_new (p);
  211. if (range == NULL)
  212. return 0;
  213. if (range->cost_config != cost)
  214. {
  215. range->cost_config = cost;
  216. if (ospf_area_range_active (range))
  217. ospf_schedule_abr_task (ospf);
  218. }
  219. return 1;
  220. }
  221. int
  222. ospf_area_range_unset (struct ospf *ospf, struct in_addr area_id,
  223. struct prefix_ipv4 *p)
  224. {
  225. struct ospf_area *area;
  226. struct ospf_area_range *range;
  227. area = ospf_area_lookup_by_area_id (ospf, area_id);
  228. if (area == NULL)
  229. return 0;
  230. range = ospf_area_range_lookup (area, p);
  231. if (range == NULL)
  232. return 0;
  233. if (ospf_area_range_active (range))
  234. ospf_schedule_abr_task (ospf);
  235. ospf_area_range_delete (area, range);
  236. return 1;
  237. }
  238. int
  239. ospf_area_range_substitute_set (struct ospf *ospf, struct in_addr area_id,
  240. struct prefix_ipv4 *p, struct prefix_ipv4 *s)
  241. {
  242. struct ospf_area *area;
  243. struct ospf_area_range *range;
  244. int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
  245. area = ospf_area_get (ospf, area_id, ret);
  246. range = ospf_area_range_lookup (area, p);
  247. if (range != NULL)
  248. {
  249. if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE) ||
  250. !CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
  251. ospf_schedule_abr_task (ospf);
  252. }
  253. else
  254. {
  255. range = ospf_area_range_new (p);
  256. ospf_area_range_add (area, range);
  257. ospf_schedule_abr_task (ospf);
  258. }
  259. SET_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE);
  260. SET_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE);
  261. range->subst_addr = s->prefix;
  262. range->subst_masklen = s->prefixlen;
  263. return 1;
  264. }
  265. int
  266. ospf_area_range_substitute_unset (struct ospf *ospf, struct in_addr area_id,
  267. struct prefix_ipv4 *p)
  268. {
  269. struct ospf_area *area;
  270. struct ospf_area_range *range;
  271. area = ospf_area_lookup_by_area_id (ospf, area_id);
  272. if (area == NULL)
  273. return 0;
  274. range = ospf_area_range_lookup (area, p);
  275. if (range == NULL)
  276. return 0;
  277. if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
  278. if (ospf_area_range_active (range))
  279. ospf_schedule_abr_task (ospf);
  280. UNSET_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE);
  281. range->subst_addr.s_addr = 0;
  282. range->subst_masklen = 0;
  283. return 1;
  284. }
  285. int
  286. ospf_act_bb_connection (struct ospf *ospf)
  287. {
  288. if (ospf->backbone == NULL)
  289. return 0;
  290. return ospf->backbone->full_nbrs;
  291. }
  292. #ifdef HAVE_NSSA
  293. /* Determine whether this router is elected translator or not for area */
  294. int
  295. ospf_abr_nssa_am_elected (struct ospf_area *area)
  296. {
  297. struct route_node *rn;
  298. struct ospf_lsa *lsa;
  299. struct router_lsa *rlsa;
  300. struct in_addr *best = NULL;
  301. LSDB_LOOP ( ROUTER_LSDB (area), rn, lsa)
  302. {
  303. /* sanity checks */
  304. if (!lsa
  305. || (lsa->data->type != OSPF_ROUTER_LSA)
  306. || IS_LSA_SELF (lsa))
  307. continue;
  308. rlsa = (struct router_lsa *) lsa->data;
  309. /* ignore non-ABR routers */
  310. if (!IS_ROUTER_LSA_BORDER (rlsa))
  311. continue;
  312. /* Router has Nt flag - always translate */
  313. if (IS_ROUTER_LSA_NT (rlsa))
  314. {
  315. if (IS_DEBUG_OSPF_NSSA)
  316. zlog_info ("ospf_abr_nssa_am_elected: "
  317. "router %s asserts Nt",
  318. inet_ntoa (lsa->data->id) );
  319. return 0;
  320. }
  321. if (best == NULL)
  322. best = &lsa->data->id;
  323. else
  324. if ( IPV4_ADDR_CMP (&best, &lsa->data->id) < 0)
  325. best = &lsa->data->id;
  326. }
  327. if (IS_DEBUG_OSPF_NSSA)
  328. zlog_info ("ospf_abr_nssa_am_elected: best electable ABR is: %s",
  329. (best) ? inet_ntoa (*best) : "<none>" );
  330. if (best == NULL)
  331. return 1;
  332. if ( IPV4_ADDR_CMP (&best, &area->ospf->router_id) < 0)
  333. return 1;
  334. else
  335. return 0;
  336. }
  337. /* Check NSSA ABR status
  338. * assumes there are nssa areas
  339. */
  340. void
  341. ospf_abr_nssa_check_status (struct ospf *ospf)
  342. {
  343. struct ospf_area *area;
  344. listnode lnode;
  345. LIST_LOOP (ospf->areas, area, lnode)
  346. {
  347. if (area->external_routing != OSPF_AREA_NSSA)
  348. continue;
  349. if (IS_DEBUG_OSPF (nssa, NSSA))
  350. zlog_info ("ospf_abr_nssa_check_status: "
  351. "checking area %s",
  352. inet_ntoa (area->area_id));
  353. if (!IS_OSPF_ABR (area->ospf))
  354. {
  355. if (IS_DEBUG_OSPF (nssa, NSSA))
  356. zlog_info ("ospf_abr_nssa_check_status: "
  357. "not ABR");
  358. area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED;
  359. continue;
  360. }
  361. switch (area->NSSATranslatorRole)
  362. {
  363. case OSPF_NSSA_ROLE_NEVER:
  364. /* We never Translate Type-7 LSA. */
  365. /* TODO: check previous state and flush? */
  366. if (IS_DEBUG_OSPF (nssa, NSSA))
  367. zlog_info ("ospf_abr_nssa_check_status: "
  368. "never translate");
  369. area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED;
  370. continue;
  371. case OSPF_NSSA_ROLE_ALWAYS:
  372. /* We always translate if we are an ABR
  373. * TODO: originate new LSAs if state change?
  374. * or let the nssa abr task take care of it?
  375. */
  376. if (IS_DEBUG_OSPF (nssa, NSSA))
  377. zlog_info ("ospf_abr_nssa_check_status: "
  378. "translate always");
  379. area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_ENABLED;
  380. continue;
  381. case OSPF_NSSA_ROLE_CANDIDATE:
  382. /* We are a candidate for Translation */
  383. if (ospf_abr_nssa_am_elected (area) > 0 )
  384. {
  385. area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_ENABLED;
  386. if (IS_DEBUG_OSPF (nssa, NSSA))
  387. zlog_info ("ospf_abr_nssa_check_status: "
  388. "elected translator");
  389. }
  390. else
  391. {
  392. area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED;
  393. if (IS_DEBUG_OSPF (nssa, NSSA))
  394. zlog_info ("ospf_abr_nssa_check_status: "
  395. "not elected");
  396. }
  397. continue;
  398. }
  399. }
  400. }
  401. #endif /* HAVE_NSSA */
  402. /* Check area border router status. */
  403. void
  404. ospf_check_abr_status (struct ospf *ospf)
  405. {
  406. struct ospf_area *area;
  407. listnode node;
  408. int bb_configured = 0;
  409. int bb_act_attached = 0;
  410. int areas_configured = 0;
  411. int areas_act_attached = 0;
  412. u_char new_flags = ospf->flags;
  413. if (IS_DEBUG_OSPF_EVENT)
  414. zlog_info ("ospf_check_abr_status(): Start");
  415. for (node = listhead (ospf->areas); node; nextnode (node))
  416. {
  417. area = getdata (node);
  418. if (listcount (area->oiflist))
  419. {
  420. areas_configured++;
  421. if (OSPF_IS_AREA_BACKBONE (area))
  422. bb_configured = 1;
  423. }
  424. if (ospf_area_actively_attached (area))
  425. {
  426. areas_act_attached++;
  427. if (OSPF_IS_AREA_BACKBONE (area))
  428. bb_act_attached = 1;
  429. }
  430. }
  431. if (IS_DEBUG_OSPF_EVENT)
  432. {
  433. zlog_info ("ospf_check_abr_status(): looked through areas");
  434. zlog_info ("ospf_check_abr_status(): bb_configured: %d", bb_configured);
  435. zlog_info ("ospf_check_abr_status(): bb_act_attached: %d",
  436. bb_act_attached);
  437. zlog_info ("ospf_check_abr_status(): areas_configured: %d",
  438. areas_configured);
  439. zlog_info ("ospf_check_abr_status(): areas_act_attached: %d",
  440. areas_act_attached);
  441. }
  442. switch (ospf->abr_type)
  443. {
  444. case OSPF_ABR_SHORTCUT:
  445. case OSPF_ABR_STAND:
  446. if (areas_act_attached > 1)
  447. SET_FLAG (new_flags, OSPF_FLAG_ABR);
  448. else
  449. UNSET_FLAG (new_flags, OSPF_FLAG_ABR);
  450. break;
  451. case OSPF_ABR_IBM:
  452. if ((areas_act_attached > 1) && bb_configured)
  453. SET_FLAG (new_flags, OSPF_FLAG_ABR);
  454. else
  455. UNSET_FLAG (new_flags, OSPF_FLAG_ABR);
  456. break;
  457. case OSPF_ABR_CISCO:
  458. if ((areas_configured > 1) && bb_act_attached)
  459. SET_FLAG (new_flags, OSPF_FLAG_ABR);
  460. else
  461. UNSET_FLAG (new_flags, OSPF_FLAG_ABR);
  462. break;
  463. default:
  464. break;
  465. }
  466. if (new_flags != ospf->flags)
  467. {
  468. ospf_spf_calculate_schedule (ospf);
  469. if (IS_DEBUG_OSPF_EVENT)
  470. zlog_info ("ospf_check_abr_status(): new router flags: %x",new_flags);
  471. ospf->flags = new_flags;
  472. OSPF_TIMER_ON (ospf->t_router_lsa_update,
  473. ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY);
  474. }
  475. }
  476. void
  477. ospf_abr_update_aggregate (struct ospf_area_range *range,
  478. struct ospf_route *or)
  479. {
  480. if (IS_DEBUG_OSPF_EVENT)
  481. zlog_info ("ospf_abr_update_aggregate(): Start");
  482. if (range->cost_config != -1)
  483. {
  484. if (IS_DEBUG_OSPF_EVENT)
  485. zlog_info ("ospf_abr_update_aggregate(): use configured cost %d",
  486. range->cost_config);
  487. range->cost = range->cost_config;
  488. }
  489. else
  490. {
  491. if (range->specifics == 0)
  492. range->cost = or->cost; /* 1st time get 1st cost */
  493. if (or->cost > range->cost)
  494. {
  495. if (IS_DEBUG_OSPF_EVENT)
  496. zlog_info ("ospf_abr_update_aggregate(): lowest cost, update");
  497. range->cost = or->cost;
  498. }
  499. }
  500. range->specifics++;
  501. }
  502. static void
  503. set_metric (struct ospf_lsa *lsa, u_int32_t metric)
  504. {
  505. struct summary_lsa *header;
  506. u_char *mp;
  507. metric = htonl (metric);
  508. mp = (char *) &metric;
  509. mp++;
  510. header = (struct summary_lsa *) lsa->data;
  511. memcpy(header->metric, mp, 3);
  512. }
  513. #ifdef HAVE_NSSA
  514. int
  515. ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost,
  516. struct ospf_area *area)
  517. {
  518. /* The Type-7 is tested against the aggregated prefix and forwarded
  519. for lsa installation and flooding */
  520. return 0;
  521. }
  522. /* ospf_abr_translate_nssa */
  523. int
  524. ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa)
  525. {
  526. /* Incoming Type-7 or later aggregated Type-7
  527. *
  528. * LSA is skipped if P-bit is off.
  529. * LSA is aggregated if within range.
  530. *
  531. * The Type-7 is translated, Installed/Approved as a Type-5 into
  532. * global LSDB, then Flooded through AS
  533. *
  534. * Later, any Unapproved Translated Type-5's are flushed/discarded
  535. */
  536. struct ospf_lsa *old = NULL,
  537. *new = NULL;
  538. struct as_external_lsa *ext7;
  539. struct prefix_ipv4 p;
  540. if (! CHECK_FLAG (lsa->data->options, OSPF_OPTION_NP))
  541. {
  542. if (IS_DEBUG_OSPF_NSSA)
  543. zlog_info ("ospf_abr_translate_nssa(): LSA Id %s, P-bit off, NO Translation",
  544. inet_ntoa (lsa->data->id));
  545. return 1;
  546. }
  547. if (IS_DEBUG_OSPF_NSSA)
  548. zlog_info ("ospf_abr_translate_nssa(): LSA Id %s, TRANSLATING 7 to 5",
  549. inet_ntoa (lsa->data->id));
  550. ext7 = (struct as_external_lsa *)(lsa->data);
  551. p.prefix = lsa->data->id;
  552. p.prefixlen = ip_masklen (ext7->mask);
  553. if (ext7->e[0].fwd_addr.s_addr == OSPF_DEFAULT_DESTINATION)
  554. {
  555. if (IS_DEBUG_OSPF_NSSA)
  556. zlog_info ("ospf_abr_translate_nssa(): LSA Id %s, "
  557. "Forward address is 0, NO Translation",
  558. inet_ntoa (lsa->data->id));
  559. return 1;
  560. }
  561. /* try find existing AS-External LSA for this prefix */
  562. old = ospf_external_info_find_lsa (area->ospf, &p);
  563. if (old)
  564. {
  565. if (IS_DEBUG_OSPF_NSSA)
  566. zlog_info ("ospf_abr_translate_nssa(): "
  567. "found old translated LSA Id %s, refreshing",
  568. inet_ntoa (old->data->id));
  569. /* refresh */
  570. new = ospf_translated_nssa_refresh (area->ospf, lsa, old);
  571. if (!new)
  572. {
  573. if (IS_DEBUG_OSPF_NSSA)
  574. zlog_info ("ospf_abr_translate_nssa(): "
  575. "could not refresh translated LSA Id %s",
  576. inet_ntoa (old->data->id));
  577. }
  578. }
  579. else
  580. {
  581. /* no existing external route for this LSA Id
  582. * originate translated LSA
  583. */
  584. if ((new = ospf_translated_nssa_originate (area->ospf, lsa))
  585. == NULL)
  586. {
  587. if (IS_DEBUG_OSPF_NSSA)
  588. zlog_info ("ospf_abr_translate_nssa(): Could not translate "
  589. "Type-7 for %s to Type-5",
  590. inet_ntoa (lsa->data->id));
  591. return 1;
  592. }
  593. }
  594. /* Area where Aggregate testing will be inserted, just like summary
  595. advertisements */
  596. /* ospf_abr_check_nssa_range (p_arg, lsa-> cost, lsa -> area); */
  597. return 0;
  598. }
  599. void
  600. ospf_abr_translate_nssa_range (struct prefix_ipv4 *p, u_int32_t cost)
  601. {
  602. /* The Type-7 is created from the aggregated prefix and forwarded
  603. for lsa installation and flooding... to be added... */
  604. }
  605. #endif /* HAVE_NSSA */
  606. void
  607. ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost,
  608. struct ospf_area *area)
  609. {
  610. struct ospf_lsa *lsa, *old = NULL;
  611. struct summary_lsa *sl = NULL;
  612. if (IS_DEBUG_OSPF_EVENT)
  613. zlog_info ("ospf_abr_announce_network_to_area(): Start");
  614. old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_SUMMARY_LSA,
  615. (struct prefix_ipv4 *) p,
  616. area->ospf->router_id);
  617. if (old)
  618. {
  619. if (IS_DEBUG_OSPF_EVENT)
  620. zlog_info ("ospf_abr_announce_network_to_area(): old summary found");
  621. sl = (struct summary_lsa *) old->data;
  622. if (IS_DEBUG_OSPF_EVENT)
  623. zlog_info ("ospf_abr_announce_network_to_area(): "
  624. "old metric: %d, new metric: %d",
  625. GET_METRIC (sl->metric), cost);
  626. if (GET_METRIC (sl->metric) == cost)
  627. {
  628. /* unchanged. simply reapprove it */
  629. if (IS_DEBUG_OSPF_EVENT)
  630. zlog_info ("ospf_abr_announce_network_to_area(): "
  631. "old summary approved");
  632. SET_FLAG (old->flags, OSPF_LSA_APPROVED);
  633. }
  634. else
  635. {
  636. /* LSA is changed, refresh it */
  637. if (IS_DEBUG_OSPF_EVENT)
  638. zlog_info ("ospf_abr_announce_network_to_area(): "
  639. "refreshing summary");
  640. set_metric (old, cost);
  641. lsa = ospf_summary_lsa_refresh (area->ospf, old);
  642. /* This will flood through area. */
  643. }
  644. }
  645. else
  646. {
  647. if (IS_DEBUG_OSPF_EVENT)
  648. zlog_info ("ospf_abr_announce_network_to_area(): "
  649. "creating new summary");
  650. lsa = ospf_summary_lsa_originate ( (struct prefix_ipv4 *)p, cost, area);
  651. /* This will flood through area. */
  652. SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
  653. if (IS_DEBUG_OSPF_EVENT)
  654. zlog_info ("ospf_abr_announce_network_to_area(): "
  655. "flooding new version of summary");
  656. }
  657. if (IS_DEBUG_OSPF_EVENT)
  658. zlog_info ("ospf_abr_announce_network_to_area(): Stop");
  659. }
  660. int
  661. ospf_abr_nexthops_belong_to_area (struct ospf_route *or,
  662. struct ospf_area *area)
  663. {
  664. listnode node;
  665. struct ospf_path *path;
  666. LIST_LOOP (or->paths, path, node)
  667. {
  668. struct ospf_interface *oi = path->oi;
  669. if (oi != NULL)
  670. if (oi->area == area)
  671. return 1;
  672. }
  673. return 0;
  674. }
  675. int
  676. ospf_abr_should_accept (struct prefix_ipv4 *p, struct ospf_area *area)
  677. {
  678. if (IMPORT_NAME (area))
  679. {
  680. if (IMPORT_LIST (area) == NULL)
  681. IMPORT_LIST (area) = access_list_lookup (AFI_IP, IMPORT_NAME (area));
  682. if (IMPORT_LIST (area))
  683. if (access_list_apply (IMPORT_LIST (area), p) == FILTER_DENY)
  684. return 0;
  685. }
  686. return 1;
  687. }
  688. int
  689. ospf_abr_plist_in_check (struct ospf_area *area, struct ospf_route *or,
  690. struct prefix_ipv4 *p)
  691. {
  692. if (PREFIX_NAME_IN (area))
  693. {
  694. if (PREFIX_LIST_IN (area) == NULL)
  695. PREFIX_LIST_IN (area) = prefix_list_lookup (AFI_IP,
  696. PREFIX_NAME_IN (area));
  697. if (PREFIX_LIST_IN (area))
  698. if (prefix_list_apply (PREFIX_LIST_IN (area), p) != PREFIX_PERMIT)
  699. return 0;
  700. }
  701. return 1;
  702. }
  703. int
  704. ospf_abr_plist_out_check (struct ospf_area *area, struct ospf_route *or,
  705. struct prefix_ipv4 *p)
  706. {
  707. if (PREFIX_NAME_OUT (area))
  708. {
  709. if (PREFIX_LIST_OUT (area) == NULL)
  710. PREFIX_LIST_OUT (area) = prefix_list_lookup (AFI_IP,
  711. PREFIX_NAME_OUT (area));
  712. if (PREFIX_LIST_OUT (area))
  713. if (prefix_list_apply (PREFIX_LIST_OUT (area), p) != PREFIX_PERMIT)
  714. return 0;
  715. }
  716. return 1;
  717. }
  718. void
  719. ospf_abr_announce_network (struct ospf *ospf,
  720. struct prefix_ipv4 *p, struct ospf_route *or)
  721. {
  722. struct ospf_area_range *range;
  723. struct ospf_area *area, *or_area;
  724. listnode node;
  725. if (IS_DEBUG_OSPF_EVENT)
  726. zlog_info ("ospf_abr_announce_network(): Start");
  727. or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
  728. assert (or_area);
  729. for (node = listhead (ospf->areas); node; nextnode (node))
  730. {
  731. area = getdata (node);
  732. if (IS_DEBUG_OSPF_EVENT)
  733. zlog_info ("ospf_abr_announce_network(): looking at area %s",
  734. inet_ntoa (area->area_id));
  735. if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
  736. continue;
  737. if (ospf_abr_nexthops_belong_to_area (or, area))
  738. continue;
  739. if (!ospf_abr_should_accept (p, area))
  740. {
  741. if (IS_DEBUG_OSPF_EVENT)
  742. zlog_info ("ospf_abr_announce_network(): "
  743. "prefix %s/%d was denied by import-list",
  744. inet_ntoa (p->prefix), p->prefixlen);
  745. continue;
  746. }
  747. if (!ospf_abr_plist_in_check (area, or, p))
  748. {
  749. if (IS_DEBUG_OSPF_EVENT)
  750. zlog_info ("ospf_abr_announce_network(): "
  751. "prefix %s/%d was denied by prefix-list",
  752. inet_ntoa (p->prefix), p->prefixlen);
  753. continue;
  754. }
  755. if (area->external_routing != OSPF_AREA_DEFAULT && area->no_summary)
  756. {
  757. if (IS_DEBUG_OSPF_EVENT)
  758. zlog_info ("ospf_abr_announce_network(): "
  759. "area %s is stub and no_summary",
  760. inet_ntoa (area->area_id));
  761. continue;
  762. }
  763. if (or->path_type == OSPF_PATH_INTER_AREA)
  764. {
  765. if (IS_DEBUG_OSPF_EVENT)
  766. zlog_info ("ospf_abr_announce_network(): this is "
  767. "inter-area route to %s/%d",
  768. inet_ntoa (p->prefix), p->prefixlen);
  769. if (!OSPF_IS_AREA_BACKBONE (area))
  770. ospf_abr_announce_network_to_area (p, or->cost, area);
  771. }
  772. if (or->path_type == OSPF_PATH_INTRA_AREA)
  773. {
  774. if (IS_DEBUG_OSPF_EVENT)
  775. zlog_info ("ospf_abr_announce_network(): "
  776. "this is intra-area route to %s/%d",
  777. inet_ntoa (p->prefix), p->prefixlen);
  778. if ((range = ospf_area_range_match (or_area, p))
  779. && !ospf_area_is_transit (area))
  780. ospf_abr_update_aggregate (range, or);
  781. else
  782. ospf_abr_announce_network_to_area (p, or->cost, area);
  783. }
  784. }
  785. }
  786. int
  787. ospf_abr_should_announce (struct ospf *ospf,
  788. struct prefix_ipv4 *p, struct ospf_route *or)
  789. {
  790. struct ospf_area *area;
  791. area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
  792. assert (area);
  793. if (EXPORT_NAME (area))
  794. {
  795. if (EXPORT_LIST (area) == NULL)
  796. EXPORT_LIST (area) = access_list_lookup (AFI_IP, EXPORT_NAME (area));
  797. if (EXPORT_LIST (area))
  798. if (access_list_apply (EXPORT_LIST (area), p) == FILTER_DENY)
  799. return 0;
  800. }
  801. return 1;
  802. }
  803. #ifdef HAVE_NSSA
  804. void
  805. ospf_abr_process_nssa_translates (struct ospf *ospf)
  806. {
  807. /* Scan through all NSSA_LSDB records for all areas;
  808. If P-bit is on, translate all Type-7's to 5's and aggregate or
  809. flood install as approved in Type-5 LSDB with XLATE Flag on
  810. later, do same for all aggregates... At end, DISCARD all
  811. remaining UNAPPROVED Type-5's (Aggregate is for future ) */
  812. listnode node;
  813. struct ospf_area *area;
  814. struct route_node *rn;
  815. struct ospf_lsa *lsa;
  816. if (IS_DEBUG_OSPF_NSSA)
  817. zlog_info ("ospf_abr_process_nssa_translates(): Start");
  818. for (node = listhead (ospf->areas); node; nextnode (node))
  819. {
  820. area = getdata (node);
  821. if (! area->NSSATranslatorState)
  822. continue; /* skip if not translator */
  823. if (area->external_routing != OSPF_AREA_NSSA)
  824. continue; /* skip if not Nssa Area */
  825. if (IS_DEBUG_OSPF_NSSA)
  826. zlog_info ("ospf_abr_process_nssa_translates(): "
  827. "looking at area %s", inet_ntoa (area->area_id));
  828. LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
  829. ospf_abr_translate_nssa (area, lsa);
  830. }
  831. if (IS_DEBUG_OSPF_NSSA)
  832. zlog_info ("ospf_abr_process_nssa_translates(): Stop");
  833. }
  834. #endif /* HAVE_NSSA */
  835. void
  836. ospf_abr_process_network_rt (struct ospf *ospf,
  837. struct route_table *rt)
  838. {
  839. struct ospf_area *area;
  840. struct ospf_route *or;
  841. struct route_node *rn;
  842. if (IS_DEBUG_OSPF_EVENT)
  843. zlog_info ("ospf_abr_process_network_rt(): Start");
  844. for (rn = route_top (rt); rn; rn = route_next (rn))
  845. {
  846. if ((or = rn->info) == NULL)
  847. continue;
  848. if (!(area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id)))
  849. {
  850. if (IS_DEBUG_OSPF_EVENT)
  851. zlog_info ("ospf_abr_process_network_rt(): area %s no longer exists",
  852. inet_ntoa (or->u.std.area_id));
  853. continue;
  854. }
  855. if (IS_DEBUG_OSPF_EVENT)
  856. zlog_info ("ospf_abr_process_network_rt(): this is a route to %s/%d",
  857. inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
  858. if (or->path_type >= OSPF_PATH_TYPE1_EXTERNAL)
  859. {
  860. if (IS_DEBUG_OSPF_EVENT)
  861. zlog_info ("ospf_abr_process_network_rt(): "
  862. "this is an External router, skipping");
  863. continue;
  864. }
  865. if (or->cost >= OSPF_LS_INFINITY)
  866. {
  867. if (IS_DEBUG_OSPF_EVENT)
  868. zlog_info ("ospf_abr_process_network_rt():"
  869. " this route's cost is infinity, skipping");
  870. continue;
  871. }
  872. if (or->type == OSPF_DESTINATION_DISCARD)
  873. {
  874. if (IS_DEBUG_OSPF_EVENT)
  875. zlog_info ("ospf_abr_process_network_rt():"
  876. " this is a discard entry, skipping");
  877. continue;
  878. }
  879. if (or->path_type == OSPF_PATH_INTRA_AREA &&
  880. !ospf_abr_should_announce (ospf, (struct prefix_ipv4 *) &rn->p, or))
  881. {
  882. if (IS_DEBUG_OSPF_EVENT)
  883. zlog_info("ospf_abr_process_network_rt(): denied by export-list");
  884. continue;
  885. }
  886. if (or->path_type == OSPF_PATH_INTRA_AREA &&
  887. !ospf_abr_plist_out_check (area, or, (struct prefix_ipv4 *) &rn->p))
  888. {
  889. if (IS_DEBUG_OSPF_EVENT)
  890. zlog_info("ospf_abr_process_network_rt(): denied by prefix-list");
  891. continue;
  892. }
  893. if ((or->path_type == OSPF_PATH_INTER_AREA) &&
  894. !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
  895. {
  896. if (IS_DEBUG_OSPF_EVENT)
  897. zlog_info ("ospf_abr_process_network_rt():"
  898. " this is route is not backbone one, skipping");
  899. continue;
  900. }
  901. if ((ospf->abr_type == OSPF_ABR_CISCO) ||
  902. (ospf->abr_type == OSPF_ABR_IBM))
  903. if (!ospf_act_bb_connection (ospf) &&
  904. or->path_type != OSPF_PATH_INTRA_AREA)
  905. {
  906. if (IS_DEBUG_OSPF_EVENT)
  907. zlog_info ("ospf_abr_process_network_rt(): ALT ABR: "
  908. "No BB connection, skip not intra-area routes");
  909. continue;
  910. }
  911. if (IS_DEBUG_OSPF_EVENT)
  912. zlog_info ("ospf_abr_process_network_rt(): announcing");
  913. ospf_abr_announce_network (ospf, (struct prefix_ipv4 *)&rn->p, or);
  914. }
  915. if (IS_DEBUG_OSPF_EVENT)
  916. zlog_info ("ospf_abr_process_network_rt(): Stop");
  917. }
  918. void
  919. ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
  920. struct ospf_area *area)
  921. {
  922. struct ospf_lsa *lsa, *old = NULL;
  923. struct summary_lsa *slsa = NULL;
  924. if (IS_DEBUG_OSPF_EVENT)
  925. zlog_info ("ospf_abr_announce_rtr_to_area(): Start");
  926. old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_ASBR_SUMMARY_LSA,
  927. p, area->ospf->router_id);
  928. if (old)
  929. {
  930. if (IS_DEBUG_OSPF_EVENT)
  931. zlog_info ("ospf_abr_announce_rtr_to_area(): old summary found");
  932. slsa = (struct summary_lsa *) old->data;
  933. if (IS_DEBUG_OSPF_EVENT)
  934. zlog_info ("ospf_abr_announce_network_to_area(): "
  935. "old metric: %d, new metric: %d",
  936. GET_METRIC (slsa->metric), cost);
  937. }
  938. if (old && (GET_METRIC (slsa->metric) == cost))
  939. {
  940. if (IS_DEBUG_OSPF_EVENT)
  941. zlog_info ("ospf_abr_announce_rtr_to_area(): old summary approved");
  942. SET_FLAG (old->flags, OSPF_LSA_APPROVED);
  943. }
  944. else
  945. {
  946. if (IS_DEBUG_OSPF_EVENT)
  947. zlog_info ("ospf_abr_announce_rtr_to_area(): 2.2");
  948. if (old)
  949. {
  950. set_metric (old, cost);
  951. lsa = ospf_summary_asbr_lsa_refresh (area->ospf, old);
  952. }
  953. else
  954. lsa = ospf_summary_asbr_lsa_originate (p, cost, area);
  955. if (IS_DEBUG_OSPF_EVENT)
  956. zlog_info ("ospf_abr_announce_rtr_to_area(): "
  957. "flooding new version of summary");
  958. /*
  959. zlog_info ("ospf_abr_announce_rtr_to_area(): creating new summary");
  960. lsa = ospf_summary_asbr_lsa (p, cost, area, old); */
  961. SET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
  962. /* ospf_flood_through_area (area, NULL, lsa);*/
  963. }
  964. if (IS_DEBUG_OSPF_EVENT)
  965. zlog_info ("ospf_abr_announce_rtr_to_area(): Stop");
  966. }
  967. void
  968. ospf_abr_announce_rtr (struct ospf *ospf,
  969. struct prefix_ipv4 *p, struct ospf_route *or)
  970. {
  971. listnode node;
  972. struct ospf_area *area;
  973. if (IS_DEBUG_OSPF_EVENT)
  974. zlog_info ("ospf_abr_announce_rtr(): Start");
  975. for (node = listhead (ospf->areas); node; nextnode (node))
  976. {
  977. area = getdata (node);
  978. if (IS_DEBUG_OSPF_EVENT)
  979. zlog_info ("ospf_abr_announce_rtr(): looking at area %s",
  980. inet_ntoa (area->area_id));
  981. if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
  982. continue;
  983. if (ospf_abr_nexthops_belong_to_area (or, area))
  984. continue;
  985. if (area->external_routing != OSPF_AREA_DEFAULT)
  986. {
  987. if (IS_DEBUG_OSPF_EVENT)
  988. zlog_info ("ospf_abr_announce_rtr(): "
  989. "area %s doesn't support external routing",
  990. inet_ntoa(area->area_id));
  991. continue;
  992. }
  993. if (or->path_type == OSPF_PATH_INTER_AREA)
  994. {
  995. if (IS_DEBUG_OSPF_EVENT)
  996. zlog_info ("ospf_abr_announce_rtr(): "
  997. "this is inter-area route to %s", inet_ntoa (p->prefix));
  998. if (!OSPF_IS_AREA_BACKBONE (area))
  999. ospf_abr_announce_rtr_to_area (p, or->cost, area);
  1000. }
  1001. if (or->path_type == OSPF_PATH_INTRA_AREA)
  1002. {
  1003. if (IS_DEBUG_OSPF_EVENT)
  1004. zlog_info ("ospf_abr_announce_rtr(): "
  1005. "this is intra-area route to %s", inet_ntoa (p->prefix));
  1006. ospf_abr_announce_rtr_to_area (p, or->cost, area);
  1007. }
  1008. }
  1009. if (IS_DEBUG_OSPF_EVENT)
  1010. zlog_info ("ospf_abr_announce_rtr(): Stop");
  1011. }
  1012. void
  1013. ospf_abr_process_router_rt (struct ospf *ospf, struct route_table *rt)
  1014. {
  1015. struct ospf_route *or;
  1016. struct route_node *rn;
  1017. struct list *l;
  1018. if (IS_DEBUG_OSPF_EVENT)
  1019. zlog_info ("ospf_abr_process_router_rt(): Start");
  1020. for (rn = route_top (rt); rn; rn = route_next (rn))
  1021. {
  1022. listnode node;
  1023. char flag = 0;
  1024. struct ospf_route *best = NULL;
  1025. if (rn->info == NULL)
  1026. continue;
  1027. l = rn->info;
  1028. if (IS_DEBUG_OSPF_EVENT)
  1029. zlog_info ("ospf_abr_process_router_rt(): this is a route to %s",
  1030. inet_ntoa (rn->p.u.prefix4));
  1031. for (node = listhead (l); node; nextnode (node))
  1032. {
  1033. or = getdata (node);
  1034. if (or == NULL)
  1035. continue;
  1036. if (!ospf_area_lookup_by_area_id (ospf, or->u.std.area_id))
  1037. {
  1038. if (IS_DEBUG_OSPF_EVENT)
  1039. zlog_info ("ospf_abr_process_router_rt(): area %s no longer exists",
  1040. inet_ntoa (or->u.std.area_id));
  1041. continue;
  1042. }
  1043. if (!CHECK_FLAG (or->u.std.flags, ROUTER_LSA_EXTERNAL))
  1044. {
  1045. if (IS_DEBUG_OSPF_EVENT)
  1046. zlog_info ("ospf_abr_process_router_rt(): "
  1047. "This is not an ASBR, skipping");
  1048. continue;
  1049. }
  1050. if (!flag)
  1051. {
  1052. best = ospf_find_asbr_route (ospf, rt,
  1053. (struct prefix_ipv4 *) &rn->p);
  1054. flag = 1;
  1055. }
  1056. if (best == NULL)
  1057. continue;
  1058. if (or != best)
  1059. {
  1060. if (IS_DEBUG_OSPF_EVENT)
  1061. zlog_info ("ospf_abr_process_router_rt(): "
  1062. "This route is not the best among possible, skipping");
  1063. continue;
  1064. }
  1065. if (or->path_type == OSPF_PATH_INTER_AREA &&
  1066. !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
  1067. {
  1068. if (IS_DEBUG_OSPF_EVENT)
  1069. zlog_info ("ospf_abr_process_router_rt(): "
  1070. "This route is not a backbone one, skipping");
  1071. continue;
  1072. }
  1073. if (or->cost >= OSPF_LS_INFINITY)
  1074. {
  1075. if (IS_DEBUG_OSPF_EVENT)
  1076. zlog_info ("ospf_abr_process_router_rt(): "
  1077. "This route has LS_INFINITY metric, skipping");
  1078. continue;
  1079. }
  1080. if (ospf->abr_type == OSPF_ABR_CISCO
  1081. || ospf->abr_type == OSPF_ABR_IBM)
  1082. if (!ospf_act_bb_connection (ospf)
  1083. && or->path_type != OSPF_PATH_INTRA_AREA)
  1084. {
  1085. if (IS_DEBUG_OSPF_EVENT)
  1086. zlog_info("ospf_abr_process_network_rt(): ALT ABR: "
  1087. "No BB connection, skip not intra-area routes");
  1088. continue;
  1089. }
  1090. ospf_abr_announce_rtr (ospf, (struct prefix_ipv4 *) &rn->p, or);
  1091. }
  1092. }
  1093. if (IS_DEBUG_OSPF_EVENT)
  1094. zlog_info ("ospf_abr_process_router_rt(): Stop");
  1095. }
  1096. #ifdef HAVE_NSSA
  1097. void
  1098. ospf_abr_unapprove_translates (struct ospf *ospf) /* For NSSA Translations */
  1099. {
  1100. struct ospf_lsa *lsa;
  1101. struct route_node *rn;
  1102. if (IS_DEBUG_OSPF_NSSA)
  1103. zlog_info ("ospf_abr_unapprove_translates(): Start");
  1104. /* NSSA Translator is not checked, because it may have gone away,
  1105. and we would want to flush any residuals anyway */
  1106. LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
  1107. if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
  1108. {
  1109. UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
  1110. if (IS_DEBUG_OSPF_NSSA)
  1111. zlog_info ("ospf_abr_unapprove_translates(): "
  1112. "approved unset on link id %s",
  1113. inet_ntoa (lsa->data->id));
  1114. }
  1115. if (IS_DEBUG_OSPF_NSSA)
  1116. zlog_info ("ospf_abr_unapprove_translates(): Stop");
  1117. }
  1118. #endif /* HAVE_NSSA */
  1119. void
  1120. ospf_abr_unapprove_summaries (struct ospf *ospf)
  1121. {
  1122. listnode node;
  1123. struct ospf_area *area;
  1124. struct route_node *rn;
  1125. struct ospf_lsa *lsa;
  1126. if (IS_DEBUG_OSPF_EVENT)
  1127. zlog_info ("ospf_abr_unapprove_summaries(): Start");
  1128. for (node = listhead (ospf->areas); node; nextnode (node))
  1129. {
  1130. area = getdata (node);
  1131. if (IS_DEBUG_OSPF_EVENT)
  1132. zlog_info ("ospf_abr_unapprove_summaries(): "
  1133. "considering area %s",
  1134. inet_ntoa (area->area_id));
  1135. LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
  1136. if (ospf_lsa_is_self_originated (ospf, lsa))
  1137. {
  1138. if (IS_DEBUG_OSPF_EVENT)
  1139. zlog_info ("ospf_abr_unapprove_summaries(): "
  1140. "approved unset on summary link id %s",
  1141. inet_ntoa (lsa->data->id));
  1142. UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
  1143. }
  1144. LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
  1145. if (ospf_lsa_is_self_originated (ospf, lsa))
  1146. {
  1147. if (IS_DEBUG_OSPF_EVENT)
  1148. zlog_info ("ospf_abr_unapprove_summaries(): "
  1149. "approved unset on asbr-summary link id %s",
  1150. inet_ntoa (lsa->data->id));
  1151. UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED);
  1152. }
  1153. }
  1154. if (IS_DEBUG_OSPF_EVENT)
  1155. zlog_info ("ospf_abr_unapprove_summaries(): Stop");
  1156. }
  1157. void
  1158. ospf_abr_prepare_aggregates (struct ospf *ospf)
  1159. {
  1160. listnode node;
  1161. struct route_node *rn;
  1162. struct ospf_area_range *range;
  1163. if (IS_DEBUG_OSPF_EVENT)
  1164. zlog_info ("ospf_abr_prepare_aggregates(): Start");
  1165. for (node = listhead (ospf->areas); node; nextnode (node))
  1166. {
  1167. struct ospf_area *area = getdata (node);
  1168. for (rn = route_top (area->ranges); rn; rn = route_next (rn))
  1169. if ((range = rn->info) != NULL)
  1170. {
  1171. range->cost = 0;
  1172. range->specifics = 0;
  1173. }
  1174. }
  1175. if (IS_DEBUG_OSPF_EVENT)
  1176. zlog_info ("ospf_abr_prepare_aggregates(): Stop");
  1177. }
  1178. void
  1179. ospf_abr_announce_aggregates (struct ospf *ospf)
  1180. {
  1181. struct ospf_area *area, *ar;
  1182. struct ospf_area_range *range;
  1183. struct route_node *rn;
  1184. struct prefix p;
  1185. listnode node, n;
  1186. if (IS_DEBUG_OSPF_EVENT)
  1187. zlog_info ("ospf_abr_announce_aggregates(): Start");
  1188. for (node = listhead (ospf->areas); node; nextnode (node))
  1189. {
  1190. area = getdata (node);
  1191. if (IS_DEBUG_OSPF_EVENT)
  1192. zlog_info ("ospf_abr_announce_aggregates(): looking at area %s",
  1193. inet_ntoa (area->area_id));
  1194. for (rn = route_top (area->ranges); rn; rn = route_next (rn))
  1195. if ((range = rn->info))
  1196. {
  1197. if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
  1198. {
  1199. if (IS_DEBUG_OSPF_EVENT)
  1200. zlog_info ("ospf_abr_announce_aggregates():"
  1201. " discarding suppress-ranges");
  1202. continue;
  1203. }
  1204. p.family = AF_INET;
  1205. p.u.prefix4 = range->addr;
  1206. p.prefixlen = range->masklen;
  1207. if (IS_DEBUG_OSPF_EVENT)
  1208. zlog_info ("ospf_abr_announce_aggregates():"
  1209. " this is range: %s/%d",
  1210. inet_ntoa (p.u.prefix4), p.prefixlen);
  1211. if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
  1212. {
  1213. p.family = AF_INET;
  1214. p.u.prefix4 = range->subst_addr;
  1215. p.prefixlen = range->subst_masklen;
  1216. }
  1217. if (range->specifics)
  1218. {
  1219. if (IS_DEBUG_OSPF_EVENT)
  1220. zlog_info ("ospf_abr_announce_aggregates(): active range");
  1221. for (n = listhead (ospf->areas); n; nextnode (n))
  1222. {
  1223. ar = getdata (n);
  1224. if (ar == area)
  1225. continue;
  1226. /* We do not check nexthops here, because
  1227. intra-area routes can be associated with
  1228. one area only */
  1229. /* backbone routes are not summarized
  1230. when announced into transit areas */
  1231. if (ospf_area_is_transit (ar) &&
  1232. OSPF_IS_AREA_BACKBONE (area))
  1233. {
  1234. if (IS_DEBUG_OSPF_EVENT)
  1235. zlog_info ("ospf_abr_announce_aggregates(): Skipping "
  1236. "announcement of BB aggregate into"
  1237. " a transit area");
  1238. continue;
  1239. }
  1240. ospf_abr_announce_network_to_area ((struct prefix_ipv4 *)&p, range->cost, ar);
  1241. }
  1242. }
  1243. }
  1244. }
  1245. if (IS_DEBUG_OSPF_EVENT)
  1246. zlog_info ("ospf_abr_announce_aggregates(): Stop");
  1247. }
  1248. #ifdef HAVE_NSSA
  1249. void
  1250. ospf_abr_send_nssa_aggregates (struct ospf *ospf) /* temporarily turned off */
  1251. {
  1252. listnode node; /*, n; */
  1253. struct ospf_area *area; /*, *ar; */
  1254. struct route_node *rn;
  1255. struct ospf_area_range *range;
  1256. struct prefix_ipv4 p;
  1257. if (IS_DEBUG_OSPF_NSSA)
  1258. zlog_info ("ospf_abr_send_nssa_aggregates(): Start");
  1259. for (node = listhead (ospf->areas); node; nextnode (node))
  1260. {
  1261. area = getdata (node);
  1262. if (! area->NSSATranslatorState)
  1263. continue;
  1264. if (IS_DEBUG_OSPF_NSSA)
  1265. zlog_info ("ospf_abr_send_nssa_aggregates(): looking at area %s",
  1266. inet_ntoa (area->area_id));
  1267. for (rn = route_top (area->ranges); rn; rn = route_next (rn))
  1268. {
  1269. if (rn->info == NULL)
  1270. continue;
  1271. range = rn->info;
  1272. if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
  1273. {
  1274. if (IS_DEBUG_OSPF_NSSA)
  1275. zlog_info ("ospf_abr_send_nssa_aggregates():"
  1276. " discarding suppress-ranges");
  1277. continue;
  1278. }
  1279. p.family = AF_INET;
  1280. p.prefix = range->addr;
  1281. p.prefixlen = range->masklen;
  1282. if (IS_DEBUG_OSPF_NSSA)
  1283. zlog_info ("ospf_abr_send_nssa_aggregates():"
  1284. " this is range: %s/%d",
  1285. inet_ntoa (p.prefix), p.prefixlen);
  1286. if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
  1287. {
  1288. p.family = AF_INET;
  1289. p.prefix = range->subst_addr;
  1290. p.prefixlen = range->subst_masklen;
  1291. }
  1292. if (range->specifics)
  1293. {
  1294. if (IS_DEBUG_OSPF_NSSA)
  1295. zlog_info ("ospf_abr_send_nssa_aggregates(): active range");
  1296. /* Fetch LSA-Type-7 from aggregate prefix, and then
  1297. * translate, Install (as Type-5), Approve, and Flood
  1298. */
  1299. ospf_abr_translate_nssa_range (&p, range->cost);
  1300. }
  1301. } /* all area ranges*/
  1302. } /* all areas */
  1303. if (IS_DEBUG_OSPF_NSSA)
  1304. zlog_info ("ospf_abr_send_nssa_aggregates(): Stop");
  1305. }
  1306. void
  1307. ospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */
  1308. {
  1309. listnode node;
  1310. struct ospf_area *area;
  1311. if (! IS_OSPF_ABR (ospf))
  1312. return;
  1313. if (IS_DEBUG_OSPF_NSSA)
  1314. zlog_info ("ospf_abr_announce_stub_defaults(): Start");
  1315. for (node = listhead (ospf->areas); node; nextnode (node))
  1316. {
  1317. area = getdata (node);
  1318. if (IS_DEBUG_OSPF_NSSA)
  1319. zlog_info ("ospf_abr_announce_nssa_defaults(): looking at area %s",
  1320. inet_ntoa (area->area_id));
  1321. if (area->external_routing != OSPF_AREA_NSSA)
  1322. continue;
  1323. if (OSPF_IS_AREA_BACKBONE (area))
  1324. continue; /* Sanity Check */
  1325. /* if (!TranslatorRole continue V 1.0 look for "always" conf */
  1326. if (area->NSSATranslatorState)
  1327. {
  1328. if (IS_DEBUG_OSPF_NSSA)
  1329. zlog_info ("ospf_abr_announce_nssa_defaults(): "
  1330. "announcing 0.0.0.0/0 to this nssa");
  1331. /* ospf_abr_announce_nssa_asbr_to_as (&p, area->default_cost, area); */
  1332. /*ospf_abr_announce_network_to_area (&p, area->default_cost, area);*/
  1333. }
  1334. }
  1335. }
  1336. #endif /* HAVE_NSSA */
  1337. void
  1338. ospf_abr_announce_stub_defaults (struct ospf *ospf)
  1339. {
  1340. listnode node;
  1341. struct ospf_area *area;
  1342. struct prefix_ipv4 p;
  1343. if (! IS_OSPF_ABR (ospf))
  1344. return;
  1345. if (IS_DEBUG_OSPF_EVENT)
  1346. zlog_info ("ospf_abr_announce_stub_defaults(): Start");
  1347. p.family = AF_INET;
  1348. p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
  1349. p.prefixlen = 0;
  1350. for (node = listhead (ospf->areas); node; nextnode (node))
  1351. {
  1352. area = getdata (node);
  1353. if (IS_DEBUG_OSPF_EVENT)
  1354. zlog_info ("ospf_abr_announce_stub_defaults(): looking at area %s",
  1355. inet_ntoa (area->area_id));
  1356. if ( (area->external_routing != OSPF_AREA_STUB)
  1357. #ifdef HAVE_NSSA
  1358. && (area->external_routing != OSPF_AREA_NSSA)
  1359. #endif /* HAVE_NSSA */
  1360. )
  1361. continue;
  1362. if (OSPF_IS_AREA_BACKBONE (area))
  1363. continue; /* Sanity Check */
  1364. if (area->no_summary)
  1365. continue;
  1366. if (IS_DEBUG_OSPF_EVENT)
  1367. zlog_info ("ospf_abr_announce_stub_defaults(): "
  1368. "announcing 0.0.0.0/0 to area %s",
  1369. inet_ntoa (area->area_id));
  1370. ospf_abr_announce_network_to_area (&p, area->default_cost, area);
  1371. }
  1372. if (IS_DEBUG_OSPF_EVENT)
  1373. zlog_info ("ospf_abr_announce_stub_defaults(): Stop");
  1374. }
  1375. #ifdef HAVE_NSSA
  1376. int
  1377. ospf_abr_remove_unapproved_translates_apply (struct ospf *ospf,
  1378. struct ospf_lsa *lsa)
  1379. {
  1380. if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)
  1381. && ! CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
  1382. {
  1383. zlog_info ("ospf_abr_remove_unapproved_translates(): "
  1384. "removing unapproved translates, ID: %s",
  1385. inet_ntoa (lsa->data->id));
  1386. /* FLUSH THROUGHOUT AS */
  1387. ospf_lsa_flush_as (ospf, lsa);
  1388. /* DISCARD from LSDB */
  1389. }
  1390. return 0;
  1391. }
  1392. void
  1393. ospf_abr_remove_unapproved_translates (struct ospf *ospf)
  1394. {
  1395. struct route_node *rn;
  1396. struct ospf_lsa *lsa;
  1397. /* All AREA PROCESS should have APPROVED necessary LSAs */
  1398. /* Remove any left over and not APPROVED */
  1399. if (IS_DEBUG_OSPF_NSSA)
  1400. zlog_info ("ospf_abr_remove_unapproved_translates(): Start");
  1401. LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
  1402. ospf_abr_remove_unapproved_translates_apply (ospf, lsa);
  1403. if (IS_DEBUG_OSPF_NSSA)
  1404. zlog_info ("ospf_abr_remove_unapproved_translates(): Stop");
  1405. }
  1406. #endif /* HAVE_NSSA */
  1407. void
  1408. ospf_abr_remove_unapproved_summaries (struct ospf *ospf)
  1409. {
  1410. listnode node;
  1411. struct ospf_area *area;
  1412. struct route_node *rn;
  1413. struct ospf_lsa *lsa;
  1414. if (IS_DEBUG_OSPF_EVENT)
  1415. zlog_info ("ospf_abr_remove_unapproved_summaries(): Start");
  1416. for (node = listhead (ospf->areas); node; nextnode (node))
  1417. {
  1418. area = getdata (node);
  1419. if (IS_DEBUG_OSPF_EVENT)
  1420. zlog_info ("ospf_abr_remove_unapproved_summaries(): "
  1421. "looking at area %s", inet_ntoa (area->area_id));
  1422. LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
  1423. if (ospf_lsa_is_self_originated (ospf, lsa))
  1424. if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
  1425. ospf_lsa_flush_area (lsa, area);
  1426. LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
  1427. if (ospf_lsa_is_self_originated (ospf, lsa))
  1428. if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED))
  1429. ospf_lsa_flush_area (lsa, area);
  1430. }
  1431. if (IS_DEBUG_OSPF_EVENT)
  1432. zlog_info ("ospf_abr_remove_unapproved_summaries(): Stop");
  1433. }
  1434. void
  1435. ospf_abr_manage_discard_routes (struct ospf *ospf)
  1436. {
  1437. listnode node;
  1438. struct route_node *rn;
  1439. struct ospf_area *area;
  1440. struct ospf_area_range *range;
  1441. for (node = listhead (ospf->areas); node; nextnode (node))
  1442. if ((area = node->data) != NULL)
  1443. for (rn = route_top (area->ranges); rn; rn = route_next (rn))
  1444. if ((range = rn->info) != NULL)
  1445. if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
  1446. {
  1447. if (range->specifics)
  1448. ospf_add_discard_route (ospf->new_table, area,
  1449. (struct prefix_ipv4 *) &rn->p);
  1450. else
  1451. ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);
  1452. }
  1453. }
  1454. #ifdef HAVE_NSSA
  1455. /* This is the function taking care about ABR NSSA, i.e. NSSA
  1456. Translator, -LSA aggregation and flooding. For all NSSAs
  1457. Any SELF-AS-LSA is in the Type-5 LSDB and Type-7 LSDB. These LSA's
  1458. are refreshed from the Type-5 LSDB, installed into the Type-7 LSDB
  1459. with the P-bit set.
  1460. Any received Type-5s are legal for an ABR, else illegal for IR.
  1461. Received Type-7s are installed, by area, with incoming P-bit. They
  1462. are flooded; if the Elected NSSA Translator, then P-bit off.
  1463. Additionally, this ABR will place "translated type-7's" into the
  1464. Type-5 LSDB in order to keep track of APPROVAL or not.
  1465. It will scan through every area, looking for Type-7 LSAs with P-Bit
  1466. SET. The Type-7's are either AS-FLOODED & 5-INSTALLED or
  1467. AGGREGATED. Later, the AGGREGATED LSAs are AS-FLOODED &
  1468. 5-INSTALLED.
  1469. 5-INSTALLED is into the Type-5 LSDB; Any UNAPPROVED Type-5 LSAs
  1470. left over are FLUSHED and DISCARDED.
  1471. For External Calculations, any NSSA areas use the Type-7 AREA-LSDB,
  1472. any ABR-non-NSSA areas use the Type-5 GLOBAL-LSDB. */
  1473. void
  1474. ospf_abr_nssa_task (struct ospf *ospf) /* called only if any_nssa */
  1475. {
  1476. if (IS_DEBUG_OSPF_NSSA)
  1477. zlog_info ("Check for NSSA-ABR Tasks():");
  1478. if (! IS_OSPF_ABR (ospf))
  1479. return;
  1480. if (! ospf->anyNSSA)
  1481. return;
  1482. /* Each area must confirm TranslatorRole */
  1483. if (IS_DEBUG_OSPF_NSSA)
  1484. zlog_info ("ospf_abr_nssa_task(): Start");
  1485. /* For all Global Entries flagged "local-translate", unset APPROVED */
  1486. if (IS_DEBUG_OSPF_NSSA)
  1487. zlog_info ("ospf_abr_nssa_task(): unapprove translates");
  1488. ospf_abr_unapprove_translates (ospf);
  1489. /* RESET all Ranges in every Area, same as summaries */
  1490. if (IS_DEBUG_OSPF_NSSA)
  1491. zlog_info ("ospf_abr_nssa_task(): NSSA initialize aggregates");
  1492. ospf_abr_prepare_aggregates (ospf); /*TURNED OFF just for now */
  1493. /* For all NSSAs, Type-7s, translate to 5's, INSTALL/FLOOD, or
  1494. * Aggregate as Type-7
  1495. * Install or Approve in Type-5 Global LSDB
  1496. */
  1497. if (IS_DEBUG_OSPF_NSSA)
  1498. zlog_info ("ospf_abr_nssa_task(): process translates");
  1499. ospf_abr_process_nssa_translates (ospf);
  1500. /* Translate/Send any "ranged" aggregates, and also 5-Install and
  1501. * Approve
  1502. * Scan Type-7's for aggregates, translate to Type-5's,
  1503. * Install/Flood/Approve
  1504. */
  1505. if (IS_DEBUG_OSPF_NSSA)
  1506. zlog_info("ospf_abr_nssa_task(): send NSSA aggregates");
  1507. ospf_abr_send_nssa_aggregates (ospf); /*TURNED OFF FOR NOW */
  1508. /* Send any NSSA defaults as Type-5
  1509. *if (IS_DEBUG_OSPF_NSSA)
  1510. * zlog_info ("ospf_abr_nssa_task(): announce nssa defaults");
  1511. *ospf_abr_announce_nssa_defaults (ospf);
  1512. * havnt a clue what above is supposed to do.
  1513. */
  1514. /* Flush any unapproved previous translates from Global Data Base */
  1515. if (IS_DEBUG_OSPF_NSSA)
  1516. zlog_info ("ospf_abr_nssa_task(): remove unapproved translates");
  1517. ospf_abr_remove_unapproved_translates (ospf);
  1518. ospf_abr_manage_discard_routes (ospf); /* same as normal...discard */
  1519. if (IS_DEBUG_OSPF_NSSA)
  1520. zlog_info ("ospf_abr_nssa_task(): Stop");
  1521. }
  1522. #endif /* HAVE_NSSA */
  1523. /* This is the function taking care about ABR stuff, i.e.
  1524. summary-LSA origination and flooding. */
  1525. void
  1526. ospf_abr_task (struct ospf *ospf)
  1527. {
  1528. if (IS_DEBUG_OSPF_EVENT)
  1529. zlog_info ("ospf_abr_task(): Start");
  1530. if (ospf->new_table == NULL || ospf->new_rtrs == NULL)
  1531. {
  1532. if (IS_DEBUG_OSPF_EVENT)
  1533. zlog_info ("ospf_abr_task(): Routing tables are not yet ready");
  1534. return;
  1535. }
  1536. if (IS_DEBUG_OSPF_EVENT)
  1537. zlog_info ("ospf_abr_task(): unapprove summaries");
  1538. ospf_abr_unapprove_summaries (ospf);
  1539. if (IS_DEBUG_OSPF_EVENT)
  1540. zlog_info ("ospf_abr_task(): prepare aggregates");
  1541. ospf_abr_prepare_aggregates (ospf);
  1542. if (IS_OSPF_ABR (ospf))
  1543. {
  1544. if (IS_DEBUG_OSPF_EVENT)
  1545. zlog_info ("ospf_abr_task(): process network RT");
  1546. ospf_abr_process_network_rt (ospf, ospf->new_table);
  1547. if (IS_DEBUG_OSPF_EVENT)
  1548. zlog_info ("ospf_abr_task(): process router RT");
  1549. ospf_abr_process_router_rt (ospf, ospf->new_rtrs);
  1550. if (IS_DEBUG_OSPF_EVENT)
  1551. zlog_info ("ospf_abr_task(): announce aggregates");
  1552. ospf_abr_announce_aggregates (ospf);
  1553. if (IS_DEBUG_OSPF_EVENT)
  1554. zlog_info ("ospf_abr_task(): announce stub defaults");
  1555. ospf_abr_announce_stub_defaults (ospf);
  1556. }
  1557. if (IS_DEBUG_OSPF_EVENT)
  1558. zlog_info ("ospf_abr_task(): remove unapproved summaries");
  1559. ospf_abr_remove_unapproved_summaries (ospf);
  1560. ospf_abr_manage_discard_routes (ospf);
  1561. if (IS_DEBUG_OSPF_EVENT)
  1562. zlog_info ("ospf_abr_task(): Stop");
  1563. }
  1564. int
  1565. ospf_abr_task_timer (struct thread *thread)
  1566. {
  1567. struct ospf *ospf = THREAD_ARG (thread);
  1568. ospf->t_abr_task = 0;
  1569. if (IS_DEBUG_OSPF_EVENT)
  1570. zlog_info ("Running ABR task on timer");
  1571. ospf_check_abr_status (ospf);
  1572. #ifdef HAVE_NSSA
  1573. ospf_abr_nssa_check_status (ospf);
  1574. #endif /* HAVE_NSSA */
  1575. ospf_abr_task (ospf);
  1576. #ifdef HAVE_NSSA
  1577. ospf_abr_nssa_task (ospf); /* if nssa-abr, then scan Type-7 LSDB */
  1578. #endif /* HAVE_NSSA */
  1579. return 0;
  1580. }
  1581. void
  1582. ospf_schedule_abr_task (struct ospf *ospf)
  1583. {
  1584. if (IS_DEBUG_OSPF_EVENT)
  1585. zlog_info ("Scheduling ABR task");
  1586. if (ospf->t_abr_task == NULL)
  1587. ospf->t_abr_task = thread_add_timer (master, ospf_abr_task_timer,
  1588. ospf, OSPF_ABR_TASK_DELAY);
  1589. }