zebra_vty.c 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286
  1. /* Zebra VTY functions
  2. * Copyright (C) 2002 Kunihiro Ishiguro
  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 "prefix.h"
  25. #include "command.h"
  26. #include "table.h"
  27. #include "rib.h"
  28. #include "vrf.h"
  29. #include "zebra/zserv.h"
  30. static int do_show_ip_route(struct vty *vty, safi_t safi);
  31. static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
  32. int mcast);
  33. /* General function for static route. */
  34. static int
  35. zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
  36. const char *dest_str, const char *mask_str,
  37. const char *gate_str, const char *flag_str,
  38. const char *distance_str)
  39. {
  40. int ret;
  41. u_char distance;
  42. struct prefix p;
  43. struct in_addr gate;
  44. struct in_addr mask;
  45. const char *ifname;
  46. u_char flag = 0;
  47. ret = str2prefix (dest_str, &p);
  48. if (ret <= 0)
  49. {
  50. vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
  51. return CMD_WARNING;
  52. }
  53. /* Cisco like mask notation. */
  54. if (mask_str)
  55. {
  56. ret = inet_aton (mask_str, &mask);
  57. if (ret == 0)
  58. {
  59. vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
  60. return CMD_WARNING;
  61. }
  62. p.prefixlen = ip_masklen (mask);
  63. }
  64. /* Apply mask for given prefix. */
  65. apply_mask (&p);
  66. /* Administrative distance. */
  67. if (distance_str)
  68. distance = atoi (distance_str);
  69. else
  70. distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
  71. /* Null0 static route. */
  72. if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
  73. {
  74. if (flag_str)
  75. {
  76. vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
  77. return CMD_WARNING;
  78. }
  79. if (add_cmd)
  80. static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0);
  81. else
  82. static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0);
  83. return CMD_SUCCESS;
  84. }
  85. /* Route flags */
  86. if (flag_str) {
  87. switch(flag_str[0]) {
  88. case 'r':
  89. case 'R': /* XXX */
  90. SET_FLAG (flag, ZEBRA_FLAG_REJECT);
  91. break;
  92. case 'b':
  93. case 'B': /* XXX */
  94. SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
  95. break;
  96. default:
  97. vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
  98. return CMD_WARNING;
  99. }
  100. }
  101. if (gate_str == NULL)
  102. {
  103. if (add_cmd)
  104. static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, 0);
  105. else
  106. static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0);
  107. return CMD_SUCCESS;
  108. }
  109. /* When gateway is A.B.C.D format, gate is treated as nexthop
  110. address other case gate is treated as interface name. */
  111. ret = inet_aton (gate_str, &gate);
  112. if (ret)
  113. ifname = NULL;
  114. else
  115. ifname = gate_str;
  116. if (add_cmd)
  117. static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, 0);
  118. else
  119. static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, 0);
  120. return CMD_SUCCESS;
  121. }
  122. static int
  123. zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
  124. const char *mask_str, const char *gate_str,
  125. const char *flag_str, const char *distance_str)
  126. {
  127. return zebra_static_ipv4_safi(vty, SAFI_UNICAST, add_cmd, dest_str, mask_str, gate_str, flag_str, distance_str);
  128. }
  129. /* Static unicast routes for multicast RPF lookup. */
  130. DEFUN (ip_mroute_dist,
  131. ip_mroute_dist_cmd,
  132. "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
  133. IP_STR
  134. "Configure static unicast route into MRIB for multicast RPF lookup\n"
  135. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  136. "Nexthop address\n"
  137. "Nexthop interface name\n"
  138. "Distance\n")
  139. {
  140. VTY_WARN_EXPERIMENTAL();
  141. return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
  142. NULL, argc > 2 ? argv[2] : NULL);
  143. }
  144. ALIAS (ip_mroute_dist,
  145. ip_mroute_cmd,
  146. "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
  147. IP_STR
  148. "Configure static unicast route into MRIB for multicast RPF lookup\n"
  149. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  150. "Nexthop address\n"
  151. "Nexthop interface name\n")
  152. DEFUN (no_ip_mroute_dist,
  153. no_ip_mroute_dist_cmd,
  154. "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
  155. IP_STR
  156. "Configure static unicast route into MRIB for multicast RPF lookup\n"
  157. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  158. "Nexthop address\n"
  159. "Nexthop interface name\n"
  160. "Distance\n")
  161. {
  162. VTY_WARN_EXPERIMENTAL();
  163. return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
  164. NULL, argc > 2 ? argv[2] : NULL);
  165. }
  166. ALIAS (no_ip_mroute_dist,
  167. no_ip_mroute_cmd,
  168. "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
  169. NO_STR
  170. IP_STR
  171. "Configure static unicast route into MRIB for multicast RPF lookup\n"
  172. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  173. "Nexthop address\n"
  174. "Nexthop interface name\n")
  175. DEFUN (ip_multicast_mode,
  176. ip_multicast_mode_cmd,
  177. "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
  178. IP_STR
  179. "Multicast options\n"
  180. "RPF lookup behavior\n"
  181. "Lookup in unicast RIB only\n"
  182. "Lookup in multicast RIB only\n"
  183. "Try multicast RIB first, fall back to unicast RIB\n"
  184. "Lookup both, use entry with lower distance\n"
  185. "Lookup both, use entry with longer prefix\n")
  186. {
  187. VTY_WARN_EXPERIMENTAL();
  188. if (!strncmp (argv[0], "u", 1))
  189. multicast_mode_ipv4_set (MCAST_URIB_ONLY);
  190. else if (!strncmp (argv[0], "mrib-o", 6))
  191. multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
  192. else if (!strncmp (argv[0], "mrib-t", 6))
  193. multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
  194. else if (!strncmp (argv[0], "low", 3))
  195. multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
  196. else if (!strncmp (argv[0], "lon", 3))
  197. multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
  198. else
  199. {
  200. vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
  201. return CMD_WARNING;
  202. }
  203. return CMD_SUCCESS;
  204. }
  205. DEFUN (no_ip_multicast_mode,
  206. no_ip_multicast_mode_cmd,
  207. "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
  208. NO_STR
  209. IP_STR
  210. "Multicast options\n"
  211. "RPF lookup behavior\n"
  212. "Lookup in unicast RIB only\n"
  213. "Lookup in multicast RIB only\n"
  214. "Try multicast RIB first, fall back to unicast RIB\n"
  215. "Lookup both, use entry with lower distance\n"
  216. "Lookup both, use entry with longer prefix\n")
  217. {
  218. multicast_mode_ipv4_set (MCAST_NO_CONFIG);
  219. return CMD_SUCCESS;
  220. }
  221. ALIAS (no_ip_multicast_mode,
  222. no_ip_multicast_mode_noarg_cmd,
  223. "no ip multicast rpf-lookup-mode",
  224. NO_STR
  225. IP_STR
  226. "Multicast options\n"
  227. "RPF lookup behavior\n")
  228. DEFUN (show_ip_rpf,
  229. show_ip_rpf_cmd,
  230. "show ip rpf",
  231. SHOW_STR
  232. IP_STR
  233. "Display RPF information for multicast source\n")
  234. {
  235. VTY_WARN_EXPERIMENTAL();
  236. return do_show_ip_route(vty, SAFI_MULTICAST);
  237. }
  238. DEFUN (show_ip_rpf_addr,
  239. show_ip_rpf_addr_cmd,
  240. "show ip rpf A.B.C.D",
  241. SHOW_STR
  242. IP_STR
  243. "Display RPF information for multicast source\n"
  244. "IP multicast source address (e.g. 10.0.0.0)\n")
  245. {
  246. struct in_addr addr;
  247. struct route_node *rn;
  248. struct rib *rib;
  249. int ret;
  250. VTY_WARN_EXPERIMENTAL();
  251. ret = inet_aton (argv[0], &addr);
  252. if (ret == 0)
  253. {
  254. vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
  255. return CMD_WARNING;
  256. }
  257. rib = rib_match_ipv4_multicast (addr, &rn);
  258. if (rib)
  259. vty_show_ip_route_detail (vty, rn, 1);
  260. else
  261. vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
  262. return CMD_SUCCESS;
  263. }
  264. /* Static route configuration. */
  265. DEFUN (ip_route,
  266. ip_route_cmd,
  267. "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
  268. IP_STR
  269. "Establish static routes\n"
  270. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  271. "IP gateway address\n"
  272. "IP gateway interface name\n"
  273. "Null interface\n")
  274. {
  275. return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL);
  276. }
  277. DEFUN (ip_route_flags,
  278. ip_route_flags_cmd,
  279. "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
  280. IP_STR
  281. "Establish static routes\n"
  282. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  283. "IP gateway address\n"
  284. "IP gateway interface name\n"
  285. "Emit an ICMP unreachable when matched\n"
  286. "Silently discard pkts when matched\n")
  287. {
  288. return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL);
  289. }
  290. DEFUN (ip_route_flags2,
  291. ip_route_flags2_cmd,
  292. "ip route A.B.C.D/M (reject|blackhole)",
  293. IP_STR
  294. "Establish static routes\n"
  295. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  296. "Emit an ICMP unreachable when matched\n"
  297. "Silently discard pkts when matched\n")
  298. {
  299. return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL);
  300. }
  301. /* Mask as A.B.C.D format. */
  302. DEFUN (ip_route_mask,
  303. ip_route_mask_cmd,
  304. "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
  305. IP_STR
  306. "Establish static routes\n"
  307. "IP destination prefix\n"
  308. "IP destination prefix mask\n"
  309. "IP gateway address\n"
  310. "IP gateway interface name\n"
  311. "Null interface\n")
  312. {
  313. return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
  314. }
  315. DEFUN (ip_route_mask_flags,
  316. ip_route_mask_flags_cmd,
  317. "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
  318. IP_STR
  319. "Establish static routes\n"
  320. "IP destination prefix\n"
  321. "IP destination prefix mask\n"
  322. "IP gateway address\n"
  323. "IP gateway interface name\n"
  324. "Emit an ICMP unreachable when matched\n"
  325. "Silently discard pkts when matched\n")
  326. {
  327. return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
  328. }
  329. DEFUN (ip_route_mask_flags2,
  330. ip_route_mask_flags2_cmd,
  331. "ip route A.B.C.D A.B.C.D (reject|blackhole)",
  332. IP_STR
  333. "Establish static routes\n"
  334. "IP destination prefix\n"
  335. "IP destination prefix mask\n"
  336. "Emit an ICMP unreachable when matched\n"
  337. "Silently discard pkts when matched\n")
  338. {
  339. return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
  340. }
  341. /* Distance option value. */
  342. DEFUN (ip_route_distance,
  343. ip_route_distance_cmd,
  344. "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
  345. IP_STR
  346. "Establish static routes\n"
  347. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  348. "IP gateway address\n"
  349. "IP gateway interface name\n"
  350. "Null interface\n"
  351. "Distance value for this route\n")
  352. {
  353. return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]);
  354. }
  355. DEFUN (ip_route_flags_distance,
  356. ip_route_flags_distance_cmd,
  357. "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
  358. IP_STR
  359. "Establish static routes\n"
  360. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  361. "IP gateway address\n"
  362. "IP gateway interface name\n"
  363. "Emit an ICMP unreachable when matched\n"
  364. "Silently discard pkts when matched\n"
  365. "Distance value for this route\n")
  366. {
  367. return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3]);
  368. }
  369. DEFUN (ip_route_flags_distance2,
  370. ip_route_flags_distance2_cmd,
  371. "ip route A.B.C.D/M (reject|blackhole) <1-255>",
  372. IP_STR
  373. "Establish static routes\n"
  374. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  375. "Emit an ICMP unreachable when matched\n"
  376. "Silently discard pkts when matched\n"
  377. "Distance value for this route\n")
  378. {
  379. return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]);
  380. }
  381. DEFUN (ip_route_mask_distance,
  382. ip_route_mask_distance_cmd,
  383. "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
  384. IP_STR
  385. "Establish static routes\n"
  386. "IP destination prefix\n"
  387. "IP destination prefix mask\n"
  388. "IP gateway address\n"
  389. "IP gateway interface name\n"
  390. "Null interface\n"
  391. "Distance value for this route\n")
  392. {
  393. return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
  394. }
  395. DEFUN (ip_route_mask_flags_distance,
  396. ip_route_mask_flags_distance_cmd,
  397. "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
  398. IP_STR
  399. "Establish static routes\n"
  400. "IP destination prefix\n"
  401. "IP destination prefix mask\n"
  402. "IP gateway address\n"
  403. "IP gateway interface name\n"
  404. "Emit an ICMP unreachable when matched\n"
  405. "Silently discard pkts when matched\n"
  406. "Distance value for this route\n")
  407. {
  408. return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
  409. }
  410. DEFUN (ip_route_mask_flags_distance2,
  411. ip_route_mask_flags_distance2_cmd,
  412. "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
  413. IP_STR
  414. "Establish static routes\n"
  415. "IP destination prefix\n"
  416. "IP destination prefix mask\n"
  417. "Emit an ICMP unreachable when matched\n"
  418. "Silently discard pkts when matched\n"
  419. "Distance value for this route\n")
  420. {
  421. return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
  422. }
  423. DEFUN (no_ip_route,
  424. no_ip_route_cmd,
  425. "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
  426. NO_STR
  427. IP_STR
  428. "Establish static routes\n"
  429. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  430. "IP gateway address\n"
  431. "IP gateway interface name\n"
  432. "Null interface\n")
  433. {
  434. return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL);
  435. }
  436. ALIAS (no_ip_route,
  437. no_ip_route_flags_cmd,
  438. "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
  439. NO_STR
  440. IP_STR
  441. "Establish static routes\n"
  442. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  443. "IP gateway address\n"
  444. "IP gateway interface name\n"
  445. "Emit an ICMP unreachable when matched\n"
  446. "Silently discard pkts when matched\n")
  447. DEFUN (no_ip_route_flags2,
  448. no_ip_route_flags2_cmd,
  449. "no ip route A.B.C.D/M (reject|blackhole)",
  450. NO_STR
  451. IP_STR
  452. "Establish static routes\n"
  453. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  454. "Emit an ICMP unreachable when matched\n"
  455. "Silently discard pkts when matched\n")
  456. {
  457. return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL);
  458. }
  459. DEFUN (no_ip_route_mask,
  460. no_ip_route_mask_cmd,
  461. "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
  462. NO_STR
  463. IP_STR
  464. "Establish static routes\n"
  465. "IP destination prefix\n"
  466. "IP destination prefix mask\n"
  467. "IP gateway address\n"
  468. "IP gateway interface name\n"
  469. "Null interface\n")
  470. {
  471. return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
  472. }
  473. ALIAS (no_ip_route_mask,
  474. no_ip_route_mask_flags_cmd,
  475. "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
  476. NO_STR
  477. IP_STR
  478. "Establish static routes\n"
  479. "IP destination prefix\n"
  480. "IP destination prefix mask\n"
  481. "IP gateway address\n"
  482. "IP gateway interface name\n"
  483. "Emit an ICMP unreachable when matched\n"
  484. "Silently discard pkts when matched\n")
  485. DEFUN (no_ip_route_mask_flags2,
  486. no_ip_route_mask_flags2_cmd,
  487. "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
  488. NO_STR
  489. IP_STR
  490. "Establish static routes\n"
  491. "IP destination prefix\n"
  492. "IP destination prefix mask\n"
  493. "Emit an ICMP unreachable when matched\n"
  494. "Silently discard pkts when matched\n")
  495. {
  496. return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
  497. }
  498. DEFUN (no_ip_route_distance,
  499. no_ip_route_distance_cmd,
  500. "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
  501. NO_STR
  502. IP_STR
  503. "Establish static routes\n"
  504. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  505. "IP gateway address\n"
  506. "IP gateway interface name\n"
  507. "Null interface\n"
  508. "Distance value for this route\n")
  509. {
  510. return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]);
  511. }
  512. DEFUN (no_ip_route_flags_distance,
  513. no_ip_route_flags_distance_cmd,
  514. "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
  515. NO_STR
  516. IP_STR
  517. "Establish static routes\n"
  518. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  519. "IP gateway address\n"
  520. "IP gateway interface name\n"
  521. "Emit an ICMP unreachable when matched\n"
  522. "Silently discard pkts when matched\n"
  523. "Distance value for this route\n")
  524. {
  525. return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3]);
  526. }
  527. DEFUN (no_ip_route_flags_distance2,
  528. no_ip_route_flags_distance2_cmd,
  529. "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
  530. NO_STR
  531. IP_STR
  532. "Establish static routes\n"
  533. "IP destination prefix (e.g. 10.0.0.0/8)\n"
  534. "Emit an ICMP unreachable when matched\n"
  535. "Silently discard pkts when matched\n"
  536. "Distance value for this route\n")
  537. {
  538. return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]);
  539. }
  540. DEFUN (no_ip_route_mask_distance,
  541. no_ip_route_mask_distance_cmd,
  542. "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
  543. NO_STR
  544. IP_STR
  545. "Establish static routes\n"
  546. "IP destination prefix\n"
  547. "IP destination prefix mask\n"
  548. "IP gateway address\n"
  549. "IP gateway interface name\n"
  550. "Null interface\n"
  551. "Distance value for this route\n")
  552. {
  553. return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
  554. }
  555. DEFUN (no_ip_route_mask_flags_distance,
  556. no_ip_route_mask_flags_distance_cmd,
  557. "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
  558. NO_STR
  559. IP_STR
  560. "Establish static routes\n"
  561. "IP destination prefix\n"
  562. "IP destination prefix mask\n"
  563. "IP gateway address\n"
  564. "IP gateway interface name\n"
  565. "Emit an ICMP unreachable when matched\n"
  566. "Silently discard pkts when matched\n"
  567. "Distance value for this route\n")
  568. {
  569. return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
  570. }
  571. DEFUN (no_ip_route_mask_flags_distance2,
  572. no_ip_route_mask_flags_distance2_cmd,
  573. "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
  574. NO_STR
  575. IP_STR
  576. "Establish static routes\n"
  577. "IP destination prefix\n"
  578. "IP destination prefix mask\n"
  579. "Emit an ICMP unreachable when matched\n"
  580. "Silently discard pkts when matched\n"
  581. "Distance value for this route\n")
  582. {
  583. return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
  584. }
  585. char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
  586. DEFUN (ip_protocol,
  587. ip_protocol_cmd,
  588. "ip protocol PROTO route-map ROUTE-MAP",
  589. NO_STR
  590. "Apply route map to PROTO\n"
  591. "Protocol name\n"
  592. "Route map name\n")
  593. {
  594. int i;
  595. if (strcasecmp(argv[0], "any") == 0)
  596. i = ZEBRA_ROUTE_MAX;
  597. else
  598. i = proto_name2num(argv[0]);
  599. if (i < 0)
  600. {
  601. vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
  602. VTY_NEWLINE);
  603. return CMD_WARNING;
  604. }
  605. if (proto_rm[AFI_IP][i])
  606. XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
  607. proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
  608. return CMD_SUCCESS;
  609. }
  610. DEFUN (no_ip_protocol,
  611. no_ip_protocol_cmd,
  612. "no ip protocol PROTO",
  613. NO_STR
  614. "Remove route map from PROTO\n"
  615. "Protocol name\n")
  616. {
  617. int i;
  618. if (strcasecmp(argv[0], "any") == 0)
  619. i = ZEBRA_ROUTE_MAX;
  620. else
  621. i = proto_name2num(argv[0]);
  622. if (i < 0)
  623. {
  624. vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
  625. VTY_NEWLINE);
  626. return CMD_WARNING;
  627. }
  628. if (proto_rm[AFI_IP][i])
  629. XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
  630. proto_rm[AFI_IP][i] = NULL;
  631. return CMD_SUCCESS;
  632. }
  633. /* New RIB. Detailed information for IPv4 route. */
  634. static void
  635. vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
  636. {
  637. struct rib *rib;
  638. struct nexthop *nexthop, *tnexthop;
  639. int recursing;
  640. char buf[PREFIX_STRLEN];
  641. RNODE_FOREACH_RIB (rn, rib)
  642. {
  643. const char *mcast_info = "";
  644. if (mcast)
  645. {
  646. rib_table_info_t *info = rn->table->info;
  647. mcast_info = (info->safi == SAFI_MULTICAST)
  648. ? " using Multicast RIB"
  649. : " using Unicast RIB";
  650. }
  651. vty_out (vty, "Routing entry for %s%s%s",
  652. prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
  653. VTY_NEWLINE);
  654. vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
  655. vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
  656. if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
  657. vty_out (vty, ", best");
  658. if (rib->refcnt)
  659. vty_out (vty, ", refcnt %ld", rib->refcnt);
  660. if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
  661. vty_out (vty, ", blackhole");
  662. if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
  663. vty_out (vty, ", reject");
  664. vty_out (vty, "%s", VTY_NEWLINE);
  665. #define ONE_DAY_SECOND 60*60*24
  666. #define ONE_WEEK_SECOND 60*60*24*7
  667. if (rib->type == ZEBRA_ROUTE_RIP
  668. || rib->type == ZEBRA_ROUTE_RIPNG
  669. || rib->type == ZEBRA_ROUTE_OSPF
  670. || rib->type == ZEBRA_ROUTE_OSPF6
  671. || rib->type == ZEBRA_ROUTE_BABEL
  672. || rib->type == ZEBRA_ROUTE_ISIS
  673. || rib->type == ZEBRA_ROUTE_BGP)
  674. {
  675. time_t uptime;
  676. struct tm *tm;
  677. uptime = time (NULL);
  678. uptime -= rib->uptime;
  679. tm = gmtime (&uptime);
  680. vty_out (vty, " Last update ");
  681. if (uptime < ONE_DAY_SECOND)
  682. vty_out (vty, "%02d:%02d:%02d",
  683. tm->tm_hour, tm->tm_min, tm->tm_sec);
  684. else if (uptime < ONE_WEEK_SECOND)
  685. vty_out (vty, "%dd%02dh%02dm",
  686. tm->tm_yday, tm->tm_hour, tm->tm_min);
  687. else
  688. vty_out (vty, "%02dw%dd%02dh",
  689. tm->tm_yday/7,
  690. tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
  691. vty_out (vty, " ago%s", VTY_NEWLINE);
  692. }
  693. for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
  694. {
  695. vty_out (vty, " %c%s",
  696. CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
  697. recursing ? " " : "");
  698. switch (nexthop->type)
  699. {
  700. case NEXTHOP_TYPE_IPV4:
  701. case NEXTHOP_TYPE_IPV4_IFINDEX:
  702. vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
  703. if (nexthop->ifindex)
  704. vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
  705. break;
  706. case NEXTHOP_TYPE_IPV6:
  707. case NEXTHOP_TYPE_IPV6_IFINDEX:
  708. case NEXTHOP_TYPE_IPV6_IFNAME:
  709. vty_out (vty, " %s",
  710. inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
  711. if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
  712. vty_out (vty, ", %s", nexthop->ifname);
  713. else if (nexthop->ifindex)
  714. vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
  715. break;
  716. case NEXTHOP_TYPE_IFINDEX:
  717. vty_out (vty, " directly connected, %s",
  718. ifindex2ifname (nexthop->ifindex));
  719. break;
  720. case NEXTHOP_TYPE_IFNAME:
  721. vty_out (vty, " directly connected, %s", nexthop->ifname);
  722. break;
  723. case NEXTHOP_TYPE_BLACKHOLE:
  724. vty_out (vty, " directly connected, Null0");
  725. break;
  726. default:
  727. break;
  728. }
  729. if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
  730. vty_out (vty, " inactive");
  731. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
  732. vty_out (vty, " onlink");
  733. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
  734. vty_out (vty, " (recursive)");
  735. switch (nexthop->type)
  736. {
  737. case NEXTHOP_TYPE_IPV4:
  738. case NEXTHOP_TYPE_IPV4_IFINDEX:
  739. case NEXTHOP_TYPE_IPV4_IFNAME:
  740. if (nexthop->src.ipv4.s_addr)
  741. {
  742. if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
  743. vty_out (vty, ", src %s", buf);
  744. }
  745. break;
  746. #ifdef HAVE_IPV6
  747. case NEXTHOP_TYPE_IPV6:
  748. case NEXTHOP_TYPE_IPV6_IFINDEX:
  749. case NEXTHOP_TYPE_IPV6_IFNAME:
  750. if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
  751. {
  752. if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
  753. vty_out (vty, ", src %s", buf);
  754. }
  755. break;
  756. #endif /* HAVE_IPV6 */
  757. default:
  758. break;
  759. }
  760. vty_out (vty, "%s", VTY_NEWLINE);
  761. }
  762. vty_out (vty, "%s", VTY_NEWLINE);
  763. }
  764. }
  765. static void
  766. vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
  767. {
  768. struct nexthop *nexthop, *tnexthop;
  769. int recursing;
  770. int len = 0;
  771. char buf[BUFSIZ];
  772. /* Nexthop information. */
  773. for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
  774. {
  775. if (nexthop == rib->nexthop)
  776. {
  777. /* Prefix information. */
  778. len = vty_out (vty, "%c%c%c %s",
  779. zebra_route_char (rib->type),
  780. CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
  781. ? '>' : ' ',
  782. CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  783. ? '*' : ' ',
  784. prefix2str (&rn->p, buf, sizeof buf));
  785. /* Distance and metric display. */
  786. if (rib->type != ZEBRA_ROUTE_CONNECT
  787. && rib->type != ZEBRA_ROUTE_KERNEL)
  788. len += vty_out (vty, " [%d/%d]", rib->distance,
  789. rib->metric);
  790. }
  791. else
  792. vty_out (vty, " %c%*c",
  793. CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  794. ? '*' : ' ',
  795. len - 3 + (2 * recursing), ' ');
  796. switch (nexthop->type)
  797. {
  798. case NEXTHOP_TYPE_IPV4:
  799. case NEXTHOP_TYPE_IPV4_IFINDEX:
  800. vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
  801. if (nexthop->ifindex)
  802. vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
  803. break;
  804. case NEXTHOP_TYPE_IPV6:
  805. case NEXTHOP_TYPE_IPV6_IFINDEX:
  806. case NEXTHOP_TYPE_IPV6_IFNAME:
  807. vty_out (vty, " via %s",
  808. inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
  809. if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
  810. vty_out (vty, ", %s", nexthop->ifname);
  811. else if (nexthop->ifindex)
  812. vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
  813. break;
  814. case NEXTHOP_TYPE_IFINDEX:
  815. vty_out (vty, " is directly connected, %s",
  816. ifindex2ifname (nexthop->ifindex));
  817. break;
  818. case NEXTHOP_TYPE_IFNAME:
  819. vty_out (vty, " is directly connected, %s", nexthop->ifname);
  820. break;
  821. case NEXTHOP_TYPE_BLACKHOLE:
  822. vty_out (vty, " is directly connected, Null0");
  823. break;
  824. default:
  825. break;
  826. }
  827. if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
  828. vty_out (vty, " inactive");
  829. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
  830. vty_out (vty, " onlink");
  831. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
  832. vty_out (vty, " (recursive)");
  833. switch (nexthop->type)
  834. {
  835. case NEXTHOP_TYPE_IPV4:
  836. case NEXTHOP_TYPE_IPV4_IFINDEX:
  837. case NEXTHOP_TYPE_IPV4_IFNAME:
  838. if (nexthop->src.ipv4.s_addr)
  839. {
  840. if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
  841. vty_out (vty, ", src %s", buf);
  842. }
  843. break;
  844. #ifdef HAVE_IPV6
  845. case NEXTHOP_TYPE_IPV6:
  846. case NEXTHOP_TYPE_IPV6_IFINDEX:
  847. case NEXTHOP_TYPE_IPV6_IFNAME:
  848. if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
  849. {
  850. if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
  851. vty_out (vty, ", src %s", buf);
  852. }
  853. break;
  854. #endif /* HAVE_IPV6 */
  855. default:
  856. break;
  857. }
  858. if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
  859. vty_out (vty, ", bh");
  860. if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
  861. vty_out (vty, ", rej");
  862. if (rib->type == ZEBRA_ROUTE_RIP
  863. || rib->type == ZEBRA_ROUTE_RIPNG
  864. || rib->type == ZEBRA_ROUTE_OSPF
  865. || rib->type == ZEBRA_ROUTE_OSPF6
  866. || rib->type == ZEBRA_ROUTE_BABEL
  867. || rib->type == ZEBRA_ROUTE_ISIS
  868. || rib->type == ZEBRA_ROUTE_BGP)
  869. {
  870. time_t uptime;
  871. struct tm *tm;
  872. uptime = time (NULL);
  873. uptime -= rib->uptime;
  874. tm = gmtime (&uptime);
  875. #define ONE_DAY_SECOND 60*60*24
  876. #define ONE_WEEK_SECOND 60*60*24*7
  877. if (uptime < ONE_DAY_SECOND)
  878. vty_out (vty, ", %02d:%02d:%02d",
  879. tm->tm_hour, tm->tm_min, tm->tm_sec);
  880. else if (uptime < ONE_WEEK_SECOND)
  881. vty_out (vty, ", %dd%02dh%02dm",
  882. tm->tm_yday, tm->tm_hour, tm->tm_min);
  883. else
  884. vty_out (vty, ", %02dw%dd%02dh",
  885. tm->tm_yday/7,
  886. tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
  887. }
  888. vty_out (vty, "%s", VTY_NEWLINE);
  889. }
  890. }
  891. DEFUN (show_ip_route,
  892. show_ip_route_cmd,
  893. "show ip route",
  894. SHOW_STR
  895. IP_STR
  896. "IP routing table\n")
  897. {
  898. return do_show_ip_route(vty, SAFI_UNICAST);
  899. }
  900. static int do_show_ip_route(struct vty *vty, safi_t safi) {
  901. struct route_table *table;
  902. struct route_node *rn;
  903. struct rib *rib;
  904. int first = 1;
  905. table = zebra_vrf_table (AFI_IP, safi, VRF_DEFAULT);
  906. if (! table)
  907. return CMD_SUCCESS;
  908. /* Show all IPv4 routes. */
  909. for (rn = route_top (table); rn; rn = route_next (rn))
  910. RNODE_FOREACH_RIB (rn, rib)
  911. {
  912. if (first)
  913. {
  914. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  915. first = 0;
  916. }
  917. vty_show_ip_route (vty, rn, rib);
  918. }
  919. return CMD_SUCCESS;
  920. }
  921. DEFUN (show_ip_route_prefix_longer,
  922. show_ip_route_prefix_longer_cmd,
  923. "show ip route A.B.C.D/M longer-prefixes",
  924. SHOW_STR
  925. IP_STR
  926. "IP routing table\n"
  927. "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
  928. "Show route matching the specified Network/Mask pair only\n")
  929. {
  930. struct route_table *table;
  931. struct route_node *rn;
  932. struct rib *rib;
  933. struct prefix p;
  934. int ret;
  935. int first = 1;
  936. ret = str2prefix (argv[0], &p);
  937. if (! ret)
  938. {
  939. vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
  940. return CMD_WARNING;
  941. }
  942. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  943. if (! table)
  944. return CMD_SUCCESS;
  945. /* Show matched type IPv4 routes. */
  946. for (rn = route_top (table); rn; rn = route_next (rn))
  947. RNODE_FOREACH_RIB (rn, rib)
  948. if (prefix_match (&p, &rn->p))
  949. {
  950. if (first)
  951. {
  952. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  953. first = 0;
  954. }
  955. vty_show_ip_route (vty, rn, rib);
  956. }
  957. return CMD_SUCCESS;
  958. }
  959. DEFUN (show_ip_route_supernets,
  960. show_ip_route_supernets_cmd,
  961. "show ip route supernets-only",
  962. SHOW_STR
  963. IP_STR
  964. "IP routing table\n"
  965. "Show supernet entries only\n")
  966. {
  967. struct route_table *table;
  968. struct route_node *rn;
  969. struct rib *rib;
  970. u_int32_t addr;
  971. int first = 1;
  972. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  973. if (! table)
  974. return CMD_SUCCESS;
  975. /* Show matched type IPv4 routes. */
  976. for (rn = route_top (table); rn; rn = route_next (rn))
  977. RNODE_FOREACH_RIB (rn, rib)
  978. {
  979. addr = ntohl (rn->p.u.prefix4.s_addr);
  980. if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
  981. || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
  982. || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
  983. {
  984. if (first)
  985. {
  986. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  987. first = 0;
  988. }
  989. vty_show_ip_route (vty, rn, rib);
  990. }
  991. }
  992. return CMD_SUCCESS;
  993. }
  994. DEFUN (show_ip_route_protocol,
  995. show_ip_route_protocol_cmd,
  996. "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
  997. SHOW_STR
  998. IP_STR
  999. "IP routing table\n"
  1000. QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
  1001. {
  1002. int type;
  1003. struct route_table *table;
  1004. struct route_node *rn;
  1005. struct rib *rib;
  1006. int first = 1;
  1007. type = proto_redistnum (AFI_IP, argv[0]);
  1008. if (type < 0)
  1009. {
  1010. vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
  1011. return CMD_WARNING;
  1012. }
  1013. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1014. if (! table)
  1015. return CMD_SUCCESS;
  1016. /* Show matched type IPv4 routes. */
  1017. for (rn = route_top (table); rn; rn = route_next (rn))
  1018. RNODE_FOREACH_RIB (rn, rib)
  1019. if (rib->type == type)
  1020. {
  1021. if (first)
  1022. {
  1023. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  1024. first = 0;
  1025. }
  1026. vty_show_ip_route (vty, rn, rib);
  1027. }
  1028. return CMD_SUCCESS;
  1029. }
  1030. DEFUN (show_ip_route_addr,
  1031. show_ip_route_addr_cmd,
  1032. "show ip route A.B.C.D",
  1033. SHOW_STR
  1034. IP_STR
  1035. "IP routing table\n"
  1036. "Network in the IP routing table to display\n")
  1037. {
  1038. int ret;
  1039. struct prefix_ipv4 p;
  1040. struct route_table *table;
  1041. struct route_node *rn;
  1042. ret = str2prefix_ipv4 (argv[0], &p);
  1043. if (ret <= 0)
  1044. {
  1045. vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
  1046. return CMD_WARNING;
  1047. }
  1048. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1049. if (! table)
  1050. return CMD_SUCCESS;
  1051. rn = route_node_match (table, (struct prefix *) &p);
  1052. if (! rn)
  1053. {
  1054. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1055. return CMD_WARNING;
  1056. }
  1057. vty_show_ip_route_detail (vty, rn, 0);
  1058. route_unlock_node (rn);
  1059. return CMD_SUCCESS;
  1060. }
  1061. DEFUN (show_ip_route_prefix,
  1062. show_ip_route_prefix_cmd,
  1063. "show ip route A.B.C.D/M",
  1064. SHOW_STR
  1065. IP_STR
  1066. "IP routing table\n"
  1067. "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
  1068. {
  1069. int ret;
  1070. struct prefix_ipv4 p;
  1071. struct route_table *table;
  1072. struct route_node *rn;
  1073. ret = str2prefix_ipv4 (argv[0], &p);
  1074. if (ret <= 0)
  1075. {
  1076. vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
  1077. return CMD_WARNING;
  1078. }
  1079. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1080. if (! table)
  1081. return CMD_SUCCESS;
  1082. rn = route_node_match (table, (struct prefix *) &p);
  1083. if (! rn || rn->p.prefixlen != p.prefixlen)
  1084. {
  1085. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1086. if (rn)
  1087. route_unlock_node (rn);
  1088. return CMD_WARNING;
  1089. }
  1090. vty_show_ip_route_detail (vty, rn, 0);
  1091. route_unlock_node (rn);
  1092. return CMD_SUCCESS;
  1093. }
  1094. static void
  1095. vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
  1096. {
  1097. struct route_node *rn;
  1098. struct rib *rib;
  1099. struct nexthop *nexthop;
  1100. #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
  1101. #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
  1102. u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1103. u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1104. u_int32_t i;
  1105. memset (&rib_cnt, 0, sizeof(rib_cnt));
  1106. memset (&fib_cnt, 0, sizeof(fib_cnt));
  1107. for (rn = route_top (table); rn; rn = route_next (rn))
  1108. RNODE_FOREACH_RIB (rn, rib)
  1109. for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
  1110. {
  1111. rib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1112. rib_cnt[rib->type]++;
  1113. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  1114. || nexthop_has_fib_child(nexthop))
  1115. {
  1116. fib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1117. fib_cnt[rib->type]++;
  1118. }
  1119. if (rib->type == ZEBRA_ROUTE_BGP &&
  1120. CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
  1121. {
  1122. rib_cnt[ZEBRA_ROUTE_IBGP]++;
  1123. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  1124. || nexthop_has_fib_child(nexthop))
  1125. fib_cnt[ZEBRA_ROUTE_IBGP]++;
  1126. }
  1127. }
  1128. vty_out (vty, "%-20s %-20s %-20s %s",
  1129. "Route Source", "Routes", "FIB", VTY_NEWLINE);
  1130. for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
  1131. {
  1132. if (rib_cnt[i] > 0)
  1133. {
  1134. if (i == ZEBRA_ROUTE_BGP)
  1135. {
  1136. vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
  1137. rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
  1138. fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
  1139. VTY_NEWLINE);
  1140. vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
  1141. rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
  1142. VTY_NEWLINE);
  1143. }
  1144. else
  1145. vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
  1146. rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
  1147. }
  1148. }
  1149. vty_out (vty, "------%s", VTY_NEWLINE);
  1150. vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
  1151. fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
  1152. }
  1153. /*
  1154. * Implementation of the ip route summary prefix command.
  1155. *
  1156. * This command prints the primary prefixes that have been installed by various
  1157. * protocols on the box.
  1158. *
  1159. */
  1160. static void
  1161. vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
  1162. {
  1163. struct route_node *rn;
  1164. struct rib *rib;
  1165. struct nexthop *nexthop;
  1166. #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
  1167. #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
  1168. u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1169. u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1170. u_int32_t i;
  1171. int cnt;
  1172. memset (&rib_cnt, 0, sizeof(rib_cnt));
  1173. memset (&fib_cnt, 0, sizeof(fib_cnt));
  1174. for (rn = route_top (table); rn; rn = route_next (rn))
  1175. RNODE_FOREACH_RIB (rn, rib)
  1176. {
  1177. /*
  1178. * In case of ECMP, count only once.
  1179. */
  1180. cnt = 0;
  1181. for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
  1182. {
  1183. cnt++;
  1184. rib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1185. rib_cnt[rib->type]++;
  1186. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
  1187. {
  1188. fib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1189. fib_cnt[rib->type]++;
  1190. }
  1191. if (rib->type == ZEBRA_ROUTE_BGP &&
  1192. CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
  1193. {
  1194. rib_cnt[ZEBRA_ROUTE_IBGP]++;
  1195. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
  1196. fib_cnt[ZEBRA_ROUTE_IBGP]++;
  1197. }
  1198. }
  1199. }
  1200. vty_out (vty, "%-20s %-20s %-20s %s",
  1201. "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE);
  1202. for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
  1203. {
  1204. if (rib_cnt[i] > 0)
  1205. {
  1206. if (i == ZEBRA_ROUTE_BGP)
  1207. {
  1208. vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
  1209. rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
  1210. fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
  1211. VTY_NEWLINE);
  1212. vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
  1213. rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
  1214. VTY_NEWLINE);
  1215. }
  1216. else
  1217. vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
  1218. rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
  1219. }
  1220. }
  1221. vty_out (vty, "------%s", VTY_NEWLINE);
  1222. vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
  1223. fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
  1224. }
  1225. /* Show route summary. */
  1226. DEFUN (show_ip_route_summary,
  1227. show_ip_route_summary_cmd,
  1228. "show ip route summary",
  1229. SHOW_STR
  1230. IP_STR
  1231. "IP routing table\n"
  1232. "Summary of all routes\n")
  1233. {
  1234. struct route_table *table;
  1235. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1236. if (! table)
  1237. return CMD_SUCCESS;
  1238. vty_show_ip_route_summary (vty, table);
  1239. return CMD_SUCCESS;
  1240. }
  1241. /* Show route summary prefix. */
  1242. DEFUN (show_ip_route_summary_prefix,
  1243. show_ip_route_summary_prefix_cmd,
  1244. "show ip route summary prefix",
  1245. SHOW_STR
  1246. IP_STR
  1247. "IP routing table\n"
  1248. "Summary of all routes\n"
  1249. "Prefix routes\n")
  1250. {
  1251. struct route_table *table;
  1252. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1253. if (! table)
  1254. return CMD_SUCCESS;
  1255. vty_show_ip_route_summary_prefix (vty, table);
  1256. return CMD_SUCCESS;
  1257. }
  1258. /* Write IPv4 static route configuration. */
  1259. static int
  1260. static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
  1261. {
  1262. struct route_node *rn;
  1263. struct static_ipv4 *si;
  1264. struct route_table *stable;
  1265. char buf[PREFIX_STRLEN];
  1266. int write;
  1267. write = 0;
  1268. /* Lookup table. */
  1269. stable = zebra_vrf_static_table (AFI_IP, safi, VRF_DEFAULT);
  1270. if (! stable)
  1271. return -1;
  1272. for (rn = route_top (stable); rn; rn = route_next (rn))
  1273. for (si = rn->info; si; si = si->next)
  1274. {
  1275. vty_out (vty, "%s %s", cmd, prefix2str (&rn->p, buf, sizeof buf));
  1276. switch (si->type)
  1277. {
  1278. case STATIC_IPV4_GATEWAY:
  1279. vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
  1280. break;
  1281. case STATIC_IPV4_IFNAME:
  1282. vty_out (vty, " %s", si->gate.ifname);
  1283. break;
  1284. case STATIC_IPV4_BLACKHOLE:
  1285. vty_out (vty, " Null0");
  1286. break;
  1287. }
  1288. /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
  1289. if (si->type != STATIC_IPV4_BLACKHOLE)
  1290. {
  1291. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
  1292. vty_out (vty, " %s", "reject");
  1293. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
  1294. vty_out (vty, " %s", "blackhole");
  1295. }
  1296. if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
  1297. vty_out (vty, " %d", si->distance);
  1298. vty_out (vty, "%s", VTY_NEWLINE);
  1299. write = 1;
  1300. }
  1301. return write;
  1302. }
  1303. DEFUN (show_ip_protocol,
  1304. show_ip_protocol_cmd,
  1305. "show ip protocol",
  1306. SHOW_STR
  1307. IP_STR
  1308. "IP protocol filtering status\n")
  1309. {
  1310. int i;
  1311. vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
  1312. vty_out(vty, "------------------------%s", VTY_NEWLINE);
  1313. for (i=0;i<ZEBRA_ROUTE_MAX;i++)
  1314. {
  1315. if (proto_rm[AFI_IP][i])
  1316. vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
  1317. proto_rm[AFI_IP][i],
  1318. VTY_NEWLINE);
  1319. else
  1320. vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
  1321. }
  1322. if (proto_rm[AFI_IP][i])
  1323. vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
  1324. VTY_NEWLINE);
  1325. else
  1326. vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
  1327. return CMD_SUCCESS;
  1328. }
  1329. /*
  1330. * Show IP mroute command to dump the BGP Multicast
  1331. * routing table
  1332. */
  1333. DEFUN (show_ip_mroute,
  1334. show_ip_mroute_cmd,
  1335. "show ip mroute",
  1336. SHOW_STR
  1337. IP_STR
  1338. "IP Multicast routing table\n")
  1339. {
  1340. struct route_table *table;
  1341. struct route_node *rn;
  1342. struct rib *rib;
  1343. int first = 1;
  1344. table = zebra_vrf_table (AFI_IP, SAFI_MULTICAST, VRF_DEFAULT);
  1345. if (! table)
  1346. return CMD_SUCCESS;
  1347. /* Show all IPv4 routes. */
  1348. for (rn = route_top (table); rn; rn = route_next (rn))
  1349. RNODE_FOREACH_RIB (rn, rib)
  1350. {
  1351. if (first)
  1352. {
  1353. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  1354. first = 0;
  1355. }
  1356. vty_show_ip_route (vty, rn, rib);
  1357. }
  1358. return CMD_SUCCESS;
  1359. }
  1360. #ifdef HAVE_IPV6
  1361. /* General fucntion for IPv6 static route. */
  1362. static int
  1363. static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
  1364. const char *gate_str, const char *ifname,
  1365. const char *flag_str, const char *distance_str)
  1366. {
  1367. int ret;
  1368. u_char distance;
  1369. struct prefix p;
  1370. struct in6_addr *gate = NULL;
  1371. struct in6_addr gate_addr;
  1372. u_char type = 0;
  1373. int table = 0;
  1374. u_char flag = 0;
  1375. ret = str2prefix (dest_str, &p);
  1376. if (ret <= 0)
  1377. {
  1378. vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
  1379. return CMD_WARNING;
  1380. }
  1381. /* Apply mask for given prefix. */
  1382. apply_mask (&p);
  1383. /* Route flags */
  1384. if (flag_str) {
  1385. switch(flag_str[0]) {
  1386. case 'r':
  1387. case 'R': /* XXX */
  1388. SET_FLAG (flag, ZEBRA_FLAG_REJECT);
  1389. break;
  1390. case 'b':
  1391. case 'B': /* XXX */
  1392. SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
  1393. break;
  1394. default:
  1395. vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
  1396. return CMD_WARNING;
  1397. }
  1398. }
  1399. /* Administrative distance. */
  1400. if (distance_str)
  1401. distance = atoi (distance_str);
  1402. else
  1403. distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
  1404. /* When gateway is valid IPv6 addrees, then gate is treated as
  1405. nexthop address other case gate is treated as interface name. */
  1406. ret = inet_pton (AF_INET6, gate_str, &gate_addr);
  1407. if (ifname)
  1408. {
  1409. /* When ifname is specified. It must be come with gateway
  1410. address. */
  1411. if (ret != 1)
  1412. {
  1413. vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
  1414. return CMD_WARNING;
  1415. }
  1416. type = STATIC_IPV6_GATEWAY_IFNAME;
  1417. gate = &gate_addr;
  1418. }
  1419. else
  1420. {
  1421. if (ret == 1)
  1422. {
  1423. type = STATIC_IPV6_GATEWAY;
  1424. gate = &gate_addr;
  1425. }
  1426. else
  1427. {
  1428. type = STATIC_IPV6_IFNAME;
  1429. ifname = gate_str;
  1430. }
  1431. }
  1432. if (add_cmd)
  1433. static_add_ipv6 (&p, type, gate, ifname, flag, distance, table);
  1434. else
  1435. static_delete_ipv6 (&p, type, gate, ifname, distance, table);
  1436. return CMD_SUCCESS;
  1437. }
  1438. DEFUN (ipv6_route,
  1439. ipv6_route_cmd,
  1440. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
  1441. IP_STR
  1442. "Establish static routes\n"
  1443. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1444. "IPv6 gateway address\n"
  1445. "IPv6 gateway interface name\n")
  1446. {
  1447. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL);
  1448. }
  1449. DEFUN (ipv6_route_flags,
  1450. ipv6_route_flags_cmd,
  1451. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
  1452. IP_STR
  1453. "Establish static routes\n"
  1454. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1455. "IPv6 gateway address\n"
  1456. "IPv6 gateway interface name\n"
  1457. "Emit an ICMP unreachable when matched\n"
  1458. "Silently discard pkts when matched\n")
  1459. {
  1460. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
  1461. }
  1462. DEFUN (ipv6_route_ifname,
  1463. ipv6_route_ifname_cmd,
  1464. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
  1465. IP_STR
  1466. "Establish static routes\n"
  1467. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1468. "IPv6 gateway address\n"
  1469. "IPv6 gateway interface name\n")
  1470. {
  1471. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
  1472. }
  1473. DEFUN (ipv6_route_ifname_flags,
  1474. ipv6_route_ifname_flags_cmd,
  1475. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
  1476. IP_STR
  1477. "Establish static routes\n"
  1478. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1479. "IPv6 gateway address\n"
  1480. "IPv6 gateway interface name\n"
  1481. "Emit an ICMP unreachable when matched\n"
  1482. "Silently discard pkts when matched\n")
  1483. {
  1484. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
  1485. }
  1486. DEFUN (ipv6_route_pref,
  1487. ipv6_route_pref_cmd,
  1488. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
  1489. IP_STR
  1490. "Establish static routes\n"
  1491. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1492. "IPv6 gateway address\n"
  1493. "IPv6 gateway interface name\n"
  1494. "Distance value for this prefix\n")
  1495. {
  1496. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]);
  1497. }
  1498. DEFUN (ipv6_route_flags_pref,
  1499. ipv6_route_flags_pref_cmd,
  1500. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
  1501. IP_STR
  1502. "Establish static routes\n"
  1503. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1504. "IPv6 gateway address\n"
  1505. "IPv6 gateway interface name\n"
  1506. "Emit an ICMP unreachable when matched\n"
  1507. "Silently discard pkts when matched\n"
  1508. "Distance value for this prefix\n")
  1509. {
  1510. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
  1511. }
  1512. DEFUN (ipv6_route_ifname_pref,
  1513. ipv6_route_ifname_pref_cmd,
  1514. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
  1515. IP_STR
  1516. "Establish static routes\n"
  1517. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1518. "IPv6 gateway address\n"
  1519. "IPv6 gateway interface name\n"
  1520. "Distance value for this prefix\n")
  1521. {
  1522. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
  1523. }
  1524. DEFUN (ipv6_route_ifname_flags_pref,
  1525. ipv6_route_ifname_flags_pref_cmd,
  1526. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
  1527. IP_STR
  1528. "Establish static routes\n"
  1529. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1530. "IPv6 gateway address\n"
  1531. "IPv6 gateway interface name\n"
  1532. "Emit an ICMP unreachable when matched\n"
  1533. "Silently discard pkts when matched\n"
  1534. "Distance value for this prefix\n")
  1535. {
  1536. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
  1537. }
  1538. DEFUN (no_ipv6_route,
  1539. no_ipv6_route_cmd,
  1540. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
  1541. NO_STR
  1542. IP_STR
  1543. "Establish static routes\n"
  1544. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1545. "IPv6 gateway address\n"
  1546. "IPv6 gateway interface name\n")
  1547. {
  1548. return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
  1549. }
  1550. ALIAS (no_ipv6_route,
  1551. no_ipv6_route_flags_cmd,
  1552. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
  1553. NO_STR
  1554. IP_STR
  1555. "Establish static routes\n"
  1556. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1557. "IPv6 gateway address\n"
  1558. "IPv6 gateway interface name\n"
  1559. "Emit an ICMP unreachable when matched\n"
  1560. "Silently discard pkts when matched\n")
  1561. DEFUN (no_ipv6_route_ifname,
  1562. no_ipv6_route_ifname_cmd,
  1563. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
  1564. NO_STR
  1565. IP_STR
  1566. "Establish static routes\n"
  1567. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1568. "IPv6 gateway address\n"
  1569. "IPv6 gateway interface name\n")
  1570. {
  1571. return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
  1572. }
  1573. ALIAS (no_ipv6_route_ifname,
  1574. no_ipv6_route_ifname_flags_cmd,
  1575. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
  1576. NO_STR
  1577. IP_STR
  1578. "Establish static routes\n"
  1579. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1580. "IPv6 gateway address\n"
  1581. "IPv6 gateway interface name\n"
  1582. "Emit an ICMP unreachable when matched\n"
  1583. "Silently discard pkts when matched\n")
  1584. DEFUN (no_ipv6_route_pref,
  1585. no_ipv6_route_pref_cmd,
  1586. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
  1587. NO_STR
  1588. IP_STR
  1589. "Establish static routes\n"
  1590. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1591. "IPv6 gateway address\n"
  1592. "IPv6 gateway interface name\n"
  1593. "Distance value for this prefix\n")
  1594. {
  1595. return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]);
  1596. }
  1597. DEFUN (no_ipv6_route_flags_pref,
  1598. no_ipv6_route_flags_pref_cmd,
  1599. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
  1600. NO_STR
  1601. IP_STR
  1602. "Establish static routes\n"
  1603. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1604. "IPv6 gateway address\n"
  1605. "IPv6 gateway interface name\n"
  1606. "Emit an ICMP unreachable when matched\n"
  1607. "Silently discard pkts when matched\n"
  1608. "Distance value for this prefix\n")
  1609. {
  1610. /* We do not care about argv[2] */
  1611. return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
  1612. }
  1613. DEFUN (no_ipv6_route_ifname_pref,
  1614. no_ipv6_route_ifname_pref_cmd,
  1615. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
  1616. NO_STR
  1617. IP_STR
  1618. "Establish static routes\n"
  1619. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1620. "IPv6 gateway address\n"
  1621. "IPv6 gateway interface name\n"
  1622. "Distance value for this prefix\n")
  1623. {
  1624. return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
  1625. }
  1626. DEFUN (no_ipv6_route_ifname_flags_pref,
  1627. no_ipv6_route_ifname_flags_pref_cmd,
  1628. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
  1629. NO_STR
  1630. IP_STR
  1631. "Establish static routes\n"
  1632. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1633. "IPv6 gateway address\n"
  1634. "IPv6 gateway interface name\n"
  1635. "Emit an ICMP unreachable when matched\n"
  1636. "Silently discard pkts when matched\n"
  1637. "Distance value for this prefix\n")
  1638. {
  1639. return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
  1640. }
  1641. DEFUN (show_ipv6_route,
  1642. show_ipv6_route_cmd,
  1643. "show ipv6 route",
  1644. SHOW_STR
  1645. IP_STR
  1646. "IPv6 routing table\n")
  1647. {
  1648. struct route_table *table;
  1649. struct route_node *rn;
  1650. struct rib *rib;
  1651. int first = 1;
  1652. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1653. if (! table)
  1654. return CMD_SUCCESS;
  1655. /* Show all IPv6 route. */
  1656. for (rn = route_top (table); rn; rn = route_next (rn))
  1657. RNODE_FOREACH_RIB (rn, rib)
  1658. {
  1659. if (first)
  1660. {
  1661. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1662. first = 0;
  1663. }
  1664. vty_show_ip_route (vty, rn, rib);
  1665. }
  1666. return CMD_SUCCESS;
  1667. }
  1668. DEFUN (show_ipv6_route_prefix_longer,
  1669. show_ipv6_route_prefix_longer_cmd,
  1670. "show ipv6 route X:X::X:X/M longer-prefixes",
  1671. SHOW_STR
  1672. IP_STR
  1673. "IPv6 routing table\n"
  1674. "IPv6 prefix\n"
  1675. "Show route matching the specified Network/Mask pair only\n")
  1676. {
  1677. struct route_table *table;
  1678. struct route_node *rn;
  1679. struct rib *rib;
  1680. struct prefix p;
  1681. int ret;
  1682. int first = 1;
  1683. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1684. if (! table)
  1685. return CMD_SUCCESS;
  1686. ret = str2prefix (argv[0], &p);
  1687. if (! ret)
  1688. {
  1689. vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
  1690. return CMD_WARNING;
  1691. }
  1692. /* Show matched type IPv6 routes. */
  1693. for (rn = route_top (table); rn; rn = route_next (rn))
  1694. RNODE_FOREACH_RIB (rn, rib)
  1695. if (prefix_match (&p, &rn->p))
  1696. {
  1697. if (first)
  1698. {
  1699. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1700. first = 0;
  1701. }
  1702. vty_show_ip_route (vty, rn, rib);
  1703. }
  1704. return CMD_SUCCESS;
  1705. }
  1706. DEFUN (show_ipv6_route_protocol,
  1707. show_ipv6_route_protocol_cmd,
  1708. "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
  1709. SHOW_STR
  1710. IP_STR
  1711. "IP routing table\n"
  1712. QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
  1713. {
  1714. int type;
  1715. struct route_table *table;
  1716. struct route_node *rn;
  1717. struct rib *rib;
  1718. int first = 1;
  1719. type = proto_redistnum (AFI_IP6, argv[0]);
  1720. if (type < 0)
  1721. {
  1722. vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
  1723. return CMD_WARNING;
  1724. }
  1725. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1726. if (! table)
  1727. return CMD_SUCCESS;
  1728. /* Show matched type IPv6 routes. */
  1729. for (rn = route_top (table); rn; rn = route_next (rn))
  1730. RNODE_FOREACH_RIB (rn, rib)
  1731. if (rib->type == type)
  1732. {
  1733. if (first)
  1734. {
  1735. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1736. first = 0;
  1737. }
  1738. vty_show_ip_route (vty, rn, rib);
  1739. }
  1740. return CMD_SUCCESS;
  1741. }
  1742. DEFUN (show_ipv6_route_addr,
  1743. show_ipv6_route_addr_cmd,
  1744. "show ipv6 route X:X::X:X",
  1745. SHOW_STR
  1746. IP_STR
  1747. "IPv6 routing table\n"
  1748. "IPv6 Address\n")
  1749. {
  1750. int ret;
  1751. struct prefix_ipv6 p;
  1752. struct route_table *table;
  1753. struct route_node *rn;
  1754. ret = str2prefix_ipv6 (argv[0], &p);
  1755. if (ret <= 0)
  1756. {
  1757. vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
  1758. return CMD_WARNING;
  1759. }
  1760. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1761. if (! table)
  1762. return CMD_SUCCESS;
  1763. rn = route_node_match (table, (struct prefix *) &p);
  1764. if (! rn)
  1765. {
  1766. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1767. return CMD_WARNING;
  1768. }
  1769. vty_show_ip_route_detail (vty, rn, 0);
  1770. route_unlock_node (rn);
  1771. return CMD_SUCCESS;
  1772. }
  1773. DEFUN (show_ipv6_route_prefix,
  1774. show_ipv6_route_prefix_cmd,
  1775. "show ipv6 route X:X::X:X/M",
  1776. SHOW_STR
  1777. IP_STR
  1778. "IPv6 routing table\n"
  1779. "IPv6 prefix\n")
  1780. {
  1781. int ret;
  1782. struct prefix_ipv6 p;
  1783. struct route_table *table;
  1784. struct route_node *rn;
  1785. ret = str2prefix_ipv6 (argv[0], &p);
  1786. if (ret <= 0)
  1787. {
  1788. vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
  1789. return CMD_WARNING;
  1790. }
  1791. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1792. if (! table)
  1793. return CMD_SUCCESS;
  1794. rn = route_node_match (table, (struct prefix *) &p);
  1795. if (! rn || rn->p.prefixlen != p.prefixlen)
  1796. {
  1797. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1798. if (rn)
  1799. route_unlock_node (rn);
  1800. return CMD_WARNING;
  1801. }
  1802. vty_show_ip_route_detail (vty, rn, 0);
  1803. route_unlock_node (rn);
  1804. return CMD_SUCCESS;
  1805. }
  1806. /* Show route summary. */
  1807. DEFUN (show_ipv6_route_summary,
  1808. show_ipv6_route_summary_cmd,
  1809. "show ipv6 route summary",
  1810. SHOW_STR
  1811. IP_STR
  1812. "IPv6 routing table\n"
  1813. "Summary of all IPv6 routes\n")
  1814. {
  1815. struct route_table *table;
  1816. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1817. if (! table)
  1818. return CMD_SUCCESS;
  1819. vty_show_ip_route_summary (vty, table);
  1820. return CMD_SUCCESS;
  1821. }
  1822. /* Show ipv6 route summary prefix. */
  1823. DEFUN (show_ipv6_route_summary_prefix,
  1824. show_ipv6_route_summary_prefix_cmd,
  1825. "show ipv6 route summary prefix",
  1826. SHOW_STR
  1827. IP_STR
  1828. "IPv6 routing table\n"
  1829. "Summary of all IPv6 routes\n"
  1830. "Prefix routes\n")
  1831. {
  1832. struct route_table *table;
  1833. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1834. if (! table)
  1835. return CMD_SUCCESS;
  1836. vty_show_ip_route_summary_prefix (vty, table);
  1837. return CMD_SUCCESS;
  1838. }
  1839. /*
  1840. * Show IPv6 mroute command.Used to dump
  1841. * the Multicast routing table.
  1842. */
  1843. DEFUN (show_ipv6_mroute,
  1844. show_ipv6_mroute_cmd,
  1845. "show ipv6 mroute",
  1846. SHOW_STR
  1847. IP_STR
  1848. "IPv6 Multicast routing table\n")
  1849. {
  1850. struct route_table *table;
  1851. struct route_node *rn;
  1852. struct rib *rib;
  1853. int first = 1;
  1854. table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, VRF_DEFAULT);
  1855. if (! table)
  1856. return CMD_SUCCESS;
  1857. /* Show all IPv6 route. */
  1858. for (rn = route_top (table); rn; rn = route_next (rn))
  1859. RNODE_FOREACH_RIB (rn, rib)
  1860. {
  1861. if (first)
  1862. {
  1863. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1864. first = 0;
  1865. }
  1866. vty_show_ip_route (vty, rn, rib);
  1867. }
  1868. return CMD_SUCCESS;
  1869. }
  1870. /* Write IPv6 static route configuration. */
  1871. static int
  1872. static_config_ipv6 (struct vty *vty)
  1873. {
  1874. struct route_node *rn;
  1875. struct static_ipv6 *si;
  1876. int write;
  1877. char buf[BUFSIZ];
  1878. struct route_table *stable;
  1879. write = 0;
  1880. /* Lookup table. */
  1881. stable = zebra_vrf_static_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1882. if (! stable)
  1883. return -1;
  1884. for (rn = route_top (stable); rn; rn = route_next (rn))
  1885. for (si = rn->info; si; si = si->next)
  1886. {
  1887. vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
  1888. switch (si->type)
  1889. {
  1890. case STATIC_IPV6_GATEWAY:
  1891. vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
  1892. break;
  1893. case STATIC_IPV6_IFNAME:
  1894. vty_out (vty, " %s", si->ifname);
  1895. break;
  1896. case STATIC_IPV6_GATEWAY_IFNAME:
  1897. vty_out (vty, " %s %s",
  1898. inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname);
  1899. break;
  1900. }
  1901. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
  1902. vty_out (vty, " %s", "reject");
  1903. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
  1904. vty_out (vty, " %s", "blackhole");
  1905. if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
  1906. vty_out (vty, " %d", si->distance);
  1907. vty_out (vty, "%s", VTY_NEWLINE);
  1908. write = 1;
  1909. }
  1910. return write;
  1911. }
  1912. #endif /* HAVE_IPV6 */
  1913. /* Static ip route configuration write function. */
  1914. static int
  1915. zebra_ip_config (struct vty *vty)
  1916. {
  1917. int write = 0;
  1918. write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
  1919. write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
  1920. #ifdef HAVE_IPV6
  1921. write += static_config_ipv6 (vty);
  1922. #endif /* HAVE_IPV6 */
  1923. return write;
  1924. }
  1925. static int config_write_vty(struct vty *vty)
  1926. {
  1927. int i;
  1928. enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
  1929. if (ipv4_multicast_mode != MCAST_NO_CONFIG)
  1930. vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
  1931. ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
  1932. ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
  1933. ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
  1934. ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
  1935. "longer-prefix",
  1936. VTY_NEWLINE);
  1937. for (i=0;i<ZEBRA_ROUTE_MAX;i++)
  1938. {
  1939. if (proto_rm[AFI_IP][i])
  1940. vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
  1941. proto_rm[AFI_IP][i], VTY_NEWLINE);
  1942. }
  1943. if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
  1944. vty_out (vty, "ip protocol %s route-map %s%s", "any",
  1945. proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
  1946. return 1;
  1947. }
  1948. /* table node for protocol filtering */
  1949. static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
  1950. /* IP node for static routes. */
  1951. static struct cmd_node ip_node = { IP_NODE, "", 1 };
  1952. /* Route VTY. */
  1953. void
  1954. zebra_vty_init (void)
  1955. {
  1956. install_node (&ip_node, zebra_ip_config);
  1957. install_node (&protocol_node, config_write_vty);
  1958. install_element (CONFIG_NODE, &ip_mroute_cmd);
  1959. install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
  1960. install_element (CONFIG_NODE, &no_ip_mroute_cmd);
  1961. install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
  1962. install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
  1963. install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
  1964. install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
  1965. install_element (CONFIG_NODE, &ip_protocol_cmd);
  1966. install_element (CONFIG_NODE, &no_ip_protocol_cmd);
  1967. install_element (VIEW_NODE, &show_ip_protocol_cmd);
  1968. install_element (ENABLE_NODE, &show_ip_protocol_cmd);
  1969. install_element (CONFIG_NODE, &ip_route_cmd);
  1970. install_element (CONFIG_NODE, &ip_route_flags_cmd);
  1971. install_element (CONFIG_NODE, &ip_route_flags2_cmd);
  1972. install_element (CONFIG_NODE, &ip_route_mask_cmd);
  1973. install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
  1974. install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
  1975. install_element (CONFIG_NODE, &no_ip_route_cmd);
  1976. install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
  1977. install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
  1978. install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
  1979. install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
  1980. install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
  1981. install_element (CONFIG_NODE, &ip_route_distance_cmd);
  1982. install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
  1983. install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
  1984. install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
  1985. install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
  1986. install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
  1987. install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
  1988. install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
  1989. install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
  1990. install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
  1991. install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
  1992. install_element (VIEW_NODE, &show_ip_route_cmd);
  1993. install_element (VIEW_NODE, &show_ip_route_addr_cmd);
  1994. install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
  1995. install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
  1996. install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
  1997. install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
  1998. install_element (VIEW_NODE, &show_ip_route_summary_cmd);
  1999. install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
  2000. install_element (ENABLE_NODE, &show_ip_route_cmd);
  2001. install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
  2002. install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
  2003. install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
  2004. install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
  2005. install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
  2006. install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
  2007. install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
  2008. install_element (VIEW_NODE, &show_ip_mroute_cmd);
  2009. install_element (ENABLE_NODE, &show_ip_mroute_cmd);
  2010. install_element (VIEW_NODE, &show_ip_rpf_cmd);
  2011. install_element (ENABLE_NODE, &show_ip_rpf_cmd);
  2012. install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
  2013. install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
  2014. #ifdef HAVE_IPV6
  2015. install_element (CONFIG_NODE, &ipv6_route_cmd);
  2016. install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
  2017. install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
  2018. install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
  2019. install_element (CONFIG_NODE, &no_ipv6_route_cmd);
  2020. install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
  2021. install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
  2022. install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
  2023. install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
  2024. install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
  2025. install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
  2026. install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
  2027. install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
  2028. install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
  2029. install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
  2030. install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
  2031. install_element (VIEW_NODE, &show_ipv6_route_cmd);
  2032. install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
  2033. install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
  2034. install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
  2035. install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
  2036. install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
  2037. install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
  2038. install_element (ENABLE_NODE, &show_ipv6_route_cmd);
  2039. install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
  2040. install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
  2041. install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
  2042. install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
  2043. install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
  2044. install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
  2045. install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
  2046. install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
  2047. #endif /* HAVE_IPV6 */
  2048. }