ospf6_interface.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960
  1. /*
  2. * Copyright (C) 2003 Yasuhiro Ohara
  3. *
  4. * This file is part of GNU Zebra.
  5. *
  6. * GNU Zebra is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * GNU Zebra is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #include <zebra.h>
  22. #include "memory.h"
  23. #include "if.h"
  24. #include "log.h"
  25. #include "command.h"
  26. #include "thread.h"
  27. #include "prefix.h"
  28. #include "plist.h"
  29. #include "ospf6_lsa.h"
  30. #include "ospf6_lsdb.h"
  31. #include "ospf6_network.h"
  32. #include "ospf6_message.h"
  33. #include "ospf6_route.h"
  34. #include "ospf6_top.h"
  35. #include "ospf6_area.h"
  36. #include "ospf6_interface.h"
  37. #include "ospf6_neighbor.h"
  38. #include "ospf6_intra.h"
  39. #include "ospf6_spf.h"
  40. #include "ospf6d.h"
  41. unsigned char conf_debug_ospf6_interface = 0;
  42. const char *ospf6_interface_state_str[] =
  43. {
  44. "None",
  45. "Down",
  46. "Loopback",
  47. "Waiting",
  48. "PointToPoint",
  49. "DROther",
  50. "BDR",
  51. "DR",
  52. NULL
  53. };
  54. struct ospf6_interface *
  55. ospf6_interface_lookup_by_ifindex (int ifindex)
  56. {
  57. struct ospf6_interface *oi;
  58. struct interface *ifp;
  59. ifp = if_lookup_by_index (ifindex);
  60. if (ifp == NULL)
  61. return (struct ospf6_interface *) NULL;
  62. oi = (struct ospf6_interface *) ifp->info;
  63. return oi;
  64. }
  65. /* schedule routing table recalculation */
  66. static void
  67. ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa, unsigned int reason)
  68. {
  69. struct ospf6_interface *oi;
  70. if (lsa == NULL)
  71. return;
  72. oi = lsa->lsdb->data;
  73. switch (ntohs (lsa->header->type))
  74. {
  75. case OSPF6_LSTYPE_LINK:
  76. if (oi->state == OSPF6_INTERFACE_DR)
  77. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  78. ospf6_spf_schedule (oi->area->ospf6, reason);
  79. break;
  80. default:
  81. break;
  82. }
  83. }
  84. static void
  85. ospf6_interface_lsdb_hook_add (struct ospf6_lsa *lsa)
  86. {
  87. ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
  88. }
  89. static void
  90. ospf6_interface_lsdb_hook_remove (struct ospf6_lsa *lsa)
  91. {
  92. ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
  93. }
  94. static u_char
  95. ospf6_default_iftype(struct interface *ifp)
  96. {
  97. if (if_is_pointopoint (ifp))
  98. return OSPF_IFTYPE_POINTOPOINT;
  99. else if (if_is_loopback (ifp))
  100. return OSPF_IFTYPE_LOOPBACK;
  101. else
  102. return OSPF_IFTYPE_BROADCAST;
  103. }
  104. static u_int32_t
  105. ospf6_interface_get_cost (struct ospf6_interface *oi)
  106. {
  107. /* If all else fails, use default OSPF cost */
  108. u_int32_t cost;
  109. u_int32_t bw, refbw;
  110. bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
  111. refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
  112. /* A specifed ip ospf cost overrides a calculated one. */
  113. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
  114. cost = oi->cost;
  115. else
  116. {
  117. cost = (u_int32_t) ((double)refbw / (double)bw + (double)0.5);
  118. if (cost < 1) cost = 1;
  119. else if (cost > UINT32_MAX) cost = UINT32_MAX;
  120. }
  121. return cost;
  122. }
  123. static void
  124. ospf6_interface_recalculate_cost (struct ospf6_interface *oi)
  125. {
  126. u_int32_t newcost;
  127. newcost = ospf6_interface_get_cost (oi);
  128. if (newcost == oi->cost) return;
  129. oi->cost = newcost;
  130. /* update cost held in route_connected list in ospf6_interface */
  131. ospf6_interface_connected_route_update (oi->interface);
  132. /* execute LSA hooks */
  133. if (oi->area)
  134. {
  135. OSPF6_LINK_LSA_SCHEDULE (oi);
  136. OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
  137. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  138. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  139. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  140. }
  141. }
  142. /* Create new ospf6 interface structure */
  143. struct ospf6_interface *
  144. ospf6_interface_create (struct interface *ifp)
  145. {
  146. struct ospf6_interface *oi;
  147. unsigned int iobuflen;
  148. oi = (struct ospf6_interface *)
  149. XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
  150. if (!oi)
  151. {
  152. zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
  153. return (struct ospf6_interface *) NULL;
  154. }
  155. oi->area = (struct ospf6_area *) NULL;
  156. oi->neighbor_list = list_new ();
  157. oi->neighbor_list->cmp = ospf6_neighbor_cmp;
  158. oi->linklocal_addr = (struct in6_addr *) NULL;
  159. oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
  160. oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
  161. oi->priority = OSPF6_INTERFACE_PRIORITY;
  162. oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
  163. oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
  164. oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
  165. oi->type = ospf6_default_iftype (ifp);
  166. oi->state = OSPF6_INTERFACE_DOWN;
  167. oi->flag = 0;
  168. oi->mtu_ignore = 0;
  169. /* Try to adjust I/O buffer size with IfMtu */
  170. oi->ifmtu = ifp->mtu6;
  171. iobuflen = ospf6_iobuf_size (ifp->mtu6);
  172. if (oi->ifmtu > iobuflen)
  173. {
  174. if (IS_OSPF6_DEBUG_INTERFACE)
  175. zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
  176. ifp->name, iobuflen);
  177. oi->ifmtu = iobuflen;
  178. }
  179. oi->lsupdate_list = ospf6_lsdb_create (oi);
  180. oi->lsack_list = ospf6_lsdb_create (oi);
  181. oi->lsdb = ospf6_lsdb_create (oi);
  182. oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
  183. oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
  184. oi->lsdb_self = ospf6_lsdb_create (oi);
  185. oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
  186. oi->route_connected->scope = oi;
  187. /* link both */
  188. oi->interface = ifp;
  189. ifp->info = oi;
  190. /* Compute cost. */
  191. oi->cost = ospf6_interface_get_cost(oi);
  192. return oi;
  193. }
  194. void
  195. ospf6_interface_delete (struct ospf6_interface *oi)
  196. {
  197. struct listnode *node, *nnode;
  198. struct ospf6_neighbor *on;
  199. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  200. ospf6_neighbor_delete (on);
  201. list_delete (oi->neighbor_list);
  202. THREAD_OFF (oi->thread_send_hello);
  203. THREAD_OFF (oi->thread_send_lsupdate);
  204. THREAD_OFF (oi->thread_send_lsack);
  205. ospf6_lsdb_remove_all (oi->lsdb);
  206. ospf6_lsdb_remove_all (oi->lsupdate_list);
  207. ospf6_lsdb_remove_all (oi->lsack_list);
  208. ospf6_lsdb_delete (oi->lsdb);
  209. ospf6_lsdb_delete (oi->lsdb_self);
  210. ospf6_lsdb_delete (oi->lsupdate_list);
  211. ospf6_lsdb_delete (oi->lsack_list);
  212. ospf6_route_table_delete (oi->route_connected);
  213. /* cut link */
  214. oi->interface->info = NULL;
  215. /* plist_name */
  216. if (oi->plist_name)
  217. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  218. XFREE (MTYPE_OSPF6_IF, oi);
  219. }
  220. void
  221. ospf6_interface_enable (struct ospf6_interface *oi)
  222. {
  223. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
  224. ospf6_interface_state_update (oi->interface);
  225. }
  226. void
  227. ospf6_interface_disable (struct ospf6_interface *oi)
  228. {
  229. SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
  230. thread_execute (master, interface_down, oi, 0);
  231. ospf6_lsdb_remove_all (oi->lsdb);
  232. ospf6_lsdb_remove_all (oi->lsdb_self);
  233. ospf6_lsdb_remove_all (oi->lsupdate_list);
  234. ospf6_lsdb_remove_all (oi->lsack_list);
  235. THREAD_OFF (oi->thread_send_hello);
  236. THREAD_OFF (oi->thread_send_lsupdate);
  237. THREAD_OFF (oi->thread_send_lsack);
  238. THREAD_OFF (oi->thread_network_lsa);
  239. THREAD_OFF (oi->thread_link_lsa);
  240. THREAD_OFF (oi->thread_intra_prefix_lsa);
  241. }
  242. static struct in6_addr *
  243. ospf6_interface_get_linklocal_address (struct interface *ifp)
  244. {
  245. struct listnode *n;
  246. struct connected *c;
  247. struct in6_addr *l = (struct in6_addr *) NULL;
  248. /* for each connected address */
  249. for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
  250. {
  251. /* if family not AF_INET6, ignore */
  252. if (c->address->family != AF_INET6)
  253. continue;
  254. /* linklocal scope check */
  255. if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
  256. l = &c->address->u.prefix6;
  257. }
  258. return l;
  259. }
  260. void
  261. ospf6_interface_if_add (struct interface *ifp)
  262. {
  263. struct ospf6_interface *oi;
  264. unsigned int iobuflen;
  265. oi = (struct ospf6_interface *) ifp->info;
  266. if (oi == NULL)
  267. return;
  268. /* Try to adjust I/O buffer size with IfMtu */
  269. if (oi->ifmtu == 0)
  270. oi->ifmtu = ifp->mtu6;
  271. iobuflen = ospf6_iobuf_size (ifp->mtu6);
  272. if (oi->ifmtu > iobuflen)
  273. {
  274. if (IS_OSPF6_DEBUG_INTERFACE)
  275. zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
  276. ifp->name, iobuflen);
  277. oi->ifmtu = iobuflen;
  278. }
  279. /* interface start */
  280. ospf6_interface_state_update(oi->interface);
  281. }
  282. void
  283. ospf6_interface_if_del (struct interface *ifp)
  284. {
  285. struct ospf6_interface *oi;
  286. oi = (struct ospf6_interface *) ifp->info;
  287. if (oi == NULL)
  288. return;
  289. /* interface stop */
  290. if (oi->area)
  291. thread_execute (master, interface_down, oi, 0);
  292. listnode_delete (oi->area->if_list, oi);
  293. oi->area = (struct ospf6_area *) NULL;
  294. /* cut link */
  295. oi->interface = NULL;
  296. ifp->info = NULL;
  297. ospf6_interface_delete (oi);
  298. }
  299. void
  300. ospf6_interface_state_update (struct interface *ifp)
  301. {
  302. struct ospf6_interface *oi;
  303. oi = (struct ospf6_interface *) ifp->info;
  304. if (oi == NULL)
  305. return;
  306. if (oi->area == NULL)
  307. return;
  308. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
  309. return;
  310. if (if_is_operative (ifp)
  311. && (ospf6_interface_get_linklocal_address(oi->interface)
  312. || if_is_loopback(oi->interface)))
  313. thread_add_event (master, interface_up, oi, 0);
  314. else
  315. thread_add_event (master, interface_down, oi, 0);
  316. return;
  317. }
  318. void
  319. ospf6_interface_connected_route_update (struct interface *ifp)
  320. {
  321. struct ospf6_interface *oi;
  322. struct ospf6_route *route;
  323. struct connected *c;
  324. struct listnode *node, *nnode;
  325. oi = (struct ospf6_interface *) ifp->info;
  326. if (oi == NULL)
  327. return;
  328. /* reset linklocal pointer */
  329. oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
  330. /* if area is null, do not make connected-route list */
  331. if (oi->area == NULL)
  332. return;
  333. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
  334. return;
  335. /* update "route to advertise" interface route table */
  336. ospf6_route_remove_all (oi->route_connected);
  337. for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
  338. {
  339. if (c->address->family != AF_INET6)
  340. continue;
  341. CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
  342. CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
  343. CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
  344. CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
  345. CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
  346. /* apply filter */
  347. if (oi->plist_name)
  348. {
  349. struct prefix_list *plist;
  350. enum prefix_list_type ret;
  351. char buf[128];
  352. prefix2str (c->address, buf, sizeof (buf));
  353. plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
  354. ret = prefix_list_apply (plist, (void *) c->address);
  355. if (ret == PREFIX_DENY)
  356. {
  357. if (IS_OSPF6_DEBUG_INTERFACE)
  358. zlog_debug ("%s on %s filtered by prefix-list %s ",
  359. buf, oi->interface->name, oi->plist_name);
  360. continue;
  361. }
  362. }
  363. route = ospf6_route_create ();
  364. memcpy (&route->prefix, c->address, sizeof (struct prefix));
  365. apply_mask (&route->prefix);
  366. route->type = OSPF6_DEST_TYPE_NETWORK;
  367. route->path.area_id = oi->area->area_id;
  368. route->path.type = OSPF6_PATH_TYPE_INTRA;
  369. route->path.cost = oi->cost;
  370. route->nexthop[0].ifindex = oi->interface->ifindex;
  371. inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
  372. ospf6_route_add (route, oi->route_connected);
  373. }
  374. /* create new Link-LSA */
  375. OSPF6_LINK_LSA_SCHEDULE (oi);
  376. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  377. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  378. }
  379. static void
  380. ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
  381. {
  382. u_char prev_state;
  383. prev_state = oi->state;
  384. oi->state = next_state;
  385. if (prev_state == next_state)
  386. return;
  387. /* log */
  388. if (IS_OSPF6_DEBUG_INTERFACE)
  389. {
  390. zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
  391. ospf6_interface_state_str[prev_state],
  392. ospf6_interface_state_str[next_state]);
  393. }
  394. oi->state_change++;
  395. if ((prev_state == OSPF6_INTERFACE_DR ||
  396. prev_state == OSPF6_INTERFACE_BDR) &&
  397. (next_state != OSPF6_INTERFACE_DR &&
  398. next_state != OSPF6_INTERFACE_BDR))
  399. ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
  400. if ((prev_state != OSPF6_INTERFACE_DR &&
  401. prev_state != OSPF6_INTERFACE_BDR) &&
  402. (next_state == OSPF6_INTERFACE_DR ||
  403. next_state == OSPF6_INTERFACE_BDR))
  404. ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
  405. OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
  406. if (next_state == OSPF6_INTERFACE_DOWN)
  407. {
  408. OSPF6_NETWORK_LSA_EXECUTE (oi);
  409. OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
  410. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  411. }
  412. else if (prev_state == OSPF6_INTERFACE_DR ||
  413. next_state == OSPF6_INTERFACE_DR)
  414. {
  415. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  416. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  417. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  418. }
  419. #ifdef HAVE_SNMP
  420. /* Terminal state or regression */
  421. if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
  422. (next_state == OSPF6_INTERFACE_DROTHER) ||
  423. (next_state == OSPF6_INTERFACE_BDR) ||
  424. (next_state == OSPF6_INTERFACE_DR) ||
  425. (next_state < prev_state))
  426. ospf6TrapIfStateChange (oi);
  427. #endif
  428. }
  429. /* DR Election, RFC2328 section 9.4 */
  430. #define IS_ELIGIBLE(n) \
  431. ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
  432. static struct ospf6_neighbor *
  433. better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
  434. {
  435. if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
  436. (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
  437. return NULL;
  438. else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
  439. return b;
  440. else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
  441. return a;
  442. if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
  443. return a;
  444. if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
  445. return b;
  446. if (a->priority > b->priority)
  447. return a;
  448. if (a->priority < b->priority)
  449. return b;
  450. if (ntohl (a->router_id) > ntohl (b->router_id))
  451. return a;
  452. if (ntohl (a->router_id) < ntohl (b->router_id))
  453. return b;
  454. zlog_warn ("Router-ID duplicate ?");
  455. return a;
  456. }
  457. static struct ospf6_neighbor *
  458. better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
  459. {
  460. if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
  461. (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
  462. return NULL;
  463. else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
  464. return b;
  465. else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
  466. return a;
  467. if (a->drouter == a->router_id && b->drouter != b->router_id)
  468. return a;
  469. if (a->drouter != a->router_id && b->drouter == b->router_id)
  470. return b;
  471. if (a->priority > b->priority)
  472. return a;
  473. if (a->priority < b->priority)
  474. return b;
  475. if (ntohl (a->router_id) > ntohl (b->router_id))
  476. return a;
  477. if (ntohl (a->router_id) < ntohl (b->router_id))
  478. return b;
  479. zlog_warn ("Router-ID duplicate ?");
  480. return a;
  481. }
  482. static u_char
  483. dr_election (struct ospf6_interface *oi)
  484. {
  485. struct listnode *node, *nnode;
  486. struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
  487. struct ospf6_neighbor *best_drouter, *best_bdrouter;
  488. u_char next_state = 0;
  489. drouter = bdrouter = NULL;
  490. best_drouter = best_bdrouter = NULL;
  491. /* pseudo neighbor myself, including noting current DR/BDR (1) */
  492. memset (&myself, 0, sizeof (myself));
  493. inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
  494. sizeof (myself.name));
  495. myself.state = OSPF6_NEIGHBOR_TWOWAY;
  496. myself.drouter = oi->drouter;
  497. myself.bdrouter = oi->bdrouter;
  498. myself.priority = oi->priority;
  499. myself.router_id = oi->area->ospf6->router_id;
  500. /* Electing BDR (2) */
  501. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  502. bdrouter = better_bdrouter (bdrouter, on);
  503. best_bdrouter = bdrouter;
  504. bdrouter = better_bdrouter (best_bdrouter, &myself);
  505. /* Electing DR (3) */
  506. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  507. drouter = better_drouter (drouter, on);
  508. best_drouter = drouter;
  509. drouter = better_drouter (best_drouter, &myself);
  510. if (drouter == NULL)
  511. drouter = bdrouter;
  512. /* the router itself is newly/no longer DR/BDR (4) */
  513. if ((drouter == &myself && myself.drouter != myself.router_id) ||
  514. (drouter != &myself && myself.drouter == myself.router_id) ||
  515. (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
  516. (bdrouter != &myself && myself.bdrouter == myself.router_id))
  517. {
  518. myself.drouter = (drouter ? drouter->router_id : htonl (0));
  519. myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
  520. /* compatible to Electing BDR (2) */
  521. bdrouter = better_bdrouter (best_bdrouter, &myself);
  522. /* compatible to Electing DR (3) */
  523. drouter = better_drouter (best_drouter, &myself);
  524. if (drouter == NULL)
  525. drouter = bdrouter;
  526. }
  527. /* Set interface state accordingly (5) */
  528. if (drouter && drouter == &myself)
  529. next_state = OSPF6_INTERFACE_DR;
  530. else if (bdrouter && bdrouter == &myself)
  531. next_state = OSPF6_INTERFACE_BDR;
  532. else
  533. next_state = OSPF6_INTERFACE_DROTHER;
  534. /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
  535. /* XXX */
  536. /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
  537. /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
  538. accordingly after AdjOK */
  539. if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
  540. oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
  541. {
  542. if (IS_OSPF6_DEBUG_INTERFACE)
  543. zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
  544. (drouter ? drouter->name : "0.0.0.0"),
  545. (bdrouter ? bdrouter->name : "0.0.0.0"));
  546. for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
  547. {
  548. if (on->state < OSPF6_NEIGHBOR_TWOWAY)
  549. continue;
  550. /* Schedule AdjOK. */
  551. thread_add_event (master, adj_ok, on, 0);
  552. }
  553. }
  554. oi->drouter = (drouter ? drouter->router_id : htonl (0));
  555. oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
  556. return next_state;
  557. }
  558. /* Interface State Machine */
  559. int
  560. interface_up (struct thread *thread)
  561. {
  562. struct ospf6_interface *oi;
  563. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  564. assert (oi && oi->interface);
  565. if (IS_OSPF6_DEBUG_INTERFACE)
  566. zlog_debug ("Interface Event %s: [InterfaceUp]",
  567. oi->interface->name);
  568. /* check physical interface is up */
  569. if (! if_is_operative (oi->interface))
  570. {
  571. if (IS_OSPF6_DEBUG_INTERFACE)
  572. zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
  573. oi->interface->name);
  574. return 0;
  575. }
  576. /* check interface has a link-local address */
  577. if (! (ospf6_interface_get_linklocal_address(oi->interface)
  578. || if_is_loopback(oi->interface)))
  579. {
  580. if (IS_OSPF6_DEBUG_INTERFACE)
  581. zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
  582. oi->interface->name);
  583. return 0;
  584. }
  585. /* Recompute cost */
  586. ospf6_interface_recalculate_cost (oi);
  587. /* if already enabled, do nothing */
  588. if (oi->state > OSPF6_INTERFACE_DOWN)
  589. {
  590. if (IS_OSPF6_DEBUG_INTERFACE)
  591. zlog_debug ("Interface %s already enabled",
  592. oi->interface->name);
  593. return 0;
  594. }
  595. /* If no area assigned, return */
  596. if (oi->area == NULL)
  597. {
  598. zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
  599. oi->interface->name);
  600. return 0;
  601. }
  602. /* Join AllSPFRouters */
  603. ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
  604. /* Update interface route */
  605. ospf6_interface_connected_route_update (oi->interface);
  606. /* Schedule Hello */
  607. if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
  608. oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
  609. /* decide next interface state */
  610. if ((if_is_pointopoint (oi->interface)) ||
  611. (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
  612. ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
  613. }
  614. else if (oi->priority == 0)
  615. ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
  616. else
  617. {
  618. ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
  619. thread_add_timer (master, wait_timer, oi, oi->dead_interval);
  620. }
  621. return 0;
  622. }
  623. int
  624. wait_timer (struct thread *thread)
  625. {
  626. struct ospf6_interface *oi;
  627. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  628. assert (oi && oi->interface);
  629. if (IS_OSPF6_DEBUG_INTERFACE)
  630. zlog_debug ("Interface Event %s: [WaitTimer]",
  631. oi->interface->name);
  632. if (oi->state == OSPF6_INTERFACE_WAITING)
  633. ospf6_interface_state_change (dr_election (oi), oi);
  634. return 0;
  635. }
  636. int
  637. backup_seen (struct thread *thread)
  638. {
  639. struct ospf6_interface *oi;
  640. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  641. assert (oi && oi->interface);
  642. if (IS_OSPF6_DEBUG_INTERFACE)
  643. zlog_debug ("Interface Event %s: [BackupSeen]",
  644. oi->interface->name);
  645. if (oi->state == OSPF6_INTERFACE_WAITING)
  646. ospf6_interface_state_change (dr_election (oi), oi);
  647. return 0;
  648. }
  649. int
  650. neighbor_change (struct thread *thread)
  651. {
  652. struct ospf6_interface *oi;
  653. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  654. assert (oi && oi->interface);
  655. if (IS_OSPF6_DEBUG_INTERFACE)
  656. zlog_debug ("Interface Event %s: [NeighborChange]",
  657. oi->interface->name);
  658. if (oi->state == OSPF6_INTERFACE_DROTHER ||
  659. oi->state == OSPF6_INTERFACE_BDR ||
  660. oi->state == OSPF6_INTERFACE_DR)
  661. ospf6_interface_state_change (dr_election (oi), oi);
  662. return 0;
  663. }
  664. int
  665. interface_down (struct thread *thread)
  666. {
  667. struct ospf6_interface *oi;
  668. struct listnode *node, *nnode;
  669. struct ospf6_neighbor *on;
  670. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  671. assert (oi && oi->interface);
  672. if (IS_OSPF6_DEBUG_INTERFACE)
  673. zlog_debug ("Interface Event %s: [InterfaceDown]",
  674. oi->interface->name);
  675. /* Stop Hellos */
  676. THREAD_OFF (oi->thread_send_hello);
  677. /* Leave AllSPFRouters */
  678. if (oi->state > OSPF6_INTERFACE_DOWN)
  679. ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
  680. ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
  681. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  682. ospf6_neighbor_delete (on);
  683. list_delete_all_node (oi->neighbor_list);
  684. /* When interface state is reset, also reset information about
  685. * DR election, as it is no longer valid. */
  686. oi->drouter = oi->prev_drouter = htonl(0);
  687. oi->bdrouter = oi->prev_bdrouter = htonl(0);
  688. return 0;
  689. }
  690. /* show specified interface structure */
  691. static int
  692. ospf6_interface_show (struct vty *vty, struct interface *ifp)
  693. {
  694. struct ospf6_interface *oi;
  695. struct connected *c;
  696. struct prefix *p;
  697. struct listnode *i;
  698. char strbuf[64], drouter[32], bdrouter[32];
  699. const char *updown[3] = {"down", "up", NULL};
  700. const char *type;
  701. struct timeval res, now;
  702. char duration[32];
  703. struct ospf6_lsa *lsa;
  704. /* check physical interface type */
  705. if (if_is_loopback (ifp))
  706. type = "LOOPBACK";
  707. else if (if_is_broadcast (ifp))
  708. type = "BROADCAST";
  709. else if (if_is_pointopoint (ifp))
  710. type = "POINTOPOINT";
  711. else
  712. type = "UNKNOWN";
  713. vty_out (vty, "%s is %s, type %s%s",
  714. ifp->name, updown[if_is_operative (ifp)], type,
  715. VNL);
  716. vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
  717. if (ifp->info == NULL)
  718. {
  719. vty_out (vty, " OSPF not enabled on this interface%s", VNL);
  720. return 0;
  721. }
  722. else
  723. oi = (struct ospf6_interface *) ifp->info;
  724. vty_out (vty, " Internet Address:%s", VNL);
  725. for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
  726. {
  727. p = c->address;
  728. prefix2str (p, strbuf, sizeof (strbuf));
  729. switch (p->family)
  730. {
  731. case AF_INET:
  732. vty_out (vty, " inet : %s%s", strbuf,
  733. VNL);
  734. break;
  735. case AF_INET6:
  736. vty_out (vty, " inet6: %s%s", strbuf,
  737. VNL);
  738. break;
  739. default:
  740. vty_out (vty, " ??? : %s%s", strbuf,
  741. VNL);
  742. break;
  743. }
  744. }
  745. if (oi->area)
  746. {
  747. vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
  748. oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
  749. vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
  750. "disabled" : "enabled", VNL);
  751. inet_ntop (AF_INET, &oi->area->area_id,
  752. strbuf, sizeof (strbuf));
  753. vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost,
  754. VNL);
  755. }
  756. else
  757. vty_out (vty, " Not Attached to Area%s", VNL);
  758. vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
  759. ospf6_interface_state_str[oi->state],
  760. oi->transdelay, oi->priority,
  761. VNL);
  762. vty_out (vty, " Timer intervals configured:%s", VNL);
  763. vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
  764. oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
  765. VNL);
  766. inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
  767. inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
  768. vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
  769. vty_out (vty, " Number of I/F scoped LSAs is %u%s",
  770. oi->lsdb->count, VNL);
  771. quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
  772. timerclear (&res);
  773. if (oi->thread_send_lsupdate)
  774. timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
  775. timerstring (&res, duration, sizeof (duration));
  776. vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
  777. oi->lsupdate_list->count, duration,
  778. (oi->thread_send_lsupdate ? "on" : "off"),
  779. VNL);
  780. for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
  781. lsa = ospf6_lsdb_next (lsa))
  782. vty_out (vty, " %s%s", lsa->name, VNL);
  783. timerclear (&res);
  784. if (oi->thread_send_lsack)
  785. timersub (&oi->thread_send_lsack->u.sands, &now, &res);
  786. timerstring (&res, duration, sizeof (duration));
  787. vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
  788. oi->lsack_list->count, duration,
  789. (oi->thread_send_lsack ? "on" : "off"),
  790. VNL);
  791. for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
  792. lsa = ospf6_lsdb_next (lsa))
  793. vty_out (vty, " %s%s", lsa->name, VNL);
  794. return 0;
  795. }
  796. /* show interface */
  797. DEFUN (show_ipv6_ospf6_interface,
  798. show_ipv6_ospf6_interface_ifname_cmd,
  799. "show ipv6 ospf6 interface IFNAME",
  800. SHOW_STR
  801. IP6_STR
  802. OSPF6_STR
  803. INTERFACE_STR
  804. IFNAME_STR
  805. )
  806. {
  807. struct interface *ifp;
  808. struct listnode *i;
  809. if (argc)
  810. {
  811. ifp = if_lookup_by_name (argv[0]);
  812. if (ifp == NULL)
  813. {
  814. vty_out (vty, "No such Interface: %s%s", argv[0],
  815. VNL);
  816. return CMD_WARNING;
  817. }
  818. ospf6_interface_show (vty, ifp);
  819. }
  820. else
  821. {
  822. for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
  823. ospf6_interface_show (vty, ifp);
  824. }
  825. return CMD_SUCCESS;
  826. }
  827. ALIAS (show_ipv6_ospf6_interface,
  828. show_ipv6_ospf6_interface_cmd,
  829. "show ipv6 ospf6 interface",
  830. SHOW_STR
  831. IP6_STR
  832. OSPF6_STR
  833. INTERFACE_STR
  834. )
  835. DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
  836. show_ipv6_ospf6_interface_ifname_prefix_cmd,
  837. "show ipv6 ospf6 interface IFNAME prefix",
  838. SHOW_STR
  839. IP6_STR
  840. OSPF6_STR
  841. INTERFACE_STR
  842. IFNAME_STR
  843. "Display connected prefixes to advertise\n"
  844. )
  845. {
  846. struct interface *ifp;
  847. struct ospf6_interface *oi;
  848. ifp = if_lookup_by_name (argv[0]);
  849. if (ifp == NULL)
  850. {
  851. vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
  852. return CMD_WARNING;
  853. }
  854. oi = ifp->info;
  855. if (oi == NULL)
  856. {
  857. vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
  858. return CMD_WARNING;
  859. }
  860. argc--;
  861. argv++;
  862. ospf6_route_table_show (vty, argc, argv, oi->route_connected);
  863. return CMD_SUCCESS;
  864. }
  865. ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
  866. show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
  867. "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
  868. SHOW_STR
  869. IP6_STR
  870. OSPF6_STR
  871. INTERFACE_STR
  872. IFNAME_STR
  873. "Display connected prefixes to advertise\n"
  874. OSPF6_ROUTE_ADDRESS_STR
  875. OSPF6_ROUTE_PREFIX_STR
  876. "Display details of the prefixes\n"
  877. )
  878. ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
  879. show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
  880. "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
  881. SHOW_STR
  882. IP6_STR
  883. OSPF6_STR
  884. INTERFACE_STR
  885. IFNAME_STR
  886. "Display connected prefixes to advertise\n"
  887. OSPF6_ROUTE_PREFIX_STR
  888. OSPF6_ROUTE_MATCH_STR
  889. "Display details of the prefixes\n"
  890. )
  891. DEFUN (show_ipv6_ospf6_interface_prefix,
  892. show_ipv6_ospf6_interface_prefix_cmd,
  893. "show ipv6 ospf6 interface prefix",
  894. SHOW_STR
  895. IP6_STR
  896. OSPF6_STR
  897. INTERFACE_STR
  898. "Display connected prefixes to advertise\n"
  899. )
  900. {
  901. struct listnode *i;
  902. struct ospf6_interface *oi;
  903. struct interface *ifp;
  904. for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
  905. {
  906. oi = (struct ospf6_interface *) ifp->info;
  907. if (oi == NULL)
  908. continue;
  909. ospf6_route_table_show (vty, argc, argv, oi->route_connected);
  910. }
  911. return CMD_SUCCESS;
  912. }
  913. ALIAS (show_ipv6_ospf6_interface_prefix,
  914. show_ipv6_ospf6_interface_prefix_detail_cmd,
  915. "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
  916. SHOW_STR
  917. IP6_STR
  918. OSPF6_STR
  919. INTERFACE_STR
  920. "Display connected prefixes to advertise\n"
  921. OSPF6_ROUTE_ADDRESS_STR
  922. OSPF6_ROUTE_PREFIX_STR
  923. "Display details of the prefixes\n"
  924. )
  925. ALIAS (show_ipv6_ospf6_interface_prefix,
  926. show_ipv6_ospf6_interface_prefix_match_cmd,
  927. "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
  928. SHOW_STR
  929. IP6_STR
  930. OSPF6_STR
  931. INTERFACE_STR
  932. "Display connected prefixes to advertise\n"
  933. OSPF6_ROUTE_PREFIX_STR
  934. OSPF6_ROUTE_MATCH_STR
  935. "Display details of the prefixes\n"
  936. )
  937. /* interface variable set command */
  938. DEFUN (ipv6_ospf6_ifmtu,
  939. ipv6_ospf6_ifmtu_cmd,
  940. "ipv6 ospf6 ifmtu <1-65535>",
  941. IP6_STR
  942. OSPF6_STR
  943. "Interface MTU\n"
  944. "OSPFv3 Interface MTU\n"
  945. )
  946. {
  947. struct ospf6_interface *oi;
  948. struct interface *ifp;
  949. unsigned int ifmtu, iobuflen;
  950. struct listnode *node, *nnode;
  951. struct ospf6_neighbor *on;
  952. ifp = (struct interface *) vty->index;
  953. assert (ifp);
  954. oi = (struct ospf6_interface *) ifp->info;
  955. if (oi == NULL)
  956. oi = ospf6_interface_create (ifp);
  957. assert (oi);
  958. ifmtu = strtol (argv[0], NULL, 10);
  959. if (oi->ifmtu == ifmtu)
  960. return CMD_SUCCESS;
  961. if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
  962. {
  963. vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
  964. ifp->name, ifp->mtu6, VNL);
  965. return CMD_WARNING;
  966. }
  967. if (oi->ifmtu < ifmtu)
  968. {
  969. iobuflen = ospf6_iobuf_size (ifmtu);
  970. if (iobuflen < ifmtu)
  971. {
  972. vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
  973. ifp->name, iobuflen, VNL);
  974. oi->ifmtu = iobuflen;
  975. }
  976. else
  977. oi->ifmtu = ifmtu;
  978. }
  979. else
  980. oi->ifmtu = ifmtu;
  981. /* re-establish adjacencies */
  982. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  983. {
  984. THREAD_OFF (on->inactivity_timer);
  985. thread_add_event (master, inactivity_timer, on, 0);
  986. }
  987. return CMD_SUCCESS;
  988. }
  989. DEFUN (no_ipv6_ospf6_ifmtu,
  990. no_ipv6_ospf6_ifmtu_cmd,
  991. "no ipv6 ospf6 ifmtu",
  992. NO_STR
  993. IP6_STR
  994. OSPF6_STR
  995. "Interface MTU\n"
  996. )
  997. {
  998. struct ospf6_interface *oi;
  999. struct interface *ifp;
  1000. unsigned int iobuflen;
  1001. struct listnode *node, *nnode;
  1002. struct ospf6_neighbor *on;
  1003. ifp = (struct interface *) vty->index;
  1004. assert (ifp);
  1005. oi = (struct ospf6_interface *) ifp->info;
  1006. if (oi == NULL)
  1007. oi = ospf6_interface_create (ifp);
  1008. assert (oi);
  1009. if (oi->ifmtu < ifp->mtu)
  1010. {
  1011. iobuflen = ospf6_iobuf_size (ifp->mtu);
  1012. if (iobuflen < ifp->mtu)
  1013. {
  1014. vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
  1015. ifp->name, iobuflen, VNL);
  1016. oi->ifmtu = iobuflen;
  1017. }
  1018. else
  1019. oi->ifmtu = ifp->mtu;
  1020. }
  1021. else
  1022. oi->ifmtu = ifp->mtu;
  1023. /* re-establish adjacencies */
  1024. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  1025. {
  1026. THREAD_OFF (on->inactivity_timer);
  1027. thread_add_event (master, inactivity_timer, on, 0);
  1028. }
  1029. return CMD_SUCCESS;
  1030. }
  1031. DEFUN (ipv6_ospf6_cost,
  1032. ipv6_ospf6_cost_cmd,
  1033. "ipv6 ospf6 cost <1-65535>",
  1034. IP6_STR
  1035. OSPF6_STR
  1036. "Interface cost\n"
  1037. "Outgoing metric of this interface\n"
  1038. )
  1039. {
  1040. struct ospf6_interface *oi;
  1041. struct interface *ifp;
  1042. unsigned long int lcost;
  1043. ifp = (struct interface *) vty->index;
  1044. assert (ifp);
  1045. oi = (struct ospf6_interface *) ifp->info;
  1046. if (oi == NULL)
  1047. oi = ospf6_interface_create (ifp);
  1048. assert (oi);
  1049. lcost = strtol (argv[0], NULL, 10);
  1050. if (lcost > UINT32_MAX)
  1051. {
  1052. vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
  1053. return CMD_WARNING;
  1054. }
  1055. if (oi->cost == lcost)
  1056. return CMD_SUCCESS;
  1057. oi->cost = lcost;
  1058. SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
  1059. ospf6_interface_recalculate_cost(oi);
  1060. return CMD_SUCCESS;
  1061. }
  1062. DEFUN (no_ipv6_ospf6_cost,
  1063. no_ipv6_ospf6_cost_cmd,
  1064. "no ipv6 ospf6 cost",
  1065. NO_STR
  1066. IP6_STR
  1067. OSPF6_STR
  1068. "Calculate interface cost from bandwidth\n"
  1069. )
  1070. {
  1071. struct ospf6_interface *oi;
  1072. struct interface *ifp;
  1073. unsigned long int lcost;
  1074. ifp = (struct interface *) vty->index;
  1075. assert (ifp);
  1076. oi = (struct ospf6_interface *) ifp->info;
  1077. if (oi == NULL)
  1078. oi = ospf6_interface_create (ifp);
  1079. assert (oi);
  1080. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
  1081. ospf6_interface_recalculate_cost(oi);
  1082. return CMD_SUCCESS;
  1083. }
  1084. DEFUN (auto_cost_reference_bandwidth,
  1085. auto_cost_reference_bandwidth_cmd,
  1086. "auto-cost reference-bandwidth <1-4294967>",
  1087. "Calculate OSPF interface cost according to bandwidth\n"
  1088. "Use reference bandwidth method to assign OSPF cost\n"
  1089. "The reference bandwidth in terms of Mbits per second\n")
  1090. {
  1091. struct ospf6 *o = vty->index;
  1092. struct ospf6_area *oa;
  1093. struct ospf6_interface *oi;
  1094. struct listnode *i, *j;
  1095. u_int32_t refbw;
  1096. refbw = strtol (argv[0], NULL, 10);
  1097. if (refbw < 1 || refbw > 4294967)
  1098. {
  1099. vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
  1100. return CMD_WARNING;
  1101. }
  1102. /* If reference bandwidth is changed. */
  1103. if ((refbw * 1000) == o->ref_bandwidth)
  1104. return CMD_SUCCESS;
  1105. o->ref_bandwidth = refbw * 1000;
  1106. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  1107. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  1108. ospf6_interface_recalculate_cost (oi);
  1109. return CMD_SUCCESS;
  1110. }
  1111. DEFUN (no_auto_cost_reference_bandwidth,
  1112. no_auto_cost_reference_bandwidth_cmd,
  1113. "no auto-cost reference-bandwidth",
  1114. NO_STR
  1115. "Calculate OSPF interface cost according to bandwidth\n"
  1116. "Use reference bandwidth method to assign OSPF cost\n")
  1117. {
  1118. struct ospf6 *o = vty->index;
  1119. struct ospf6_area *oa;
  1120. struct ospf6_interface *oi;
  1121. struct listnode *i, *j;
  1122. if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
  1123. return CMD_SUCCESS;
  1124. o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
  1125. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  1126. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  1127. ospf6_interface_recalculate_cost (oi);
  1128. return CMD_SUCCESS;
  1129. }
  1130. DEFUN (ipv6_ospf6_hellointerval,
  1131. ipv6_ospf6_hellointerval_cmd,
  1132. "ipv6 ospf6 hello-interval <1-65535>",
  1133. IP6_STR
  1134. OSPF6_STR
  1135. "Interval time of Hello packets\n"
  1136. SECONDS_STR
  1137. )
  1138. {
  1139. struct ospf6_interface *oi;
  1140. struct interface *ifp;
  1141. ifp = (struct interface *) vty->index;
  1142. assert (ifp);
  1143. oi = (struct ospf6_interface *) ifp->info;
  1144. if (oi == NULL)
  1145. oi = ospf6_interface_create (ifp);
  1146. assert (oi);
  1147. oi->hello_interval = strtol (argv[0], NULL, 10);
  1148. return CMD_SUCCESS;
  1149. }
  1150. /* interface variable set command */
  1151. DEFUN (ipv6_ospf6_deadinterval,
  1152. ipv6_ospf6_deadinterval_cmd,
  1153. "ipv6 ospf6 dead-interval <1-65535>",
  1154. IP6_STR
  1155. OSPF6_STR
  1156. "Interval time after which a neighbor is declared down\n"
  1157. SECONDS_STR
  1158. )
  1159. {
  1160. struct ospf6_interface *oi;
  1161. struct interface *ifp;
  1162. ifp = (struct interface *) vty->index;
  1163. assert (ifp);
  1164. oi = (struct ospf6_interface *) ifp->info;
  1165. if (oi == NULL)
  1166. oi = ospf6_interface_create (ifp);
  1167. assert (oi);
  1168. oi->dead_interval = strtol (argv[0], NULL, 10);
  1169. return CMD_SUCCESS;
  1170. }
  1171. /* interface variable set command */
  1172. DEFUN (ipv6_ospf6_transmitdelay,
  1173. ipv6_ospf6_transmitdelay_cmd,
  1174. "ipv6 ospf6 transmit-delay <1-3600>",
  1175. IP6_STR
  1176. OSPF6_STR
  1177. "Transmit delay of this interface\n"
  1178. SECONDS_STR
  1179. )
  1180. {
  1181. struct ospf6_interface *oi;
  1182. struct interface *ifp;
  1183. ifp = (struct interface *) vty->index;
  1184. assert (ifp);
  1185. oi = (struct ospf6_interface *) ifp->info;
  1186. if (oi == NULL)
  1187. oi = ospf6_interface_create (ifp);
  1188. assert (oi);
  1189. oi->transdelay = strtol (argv[0], NULL, 10);
  1190. return CMD_SUCCESS;
  1191. }
  1192. /* interface variable set command */
  1193. DEFUN (ipv6_ospf6_retransmitinterval,
  1194. ipv6_ospf6_retransmitinterval_cmd,
  1195. "ipv6 ospf6 retransmit-interval <1-65535>",
  1196. IP6_STR
  1197. OSPF6_STR
  1198. "Time between retransmitting lost link state advertisements\n"
  1199. SECONDS_STR
  1200. )
  1201. {
  1202. struct ospf6_interface *oi;
  1203. struct interface *ifp;
  1204. ifp = (struct interface *) vty->index;
  1205. assert (ifp);
  1206. oi = (struct ospf6_interface *) ifp->info;
  1207. if (oi == NULL)
  1208. oi = ospf6_interface_create (ifp);
  1209. assert (oi);
  1210. oi->rxmt_interval = strtol (argv[0], NULL, 10);
  1211. return CMD_SUCCESS;
  1212. }
  1213. /* interface variable set command */
  1214. DEFUN (ipv6_ospf6_priority,
  1215. ipv6_ospf6_priority_cmd,
  1216. "ipv6 ospf6 priority <0-255>",
  1217. IP6_STR
  1218. OSPF6_STR
  1219. "Router priority\n"
  1220. "Priority value\n"
  1221. )
  1222. {
  1223. struct ospf6_interface *oi;
  1224. struct interface *ifp;
  1225. ifp = (struct interface *) vty->index;
  1226. assert (ifp);
  1227. oi = (struct ospf6_interface *) ifp->info;
  1228. if (oi == NULL)
  1229. oi = ospf6_interface_create (ifp);
  1230. assert (oi);
  1231. oi->priority = strtol (argv[0], NULL, 10);
  1232. if (oi->area &&
  1233. (oi->state == OSPF6_INTERFACE_DROTHER ||
  1234. oi->state == OSPF6_INTERFACE_BDR ||
  1235. oi->state == OSPF6_INTERFACE_DR))
  1236. ospf6_interface_state_change (dr_election (oi), oi);
  1237. return CMD_SUCCESS;
  1238. }
  1239. DEFUN (ipv6_ospf6_instance,
  1240. ipv6_ospf6_instance_cmd,
  1241. "ipv6 ospf6 instance-id <0-255>",
  1242. IP6_STR
  1243. OSPF6_STR
  1244. "Instance ID for this interface\n"
  1245. "Instance ID value\n"
  1246. )
  1247. {
  1248. struct ospf6_interface *oi;
  1249. struct interface *ifp;
  1250. ifp = (struct interface *)vty->index;
  1251. assert (ifp);
  1252. oi = (struct ospf6_interface *)ifp->info;
  1253. if (oi == NULL)
  1254. oi = ospf6_interface_create (ifp);
  1255. assert (oi);
  1256. oi->instance_id = strtol (argv[0], NULL, 10);
  1257. return CMD_SUCCESS;
  1258. }
  1259. DEFUN (ipv6_ospf6_passive,
  1260. ipv6_ospf6_passive_cmd,
  1261. "ipv6 ospf6 passive",
  1262. IP6_STR
  1263. OSPF6_STR
  1264. "passive interface, No adjacency will be formed on this interface\n"
  1265. )
  1266. {
  1267. struct ospf6_interface *oi;
  1268. struct interface *ifp;
  1269. struct listnode *node, *nnode;
  1270. struct ospf6_neighbor *on;
  1271. ifp = (struct interface *) vty->index;
  1272. assert (ifp);
  1273. oi = (struct ospf6_interface *) ifp->info;
  1274. if (oi == NULL)
  1275. oi = ospf6_interface_create (ifp);
  1276. assert (oi);
  1277. SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
  1278. THREAD_OFF (oi->thread_send_hello);
  1279. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  1280. {
  1281. THREAD_OFF (on->inactivity_timer);
  1282. thread_add_event (master, inactivity_timer, on, 0);
  1283. }
  1284. return CMD_SUCCESS;
  1285. }
  1286. DEFUN (no_ipv6_ospf6_passive,
  1287. no_ipv6_ospf6_passive_cmd,
  1288. "no ipv6 ospf6 passive",
  1289. NO_STR
  1290. IP6_STR
  1291. OSPF6_STR
  1292. "passive interface: No Adjacency will be formed on this I/F\n"
  1293. )
  1294. {
  1295. struct ospf6_interface *oi;
  1296. struct interface *ifp;
  1297. ifp = (struct interface *) vty->index;
  1298. assert (ifp);
  1299. oi = (struct ospf6_interface *) ifp->info;
  1300. if (oi == NULL)
  1301. oi = ospf6_interface_create (ifp);
  1302. assert (oi);
  1303. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
  1304. THREAD_OFF (oi->thread_send_hello);
  1305. oi->thread_send_hello =
  1306. thread_add_event (master, ospf6_hello_send, oi, 0);
  1307. return CMD_SUCCESS;
  1308. }
  1309. DEFUN (ipv6_ospf6_mtu_ignore,
  1310. ipv6_ospf6_mtu_ignore_cmd,
  1311. "ipv6 ospf6 mtu-ignore",
  1312. IP6_STR
  1313. OSPF6_STR
  1314. "Ignore MTU mismatch on this interface\n"
  1315. )
  1316. {
  1317. struct ospf6_interface *oi;
  1318. struct interface *ifp;
  1319. ifp = (struct interface *) vty->index;
  1320. assert (ifp);
  1321. oi = (struct ospf6_interface *) ifp->info;
  1322. if (oi == NULL)
  1323. oi = ospf6_interface_create (ifp);
  1324. assert (oi);
  1325. oi->mtu_ignore = 1;
  1326. return CMD_SUCCESS;
  1327. }
  1328. DEFUN (no_ipv6_ospf6_mtu_ignore,
  1329. no_ipv6_ospf6_mtu_ignore_cmd,
  1330. "no ipv6 ospf6 mtu-ignore",
  1331. NO_STR
  1332. IP6_STR
  1333. OSPF6_STR
  1334. "Ignore MTU mismatch on this interface\n"
  1335. )
  1336. {
  1337. struct ospf6_interface *oi;
  1338. struct interface *ifp;
  1339. ifp = (struct interface *) vty->index;
  1340. assert (ifp);
  1341. oi = (struct ospf6_interface *) ifp->info;
  1342. if (oi == NULL)
  1343. oi = ospf6_interface_create (ifp);
  1344. assert (oi);
  1345. oi->mtu_ignore = 0;
  1346. return CMD_SUCCESS;
  1347. }
  1348. DEFUN (ipv6_ospf6_advertise_prefix_list,
  1349. ipv6_ospf6_advertise_prefix_list_cmd,
  1350. "ipv6 ospf6 advertise prefix-list WORD",
  1351. IP6_STR
  1352. OSPF6_STR
  1353. "Advertising options\n"
  1354. "Filter prefix using prefix-list\n"
  1355. "Prefix list name\n"
  1356. )
  1357. {
  1358. struct ospf6_interface *oi;
  1359. struct interface *ifp;
  1360. ifp = (struct interface *) vty->index;
  1361. assert (ifp);
  1362. oi = (struct ospf6_interface *) ifp->info;
  1363. if (oi == NULL)
  1364. oi = ospf6_interface_create (ifp);
  1365. assert (oi);
  1366. if (oi->plist_name)
  1367. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  1368. oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
  1369. ospf6_interface_connected_route_update (oi->interface);
  1370. if (oi->area)
  1371. {
  1372. OSPF6_LINK_LSA_SCHEDULE (oi);
  1373. if (oi->state == OSPF6_INTERFACE_DR)
  1374. {
  1375. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  1376. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  1377. }
  1378. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  1379. }
  1380. return CMD_SUCCESS;
  1381. }
  1382. DEFUN (no_ipv6_ospf6_advertise_prefix_list,
  1383. no_ipv6_ospf6_advertise_prefix_list_cmd,
  1384. "no ipv6 ospf6 advertise prefix-list",
  1385. NO_STR
  1386. IP6_STR
  1387. OSPF6_STR
  1388. "Advertising options\n"
  1389. "Filter prefix using prefix-list\n"
  1390. )
  1391. {
  1392. struct ospf6_interface *oi;
  1393. struct interface *ifp;
  1394. ifp = (struct interface *) vty->index;
  1395. assert (ifp);
  1396. oi = (struct ospf6_interface *) ifp->info;
  1397. if (oi == NULL)
  1398. oi = ospf6_interface_create (ifp);
  1399. assert (oi);
  1400. if (oi->plist_name)
  1401. {
  1402. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  1403. oi->plist_name = NULL;
  1404. }
  1405. ospf6_interface_connected_route_update (oi->interface);
  1406. if (oi->area)
  1407. {
  1408. OSPF6_LINK_LSA_SCHEDULE (oi);
  1409. if (oi->state == OSPF6_INTERFACE_DR)
  1410. {
  1411. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  1412. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  1413. }
  1414. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  1415. }
  1416. return CMD_SUCCESS;
  1417. }
  1418. DEFUN (ipv6_ospf6_network,
  1419. ipv6_ospf6_network_cmd,
  1420. "ipv6 ospf6 network (broadcast|point-to-point)",
  1421. IP6_STR
  1422. OSPF6_STR
  1423. "Network Type\n"
  1424. "Specify OSPFv6 broadcast network\n"
  1425. "Specify OSPF6 point-to-point network\n"
  1426. )
  1427. {
  1428. struct ospf6_interface *oi;
  1429. struct interface *ifp;
  1430. ifp = (struct interface *) vty->index;
  1431. assert (ifp);
  1432. oi = (struct ospf6_interface *) ifp->info;
  1433. if (oi == NULL) {
  1434. oi = ospf6_interface_create (ifp);
  1435. }
  1436. assert (oi);
  1437. if (strncmp (argv[0], "b", 1) == 0)
  1438. {
  1439. if (oi->type == OSPF_IFTYPE_BROADCAST)
  1440. return CMD_SUCCESS;
  1441. oi->type = OSPF_IFTYPE_BROADCAST;
  1442. }
  1443. else if (strncmp (argv[0], "point-to-p", 10) == 0)
  1444. {
  1445. if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
  1446. return CMD_SUCCESS;
  1447. }
  1448. oi->type = OSPF_IFTYPE_POINTOPOINT;
  1449. }
  1450. /* Reset the interface */
  1451. thread_add_event (master, interface_down, oi, 0);
  1452. thread_add_event (master, interface_up, oi, 0);
  1453. return CMD_SUCCESS;
  1454. }
  1455. DEFUN (no_ipv6_ospf6_network,
  1456. no_ipv6_ospf6_network_cmd,
  1457. "no ipv6 ospf6 network",
  1458. NO_STR
  1459. IP6_STR
  1460. OSPF6_STR
  1461. "Network Type\n"
  1462. "Default to whatever interface type system specifies"
  1463. )
  1464. {
  1465. struct ospf6_interface *oi;
  1466. struct interface *ifp;
  1467. int type;
  1468. ifp = (struct interface *) vty->index;
  1469. assert (ifp);
  1470. oi = (struct ospf6_interface *) ifp->info;
  1471. if (oi == NULL) {
  1472. return CMD_SUCCESS;
  1473. }
  1474. type = ospf6_default_iftype (ifp);
  1475. if (oi->type == type)
  1476. {
  1477. return CMD_SUCCESS;
  1478. }
  1479. oi->type = type;
  1480. /* Reset the interface */
  1481. thread_add_event (master, interface_down, oi, 0);
  1482. thread_add_event (master, interface_up, oi, 0);
  1483. return CMD_SUCCESS;
  1484. }
  1485. static int
  1486. config_write_ospf6_interface (struct vty *vty)
  1487. {
  1488. struct listnode *i;
  1489. struct ospf6_interface *oi;
  1490. struct interface *ifp;
  1491. for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
  1492. {
  1493. oi = (struct ospf6_interface *) ifp->info;
  1494. if (oi == NULL)
  1495. continue;
  1496. vty_out (vty, "interface %s%s",
  1497. oi->interface->name, VNL);
  1498. if (ifp->desc)
  1499. vty_out (vty, " description %s%s", ifp->desc, VNL);
  1500. if (ifp->mtu6 != oi->ifmtu)
  1501. vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
  1502. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
  1503. vty_out (vty, " ipv6 ospf6 cost %d%s",
  1504. oi->cost, VNL);
  1505. if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
  1506. vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
  1507. oi->hello_interval, VNL);
  1508. if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
  1509. vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
  1510. oi->dead_interval, VNL);
  1511. if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
  1512. vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
  1513. oi->rxmt_interval, VNL);
  1514. if (oi->priority != OSPF6_INTERFACE_PRIORITY)
  1515. vty_out (vty, " ipv6 ospf6 priority %d%s",
  1516. oi->priority, VNL);
  1517. if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
  1518. vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
  1519. oi->transdelay, VNL);
  1520. if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
  1521. vty_out (vty, " ipv6 ospf6 instance-id %d%s",
  1522. oi->instance_id, VNL);
  1523. if (oi->plist_name)
  1524. vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
  1525. oi->plist_name, VNL);
  1526. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
  1527. vty_out (vty, " ipv6 ospf6 passive%s", VNL);
  1528. if (oi->mtu_ignore)
  1529. vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
  1530. if (oi->type == OSPF_IFTYPE_POINTOPOINT)
  1531. vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
  1532. else if (oi->type == OSPF_IFTYPE_BROADCAST)
  1533. vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
  1534. vty_out (vty, "!%s", VNL);
  1535. }
  1536. return 0;
  1537. }
  1538. static struct cmd_node interface_node =
  1539. {
  1540. INTERFACE_NODE,
  1541. "%s(config-if)# ",
  1542. 1 /* VTYSH */
  1543. };
  1544. void
  1545. ospf6_interface_init (void)
  1546. {
  1547. /* Install interface node. */
  1548. install_node (&interface_node, config_write_ospf6_interface);
  1549. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
  1550. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
  1551. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
  1552. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
  1553. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
  1554. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
  1555. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
  1556. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
  1557. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
  1558. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
  1559. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
  1560. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
  1561. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
  1562. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
  1563. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
  1564. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
  1565. install_element (CONFIG_NODE, &interface_cmd);
  1566. install_default (INTERFACE_NODE);
  1567. install_element (INTERFACE_NODE, &interface_desc_cmd);
  1568. install_element (INTERFACE_NODE, &no_interface_desc_cmd);
  1569. install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
  1570. install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
  1571. install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
  1572. install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
  1573. install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
  1574. install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
  1575. install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
  1576. install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
  1577. install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
  1578. install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
  1579. install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
  1580. install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
  1581. install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
  1582. install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
  1583. install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
  1584. install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
  1585. install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
  1586. install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
  1587. /* reference bandwidth commands */
  1588. install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
  1589. install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
  1590. }
  1591. DEFUN (debug_ospf6_interface,
  1592. debug_ospf6_interface_cmd,
  1593. "debug ospf6 interface",
  1594. DEBUG_STR
  1595. OSPF6_STR
  1596. "Debug OSPFv3 Interface\n"
  1597. )
  1598. {
  1599. OSPF6_DEBUG_INTERFACE_ON ();
  1600. return CMD_SUCCESS;
  1601. }
  1602. DEFUN (no_debug_ospf6_interface,
  1603. no_debug_ospf6_interface_cmd,
  1604. "no debug ospf6 interface",
  1605. NO_STR
  1606. DEBUG_STR
  1607. OSPF6_STR
  1608. "Debug OSPFv3 Interface\n"
  1609. )
  1610. {
  1611. OSPF6_DEBUG_INTERFACE_OFF ();
  1612. return CMD_SUCCESS;
  1613. }
  1614. int
  1615. config_write_ospf6_debug_interface (struct vty *vty)
  1616. {
  1617. if (IS_OSPF6_DEBUG_INTERFACE)
  1618. vty_out (vty, "debug ospf6 interface%s", VNL);
  1619. return 0;
  1620. }
  1621. void
  1622. install_element_ospf6_debug_interface (void)
  1623. {
  1624. install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
  1625. install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
  1626. install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
  1627. install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
  1628. }