ospf6_interface.c 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959
  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. ifp = (struct interface *) vty->index;
  1074. assert (ifp);
  1075. oi = (struct ospf6_interface *) ifp->info;
  1076. if (oi == NULL)
  1077. oi = ospf6_interface_create (ifp);
  1078. assert (oi);
  1079. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
  1080. ospf6_interface_recalculate_cost(oi);
  1081. return CMD_SUCCESS;
  1082. }
  1083. DEFUN (auto_cost_reference_bandwidth,
  1084. auto_cost_reference_bandwidth_cmd,
  1085. "auto-cost reference-bandwidth <1-4294967>",
  1086. "Calculate OSPF interface cost according to bandwidth\n"
  1087. "Use reference bandwidth method to assign OSPF cost\n"
  1088. "The reference bandwidth in terms of Mbits per second\n")
  1089. {
  1090. struct ospf6 *o = vty->index;
  1091. struct ospf6_area *oa;
  1092. struct ospf6_interface *oi;
  1093. struct listnode *i, *j;
  1094. u_int32_t refbw;
  1095. refbw = strtol (argv[0], NULL, 10);
  1096. if (refbw < 1 || refbw > 4294967)
  1097. {
  1098. vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
  1099. return CMD_WARNING;
  1100. }
  1101. /* If reference bandwidth is changed. */
  1102. if ((refbw * 1000) == o->ref_bandwidth)
  1103. return CMD_SUCCESS;
  1104. o->ref_bandwidth = refbw * 1000;
  1105. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  1106. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  1107. ospf6_interface_recalculate_cost (oi);
  1108. return CMD_SUCCESS;
  1109. }
  1110. DEFUN (no_auto_cost_reference_bandwidth,
  1111. no_auto_cost_reference_bandwidth_cmd,
  1112. "no auto-cost reference-bandwidth",
  1113. NO_STR
  1114. "Calculate OSPF interface cost according to bandwidth\n"
  1115. "Use reference bandwidth method to assign OSPF cost\n")
  1116. {
  1117. struct ospf6 *o = vty->index;
  1118. struct ospf6_area *oa;
  1119. struct ospf6_interface *oi;
  1120. struct listnode *i, *j;
  1121. if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
  1122. return CMD_SUCCESS;
  1123. o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
  1124. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  1125. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  1126. ospf6_interface_recalculate_cost (oi);
  1127. return CMD_SUCCESS;
  1128. }
  1129. DEFUN (ipv6_ospf6_hellointerval,
  1130. ipv6_ospf6_hellointerval_cmd,
  1131. "ipv6 ospf6 hello-interval <1-65535>",
  1132. IP6_STR
  1133. OSPF6_STR
  1134. "Interval time of Hello packets\n"
  1135. SECONDS_STR
  1136. )
  1137. {
  1138. struct ospf6_interface *oi;
  1139. struct interface *ifp;
  1140. ifp = (struct interface *) vty->index;
  1141. assert (ifp);
  1142. oi = (struct ospf6_interface *) ifp->info;
  1143. if (oi == NULL)
  1144. oi = ospf6_interface_create (ifp);
  1145. assert (oi);
  1146. oi->hello_interval = strtol (argv[0], NULL, 10);
  1147. return CMD_SUCCESS;
  1148. }
  1149. /* interface variable set command */
  1150. DEFUN (ipv6_ospf6_deadinterval,
  1151. ipv6_ospf6_deadinterval_cmd,
  1152. "ipv6 ospf6 dead-interval <1-65535>",
  1153. IP6_STR
  1154. OSPF6_STR
  1155. "Interval time after which a neighbor is declared down\n"
  1156. SECONDS_STR
  1157. )
  1158. {
  1159. struct ospf6_interface *oi;
  1160. struct interface *ifp;
  1161. ifp = (struct interface *) vty->index;
  1162. assert (ifp);
  1163. oi = (struct ospf6_interface *) ifp->info;
  1164. if (oi == NULL)
  1165. oi = ospf6_interface_create (ifp);
  1166. assert (oi);
  1167. oi->dead_interval = strtol (argv[0], NULL, 10);
  1168. return CMD_SUCCESS;
  1169. }
  1170. /* interface variable set command */
  1171. DEFUN (ipv6_ospf6_transmitdelay,
  1172. ipv6_ospf6_transmitdelay_cmd,
  1173. "ipv6 ospf6 transmit-delay <1-3600>",
  1174. IP6_STR
  1175. OSPF6_STR
  1176. "Transmit delay of this interface\n"
  1177. SECONDS_STR
  1178. )
  1179. {
  1180. struct ospf6_interface *oi;
  1181. struct interface *ifp;
  1182. ifp = (struct interface *) vty->index;
  1183. assert (ifp);
  1184. oi = (struct ospf6_interface *) ifp->info;
  1185. if (oi == NULL)
  1186. oi = ospf6_interface_create (ifp);
  1187. assert (oi);
  1188. oi->transdelay = strtol (argv[0], NULL, 10);
  1189. return CMD_SUCCESS;
  1190. }
  1191. /* interface variable set command */
  1192. DEFUN (ipv6_ospf6_retransmitinterval,
  1193. ipv6_ospf6_retransmitinterval_cmd,
  1194. "ipv6 ospf6 retransmit-interval <1-65535>",
  1195. IP6_STR
  1196. OSPF6_STR
  1197. "Time between retransmitting lost link state advertisements\n"
  1198. SECONDS_STR
  1199. )
  1200. {
  1201. struct ospf6_interface *oi;
  1202. struct interface *ifp;
  1203. ifp = (struct interface *) vty->index;
  1204. assert (ifp);
  1205. oi = (struct ospf6_interface *) ifp->info;
  1206. if (oi == NULL)
  1207. oi = ospf6_interface_create (ifp);
  1208. assert (oi);
  1209. oi->rxmt_interval = strtol (argv[0], NULL, 10);
  1210. return CMD_SUCCESS;
  1211. }
  1212. /* interface variable set command */
  1213. DEFUN (ipv6_ospf6_priority,
  1214. ipv6_ospf6_priority_cmd,
  1215. "ipv6 ospf6 priority <0-255>",
  1216. IP6_STR
  1217. OSPF6_STR
  1218. "Router priority\n"
  1219. "Priority value\n"
  1220. )
  1221. {
  1222. struct ospf6_interface *oi;
  1223. struct interface *ifp;
  1224. ifp = (struct interface *) vty->index;
  1225. assert (ifp);
  1226. oi = (struct ospf6_interface *) ifp->info;
  1227. if (oi == NULL)
  1228. oi = ospf6_interface_create (ifp);
  1229. assert (oi);
  1230. oi->priority = strtol (argv[0], NULL, 10);
  1231. if (oi->area &&
  1232. (oi->state == OSPF6_INTERFACE_DROTHER ||
  1233. oi->state == OSPF6_INTERFACE_BDR ||
  1234. oi->state == OSPF6_INTERFACE_DR))
  1235. ospf6_interface_state_change (dr_election (oi), oi);
  1236. return CMD_SUCCESS;
  1237. }
  1238. DEFUN (ipv6_ospf6_instance,
  1239. ipv6_ospf6_instance_cmd,
  1240. "ipv6 ospf6 instance-id <0-255>",
  1241. IP6_STR
  1242. OSPF6_STR
  1243. "Instance ID for this interface\n"
  1244. "Instance ID value\n"
  1245. )
  1246. {
  1247. struct ospf6_interface *oi;
  1248. struct interface *ifp;
  1249. ifp = (struct interface *)vty->index;
  1250. assert (ifp);
  1251. oi = (struct ospf6_interface *)ifp->info;
  1252. if (oi == NULL)
  1253. oi = ospf6_interface_create (ifp);
  1254. assert (oi);
  1255. oi->instance_id = strtol (argv[0], NULL, 10);
  1256. return CMD_SUCCESS;
  1257. }
  1258. DEFUN (ipv6_ospf6_passive,
  1259. ipv6_ospf6_passive_cmd,
  1260. "ipv6 ospf6 passive",
  1261. IP6_STR
  1262. OSPF6_STR
  1263. "passive interface, No adjacency will be formed on this interface\n"
  1264. )
  1265. {
  1266. struct ospf6_interface *oi;
  1267. struct interface *ifp;
  1268. struct listnode *node, *nnode;
  1269. struct ospf6_neighbor *on;
  1270. ifp = (struct interface *) vty->index;
  1271. assert (ifp);
  1272. oi = (struct ospf6_interface *) ifp->info;
  1273. if (oi == NULL)
  1274. oi = ospf6_interface_create (ifp);
  1275. assert (oi);
  1276. SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
  1277. THREAD_OFF (oi->thread_send_hello);
  1278. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  1279. {
  1280. THREAD_OFF (on->inactivity_timer);
  1281. thread_add_event (master, inactivity_timer, on, 0);
  1282. }
  1283. return CMD_SUCCESS;
  1284. }
  1285. DEFUN (no_ipv6_ospf6_passive,
  1286. no_ipv6_ospf6_passive_cmd,
  1287. "no ipv6 ospf6 passive",
  1288. NO_STR
  1289. IP6_STR
  1290. OSPF6_STR
  1291. "passive interface: No Adjacency will be formed on this I/F\n"
  1292. )
  1293. {
  1294. struct ospf6_interface *oi;
  1295. struct interface *ifp;
  1296. ifp = (struct interface *) vty->index;
  1297. assert (ifp);
  1298. oi = (struct ospf6_interface *) ifp->info;
  1299. if (oi == NULL)
  1300. oi = ospf6_interface_create (ifp);
  1301. assert (oi);
  1302. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
  1303. THREAD_OFF (oi->thread_send_hello);
  1304. oi->thread_send_hello =
  1305. thread_add_event (master, ospf6_hello_send, oi, 0);
  1306. return CMD_SUCCESS;
  1307. }
  1308. DEFUN (ipv6_ospf6_mtu_ignore,
  1309. ipv6_ospf6_mtu_ignore_cmd,
  1310. "ipv6 ospf6 mtu-ignore",
  1311. IP6_STR
  1312. OSPF6_STR
  1313. "Ignore MTU mismatch on this interface\n"
  1314. )
  1315. {
  1316. struct ospf6_interface *oi;
  1317. struct interface *ifp;
  1318. ifp = (struct interface *) vty->index;
  1319. assert (ifp);
  1320. oi = (struct ospf6_interface *) ifp->info;
  1321. if (oi == NULL)
  1322. oi = ospf6_interface_create (ifp);
  1323. assert (oi);
  1324. oi->mtu_ignore = 1;
  1325. return CMD_SUCCESS;
  1326. }
  1327. DEFUN (no_ipv6_ospf6_mtu_ignore,
  1328. no_ipv6_ospf6_mtu_ignore_cmd,
  1329. "no ipv6 ospf6 mtu-ignore",
  1330. NO_STR
  1331. IP6_STR
  1332. OSPF6_STR
  1333. "Ignore MTU mismatch on this interface\n"
  1334. )
  1335. {
  1336. struct ospf6_interface *oi;
  1337. struct interface *ifp;
  1338. ifp = (struct interface *) vty->index;
  1339. assert (ifp);
  1340. oi = (struct ospf6_interface *) ifp->info;
  1341. if (oi == NULL)
  1342. oi = ospf6_interface_create (ifp);
  1343. assert (oi);
  1344. oi->mtu_ignore = 0;
  1345. return CMD_SUCCESS;
  1346. }
  1347. DEFUN (ipv6_ospf6_advertise_prefix_list,
  1348. ipv6_ospf6_advertise_prefix_list_cmd,
  1349. "ipv6 ospf6 advertise prefix-list WORD",
  1350. IP6_STR
  1351. OSPF6_STR
  1352. "Advertising options\n"
  1353. "Filter prefix using prefix-list\n"
  1354. "Prefix list name\n"
  1355. )
  1356. {
  1357. struct ospf6_interface *oi;
  1358. struct interface *ifp;
  1359. ifp = (struct interface *) vty->index;
  1360. assert (ifp);
  1361. oi = (struct ospf6_interface *) ifp->info;
  1362. if (oi == NULL)
  1363. oi = ospf6_interface_create (ifp);
  1364. assert (oi);
  1365. if (oi->plist_name)
  1366. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  1367. oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
  1368. ospf6_interface_connected_route_update (oi->interface);
  1369. if (oi->area)
  1370. {
  1371. OSPF6_LINK_LSA_SCHEDULE (oi);
  1372. if (oi->state == OSPF6_INTERFACE_DR)
  1373. {
  1374. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  1375. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  1376. }
  1377. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  1378. }
  1379. return CMD_SUCCESS;
  1380. }
  1381. DEFUN (no_ipv6_ospf6_advertise_prefix_list,
  1382. no_ipv6_ospf6_advertise_prefix_list_cmd,
  1383. "no ipv6 ospf6 advertise prefix-list",
  1384. NO_STR
  1385. IP6_STR
  1386. OSPF6_STR
  1387. "Advertising options\n"
  1388. "Filter prefix using prefix-list\n"
  1389. )
  1390. {
  1391. struct ospf6_interface *oi;
  1392. struct interface *ifp;
  1393. ifp = (struct interface *) vty->index;
  1394. assert (ifp);
  1395. oi = (struct ospf6_interface *) ifp->info;
  1396. if (oi == NULL)
  1397. oi = ospf6_interface_create (ifp);
  1398. assert (oi);
  1399. if (oi->plist_name)
  1400. {
  1401. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  1402. oi->plist_name = NULL;
  1403. }
  1404. ospf6_interface_connected_route_update (oi->interface);
  1405. if (oi->area)
  1406. {
  1407. OSPF6_LINK_LSA_SCHEDULE (oi);
  1408. if (oi->state == OSPF6_INTERFACE_DR)
  1409. {
  1410. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  1411. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  1412. }
  1413. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  1414. }
  1415. return CMD_SUCCESS;
  1416. }
  1417. DEFUN (ipv6_ospf6_network,
  1418. ipv6_ospf6_network_cmd,
  1419. "ipv6 ospf6 network (broadcast|point-to-point)",
  1420. IP6_STR
  1421. OSPF6_STR
  1422. "Network Type\n"
  1423. "Specify OSPFv6 broadcast network\n"
  1424. "Specify OSPF6 point-to-point network\n"
  1425. )
  1426. {
  1427. struct ospf6_interface *oi;
  1428. struct interface *ifp;
  1429. ifp = (struct interface *) vty->index;
  1430. assert (ifp);
  1431. oi = (struct ospf6_interface *) ifp->info;
  1432. if (oi == NULL) {
  1433. oi = ospf6_interface_create (ifp);
  1434. }
  1435. assert (oi);
  1436. if (strncmp (argv[0], "b", 1) == 0)
  1437. {
  1438. if (oi->type == OSPF_IFTYPE_BROADCAST)
  1439. return CMD_SUCCESS;
  1440. oi->type = OSPF_IFTYPE_BROADCAST;
  1441. }
  1442. else if (strncmp (argv[0], "point-to-p", 10) == 0)
  1443. {
  1444. if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
  1445. return CMD_SUCCESS;
  1446. }
  1447. oi->type = OSPF_IFTYPE_POINTOPOINT;
  1448. }
  1449. /* Reset the interface */
  1450. thread_add_event (master, interface_down, oi, 0);
  1451. thread_add_event (master, interface_up, oi, 0);
  1452. return CMD_SUCCESS;
  1453. }
  1454. DEFUN (no_ipv6_ospf6_network,
  1455. no_ipv6_ospf6_network_cmd,
  1456. "no ipv6 ospf6 network",
  1457. NO_STR
  1458. IP6_STR
  1459. OSPF6_STR
  1460. "Network Type\n"
  1461. "Default to whatever interface type system specifies"
  1462. )
  1463. {
  1464. struct ospf6_interface *oi;
  1465. struct interface *ifp;
  1466. int type;
  1467. ifp = (struct interface *) vty->index;
  1468. assert (ifp);
  1469. oi = (struct ospf6_interface *) ifp->info;
  1470. if (oi == NULL) {
  1471. return CMD_SUCCESS;
  1472. }
  1473. type = ospf6_default_iftype (ifp);
  1474. if (oi->type == type)
  1475. {
  1476. return CMD_SUCCESS;
  1477. }
  1478. oi->type = type;
  1479. /* Reset the interface */
  1480. thread_add_event (master, interface_down, oi, 0);
  1481. thread_add_event (master, interface_up, oi, 0);
  1482. return CMD_SUCCESS;
  1483. }
  1484. static int
  1485. config_write_ospf6_interface (struct vty *vty)
  1486. {
  1487. struct listnode *i;
  1488. struct ospf6_interface *oi;
  1489. struct interface *ifp;
  1490. for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
  1491. {
  1492. oi = (struct ospf6_interface *) ifp->info;
  1493. if (oi == NULL)
  1494. continue;
  1495. vty_out (vty, "interface %s%s",
  1496. oi->interface->name, VNL);
  1497. if (ifp->desc)
  1498. vty_out (vty, " description %s%s", ifp->desc, VNL);
  1499. if (ifp->mtu6 != oi->ifmtu)
  1500. vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
  1501. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
  1502. vty_out (vty, " ipv6 ospf6 cost %d%s",
  1503. oi->cost, VNL);
  1504. if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
  1505. vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
  1506. oi->hello_interval, VNL);
  1507. if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
  1508. vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
  1509. oi->dead_interval, VNL);
  1510. if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
  1511. vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
  1512. oi->rxmt_interval, VNL);
  1513. if (oi->priority != OSPF6_INTERFACE_PRIORITY)
  1514. vty_out (vty, " ipv6 ospf6 priority %d%s",
  1515. oi->priority, VNL);
  1516. if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
  1517. vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
  1518. oi->transdelay, VNL);
  1519. if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
  1520. vty_out (vty, " ipv6 ospf6 instance-id %d%s",
  1521. oi->instance_id, VNL);
  1522. if (oi->plist_name)
  1523. vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
  1524. oi->plist_name, VNL);
  1525. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
  1526. vty_out (vty, " ipv6 ospf6 passive%s", VNL);
  1527. if (oi->mtu_ignore)
  1528. vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
  1529. if (oi->type == OSPF_IFTYPE_POINTOPOINT)
  1530. vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
  1531. else if (oi->type == OSPF_IFTYPE_BROADCAST)
  1532. vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
  1533. vty_out (vty, "!%s", VNL);
  1534. }
  1535. return 0;
  1536. }
  1537. static struct cmd_node interface_node =
  1538. {
  1539. INTERFACE_NODE,
  1540. "%s(config-if)# ",
  1541. 1 /* VTYSH */
  1542. };
  1543. void
  1544. ospf6_interface_init (void)
  1545. {
  1546. /* Install interface node. */
  1547. install_node (&interface_node, config_write_ospf6_interface);
  1548. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
  1549. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
  1550. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
  1551. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
  1552. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
  1553. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
  1554. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
  1555. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
  1556. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd);
  1557. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
  1558. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
  1559. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
  1560. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
  1561. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
  1562. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
  1563. install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
  1564. install_element (CONFIG_NODE, &interface_cmd);
  1565. install_default (INTERFACE_NODE);
  1566. install_element (INTERFACE_NODE, &interface_desc_cmd);
  1567. install_element (INTERFACE_NODE, &no_interface_desc_cmd);
  1568. install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
  1569. install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
  1570. install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
  1571. install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
  1572. install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
  1573. install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
  1574. install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
  1575. install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
  1576. install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
  1577. install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
  1578. install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
  1579. install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
  1580. install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
  1581. install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
  1582. install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
  1583. install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
  1584. install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
  1585. install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
  1586. /* reference bandwidth commands */
  1587. install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
  1588. install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
  1589. }
  1590. DEFUN (debug_ospf6_interface,
  1591. debug_ospf6_interface_cmd,
  1592. "debug ospf6 interface",
  1593. DEBUG_STR
  1594. OSPF6_STR
  1595. "Debug OSPFv3 Interface\n"
  1596. )
  1597. {
  1598. OSPF6_DEBUG_INTERFACE_ON ();
  1599. return CMD_SUCCESS;
  1600. }
  1601. DEFUN (no_debug_ospf6_interface,
  1602. no_debug_ospf6_interface_cmd,
  1603. "no debug ospf6 interface",
  1604. NO_STR
  1605. DEBUG_STR
  1606. OSPF6_STR
  1607. "Debug OSPFv3 Interface\n"
  1608. )
  1609. {
  1610. OSPF6_DEBUG_INTERFACE_OFF ();
  1611. return CMD_SUCCESS;
  1612. }
  1613. int
  1614. config_write_ospf6_debug_interface (struct vty *vty)
  1615. {
  1616. if (IS_OSPF6_DEBUG_INTERFACE)
  1617. vty_out (vty, "debug ospf6 interface%s", VNL);
  1618. return 0;
  1619. }
  1620. void
  1621. install_element_ospf6_debug_interface (void)
  1622. {
  1623. install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
  1624. install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
  1625. install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
  1626. install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
  1627. }