interface.c 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848
  1. /*
  2. * Interface function.
  3. * Copyright (C) 1997, 1999 Kunihiro Ishiguro
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2, or (at your option) any
  10. * later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  19. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. * 02111-1307, USA.
  21. */
  22. #include <zebra.h>
  23. #include "if.h"
  24. #include "vty.h"
  25. #include "sockunion.h"
  26. #include "prefix.h"
  27. #include "command.h"
  28. #include "memory.h"
  29. #include "ioctl.h"
  30. #include "connected.h"
  31. #include "log.h"
  32. #include "zclient.h"
  33. #include "vrf.h"
  34. #include "zebra/interface.h"
  35. #include "zebra/rtadv.h"
  36. #include "zebra/rib.h"
  37. #include "zebra/zserv.h"
  38. #include "zebra/redistribute.h"
  39. #include "zebra/debug.h"
  40. #include "zebra/irdp.h"
  41. #ifdef RTADV
  42. /* Order is intentional. Matches RFC4191. This array is also used for
  43. command matching, so only modify with care. */
  44. const char *rtadv_pref_strs[] = { "medium", "high", "INVALID", "low", 0 };
  45. #endif /* RTADV */
  46. /* Called when new interface is added. */
  47. static int
  48. if_zebra_new_hook (struct interface *ifp)
  49. {
  50. struct zebra_if *zebra_if;
  51. zebra_if = XCALLOC (MTYPE_TMP, sizeof (struct zebra_if));
  52. zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC;
  53. zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_OFF;
  54. #ifdef RTADV
  55. {
  56. /* Set default router advertise values. */
  57. struct rtadvconf *rtadv;
  58. rtadv = &zebra_if->rtadv;
  59. rtadv->AdvSendAdvertisements = 0;
  60. rtadv->MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL;
  61. rtadv->MinRtrAdvInterval = RTADV_MIN_RTR_ADV_INTERVAL;
  62. rtadv->AdvIntervalTimer = 0;
  63. rtadv->AdvManagedFlag = 0;
  64. rtadv->AdvOtherConfigFlag = 0;
  65. rtadv->AdvHomeAgentFlag = 0;
  66. rtadv->AdvLinkMTU = 0;
  67. rtadv->AdvReachableTime = 0;
  68. rtadv->AdvRetransTimer = 0;
  69. rtadv->AdvCurHopLimit = 0;
  70. rtadv->AdvDefaultLifetime = -1; /* derive from MaxRtrAdvInterval */
  71. rtadv->HomeAgentPreference = 0;
  72. rtadv->HomeAgentLifetime = -1; /* derive from AdvDefaultLifetime */
  73. rtadv->AdvIntervalOption = 0;
  74. rtadv->DefaultPreference = RTADV_PREF_MEDIUM;
  75. rtadv->AdvPrefixList = list_new ();
  76. }
  77. #endif /* RTADV */
  78. /* Initialize installed address chains tree. */
  79. zebra_if->ipv4_subnets = route_table_init ();
  80. ifp->info = zebra_if;
  81. return 0;
  82. }
  83. /* Called when interface is deleted. */
  84. static int
  85. if_zebra_delete_hook (struct interface *ifp)
  86. {
  87. struct zebra_if *zebra_if;
  88. if (ifp->info)
  89. {
  90. zebra_if = ifp->info;
  91. /* Free installed address chains tree. */
  92. if (zebra_if->ipv4_subnets)
  93. route_table_finish (zebra_if->ipv4_subnets);
  94. XFREE (MTYPE_TMP, zebra_if);
  95. }
  96. return 0;
  97. }
  98. /* Tie an interface address to its derived subnet list of addresses. */
  99. int
  100. if_subnet_add (struct interface *ifp, struct connected *ifc)
  101. {
  102. struct route_node *rn;
  103. struct zebra_if *zebra_if;
  104. struct prefix cp;
  105. struct list *addr_list;
  106. assert (ifp && ifp->info && ifc);
  107. zebra_if = ifp->info;
  108. /* Get address derived subnet node and associated address list, while marking
  109. address secondary attribute appropriately. */
  110. cp = *ifc->address;
  111. apply_mask (&cp);
  112. rn = route_node_get (zebra_if->ipv4_subnets, &cp);
  113. if ((addr_list = rn->info))
  114. SET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY);
  115. else
  116. {
  117. UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY);
  118. rn->info = addr_list = list_new ();
  119. route_lock_node (rn);
  120. }
  121. /* Tie address at the tail of address list. */
  122. listnode_add (addr_list, ifc);
  123. /* Return list element count. */
  124. return (addr_list->count);
  125. }
  126. /* Untie an interface address from its derived subnet list of addresses. */
  127. int
  128. if_subnet_delete (struct interface *ifp, struct connected *ifc)
  129. {
  130. struct route_node *rn;
  131. struct zebra_if *zebra_if;
  132. struct list *addr_list;
  133. assert (ifp && ifp->info && ifc);
  134. zebra_if = ifp->info;
  135. /* Get address derived subnet node. */
  136. rn = route_node_lookup (zebra_if->ipv4_subnets, ifc->address);
  137. if (! (rn && rn->info))
  138. {
  139. zlog_warn("Trying to remove an address from an unknown subnet."
  140. " (please report this bug)");
  141. return -1;
  142. }
  143. route_unlock_node (rn);
  144. /* Untie address from subnet's address list. */
  145. addr_list = rn->info;
  146. /* Deleting an address that is not registered is a bug.
  147. * In any case, we shouldn't decrement the lock counter if the address
  148. * is unknown. */
  149. if (!listnode_lookup(addr_list, ifc))
  150. {
  151. zlog_warn("Trying to remove an address from a subnet where it is not"
  152. " currently registered. (please report this bug)");
  153. return -1;
  154. }
  155. listnode_delete (addr_list, ifc);
  156. route_unlock_node (rn);
  157. /* Return list element count, if not empty. */
  158. if (addr_list->count)
  159. {
  160. /* If deleted address is primary, mark subsequent one as such and distribute. */
  161. if (! CHECK_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY))
  162. {
  163. ifc = listgetdata (listhead (addr_list));
  164. zebra_interface_address_delete_update (ifp, ifc);
  165. UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY);
  166. /* XXX: Linux kernel removes all the secondary addresses when the primary
  167. * address is removed. We could try to work around that, though this is
  168. * non-trivial. */
  169. zebra_interface_address_add_update (ifp, ifc);
  170. }
  171. return addr_list->count;
  172. }
  173. /* Otherwise, free list and route node. */
  174. list_free (addr_list);
  175. rn->info = NULL;
  176. route_unlock_node (rn);
  177. return 0;
  178. }
  179. /* if_flags_mangle: A place for hacks that require mangling
  180. * or tweaking the interface flags.
  181. *
  182. * ******************** Solaris flags hacks **************************
  183. *
  184. * Solaris IFF_UP flag reflects only the primary interface as the
  185. * routing socket only sends IFINFO for the primary interface. Hence
  186. * ~IFF_UP does not per se imply all the logical interfaces are also
  187. * down - which we only know of as addresses. Instead we must determine
  188. * whether the interface really is up or not according to how many
  189. * addresses are still attached. (Solaris always sends RTM_DELADDR if
  190. * an interface, logical or not, goes ~IFF_UP).
  191. *
  192. * Ie, we mangle IFF_UP to *additionally* reflect whether or not there
  193. * are addresses left in struct connected, not just the actual underlying
  194. * IFF_UP flag.
  195. *
  196. * We must hence remember the real state of IFF_UP, which we do in
  197. * struct zebra_if.primary_state.
  198. *
  199. * Setting IFF_UP within zebra to administratively shutdown the
  200. * interface will affect only the primary interface/address on Solaris.
  201. ************************End Solaris flags hacks ***********************
  202. */
  203. static void
  204. if_flags_mangle (struct interface *ifp, uint64_t *newflags)
  205. {
  206. #ifdef SUNOS_5
  207. struct zebra_if *zif = ifp->info;
  208. zif->primary_state = *newflags & (IFF_UP & 0xff);
  209. if (CHECK_FLAG (zif->primary_state, IFF_UP)
  210. || listcount(ifp->connected) > 0)
  211. SET_FLAG (*newflags, IFF_UP);
  212. else
  213. UNSET_FLAG (*newflags, IFF_UP);
  214. #endif /* SUNOS_5 */
  215. }
  216. /* Update the flags field of the ifp with the new flag set provided.
  217. * Take whatever actions are required for any changes in flags we care
  218. * about.
  219. *
  220. * newflags should be the raw value, as obtained from the OS.
  221. */
  222. void
  223. if_flags_update (struct interface *ifp, uint64_t newflags)
  224. {
  225. if_flags_mangle (ifp, &newflags);
  226. if (if_is_operative (ifp))
  227. {
  228. /* operative -> inoperative? */
  229. ifp->flags = newflags;
  230. if (!if_is_operative (ifp))
  231. if_down (ifp);
  232. }
  233. else
  234. {
  235. /* inoperative -> operative? */
  236. ifp->flags = newflags;
  237. if (if_is_operative (ifp))
  238. if_up (ifp);
  239. }
  240. }
  241. /* Wake up configured address if it is not in current kernel
  242. address. */
  243. static void
  244. if_addr_wakeup (struct interface *ifp)
  245. {
  246. struct listnode *node, *nnode;
  247. struct connected *ifc;
  248. struct prefix *p;
  249. int ret;
  250. for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc))
  251. {
  252. p = ifc->address;
  253. if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)
  254. && ! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED))
  255. {
  256. /* Address check. */
  257. if (p->family == AF_INET)
  258. {
  259. if (! if_is_up (ifp))
  260. {
  261. /* Assume zebra is configured like following:
  262. *
  263. * interface gre0
  264. * ip addr 192.0.2.1/24
  265. * !
  266. *
  267. * As soon as zebra becomes first aware that gre0 exists in the
  268. * kernel, it will set gre0 up and configure its addresses.
  269. *
  270. * (This may happen at startup when the interface already exists
  271. * or during runtime when the interface is added to the kernel)
  272. *
  273. * XXX: IRDP code is calling here via if_add_update - this seems
  274. * somewhat weird.
  275. * XXX: RUNNING is not a settable flag on any system
  276. * I (paulj) am aware of.
  277. */
  278. if_set_flags (ifp, IFF_UP | IFF_RUNNING);
  279. if_refresh (ifp);
  280. }
  281. ret = if_set_prefix (ifp, ifc);
  282. if (ret < 0)
  283. {
  284. zlog_warn ("Can't set interface's address: %s",
  285. safe_strerror(errno));
  286. continue;
  287. }
  288. SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  289. /* The address will be advertised to zebra clients when the notification
  290. * from the kernel has been received.
  291. * It will also be added to the interface's subnet list then. */
  292. }
  293. #ifdef HAVE_IPV6
  294. if (p->family == AF_INET6)
  295. {
  296. if (! if_is_up (ifp))
  297. {
  298. /* See long comment above */
  299. if_set_flags (ifp, IFF_UP | IFF_RUNNING);
  300. if_refresh (ifp);
  301. }
  302. ret = if_prefix_add_ipv6 (ifp, ifc);
  303. if (ret < 0)
  304. {
  305. zlog_warn ("Can't set interface's address: %s",
  306. safe_strerror(errno));
  307. continue;
  308. }
  309. SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  310. /* The address will be advertised to zebra clients when the notification
  311. * from the kernel has been received. */
  312. }
  313. #endif /* HAVE_IPV6 */
  314. }
  315. }
  316. }
  317. /* Handle interface addition */
  318. void
  319. if_add_update (struct interface *ifp)
  320. {
  321. struct zebra_if *if_data;
  322. if_data = ifp->info;
  323. if (if_data->multicast == IF_ZEBRA_MULTICAST_ON)
  324. if_set_flags (ifp, IFF_MULTICAST);
  325. else if (if_data->multicast == IF_ZEBRA_MULTICAST_OFF)
  326. if_unset_flags (ifp, IFF_MULTICAST);
  327. zebra_interface_add_update (ifp);
  328. if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
  329. {
  330. SET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
  331. if (if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)
  332. {
  333. if (IS_ZEBRA_DEBUG_KERNEL)
  334. zlog_debug ("interface %s vrf %u index %d is shutdown. "
  335. "Won't wake it up.",
  336. ifp->name, ifp->vrf_id, ifp->ifindex);
  337. return;
  338. }
  339. if_addr_wakeup (ifp);
  340. if (IS_ZEBRA_DEBUG_KERNEL)
  341. zlog_debug ("interface %s vrf %u index %d becomes active.",
  342. ifp->name, ifp->vrf_id, ifp->ifindex);
  343. }
  344. else
  345. {
  346. if (IS_ZEBRA_DEBUG_KERNEL)
  347. zlog_debug ("interface %s vrf %u index %d is added.",
  348. ifp->name, ifp->vrf_id, ifp->ifindex);
  349. }
  350. }
  351. /* Handle an interface delete event */
  352. void
  353. if_delete_update (struct interface *ifp)
  354. {
  355. struct connected *ifc;
  356. struct prefix *p;
  357. struct route_node *rn;
  358. struct zebra_if *zebra_if;
  359. zebra_if = ifp->info;
  360. if (if_is_up(ifp))
  361. {
  362. zlog_err ("interface %s vrf %u index %d is still up while being deleted.",
  363. ifp->name, ifp->vrf_id, ifp->ifindex);
  364. return;
  365. }
  366. /* Mark interface as inactive */
  367. UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
  368. if (IS_ZEBRA_DEBUG_KERNEL)
  369. zlog_debug ("interface %s vrf %u index %d is now inactive.",
  370. ifp->name, ifp->vrf_id, ifp->ifindex);
  371. /* Delete connected routes from the kernel. */
  372. if (ifp->connected)
  373. {
  374. struct listnode *node;
  375. struct listnode *last = NULL;
  376. while ((node = (last ? last->next : listhead (ifp->connected))))
  377. {
  378. ifc = listgetdata (node);
  379. p = ifc->address;
  380. if (p->family == AF_INET
  381. && (rn = route_node_lookup (zebra_if->ipv4_subnets, p)))
  382. {
  383. struct listnode *anode;
  384. struct listnode *next;
  385. struct listnode *first;
  386. struct list *addr_list;
  387. route_unlock_node (rn);
  388. addr_list = (struct list *) rn->info;
  389. /* Remove addresses, secondaries first. */
  390. first = listhead (addr_list);
  391. for (anode = first->next; anode || first; anode = next)
  392. {
  393. if (!anode)
  394. {
  395. anode = first;
  396. first = NULL;
  397. }
  398. next = anode->next;
  399. ifc = listgetdata (anode);
  400. p = ifc->address;
  401. connected_down_ipv4 (ifp, ifc);
  402. /* XXX: We have to send notifications here explicitly, because we destroy
  403. * the ifc before receiving the notification about the address being deleted.
  404. */
  405. zebra_interface_address_delete_update (ifp, ifc);
  406. UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
  407. UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  408. /* Remove from subnet chain. */
  409. list_delete_node (addr_list, anode);
  410. route_unlock_node (rn);
  411. /* Remove from interface address list (unconditionally). */
  412. if (!CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
  413. {
  414. listnode_delete (ifp->connected, ifc);
  415. connected_free (ifc);
  416. }
  417. else
  418. last = node;
  419. }
  420. /* Free chain list and respective route node. */
  421. list_delete (addr_list);
  422. rn->info = NULL;
  423. route_unlock_node (rn);
  424. }
  425. #ifdef HAVE_IPV6
  426. else if (p->family == AF_INET6)
  427. {
  428. connected_down_ipv6 (ifp, ifc);
  429. zebra_interface_address_delete_update (ifp, ifc);
  430. UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
  431. UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  432. if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
  433. last = node;
  434. else
  435. {
  436. listnode_delete (ifp->connected, ifc);
  437. connected_free (ifc);
  438. }
  439. }
  440. #endif /* HAVE_IPV6 */
  441. else
  442. {
  443. last = node;
  444. }
  445. }
  446. }
  447. zebra_interface_delete_update (ifp);
  448. /* Update ifindex after distributing the delete message. This is in
  449. case any client needs to have the old value of ifindex available
  450. while processing the deletion. Each client daemon is responsible
  451. for setting ifindex to IFINDEX_INTERNAL after processing the
  452. interface deletion message. */
  453. ifp->ifindex = IFINDEX_INTERNAL;
  454. }
  455. /* Interface is up. */
  456. void
  457. if_up (struct interface *ifp)
  458. {
  459. struct listnode *node;
  460. struct listnode *next;
  461. struct connected *ifc;
  462. struct prefix *p;
  463. /* Notify the protocol daemons. */
  464. zebra_interface_up_update (ifp);
  465. /* Install connected routes to the kernel. */
  466. if (ifp->connected)
  467. {
  468. for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
  469. {
  470. p = ifc->address;
  471. if (p->family == AF_INET)
  472. connected_up_ipv4 (ifp, ifc);
  473. #ifdef HAVE_IPV6
  474. else if (p->family == AF_INET6)
  475. connected_up_ipv6 (ifp, ifc);
  476. #endif /* HAVE_IPV6 */
  477. }
  478. }
  479. /* Examine all static routes. */
  480. rib_update (ifp->vrf_id);
  481. }
  482. /* Interface goes down. We have to manage different behavior of based
  483. OS. */
  484. void
  485. if_down (struct interface *ifp)
  486. {
  487. struct listnode *node;
  488. struct listnode *next;
  489. struct connected *ifc;
  490. struct prefix *p;
  491. /* Notify to the protocol daemons. */
  492. zebra_interface_down_update (ifp);
  493. /* Delete connected routes from the kernel. */
  494. if (ifp->connected)
  495. {
  496. for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
  497. {
  498. p = ifc->address;
  499. if (p->family == AF_INET)
  500. connected_down_ipv4 (ifp, ifc);
  501. #ifdef HAVE_IPV6
  502. else if (p->family == AF_INET6)
  503. connected_down_ipv6 (ifp, ifc);
  504. #endif /* HAVE_IPV6 */
  505. }
  506. }
  507. /* Examine all static routes which direct to the interface. */
  508. rib_update (ifp->vrf_id);
  509. }
  510. void
  511. if_refresh (struct interface *ifp)
  512. {
  513. if_get_flags (ifp);
  514. }
  515. /* Output prefix string to vty. */
  516. static int
  517. prefix_vty_out (struct vty *vty, struct prefix *p)
  518. {
  519. char str[INET6_ADDRSTRLEN];
  520. inet_ntop (p->family, &p->u.prefix, str, sizeof (str));
  521. vty_out (vty, "%s", str);
  522. return strlen (str);
  523. }
  524. /* Dump if address information to vty. */
  525. static void
  526. connected_dump_vty (struct vty *vty, struct connected *connected)
  527. {
  528. struct prefix *p;
  529. /* Print interface address. */
  530. p = connected->address;
  531. vty_out (vty, " %s ", prefix_family_str (p));
  532. prefix_vty_out (vty, p);
  533. vty_out (vty, "/%d", p->prefixlen);
  534. /* If there is destination address, print it. */
  535. if (connected->destination)
  536. {
  537. vty_out (vty, (CONNECTED_PEER(connected) ? " peer " : " broadcast "));
  538. prefix_vty_out (vty, connected->destination);
  539. }
  540. if (CHECK_FLAG (connected->flags, ZEBRA_IFA_SECONDARY))
  541. vty_out (vty, " secondary");
  542. if (connected->label)
  543. vty_out (vty, " %s", connected->label);
  544. vty_out (vty, "%s", VTY_NEWLINE);
  545. }
  546. #ifdef RTADV
  547. /* Dump interface ND information to vty. */
  548. static void
  549. nd_dump_vty (struct vty *vty, struct interface *ifp)
  550. {
  551. struct zebra_if *zif;
  552. struct rtadvconf *rtadv;
  553. int interval;
  554. zif = (struct zebra_if *) ifp->info;
  555. rtadv = &zif->rtadv;
  556. if (rtadv->AdvSendAdvertisements)
  557. {
  558. vty_out (vty, " ND advertised reachable time is %d milliseconds%s",
  559. rtadv->AdvReachableTime, VTY_NEWLINE);
  560. vty_out (vty, " ND advertised retransmit interval is %d milliseconds%s",
  561. rtadv->AdvRetransTimer, VTY_NEWLINE);
  562. interval = rtadv->MaxRtrAdvInterval;
  563. if (interval % 1000)
  564. vty_out (vty, " ND router advertisements are sent every "
  565. "%d milliseconds%s", interval,
  566. VTY_NEWLINE);
  567. else
  568. vty_out (vty, " ND router advertisements are sent every "
  569. "%d seconds%s", interval / 1000,
  570. VTY_NEWLINE);
  571. if (rtadv->AdvDefaultLifetime != -1)
  572. vty_out (vty, " ND router advertisements live for %d seconds%s",
  573. rtadv->AdvDefaultLifetime, VTY_NEWLINE);
  574. else
  575. vty_out (vty, " ND router advertisements lifetime tracks ra-interval%s",
  576. VTY_NEWLINE);
  577. vty_out (vty, " ND router advertisement default router preference is "
  578. "%s%s", rtadv_pref_strs[rtadv->DefaultPreference],
  579. VTY_NEWLINE);
  580. if (rtadv->AdvManagedFlag)
  581. vty_out (vty, " Hosts use DHCP to obtain routable addresses.%s",
  582. VTY_NEWLINE);
  583. else
  584. vty_out (vty, " Hosts use stateless autoconfig for addresses.%s",
  585. VTY_NEWLINE);
  586. if (rtadv->AdvHomeAgentFlag)
  587. {
  588. vty_out (vty, " ND router advertisements with "
  589. "Home Agent flag bit set.%s",
  590. VTY_NEWLINE);
  591. if (rtadv->HomeAgentLifetime != -1)
  592. vty_out (vty, " Home Agent lifetime is %u seconds%s",
  593. rtadv->HomeAgentLifetime, VTY_NEWLINE);
  594. else
  595. vty_out (vty, " Home Agent lifetime tracks ra-lifetime%s",
  596. VTY_NEWLINE);
  597. vty_out (vty, " Home Agent preference is %u%s",
  598. rtadv->HomeAgentPreference, VTY_NEWLINE);
  599. }
  600. if (rtadv->AdvIntervalOption)
  601. vty_out (vty, " ND router advertisements with Adv. Interval option.%s",
  602. VTY_NEWLINE);
  603. }
  604. }
  605. #endif /* RTADV */
  606. /* Interface's information print out to vty interface. */
  607. static void
  608. if_dump_vty (struct vty *vty, struct interface *ifp)
  609. {
  610. #ifdef HAVE_STRUCT_SOCKADDR_DL
  611. struct sockaddr_dl *sdl;
  612. #endif /* HAVE_STRUCT_SOCKADDR_DL */
  613. struct connected *connected;
  614. struct listnode *node;
  615. struct route_node *rn;
  616. struct zebra_if *zebra_if;
  617. zebra_if = ifp->info;
  618. vty_out (vty, "Interface %s is ", ifp->name);
  619. if (if_is_up(ifp)) {
  620. vty_out (vty, "up, line protocol ");
  621. if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) {
  622. if (if_is_running(ifp))
  623. vty_out (vty, "is up%s", VTY_NEWLINE);
  624. else
  625. vty_out (vty, "is down%s", VTY_NEWLINE);
  626. } else {
  627. vty_out (vty, "detection is disabled%s", VTY_NEWLINE);
  628. }
  629. } else {
  630. vty_out (vty, "down%s", VTY_NEWLINE);
  631. }
  632. vty_out (vty, " vrf: %u%s", ifp->vrf_id, VTY_NEWLINE);
  633. if (ifp->desc)
  634. vty_out (vty, " Description: %s%s", ifp->desc,
  635. VTY_NEWLINE);
  636. if (ifp->ifindex == IFINDEX_INTERNAL)
  637. {
  638. vty_out(vty, " pseudo interface%s", VTY_NEWLINE);
  639. return;
  640. }
  641. else if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
  642. {
  643. vty_out(vty, " index %d inactive interface%s",
  644. ifp->ifindex,
  645. VTY_NEWLINE);
  646. return;
  647. }
  648. vty_out (vty, " index %d metric %d mtu %d ",
  649. ifp->ifindex, ifp->metric, ifp->mtu);
  650. #ifdef HAVE_IPV6
  651. if (ifp->mtu6 != ifp->mtu)
  652. vty_out (vty, "mtu6 %d ", ifp->mtu6);
  653. #endif
  654. vty_out (vty, "%s flags: %s%s", VTY_NEWLINE,
  655. if_flag_dump (ifp->flags), VTY_NEWLINE);
  656. /* Hardware address. */
  657. #ifdef HAVE_STRUCT_SOCKADDR_DL
  658. sdl = &ifp->sdl;
  659. if (sdl != NULL && sdl->sdl_alen != 0)
  660. {
  661. int i;
  662. u_char *ptr;
  663. vty_out (vty, " HWaddr: ");
  664. for (i = 0, ptr = (u_char *)LLADDR (sdl); i < sdl->sdl_alen; i++, ptr++)
  665. vty_out (vty, "%s%02x", i == 0 ? "" : ":", *ptr);
  666. vty_out (vty, "%s", VTY_NEWLINE);
  667. }
  668. #else
  669. if (ifp->hw_addr_len != 0)
  670. {
  671. int i;
  672. vty_out (vty, " HWaddr: ");
  673. for (i = 0; i < ifp->hw_addr_len; i++)
  674. vty_out (vty, "%s%02x", i == 0 ? "" : ":", ifp->hw_addr[i]);
  675. vty_out (vty, "%s", VTY_NEWLINE);
  676. }
  677. #endif /* HAVE_STRUCT_SOCKADDR_DL */
  678. /* Bandwidth in kbps */
  679. if (ifp->bandwidth != 0)
  680. {
  681. vty_out(vty, " bandwidth %u kbps", ifp->bandwidth);
  682. vty_out(vty, "%s", VTY_NEWLINE);
  683. }
  684. for (rn = route_top (zebra_if->ipv4_subnets); rn; rn = route_next (rn))
  685. {
  686. if (! rn->info)
  687. continue;
  688. for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, connected))
  689. connected_dump_vty (vty, connected);
  690. }
  691. for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
  692. {
  693. if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) &&
  694. (connected->address->family == AF_INET6))
  695. connected_dump_vty (vty, connected);
  696. }
  697. #ifdef RTADV
  698. nd_dump_vty (vty, ifp);
  699. #endif /* RTADV */
  700. #ifdef HAVE_PROC_NET_DEV
  701. /* Statistics print out using proc file system. */
  702. vty_out (vty, " %lu input packets (%lu multicast), %lu bytes, "
  703. "%lu dropped%s",
  704. ifp->stats.rx_packets, ifp->stats.rx_multicast,
  705. ifp->stats.rx_bytes, ifp->stats.rx_dropped, VTY_NEWLINE);
  706. vty_out (vty, " %lu input errors, %lu length, %lu overrun,"
  707. " %lu CRC, %lu frame%s",
  708. ifp->stats.rx_errors, ifp->stats.rx_length_errors,
  709. ifp->stats.rx_over_errors, ifp->stats.rx_crc_errors,
  710. ifp->stats.rx_frame_errors, VTY_NEWLINE);
  711. vty_out (vty, " %lu fifo, %lu missed%s", ifp->stats.rx_fifo_errors,
  712. ifp->stats.rx_missed_errors, VTY_NEWLINE);
  713. vty_out (vty, " %lu output packets, %lu bytes, %lu dropped%s",
  714. ifp->stats.tx_packets, ifp->stats.tx_bytes,
  715. ifp->stats.tx_dropped, VTY_NEWLINE);
  716. vty_out (vty, " %lu output errors, %lu aborted, %lu carrier,"
  717. " %lu fifo, %lu heartbeat%s",
  718. ifp->stats.tx_errors, ifp->stats.tx_aborted_errors,
  719. ifp->stats.tx_carrier_errors, ifp->stats.tx_fifo_errors,
  720. ifp->stats.tx_heartbeat_errors, VTY_NEWLINE);
  721. vty_out (vty, " %lu window, %lu collisions%s",
  722. ifp->stats.tx_window_errors, ifp->stats.collisions, VTY_NEWLINE);
  723. #endif /* HAVE_PROC_NET_DEV */
  724. #ifdef HAVE_NET_RT_IFLIST
  725. #if defined (__bsdi__) || defined (__NetBSD__)
  726. /* Statistics print out using sysctl (). */
  727. vty_out (vty, " input packets %llu, bytes %llu, dropped %llu,"
  728. " multicast packets %llu%s",
  729. (unsigned long long)ifp->stats.ifi_ipackets,
  730. (unsigned long long)ifp->stats.ifi_ibytes,
  731. (unsigned long long)ifp->stats.ifi_iqdrops,
  732. (unsigned long long)ifp->stats.ifi_imcasts,
  733. VTY_NEWLINE);
  734. vty_out (vty, " input errors %llu%s",
  735. (unsigned long long)ifp->stats.ifi_ierrors, VTY_NEWLINE);
  736. vty_out (vty, " output packets %llu, bytes %llu,"
  737. " multicast packets %llu%s",
  738. (unsigned long long)ifp->stats.ifi_opackets,
  739. (unsigned long long)ifp->stats.ifi_obytes,
  740. (unsigned long long)ifp->stats.ifi_omcasts,
  741. VTY_NEWLINE);
  742. vty_out (vty, " output errors %llu%s",
  743. (unsigned long long)ifp->stats.ifi_oerrors, VTY_NEWLINE);
  744. vty_out (vty, " collisions %llu%s",
  745. (unsigned long long)ifp->stats.ifi_collisions, VTY_NEWLINE);
  746. #else
  747. /* Statistics print out using sysctl (). */
  748. vty_out (vty, " input packets %lu, bytes %lu, dropped %lu,"
  749. " multicast packets %lu%s",
  750. ifp->stats.ifi_ipackets, ifp->stats.ifi_ibytes,
  751. ifp->stats.ifi_iqdrops, ifp->stats.ifi_imcasts,
  752. VTY_NEWLINE);
  753. vty_out (vty, " input errors %lu%s",
  754. ifp->stats.ifi_ierrors, VTY_NEWLINE);
  755. vty_out (vty, " output packets %lu, bytes %lu, multicast packets %lu%s",
  756. ifp->stats.ifi_opackets, ifp->stats.ifi_obytes,
  757. ifp->stats.ifi_omcasts, VTY_NEWLINE);
  758. vty_out (vty, " output errors %lu%s",
  759. ifp->stats.ifi_oerrors, VTY_NEWLINE);
  760. vty_out (vty, " collisions %lu%s",
  761. ifp->stats.ifi_collisions, VTY_NEWLINE);
  762. #endif /* __bsdi__ || __NetBSD__ */
  763. #endif /* HAVE_NET_RT_IFLIST */
  764. }
  765. /* Wrapper hook point for zebra daemon so that ifindex can be set
  766. * DEFUN macro not used as extract.pl HAS to ignore this
  767. * See also interface_cmd in lib/if.c
  768. */
  769. DEFUN_NOSH (zebra_interface,
  770. zebra_interface_cmd,
  771. "interface IFNAME",
  772. "Select an interface to configure\n"
  773. "Interface's name\n")
  774. {
  775. int ret;
  776. struct interface * ifp;
  777. /* Call lib interface() */
  778. if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS)
  779. return ret;
  780. ifp = vty->index;
  781. if (ifp->ifindex == IFINDEX_INTERNAL)
  782. /* Is this really necessary? Shouldn't status be initialized to 0
  783. in that case? */
  784. UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
  785. return ret;
  786. }
  787. ALIAS (zebra_interface,
  788. zebra_interface_vrf_cmd,
  789. "interface IFNAME " VRF_CMD_STR,
  790. "Select an interface to configure\n"
  791. "Interface's name\n"
  792. VRF_CMD_HELP_STR)
  793. struct cmd_node interface_node =
  794. {
  795. INTERFACE_NODE,
  796. "%s(config-if)# ",
  797. 1
  798. };
  799. /* Show all interfaces to vty. */
  800. DEFUN (show_interface, show_interface_cmd,
  801. "show interface",
  802. SHOW_STR
  803. "Interface status and configuration\n")
  804. {
  805. struct listnode *node;
  806. struct interface *ifp;
  807. vrf_id_t vrf_id = VRF_DEFAULT;
  808. #ifdef HAVE_PROC_NET_DEV
  809. /* If system has interface statistics via proc file system, update
  810. statistics. */
  811. ifstat_update_proc ();
  812. #endif /* HAVE_PROC_NET_DEV */
  813. #ifdef HAVE_NET_RT_IFLIST
  814. ifstat_update_sysctl ();
  815. #endif /* HAVE_NET_RT_IFLIST */
  816. if (argc > 0)
  817. VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
  818. /* All interface print. */
  819. for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp))
  820. if_dump_vty (vty, ifp);
  821. return CMD_SUCCESS;
  822. }
  823. ALIAS (show_interface,
  824. show_interface_vrf_cmd,
  825. "show interface " VRF_CMD_STR,
  826. SHOW_STR
  827. "Interface status and configuration\n"
  828. VRF_CMD_HELP_STR)
  829. /* Show all interfaces to vty. */
  830. DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd,
  831. "show interface " VRF_ALL_CMD_STR,
  832. SHOW_STR
  833. "Interface status and configuration\n"
  834. VRF_ALL_CMD_HELP_STR)
  835. {
  836. struct listnode *node;
  837. struct interface *ifp;
  838. vrf_iter_t iter;
  839. #ifdef HAVE_PROC_NET_DEV
  840. /* If system has interface statistics via proc file system, update
  841. statistics. */
  842. ifstat_update_proc ();
  843. #endif /* HAVE_PROC_NET_DEV */
  844. #ifdef HAVE_NET_RT_IFLIST
  845. ifstat_update_sysctl ();
  846. #endif /* HAVE_NET_RT_IFLIST */
  847. /* All interface print. */
  848. for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
  849. for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp))
  850. if_dump_vty (vty, ifp);
  851. return CMD_SUCCESS;
  852. }
  853. /* Show specified interface to vty. */
  854. DEFUN (show_interface_name, show_interface_name_cmd,
  855. "show interface IFNAME",
  856. SHOW_STR
  857. "Interface status and configuration\n"
  858. "Inteface name\n")
  859. {
  860. struct interface *ifp;
  861. vrf_id_t vrf_id = VRF_DEFAULT;
  862. #ifdef HAVE_PROC_NET_DEV
  863. /* If system has interface statistics via proc file system, update
  864. statistics. */
  865. ifstat_update_proc ();
  866. #endif /* HAVE_PROC_NET_DEV */
  867. #ifdef HAVE_NET_RT_IFLIST
  868. ifstat_update_sysctl ();
  869. #endif /* HAVE_NET_RT_IFLIST */
  870. if (argc > 1)
  871. VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
  872. /* Specified interface print. */
  873. ifp = if_lookup_by_name_vrf (argv[0], vrf_id);
  874. if (ifp == NULL)
  875. {
  876. vty_out (vty, "%% Can't find interface %s%s", argv[0],
  877. VTY_NEWLINE);
  878. return CMD_WARNING;
  879. }
  880. if_dump_vty (vty, ifp);
  881. return CMD_SUCCESS;
  882. }
  883. ALIAS (show_interface_name,
  884. show_interface_name_vrf_cmd,
  885. "show interface IFNAME " VRF_CMD_STR,
  886. SHOW_STR
  887. "Interface status and configuration\n"
  888. "Inteface name\n"
  889. VRF_CMD_HELP_STR)
  890. /* Show specified interface to vty. */
  891. DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd,
  892. "show interface IFNAME " VRF_ALL_CMD_STR,
  893. SHOW_STR
  894. "Interface status and configuration\n"
  895. "Inteface name\n"
  896. VRF_ALL_CMD_HELP_STR)
  897. {
  898. struct interface *ifp;
  899. vrf_iter_t iter;
  900. int found = 0;
  901. #ifdef HAVE_PROC_NET_DEV
  902. /* If system has interface statistics via proc file system, update
  903. statistics. */
  904. ifstat_update_proc ();
  905. #endif /* HAVE_PROC_NET_DEV */
  906. #ifdef HAVE_NET_RT_IFLIST
  907. ifstat_update_sysctl ();
  908. #endif /* HAVE_NET_RT_IFLIST */
  909. /* All interface print. */
  910. for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
  911. {
  912. /* Specified interface print. */
  913. ifp = if_lookup_by_name_vrf (argv[0], vrf_iter2id (iter));
  914. if (ifp)
  915. {
  916. if_dump_vty (vty, ifp);
  917. found++;
  918. }
  919. }
  920. if (!found)
  921. {
  922. vty_out (vty, "%% Can't find interface %s%s", argv[0], VTY_NEWLINE);
  923. return CMD_WARNING;
  924. }
  925. return CMD_SUCCESS;
  926. }
  927. static void
  928. if_show_description (struct vty *vty, vrf_id_t vrf_id)
  929. {
  930. struct listnode *node;
  931. struct interface *ifp;
  932. vty_out (vty, "Interface Status Protocol Description%s", VTY_NEWLINE);
  933. for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp))
  934. {
  935. int len;
  936. len = vty_out (vty, "%s", ifp->name);
  937. vty_out (vty, "%*s", (16 - len), " ");
  938. if (if_is_up(ifp))
  939. {
  940. vty_out (vty, "up ");
  941. if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))
  942. {
  943. if (if_is_running(ifp))
  944. vty_out (vty, "up ");
  945. else
  946. vty_out (vty, "down ");
  947. }
  948. else
  949. {
  950. vty_out (vty, "unknown ");
  951. }
  952. }
  953. else
  954. {
  955. vty_out (vty, "down down ");
  956. }
  957. if (ifp->desc)
  958. vty_out (vty, "%s", ifp->desc);
  959. vty_out (vty, "%s", VTY_NEWLINE);
  960. }
  961. }
  962. DEFUN (show_interface_desc,
  963. show_interface_desc_cmd,
  964. "show interface description",
  965. SHOW_STR
  966. "Interface status and configuration\n"
  967. "Interface description\n")
  968. {
  969. vrf_id_t vrf_id = VRF_DEFAULT;
  970. if (argc > 0)
  971. VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
  972. if_show_description (vty, vrf_id);
  973. return CMD_SUCCESS;
  974. }
  975. ALIAS (show_interface_desc,
  976. show_interface_desc_vrf_cmd,
  977. "show interface description " VRF_CMD_STR,
  978. SHOW_STR
  979. "Interface status and configuration\n"
  980. "Interface description\n"
  981. VRF_CMD_HELP_STR)
  982. DEFUN (show_interface_desc_vrf_all,
  983. show_interface_desc_vrf_all_cmd,
  984. "show interface description " VRF_ALL_CMD_STR,
  985. SHOW_STR
  986. "Interface status and configuration\n"
  987. "Interface description\n"
  988. VRF_ALL_CMD_HELP_STR)
  989. {
  990. vrf_iter_t iter;
  991. for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
  992. if (!list_isempty (vrf_iter2iflist (iter)))
  993. {
  994. vty_out (vty, "%s\tVRF %u%s%s", VTY_NEWLINE,
  995. vrf_iter2id (iter),
  996. VTY_NEWLINE, VTY_NEWLINE);
  997. if_show_description (vty, vrf_iter2id (iter));
  998. }
  999. return CMD_SUCCESS;
  1000. }
  1001. DEFUN (multicast,
  1002. multicast_cmd,
  1003. "multicast",
  1004. "Set multicast flag to interface\n")
  1005. {
  1006. int ret;
  1007. struct interface *ifp;
  1008. struct zebra_if *if_data;
  1009. ifp = (struct interface *) vty->index;
  1010. if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
  1011. {
  1012. ret = if_set_flags (ifp, IFF_MULTICAST);
  1013. if (ret < 0)
  1014. {
  1015. vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE);
  1016. return CMD_WARNING;
  1017. }
  1018. if_refresh (ifp);
  1019. }
  1020. if_data = ifp->info;
  1021. if_data->multicast = IF_ZEBRA_MULTICAST_ON;
  1022. return CMD_SUCCESS;
  1023. }
  1024. DEFUN (no_multicast,
  1025. no_multicast_cmd,
  1026. "no multicast",
  1027. NO_STR
  1028. "Unset multicast flag to interface\n")
  1029. {
  1030. int ret;
  1031. struct interface *ifp;
  1032. struct zebra_if *if_data;
  1033. ifp = (struct interface *) vty->index;
  1034. if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
  1035. {
  1036. ret = if_unset_flags (ifp, IFF_MULTICAST);
  1037. if (ret < 0)
  1038. {
  1039. vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE);
  1040. return CMD_WARNING;
  1041. }
  1042. if_refresh (ifp);
  1043. }
  1044. if_data = ifp->info;
  1045. if_data->multicast = IF_ZEBRA_MULTICAST_OFF;
  1046. return CMD_SUCCESS;
  1047. }
  1048. DEFUN (linkdetect,
  1049. linkdetect_cmd,
  1050. "link-detect",
  1051. "Enable link detection on interface\n")
  1052. {
  1053. struct interface *ifp;
  1054. int if_was_operative;
  1055. ifp = (struct interface *) vty->index;
  1056. if_was_operative = if_is_operative(ifp);
  1057. SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
  1058. /* When linkdetection is enabled, if might come down */
  1059. if (!if_is_operative(ifp) && if_was_operative) if_down(ifp);
  1060. /* FIXME: Will defer status change forwarding if interface
  1061. does not come down! */
  1062. return CMD_SUCCESS;
  1063. }
  1064. DEFUN (no_linkdetect,
  1065. no_linkdetect_cmd,
  1066. "no link-detect",
  1067. NO_STR
  1068. "Disable link detection on interface\n")
  1069. {
  1070. struct interface *ifp;
  1071. int if_was_operative;
  1072. ifp = (struct interface *) vty->index;
  1073. if_was_operative = if_is_operative(ifp);
  1074. UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
  1075. /* Interface may come up after disabling link detection */
  1076. if (if_is_operative(ifp) && !if_was_operative) if_up(ifp);
  1077. /* FIXME: see linkdetect_cmd */
  1078. return CMD_SUCCESS;
  1079. }
  1080. DEFUN (shutdown_if,
  1081. shutdown_if_cmd,
  1082. "shutdown",
  1083. "Shutdown the selected interface\n")
  1084. {
  1085. int ret;
  1086. struct interface *ifp;
  1087. struct zebra_if *if_data;
  1088. ifp = (struct interface *) vty->index;
  1089. if (ifp->ifindex != IFINDEX_INTERNAL)
  1090. {
  1091. ret = if_unset_flags (ifp, IFF_UP);
  1092. if (ret < 0)
  1093. {
  1094. vty_out (vty, "Can't shutdown interface%s", VTY_NEWLINE);
  1095. return CMD_WARNING;
  1096. }
  1097. if_refresh (ifp);
  1098. }
  1099. if_data = ifp->info;
  1100. if_data->shutdown = IF_ZEBRA_SHUTDOWN_ON;
  1101. return CMD_SUCCESS;
  1102. }
  1103. DEFUN (no_shutdown_if,
  1104. no_shutdown_if_cmd,
  1105. "no shutdown",
  1106. NO_STR
  1107. "Shutdown the selected interface\n")
  1108. {
  1109. int ret;
  1110. struct interface *ifp;
  1111. struct zebra_if *if_data;
  1112. ifp = (struct interface *) vty->index;
  1113. if (ifp->ifindex != IFINDEX_INTERNAL)
  1114. {
  1115. ret = if_set_flags (ifp, IFF_UP | IFF_RUNNING);
  1116. if (ret < 0)
  1117. {
  1118. vty_out (vty, "Can't up interface%s", VTY_NEWLINE);
  1119. return CMD_WARNING;
  1120. }
  1121. if_refresh (ifp);
  1122. /* Some addresses (in particular, IPv6 addresses on Linux) get
  1123. * removed when the interface goes down. They need to be readded.
  1124. */
  1125. if_addr_wakeup(ifp);
  1126. }
  1127. if_data = ifp->info;
  1128. if_data->shutdown = IF_ZEBRA_SHUTDOWN_OFF;
  1129. return CMD_SUCCESS;
  1130. }
  1131. DEFUN (bandwidth_if,
  1132. bandwidth_if_cmd,
  1133. "bandwidth <1-10000000>",
  1134. "Set bandwidth informational parameter\n"
  1135. "Bandwidth in kilobits\n")
  1136. {
  1137. struct interface *ifp;
  1138. unsigned int bandwidth;
  1139. ifp = (struct interface *) vty->index;
  1140. bandwidth = strtol(argv[0], NULL, 10);
  1141. /* bandwidth range is <1-10000000> */
  1142. if (bandwidth < 1 || bandwidth > 10000000)
  1143. {
  1144. vty_out (vty, "Bandwidth is invalid%s", VTY_NEWLINE);
  1145. return CMD_WARNING;
  1146. }
  1147. ifp->bandwidth = bandwidth;
  1148. /* force protocols to recalculate routes due to cost change */
  1149. if (if_is_operative (ifp))
  1150. zebra_interface_up_update (ifp);
  1151. return CMD_SUCCESS;
  1152. }
  1153. DEFUN (no_bandwidth_if,
  1154. no_bandwidth_if_cmd,
  1155. "no bandwidth",
  1156. NO_STR
  1157. "Set bandwidth informational parameter\n")
  1158. {
  1159. struct interface *ifp;
  1160. ifp = (struct interface *) vty->index;
  1161. ifp->bandwidth = 0;
  1162. /* force protocols to recalculate routes due to cost change */
  1163. if (if_is_operative (ifp))
  1164. zebra_interface_up_update (ifp);
  1165. return CMD_SUCCESS;
  1166. }
  1167. ALIAS (no_bandwidth_if,
  1168. no_bandwidth_if_val_cmd,
  1169. "no bandwidth <1-10000000>",
  1170. NO_STR
  1171. "Set bandwidth informational parameter\n"
  1172. "Bandwidth in kilobits\n")
  1173. static int
  1174. ip_address_install (struct vty *vty, struct interface *ifp,
  1175. const char *addr_str, const char *peer_str,
  1176. const char *label)
  1177. {
  1178. struct zebra_if *if_data;
  1179. struct prefix_ipv4 cp;
  1180. struct connected *ifc;
  1181. struct prefix_ipv4 *p;
  1182. int ret;
  1183. if_data = ifp->info;
  1184. ret = str2prefix_ipv4 (addr_str, &cp);
  1185. if (ret <= 0)
  1186. {
  1187. vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
  1188. return CMD_WARNING;
  1189. }
  1190. ifc = connected_check (ifp, (struct prefix *) &cp);
  1191. if (! ifc)
  1192. {
  1193. ifc = connected_new ();
  1194. ifc->ifp = ifp;
  1195. /* Address. */
  1196. p = prefix_ipv4_new ();
  1197. *p = cp;
  1198. ifc->address = (struct prefix *) p;
  1199. /* Broadcast. */
  1200. if (p->prefixlen <= IPV4_MAX_PREFIXLEN-2)
  1201. {
  1202. p = prefix_ipv4_new ();
  1203. *p = cp;
  1204. p->prefix.s_addr = ipv4_broadcast_addr(p->prefix.s_addr,p->prefixlen);
  1205. ifc->destination = (struct prefix *) p;
  1206. }
  1207. /* Label. */
  1208. if (label)
  1209. ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label);
  1210. /* Add to linked list. */
  1211. listnode_add (ifp->connected, ifc);
  1212. }
  1213. /* This address is configured from zebra. */
  1214. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
  1215. SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED);
  1216. /* In case of this route need to install kernel. */
  1217. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED)
  1218. && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)
  1219. && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON))
  1220. {
  1221. /* Some system need to up the interface to set IP address. */
  1222. if (! if_is_up (ifp))
  1223. {
  1224. if_set_flags (ifp, IFF_UP | IFF_RUNNING);
  1225. if_refresh (ifp);
  1226. }
  1227. ret = if_set_prefix (ifp, ifc);
  1228. if (ret < 0)
  1229. {
  1230. vty_out (vty, "%% Can't set interface IP address: %s.%s",
  1231. safe_strerror(errno), VTY_NEWLINE);
  1232. return CMD_WARNING;
  1233. }
  1234. SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  1235. /* The address will be advertised to zebra clients when the notification
  1236. * from the kernel has been received.
  1237. * It will also be added to the subnet chain list, then. */
  1238. }
  1239. return CMD_SUCCESS;
  1240. }
  1241. static int
  1242. ip_address_uninstall (struct vty *vty, struct interface *ifp,
  1243. const char *addr_str, const char *peer_str,
  1244. const char *label)
  1245. {
  1246. struct prefix_ipv4 cp;
  1247. struct connected *ifc;
  1248. int ret;
  1249. /* Convert to prefix structure. */
  1250. ret = str2prefix_ipv4 (addr_str, &cp);
  1251. if (ret <= 0)
  1252. {
  1253. vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
  1254. return CMD_WARNING;
  1255. }
  1256. /* Check current interface address. */
  1257. ifc = connected_check (ifp, (struct prefix *) &cp);
  1258. if (! ifc)
  1259. {
  1260. vty_out (vty, "%% Can't find address%s", VTY_NEWLINE);
  1261. return CMD_WARNING;
  1262. }
  1263. /* This is not configured address. */
  1264. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
  1265. return CMD_WARNING;
  1266. UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED);
  1267. /* This is not real address or interface is not active. */
  1268. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED)
  1269. || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
  1270. {
  1271. listnode_delete (ifp->connected, ifc);
  1272. connected_free (ifc);
  1273. return CMD_WARNING;
  1274. }
  1275. /* This is real route. */
  1276. ret = if_unset_prefix (ifp, ifc);
  1277. if (ret < 0)
  1278. {
  1279. vty_out (vty, "%% Can't unset interface IP address: %s.%s",
  1280. safe_strerror(errno), VTY_NEWLINE);
  1281. return CMD_WARNING;
  1282. }
  1283. UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  1284. /* we will receive a kernel notification about this route being removed.
  1285. * this will trigger its removal from the connected list. */
  1286. return CMD_SUCCESS;
  1287. }
  1288. DEFUN (ip_address,
  1289. ip_address_cmd,
  1290. "ip address A.B.C.D/M",
  1291. "Interface Internet Protocol config commands\n"
  1292. "Set the IP address of an interface\n"
  1293. "IP address (e.g. 10.0.0.1/8)\n")
  1294. {
  1295. return ip_address_install (vty, vty->index, argv[0], NULL, NULL);
  1296. }
  1297. DEFUN (no_ip_address,
  1298. no_ip_address_cmd,
  1299. "no ip address A.B.C.D/M",
  1300. NO_STR
  1301. "Interface Internet Protocol config commands\n"
  1302. "Set the IP address of an interface\n"
  1303. "IP Address (e.g. 10.0.0.1/8)")
  1304. {
  1305. return ip_address_uninstall (vty, vty->index, argv[0], NULL, NULL);
  1306. }
  1307. #ifdef HAVE_NETLINK
  1308. DEFUN (ip_address_label,
  1309. ip_address_label_cmd,
  1310. "ip address A.B.C.D/M label LINE",
  1311. "Interface Internet Protocol config commands\n"
  1312. "Set the IP address of an interface\n"
  1313. "IP address (e.g. 10.0.0.1/8)\n"
  1314. "Label of this address\n"
  1315. "Label\n")
  1316. {
  1317. return ip_address_install (vty, vty->index, argv[0], NULL, argv[1]);
  1318. }
  1319. DEFUN (no_ip_address_label,
  1320. no_ip_address_label_cmd,
  1321. "no ip address A.B.C.D/M label LINE",
  1322. NO_STR
  1323. "Interface Internet Protocol config commands\n"
  1324. "Set the IP address of an interface\n"
  1325. "IP address (e.g. 10.0.0.1/8)\n"
  1326. "Label of this address\n"
  1327. "Label\n")
  1328. {
  1329. return ip_address_uninstall (vty, vty->index, argv[0], NULL, argv[1]);
  1330. }
  1331. #endif /* HAVE_NETLINK */
  1332. #ifdef HAVE_IPV6
  1333. static int
  1334. ipv6_address_install (struct vty *vty, struct interface *ifp,
  1335. const char *addr_str, const char *peer_str,
  1336. const char *label, int secondary)
  1337. {
  1338. struct zebra_if *if_data;
  1339. struct prefix_ipv6 cp;
  1340. struct connected *ifc;
  1341. struct prefix_ipv6 *p;
  1342. int ret;
  1343. if_data = ifp->info;
  1344. ret = str2prefix_ipv6 (addr_str, &cp);
  1345. if (ret <= 0)
  1346. {
  1347. vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
  1348. return CMD_WARNING;
  1349. }
  1350. ifc = connected_check (ifp, (struct prefix *) &cp);
  1351. if (! ifc)
  1352. {
  1353. ifc = connected_new ();
  1354. ifc->ifp = ifp;
  1355. /* Address. */
  1356. p = prefix_ipv6_new ();
  1357. *p = cp;
  1358. ifc->address = (struct prefix *) p;
  1359. /* Secondary. */
  1360. if (secondary)
  1361. SET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY);
  1362. /* Label. */
  1363. if (label)
  1364. ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label);
  1365. /* Add to linked list. */
  1366. listnode_add (ifp->connected, ifc);
  1367. }
  1368. /* This address is configured from zebra. */
  1369. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
  1370. SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED);
  1371. /* In case of this route need to install kernel. */
  1372. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED)
  1373. && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)
  1374. && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON))
  1375. {
  1376. /* Some system need to up the interface to set IP address. */
  1377. if (! if_is_up (ifp))
  1378. {
  1379. if_set_flags (ifp, IFF_UP | IFF_RUNNING);
  1380. if_refresh (ifp);
  1381. }
  1382. ret = if_prefix_add_ipv6 (ifp, ifc);
  1383. if (ret < 0)
  1384. {
  1385. vty_out (vty, "%% Can't set interface IP address: %s.%s",
  1386. safe_strerror(errno), VTY_NEWLINE);
  1387. return CMD_WARNING;
  1388. }
  1389. SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  1390. /* The address will be advertised to zebra clients when the notification
  1391. * from the kernel has been received. */
  1392. }
  1393. return CMD_SUCCESS;
  1394. }
  1395. static int
  1396. ipv6_address_uninstall (struct vty *vty, struct interface *ifp,
  1397. const char *addr_str, const char *peer_str,
  1398. const char *label, int secondry)
  1399. {
  1400. struct prefix_ipv6 cp;
  1401. struct connected *ifc;
  1402. int ret;
  1403. /* Convert to prefix structure. */
  1404. ret = str2prefix_ipv6 (addr_str, &cp);
  1405. if (ret <= 0)
  1406. {
  1407. vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
  1408. return CMD_WARNING;
  1409. }
  1410. /* Check current interface address. */
  1411. ifc = connected_check (ifp, (struct prefix *) &cp);
  1412. if (! ifc)
  1413. {
  1414. vty_out (vty, "%% Can't find address%s", VTY_NEWLINE);
  1415. return CMD_WARNING;
  1416. }
  1417. /* This is not configured address. */
  1418. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
  1419. return CMD_WARNING;
  1420. UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED);
  1421. /* This is not real address or interface is not active. */
  1422. if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED)
  1423. || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
  1424. {
  1425. listnode_delete (ifp->connected, ifc);
  1426. connected_free (ifc);
  1427. return CMD_WARNING;
  1428. }
  1429. /* This is real route. */
  1430. ret = if_prefix_delete_ipv6 (ifp, ifc);
  1431. if (ret < 0)
  1432. {
  1433. vty_out (vty, "%% Can't unset interface IP address: %s.%s",
  1434. safe_strerror(errno), VTY_NEWLINE);
  1435. return CMD_WARNING;
  1436. }
  1437. UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
  1438. /* This information will be propagated to the zclients when the
  1439. * kernel notification is received. */
  1440. return CMD_SUCCESS;
  1441. }
  1442. DEFUN (ipv6_address,
  1443. ipv6_address_cmd,
  1444. "ipv6 address X:X::X:X/M",
  1445. "Interface IPv6 config commands\n"
  1446. "Set the IP address of an interface\n"
  1447. "IPv6 address (e.g. 3ffe:506::1/48)\n")
  1448. {
  1449. return ipv6_address_install (vty, vty->index, argv[0], NULL, NULL, 0);
  1450. }
  1451. DEFUN (no_ipv6_address,
  1452. no_ipv6_address_cmd,
  1453. "no ipv6 address X:X::X:X/M",
  1454. NO_STR
  1455. "Interface IPv6 config commands\n"
  1456. "Set the IP address of an interface\n"
  1457. "IPv6 address (e.g. 3ffe:506::1/48)\n")
  1458. {
  1459. return ipv6_address_uninstall (vty, vty->index, argv[0], NULL, NULL, 0);
  1460. }
  1461. #endif /* HAVE_IPV6 */
  1462. static int
  1463. if_config_write (struct vty *vty)
  1464. {
  1465. struct listnode *node;
  1466. struct interface *ifp;
  1467. vrf_iter_t iter;
  1468. for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
  1469. for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp))
  1470. {
  1471. struct zebra_if *if_data;
  1472. struct listnode *addrnode;
  1473. struct connected *ifc;
  1474. struct prefix *p;
  1475. if_data = ifp->info;
  1476. if (ifp->vrf_id == VRF_DEFAULT)
  1477. vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
  1478. else
  1479. vty_out (vty, "interface %s vrf %u%s", ifp->name, ifp->vrf_id,
  1480. VTY_NEWLINE);
  1481. if (if_data)
  1482. {
  1483. if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)
  1484. vty_out (vty, " shutdown%s", VTY_NEWLINE);
  1485. }
  1486. if (ifp->desc)
  1487. vty_out (vty, " description %s%s", ifp->desc,
  1488. VTY_NEWLINE);
  1489. /* Assign bandwidth here to avoid unnecessary interface flap
  1490. while processing config script */
  1491. if (ifp->bandwidth != 0)
  1492. vty_out(vty, " bandwidth %u%s", ifp->bandwidth, VTY_NEWLINE);
  1493. if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))
  1494. vty_out(vty, " link-detect%s", VTY_NEWLINE);
  1495. else
  1496. vty_out(vty, " no link-detect%s", VTY_NEWLINE);
  1497. for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc))
  1498. {
  1499. if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
  1500. {
  1501. char buf[INET6_ADDRSTRLEN];
  1502. p = ifc->address;
  1503. vty_out (vty, " ip%s address %s",
  1504. p->family == AF_INET ? "" : "v6",
  1505. prefix2str (p, buf, sizeof(buf)));
  1506. if (ifc->label)
  1507. vty_out (vty, " label %s", ifc->label);
  1508. vty_out (vty, "%s", VTY_NEWLINE);
  1509. }
  1510. }
  1511. if (if_data)
  1512. {
  1513. if (if_data->multicast != IF_ZEBRA_MULTICAST_UNSPEC)
  1514. vty_out (vty, " %smulticast%s",
  1515. if_data->multicast == IF_ZEBRA_MULTICAST_ON ? "" : "no ",
  1516. VTY_NEWLINE);
  1517. }
  1518. #ifdef RTADV
  1519. rtadv_config_write (vty, ifp);
  1520. #endif /* RTADV */
  1521. #ifdef HAVE_IRDP
  1522. irdp_config_write (vty, ifp);
  1523. #endif /* IRDP */
  1524. vty_out (vty, "!%s", VTY_NEWLINE);
  1525. }
  1526. return 0;
  1527. }
  1528. /* Allocate and initialize interface vector. */
  1529. void
  1530. zebra_if_init (void)
  1531. {
  1532. /* Initialize interface and new hook. */
  1533. if_add_hook (IF_NEW_HOOK, if_zebra_new_hook);
  1534. if_add_hook (IF_DELETE_HOOK, if_zebra_delete_hook);
  1535. /* Install configuration write function. */
  1536. install_node (&interface_node, if_config_write);
  1537. install_element (VIEW_NODE, &show_interface_cmd);
  1538. install_element (VIEW_NODE, &show_interface_vrf_cmd);
  1539. install_element (VIEW_NODE, &show_interface_vrf_all_cmd);
  1540. install_element (VIEW_NODE, &show_interface_name_cmd);
  1541. install_element (VIEW_NODE, &show_interface_name_vrf_cmd);
  1542. install_element (VIEW_NODE, &show_interface_name_vrf_all_cmd);
  1543. install_element (ENABLE_NODE, &show_interface_cmd);
  1544. install_element (ENABLE_NODE, &show_interface_vrf_cmd);
  1545. install_element (ENABLE_NODE, &show_interface_vrf_all_cmd);
  1546. install_element (ENABLE_NODE, &show_interface_name_cmd);
  1547. install_element (ENABLE_NODE, &show_interface_name_vrf_cmd);
  1548. install_element (ENABLE_NODE, &show_interface_name_vrf_all_cmd);
  1549. install_element (ENABLE_NODE, &show_interface_desc_cmd);
  1550. install_element (ENABLE_NODE, &show_interface_desc_vrf_cmd);
  1551. install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd);
  1552. install_element (CONFIG_NODE, &zebra_interface_cmd);
  1553. install_element (CONFIG_NODE, &zebra_interface_vrf_cmd);
  1554. install_element (CONFIG_NODE, &no_interface_cmd);
  1555. install_element (CONFIG_NODE, &no_interface_vrf_cmd);
  1556. install_default (INTERFACE_NODE);
  1557. install_element (INTERFACE_NODE, &interface_desc_cmd);
  1558. install_element (INTERFACE_NODE, &no_interface_desc_cmd);
  1559. install_element (INTERFACE_NODE, &multicast_cmd);
  1560. install_element (INTERFACE_NODE, &no_multicast_cmd);
  1561. install_element (INTERFACE_NODE, &linkdetect_cmd);
  1562. install_element (INTERFACE_NODE, &no_linkdetect_cmd);
  1563. install_element (INTERFACE_NODE, &shutdown_if_cmd);
  1564. install_element (INTERFACE_NODE, &no_shutdown_if_cmd);
  1565. install_element (INTERFACE_NODE, &bandwidth_if_cmd);
  1566. install_element (INTERFACE_NODE, &no_bandwidth_if_cmd);
  1567. install_element (INTERFACE_NODE, &no_bandwidth_if_val_cmd);
  1568. install_element (INTERFACE_NODE, &ip_address_cmd);
  1569. install_element (INTERFACE_NODE, &no_ip_address_cmd);
  1570. #ifdef HAVE_IPV6
  1571. install_element (INTERFACE_NODE, &ipv6_address_cmd);
  1572. install_element (INTERFACE_NODE, &no_ipv6_address_cmd);
  1573. #endif /* HAVE_IPV6 */
  1574. #ifdef HAVE_NETLINK
  1575. install_element (INTERFACE_NODE, &ip_address_label_cmd);
  1576. install_element (INTERFACE_NODE, &no_ip_address_label_cmd);
  1577. #endif /* HAVE_NETLINK */
  1578. }