zebra_vty.c 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290
  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, VRF_DEFAULT);
  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",
  705. ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
  706. break;
  707. case NEXTHOP_TYPE_IPV6:
  708. case NEXTHOP_TYPE_IPV6_IFINDEX:
  709. case NEXTHOP_TYPE_IPV6_IFNAME:
  710. vty_out (vty, " %s",
  711. inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
  712. if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
  713. vty_out (vty, ", %s", nexthop->ifname);
  714. else if (nexthop->ifindex)
  715. vty_out (vty, ", via %s",
  716. ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
  717. break;
  718. case NEXTHOP_TYPE_IFINDEX:
  719. vty_out (vty, " directly connected, %s",
  720. ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
  721. break;
  722. case NEXTHOP_TYPE_IFNAME:
  723. vty_out (vty, " directly connected, %s", nexthop->ifname);
  724. break;
  725. case NEXTHOP_TYPE_BLACKHOLE:
  726. vty_out (vty, " directly connected, Null0");
  727. break;
  728. default:
  729. break;
  730. }
  731. if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
  732. vty_out (vty, " inactive");
  733. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
  734. vty_out (vty, " onlink");
  735. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
  736. vty_out (vty, " (recursive)");
  737. switch (nexthop->type)
  738. {
  739. case NEXTHOP_TYPE_IPV4:
  740. case NEXTHOP_TYPE_IPV4_IFINDEX:
  741. case NEXTHOP_TYPE_IPV4_IFNAME:
  742. if (nexthop->src.ipv4.s_addr)
  743. {
  744. if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
  745. vty_out (vty, ", src %s", buf);
  746. }
  747. break;
  748. #ifdef HAVE_IPV6
  749. case NEXTHOP_TYPE_IPV6:
  750. case NEXTHOP_TYPE_IPV6_IFINDEX:
  751. case NEXTHOP_TYPE_IPV6_IFNAME:
  752. if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
  753. {
  754. if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
  755. vty_out (vty, ", src %s", buf);
  756. }
  757. break;
  758. #endif /* HAVE_IPV6 */
  759. default:
  760. break;
  761. }
  762. vty_out (vty, "%s", VTY_NEWLINE);
  763. }
  764. vty_out (vty, "%s", VTY_NEWLINE);
  765. }
  766. }
  767. static void
  768. vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
  769. {
  770. struct nexthop *nexthop, *tnexthop;
  771. int recursing;
  772. int len = 0;
  773. char buf[BUFSIZ];
  774. /* Nexthop information. */
  775. for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
  776. {
  777. if (nexthop == rib->nexthop)
  778. {
  779. /* Prefix information. */
  780. len = vty_out (vty, "%c%c%c %s",
  781. zebra_route_char (rib->type),
  782. CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
  783. ? '>' : ' ',
  784. CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  785. ? '*' : ' ',
  786. prefix2str (&rn->p, buf, sizeof buf));
  787. /* Distance and metric display. */
  788. if (rib->type != ZEBRA_ROUTE_CONNECT
  789. && rib->type != ZEBRA_ROUTE_KERNEL)
  790. len += vty_out (vty, " [%d/%d]", rib->distance,
  791. rib->metric);
  792. }
  793. else
  794. vty_out (vty, " %c%*c",
  795. CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  796. ? '*' : ' ',
  797. len - 3 + (2 * recursing), ' ');
  798. switch (nexthop->type)
  799. {
  800. case NEXTHOP_TYPE_IPV4:
  801. case NEXTHOP_TYPE_IPV4_IFINDEX:
  802. vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
  803. if (nexthop->ifindex)
  804. vty_out (vty, ", %s",
  805. ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
  806. break;
  807. case NEXTHOP_TYPE_IPV6:
  808. case NEXTHOP_TYPE_IPV6_IFINDEX:
  809. case NEXTHOP_TYPE_IPV6_IFNAME:
  810. vty_out (vty, " via %s",
  811. inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
  812. if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
  813. vty_out (vty, ", %s", nexthop->ifname);
  814. else if (nexthop->ifindex)
  815. vty_out (vty, ", %s",
  816. ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
  817. break;
  818. case NEXTHOP_TYPE_IFINDEX:
  819. vty_out (vty, " is directly connected, %s",
  820. ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
  821. break;
  822. case NEXTHOP_TYPE_IFNAME:
  823. vty_out (vty, " is directly connected, %s", nexthop->ifname);
  824. break;
  825. case NEXTHOP_TYPE_BLACKHOLE:
  826. vty_out (vty, " is directly connected, Null0");
  827. break;
  828. default:
  829. break;
  830. }
  831. if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
  832. vty_out (vty, " inactive");
  833. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
  834. vty_out (vty, " onlink");
  835. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
  836. vty_out (vty, " (recursive)");
  837. switch (nexthop->type)
  838. {
  839. case NEXTHOP_TYPE_IPV4:
  840. case NEXTHOP_TYPE_IPV4_IFINDEX:
  841. case NEXTHOP_TYPE_IPV4_IFNAME:
  842. if (nexthop->src.ipv4.s_addr)
  843. {
  844. if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
  845. vty_out (vty, ", src %s", buf);
  846. }
  847. break;
  848. #ifdef HAVE_IPV6
  849. case NEXTHOP_TYPE_IPV6:
  850. case NEXTHOP_TYPE_IPV6_IFINDEX:
  851. case NEXTHOP_TYPE_IPV6_IFNAME:
  852. if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
  853. {
  854. if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
  855. vty_out (vty, ", src %s", buf);
  856. }
  857. break;
  858. #endif /* HAVE_IPV6 */
  859. default:
  860. break;
  861. }
  862. if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
  863. vty_out (vty, ", bh");
  864. if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
  865. vty_out (vty, ", rej");
  866. if (rib->type == ZEBRA_ROUTE_RIP
  867. || rib->type == ZEBRA_ROUTE_RIPNG
  868. || rib->type == ZEBRA_ROUTE_OSPF
  869. || rib->type == ZEBRA_ROUTE_OSPF6
  870. || rib->type == ZEBRA_ROUTE_BABEL
  871. || rib->type == ZEBRA_ROUTE_ISIS
  872. || rib->type == ZEBRA_ROUTE_BGP)
  873. {
  874. time_t uptime;
  875. struct tm *tm;
  876. uptime = time (NULL);
  877. uptime -= rib->uptime;
  878. tm = gmtime (&uptime);
  879. #define ONE_DAY_SECOND 60*60*24
  880. #define ONE_WEEK_SECOND 60*60*24*7
  881. if (uptime < ONE_DAY_SECOND)
  882. vty_out (vty, ", %02d:%02d:%02d",
  883. tm->tm_hour, tm->tm_min, tm->tm_sec);
  884. else if (uptime < ONE_WEEK_SECOND)
  885. vty_out (vty, ", %dd%02dh%02dm",
  886. tm->tm_yday, tm->tm_hour, tm->tm_min);
  887. else
  888. vty_out (vty, ", %02dw%dd%02dh",
  889. tm->tm_yday/7,
  890. tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
  891. }
  892. vty_out (vty, "%s", VTY_NEWLINE);
  893. }
  894. }
  895. DEFUN (show_ip_route,
  896. show_ip_route_cmd,
  897. "show ip route",
  898. SHOW_STR
  899. IP_STR
  900. "IP routing table\n")
  901. {
  902. return do_show_ip_route(vty, SAFI_UNICAST);
  903. }
  904. static int do_show_ip_route(struct vty *vty, safi_t safi) {
  905. struct route_table *table;
  906. struct route_node *rn;
  907. struct rib *rib;
  908. int first = 1;
  909. table = zebra_vrf_table (AFI_IP, safi, VRF_DEFAULT);
  910. if (! table)
  911. return CMD_SUCCESS;
  912. /* Show all IPv4 routes. */
  913. for (rn = route_top (table); rn; rn = route_next (rn))
  914. RNODE_FOREACH_RIB (rn, rib)
  915. {
  916. if (first)
  917. {
  918. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  919. first = 0;
  920. }
  921. vty_show_ip_route (vty, rn, rib);
  922. }
  923. return CMD_SUCCESS;
  924. }
  925. DEFUN (show_ip_route_prefix_longer,
  926. show_ip_route_prefix_longer_cmd,
  927. "show ip route A.B.C.D/M longer-prefixes",
  928. SHOW_STR
  929. IP_STR
  930. "IP routing table\n"
  931. "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
  932. "Show route matching the specified Network/Mask pair only\n")
  933. {
  934. struct route_table *table;
  935. struct route_node *rn;
  936. struct rib *rib;
  937. struct prefix p;
  938. int ret;
  939. int first = 1;
  940. ret = str2prefix (argv[0], &p);
  941. if (! ret)
  942. {
  943. vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
  944. return CMD_WARNING;
  945. }
  946. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  947. if (! table)
  948. return CMD_SUCCESS;
  949. /* Show matched type IPv4 routes. */
  950. for (rn = route_top (table); rn; rn = route_next (rn))
  951. RNODE_FOREACH_RIB (rn, rib)
  952. if (prefix_match (&p, &rn->p))
  953. {
  954. if (first)
  955. {
  956. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  957. first = 0;
  958. }
  959. vty_show_ip_route (vty, rn, rib);
  960. }
  961. return CMD_SUCCESS;
  962. }
  963. DEFUN (show_ip_route_supernets,
  964. show_ip_route_supernets_cmd,
  965. "show ip route supernets-only",
  966. SHOW_STR
  967. IP_STR
  968. "IP routing table\n"
  969. "Show supernet entries only\n")
  970. {
  971. struct route_table *table;
  972. struct route_node *rn;
  973. struct rib *rib;
  974. u_int32_t addr;
  975. int first = 1;
  976. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  977. if (! table)
  978. return CMD_SUCCESS;
  979. /* Show matched type IPv4 routes. */
  980. for (rn = route_top (table); rn; rn = route_next (rn))
  981. RNODE_FOREACH_RIB (rn, rib)
  982. {
  983. addr = ntohl (rn->p.u.prefix4.s_addr);
  984. if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
  985. || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
  986. || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
  987. {
  988. if (first)
  989. {
  990. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  991. first = 0;
  992. }
  993. vty_show_ip_route (vty, rn, rib);
  994. }
  995. }
  996. return CMD_SUCCESS;
  997. }
  998. DEFUN (show_ip_route_protocol,
  999. show_ip_route_protocol_cmd,
  1000. "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
  1001. SHOW_STR
  1002. IP_STR
  1003. "IP routing table\n"
  1004. QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
  1005. {
  1006. int type;
  1007. struct route_table *table;
  1008. struct route_node *rn;
  1009. struct rib *rib;
  1010. int first = 1;
  1011. type = proto_redistnum (AFI_IP, argv[0]);
  1012. if (type < 0)
  1013. {
  1014. vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
  1015. return CMD_WARNING;
  1016. }
  1017. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1018. if (! table)
  1019. return CMD_SUCCESS;
  1020. /* Show matched type IPv4 routes. */
  1021. for (rn = route_top (table); rn; rn = route_next (rn))
  1022. RNODE_FOREACH_RIB (rn, rib)
  1023. if (rib->type == type)
  1024. {
  1025. if (first)
  1026. {
  1027. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  1028. first = 0;
  1029. }
  1030. vty_show_ip_route (vty, rn, rib);
  1031. }
  1032. return CMD_SUCCESS;
  1033. }
  1034. DEFUN (show_ip_route_addr,
  1035. show_ip_route_addr_cmd,
  1036. "show ip route A.B.C.D",
  1037. SHOW_STR
  1038. IP_STR
  1039. "IP routing table\n"
  1040. "Network in the IP routing table to display\n")
  1041. {
  1042. int ret;
  1043. struct prefix_ipv4 p;
  1044. struct route_table *table;
  1045. struct route_node *rn;
  1046. ret = str2prefix_ipv4 (argv[0], &p);
  1047. if (ret <= 0)
  1048. {
  1049. vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
  1050. return CMD_WARNING;
  1051. }
  1052. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1053. if (! table)
  1054. return CMD_SUCCESS;
  1055. rn = route_node_match (table, (struct prefix *) &p);
  1056. if (! rn)
  1057. {
  1058. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1059. return CMD_WARNING;
  1060. }
  1061. vty_show_ip_route_detail (vty, rn, 0);
  1062. route_unlock_node (rn);
  1063. return CMD_SUCCESS;
  1064. }
  1065. DEFUN (show_ip_route_prefix,
  1066. show_ip_route_prefix_cmd,
  1067. "show ip route A.B.C.D/M",
  1068. SHOW_STR
  1069. IP_STR
  1070. "IP routing table\n"
  1071. "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
  1072. {
  1073. int ret;
  1074. struct prefix_ipv4 p;
  1075. struct route_table *table;
  1076. struct route_node *rn;
  1077. ret = str2prefix_ipv4 (argv[0], &p);
  1078. if (ret <= 0)
  1079. {
  1080. vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
  1081. return CMD_WARNING;
  1082. }
  1083. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1084. if (! table)
  1085. return CMD_SUCCESS;
  1086. rn = route_node_match (table, (struct prefix *) &p);
  1087. if (! rn || rn->p.prefixlen != p.prefixlen)
  1088. {
  1089. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1090. if (rn)
  1091. route_unlock_node (rn);
  1092. return CMD_WARNING;
  1093. }
  1094. vty_show_ip_route_detail (vty, rn, 0);
  1095. route_unlock_node (rn);
  1096. return CMD_SUCCESS;
  1097. }
  1098. static void
  1099. vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
  1100. {
  1101. struct route_node *rn;
  1102. struct rib *rib;
  1103. struct nexthop *nexthop;
  1104. #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
  1105. #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
  1106. u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1107. u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1108. u_int32_t i;
  1109. memset (&rib_cnt, 0, sizeof(rib_cnt));
  1110. memset (&fib_cnt, 0, sizeof(fib_cnt));
  1111. for (rn = route_top (table); rn; rn = route_next (rn))
  1112. RNODE_FOREACH_RIB (rn, rib)
  1113. for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
  1114. {
  1115. rib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1116. rib_cnt[rib->type]++;
  1117. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  1118. || nexthop_has_fib_child(nexthop))
  1119. {
  1120. fib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1121. fib_cnt[rib->type]++;
  1122. }
  1123. if (rib->type == ZEBRA_ROUTE_BGP &&
  1124. CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
  1125. {
  1126. rib_cnt[ZEBRA_ROUTE_IBGP]++;
  1127. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
  1128. || nexthop_has_fib_child(nexthop))
  1129. fib_cnt[ZEBRA_ROUTE_IBGP]++;
  1130. }
  1131. }
  1132. vty_out (vty, "%-20s %-20s %-20s %s",
  1133. "Route Source", "Routes", "FIB", VTY_NEWLINE);
  1134. for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
  1135. {
  1136. if (rib_cnt[i] > 0)
  1137. {
  1138. if (i == ZEBRA_ROUTE_BGP)
  1139. {
  1140. vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
  1141. rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
  1142. fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
  1143. VTY_NEWLINE);
  1144. vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
  1145. rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
  1146. VTY_NEWLINE);
  1147. }
  1148. else
  1149. vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
  1150. rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
  1151. }
  1152. }
  1153. vty_out (vty, "------%s", VTY_NEWLINE);
  1154. vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
  1155. fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
  1156. }
  1157. /*
  1158. * Implementation of the ip route summary prefix command.
  1159. *
  1160. * This command prints the primary prefixes that have been installed by various
  1161. * protocols on the box.
  1162. *
  1163. */
  1164. static void
  1165. vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
  1166. {
  1167. struct route_node *rn;
  1168. struct rib *rib;
  1169. struct nexthop *nexthop;
  1170. #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
  1171. #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
  1172. u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1173. u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
  1174. u_int32_t i;
  1175. int cnt;
  1176. memset (&rib_cnt, 0, sizeof(rib_cnt));
  1177. memset (&fib_cnt, 0, sizeof(fib_cnt));
  1178. for (rn = route_top (table); rn; rn = route_next (rn))
  1179. RNODE_FOREACH_RIB (rn, rib)
  1180. {
  1181. /*
  1182. * In case of ECMP, count only once.
  1183. */
  1184. cnt = 0;
  1185. for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
  1186. {
  1187. cnt++;
  1188. rib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1189. rib_cnt[rib->type]++;
  1190. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
  1191. {
  1192. fib_cnt[ZEBRA_ROUTE_TOTAL]++;
  1193. fib_cnt[rib->type]++;
  1194. }
  1195. if (rib->type == ZEBRA_ROUTE_BGP &&
  1196. CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
  1197. {
  1198. rib_cnt[ZEBRA_ROUTE_IBGP]++;
  1199. if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
  1200. fib_cnt[ZEBRA_ROUTE_IBGP]++;
  1201. }
  1202. }
  1203. }
  1204. vty_out (vty, "%-20s %-20s %-20s %s",
  1205. "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE);
  1206. for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
  1207. {
  1208. if (rib_cnt[i] > 0)
  1209. {
  1210. if (i == ZEBRA_ROUTE_BGP)
  1211. {
  1212. vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
  1213. rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
  1214. fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
  1215. VTY_NEWLINE);
  1216. vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
  1217. rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
  1218. VTY_NEWLINE);
  1219. }
  1220. else
  1221. vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
  1222. rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
  1223. }
  1224. }
  1225. vty_out (vty, "------%s", VTY_NEWLINE);
  1226. vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
  1227. fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
  1228. }
  1229. /* Show route summary. */
  1230. DEFUN (show_ip_route_summary,
  1231. show_ip_route_summary_cmd,
  1232. "show ip route summary",
  1233. SHOW_STR
  1234. IP_STR
  1235. "IP routing table\n"
  1236. "Summary of all routes\n")
  1237. {
  1238. struct route_table *table;
  1239. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1240. if (! table)
  1241. return CMD_SUCCESS;
  1242. vty_show_ip_route_summary (vty, table);
  1243. return CMD_SUCCESS;
  1244. }
  1245. /* Show route summary prefix. */
  1246. DEFUN (show_ip_route_summary_prefix,
  1247. show_ip_route_summary_prefix_cmd,
  1248. "show ip route summary prefix",
  1249. SHOW_STR
  1250. IP_STR
  1251. "IP routing table\n"
  1252. "Summary of all routes\n"
  1253. "Prefix routes\n")
  1254. {
  1255. struct route_table *table;
  1256. table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
  1257. if (! table)
  1258. return CMD_SUCCESS;
  1259. vty_show_ip_route_summary_prefix (vty, table);
  1260. return CMD_SUCCESS;
  1261. }
  1262. /* Write IPv4 static route configuration. */
  1263. static int
  1264. static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
  1265. {
  1266. struct route_node *rn;
  1267. struct static_ipv4 *si;
  1268. struct route_table *stable;
  1269. char buf[PREFIX_STRLEN];
  1270. int write;
  1271. write = 0;
  1272. /* Lookup table. */
  1273. stable = zebra_vrf_static_table (AFI_IP, safi, VRF_DEFAULT);
  1274. if (! stable)
  1275. return -1;
  1276. for (rn = route_top (stable); rn; rn = route_next (rn))
  1277. for (si = rn->info; si; si = si->next)
  1278. {
  1279. vty_out (vty, "%s %s", cmd, prefix2str (&rn->p, buf, sizeof buf));
  1280. switch (si->type)
  1281. {
  1282. case STATIC_IPV4_GATEWAY:
  1283. vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
  1284. break;
  1285. case STATIC_IPV4_IFNAME:
  1286. vty_out (vty, " %s", si->gate.ifname);
  1287. break;
  1288. case STATIC_IPV4_BLACKHOLE:
  1289. vty_out (vty, " Null0");
  1290. break;
  1291. }
  1292. /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
  1293. if (si->type != STATIC_IPV4_BLACKHOLE)
  1294. {
  1295. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
  1296. vty_out (vty, " %s", "reject");
  1297. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
  1298. vty_out (vty, " %s", "blackhole");
  1299. }
  1300. if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
  1301. vty_out (vty, " %d", si->distance);
  1302. vty_out (vty, "%s", VTY_NEWLINE);
  1303. write = 1;
  1304. }
  1305. return write;
  1306. }
  1307. DEFUN (show_ip_protocol,
  1308. show_ip_protocol_cmd,
  1309. "show ip protocol",
  1310. SHOW_STR
  1311. IP_STR
  1312. "IP protocol filtering status\n")
  1313. {
  1314. int i;
  1315. vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
  1316. vty_out(vty, "------------------------%s", VTY_NEWLINE);
  1317. for (i=0;i<ZEBRA_ROUTE_MAX;i++)
  1318. {
  1319. if (proto_rm[AFI_IP][i])
  1320. vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
  1321. proto_rm[AFI_IP][i],
  1322. VTY_NEWLINE);
  1323. else
  1324. vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
  1325. }
  1326. if (proto_rm[AFI_IP][i])
  1327. vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
  1328. VTY_NEWLINE);
  1329. else
  1330. vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
  1331. return CMD_SUCCESS;
  1332. }
  1333. /*
  1334. * Show IP mroute command to dump the BGP Multicast
  1335. * routing table
  1336. */
  1337. DEFUN (show_ip_mroute,
  1338. show_ip_mroute_cmd,
  1339. "show ip mroute",
  1340. SHOW_STR
  1341. IP_STR
  1342. "IP Multicast routing table\n")
  1343. {
  1344. struct route_table *table;
  1345. struct route_node *rn;
  1346. struct rib *rib;
  1347. int first = 1;
  1348. table = zebra_vrf_table (AFI_IP, SAFI_MULTICAST, VRF_DEFAULT);
  1349. if (! table)
  1350. return CMD_SUCCESS;
  1351. /* Show all IPv4 routes. */
  1352. for (rn = route_top (table); rn; rn = route_next (rn))
  1353. RNODE_FOREACH_RIB (rn, rib)
  1354. {
  1355. if (first)
  1356. {
  1357. vty_out (vty, SHOW_ROUTE_V4_HEADER);
  1358. first = 0;
  1359. }
  1360. vty_show_ip_route (vty, rn, rib);
  1361. }
  1362. return CMD_SUCCESS;
  1363. }
  1364. #ifdef HAVE_IPV6
  1365. /* General fucntion for IPv6 static route. */
  1366. static int
  1367. static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
  1368. const char *gate_str, const char *ifname,
  1369. const char *flag_str, const char *distance_str)
  1370. {
  1371. int ret;
  1372. u_char distance;
  1373. struct prefix p;
  1374. struct in6_addr *gate = NULL;
  1375. struct in6_addr gate_addr;
  1376. u_char type = 0;
  1377. int table = 0;
  1378. u_char flag = 0;
  1379. ret = str2prefix (dest_str, &p);
  1380. if (ret <= 0)
  1381. {
  1382. vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
  1383. return CMD_WARNING;
  1384. }
  1385. /* Apply mask for given prefix. */
  1386. apply_mask (&p);
  1387. /* Route flags */
  1388. if (flag_str) {
  1389. switch(flag_str[0]) {
  1390. case 'r':
  1391. case 'R': /* XXX */
  1392. SET_FLAG (flag, ZEBRA_FLAG_REJECT);
  1393. break;
  1394. case 'b':
  1395. case 'B': /* XXX */
  1396. SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
  1397. break;
  1398. default:
  1399. vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
  1400. return CMD_WARNING;
  1401. }
  1402. }
  1403. /* Administrative distance. */
  1404. if (distance_str)
  1405. distance = atoi (distance_str);
  1406. else
  1407. distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
  1408. /* When gateway is valid IPv6 addrees, then gate is treated as
  1409. nexthop address other case gate is treated as interface name. */
  1410. ret = inet_pton (AF_INET6, gate_str, &gate_addr);
  1411. if (ifname)
  1412. {
  1413. /* When ifname is specified. It must be come with gateway
  1414. address. */
  1415. if (ret != 1)
  1416. {
  1417. vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
  1418. return CMD_WARNING;
  1419. }
  1420. type = STATIC_IPV6_GATEWAY_IFNAME;
  1421. gate = &gate_addr;
  1422. }
  1423. else
  1424. {
  1425. if (ret == 1)
  1426. {
  1427. type = STATIC_IPV6_GATEWAY;
  1428. gate = &gate_addr;
  1429. }
  1430. else
  1431. {
  1432. type = STATIC_IPV6_IFNAME;
  1433. ifname = gate_str;
  1434. }
  1435. }
  1436. if (add_cmd)
  1437. static_add_ipv6 (&p, type, gate, ifname, flag, distance, table);
  1438. else
  1439. static_delete_ipv6 (&p, type, gate, ifname, distance, table);
  1440. return CMD_SUCCESS;
  1441. }
  1442. DEFUN (ipv6_route,
  1443. ipv6_route_cmd,
  1444. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
  1445. IP_STR
  1446. "Establish static routes\n"
  1447. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1448. "IPv6 gateway address\n"
  1449. "IPv6 gateway interface name\n")
  1450. {
  1451. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL);
  1452. }
  1453. DEFUN (ipv6_route_flags,
  1454. ipv6_route_flags_cmd,
  1455. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
  1456. IP_STR
  1457. "Establish static routes\n"
  1458. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1459. "IPv6 gateway address\n"
  1460. "IPv6 gateway interface name\n"
  1461. "Emit an ICMP unreachable when matched\n"
  1462. "Silently discard pkts when matched\n")
  1463. {
  1464. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
  1465. }
  1466. DEFUN (ipv6_route_ifname,
  1467. ipv6_route_ifname_cmd,
  1468. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
  1469. IP_STR
  1470. "Establish static routes\n"
  1471. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1472. "IPv6 gateway address\n"
  1473. "IPv6 gateway interface name\n")
  1474. {
  1475. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
  1476. }
  1477. DEFUN (ipv6_route_ifname_flags,
  1478. ipv6_route_ifname_flags_cmd,
  1479. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
  1480. IP_STR
  1481. "Establish static routes\n"
  1482. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1483. "IPv6 gateway address\n"
  1484. "IPv6 gateway interface name\n"
  1485. "Emit an ICMP unreachable when matched\n"
  1486. "Silently discard pkts when matched\n")
  1487. {
  1488. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
  1489. }
  1490. DEFUN (ipv6_route_pref,
  1491. ipv6_route_pref_cmd,
  1492. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
  1493. IP_STR
  1494. "Establish static routes\n"
  1495. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1496. "IPv6 gateway address\n"
  1497. "IPv6 gateway interface name\n"
  1498. "Distance value for this prefix\n")
  1499. {
  1500. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]);
  1501. }
  1502. DEFUN (ipv6_route_flags_pref,
  1503. ipv6_route_flags_pref_cmd,
  1504. "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
  1505. IP_STR
  1506. "Establish static routes\n"
  1507. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1508. "IPv6 gateway address\n"
  1509. "IPv6 gateway interface name\n"
  1510. "Emit an ICMP unreachable when matched\n"
  1511. "Silently discard pkts when matched\n"
  1512. "Distance value for this prefix\n")
  1513. {
  1514. return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
  1515. }
  1516. DEFUN (ipv6_route_ifname_pref,
  1517. ipv6_route_ifname_pref_cmd,
  1518. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
  1519. IP_STR
  1520. "Establish static routes\n"
  1521. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1522. "IPv6 gateway address\n"
  1523. "IPv6 gateway interface name\n"
  1524. "Distance value for this prefix\n")
  1525. {
  1526. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
  1527. }
  1528. DEFUN (ipv6_route_ifname_flags_pref,
  1529. ipv6_route_ifname_flags_pref_cmd,
  1530. "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
  1531. IP_STR
  1532. "Establish static routes\n"
  1533. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1534. "IPv6 gateway address\n"
  1535. "IPv6 gateway interface name\n"
  1536. "Emit an ICMP unreachable when matched\n"
  1537. "Silently discard pkts when matched\n"
  1538. "Distance value for this prefix\n")
  1539. {
  1540. return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
  1541. }
  1542. DEFUN (no_ipv6_route,
  1543. no_ipv6_route_cmd,
  1544. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
  1545. NO_STR
  1546. IP_STR
  1547. "Establish static routes\n"
  1548. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1549. "IPv6 gateway address\n"
  1550. "IPv6 gateway interface name\n")
  1551. {
  1552. return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
  1553. }
  1554. ALIAS (no_ipv6_route,
  1555. no_ipv6_route_flags_cmd,
  1556. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
  1557. NO_STR
  1558. IP_STR
  1559. "Establish static routes\n"
  1560. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1561. "IPv6 gateway address\n"
  1562. "IPv6 gateway interface name\n"
  1563. "Emit an ICMP unreachable when matched\n"
  1564. "Silently discard pkts when matched\n")
  1565. DEFUN (no_ipv6_route_ifname,
  1566. no_ipv6_route_ifname_cmd,
  1567. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
  1568. NO_STR
  1569. IP_STR
  1570. "Establish static routes\n"
  1571. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1572. "IPv6 gateway address\n"
  1573. "IPv6 gateway interface name\n")
  1574. {
  1575. return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
  1576. }
  1577. ALIAS (no_ipv6_route_ifname,
  1578. no_ipv6_route_ifname_flags_cmd,
  1579. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
  1580. NO_STR
  1581. IP_STR
  1582. "Establish static routes\n"
  1583. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1584. "IPv6 gateway address\n"
  1585. "IPv6 gateway interface name\n"
  1586. "Emit an ICMP unreachable when matched\n"
  1587. "Silently discard pkts when matched\n")
  1588. DEFUN (no_ipv6_route_pref,
  1589. no_ipv6_route_pref_cmd,
  1590. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
  1591. NO_STR
  1592. IP_STR
  1593. "Establish static routes\n"
  1594. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1595. "IPv6 gateway address\n"
  1596. "IPv6 gateway interface name\n"
  1597. "Distance value for this prefix\n")
  1598. {
  1599. return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]);
  1600. }
  1601. DEFUN (no_ipv6_route_flags_pref,
  1602. no_ipv6_route_flags_pref_cmd,
  1603. "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
  1604. NO_STR
  1605. IP_STR
  1606. "Establish static routes\n"
  1607. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1608. "IPv6 gateway address\n"
  1609. "IPv6 gateway interface name\n"
  1610. "Emit an ICMP unreachable when matched\n"
  1611. "Silently discard pkts when matched\n"
  1612. "Distance value for this prefix\n")
  1613. {
  1614. /* We do not care about argv[2] */
  1615. return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
  1616. }
  1617. DEFUN (no_ipv6_route_ifname_pref,
  1618. no_ipv6_route_ifname_pref_cmd,
  1619. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
  1620. NO_STR
  1621. IP_STR
  1622. "Establish static routes\n"
  1623. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1624. "IPv6 gateway address\n"
  1625. "IPv6 gateway interface name\n"
  1626. "Distance value for this prefix\n")
  1627. {
  1628. return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
  1629. }
  1630. DEFUN (no_ipv6_route_ifname_flags_pref,
  1631. no_ipv6_route_ifname_flags_pref_cmd,
  1632. "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
  1633. NO_STR
  1634. IP_STR
  1635. "Establish static routes\n"
  1636. "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
  1637. "IPv6 gateway address\n"
  1638. "IPv6 gateway interface name\n"
  1639. "Emit an ICMP unreachable when matched\n"
  1640. "Silently discard pkts when matched\n"
  1641. "Distance value for this prefix\n")
  1642. {
  1643. return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
  1644. }
  1645. DEFUN (show_ipv6_route,
  1646. show_ipv6_route_cmd,
  1647. "show ipv6 route",
  1648. SHOW_STR
  1649. IP_STR
  1650. "IPv6 routing table\n")
  1651. {
  1652. struct route_table *table;
  1653. struct route_node *rn;
  1654. struct rib *rib;
  1655. int first = 1;
  1656. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1657. if (! table)
  1658. return CMD_SUCCESS;
  1659. /* Show all IPv6 route. */
  1660. for (rn = route_top (table); rn; rn = route_next (rn))
  1661. RNODE_FOREACH_RIB (rn, rib)
  1662. {
  1663. if (first)
  1664. {
  1665. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1666. first = 0;
  1667. }
  1668. vty_show_ip_route (vty, rn, rib);
  1669. }
  1670. return CMD_SUCCESS;
  1671. }
  1672. DEFUN (show_ipv6_route_prefix_longer,
  1673. show_ipv6_route_prefix_longer_cmd,
  1674. "show ipv6 route X:X::X:X/M longer-prefixes",
  1675. SHOW_STR
  1676. IP_STR
  1677. "IPv6 routing table\n"
  1678. "IPv6 prefix\n"
  1679. "Show route matching the specified Network/Mask pair only\n")
  1680. {
  1681. struct route_table *table;
  1682. struct route_node *rn;
  1683. struct rib *rib;
  1684. struct prefix p;
  1685. int ret;
  1686. int first = 1;
  1687. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1688. if (! table)
  1689. return CMD_SUCCESS;
  1690. ret = str2prefix (argv[0], &p);
  1691. if (! ret)
  1692. {
  1693. vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
  1694. return CMD_WARNING;
  1695. }
  1696. /* Show matched type IPv6 routes. */
  1697. for (rn = route_top (table); rn; rn = route_next (rn))
  1698. RNODE_FOREACH_RIB (rn, rib)
  1699. if (prefix_match (&p, &rn->p))
  1700. {
  1701. if (first)
  1702. {
  1703. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1704. first = 0;
  1705. }
  1706. vty_show_ip_route (vty, rn, rib);
  1707. }
  1708. return CMD_SUCCESS;
  1709. }
  1710. DEFUN (show_ipv6_route_protocol,
  1711. show_ipv6_route_protocol_cmd,
  1712. "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
  1713. SHOW_STR
  1714. IP_STR
  1715. "IP routing table\n"
  1716. QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
  1717. {
  1718. int type;
  1719. struct route_table *table;
  1720. struct route_node *rn;
  1721. struct rib *rib;
  1722. int first = 1;
  1723. type = proto_redistnum (AFI_IP6, argv[0]);
  1724. if (type < 0)
  1725. {
  1726. vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
  1727. return CMD_WARNING;
  1728. }
  1729. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1730. if (! table)
  1731. return CMD_SUCCESS;
  1732. /* Show matched type IPv6 routes. */
  1733. for (rn = route_top (table); rn; rn = route_next (rn))
  1734. RNODE_FOREACH_RIB (rn, rib)
  1735. if (rib->type == type)
  1736. {
  1737. if (first)
  1738. {
  1739. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1740. first = 0;
  1741. }
  1742. vty_show_ip_route (vty, rn, rib);
  1743. }
  1744. return CMD_SUCCESS;
  1745. }
  1746. DEFUN (show_ipv6_route_addr,
  1747. show_ipv6_route_addr_cmd,
  1748. "show ipv6 route X:X::X:X",
  1749. SHOW_STR
  1750. IP_STR
  1751. "IPv6 routing table\n"
  1752. "IPv6 Address\n")
  1753. {
  1754. int ret;
  1755. struct prefix_ipv6 p;
  1756. struct route_table *table;
  1757. struct route_node *rn;
  1758. ret = str2prefix_ipv6 (argv[0], &p);
  1759. if (ret <= 0)
  1760. {
  1761. vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
  1762. return CMD_WARNING;
  1763. }
  1764. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1765. if (! table)
  1766. return CMD_SUCCESS;
  1767. rn = route_node_match (table, (struct prefix *) &p);
  1768. if (! rn)
  1769. {
  1770. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1771. return CMD_WARNING;
  1772. }
  1773. vty_show_ip_route_detail (vty, rn, 0);
  1774. route_unlock_node (rn);
  1775. return CMD_SUCCESS;
  1776. }
  1777. DEFUN (show_ipv6_route_prefix,
  1778. show_ipv6_route_prefix_cmd,
  1779. "show ipv6 route X:X::X:X/M",
  1780. SHOW_STR
  1781. IP_STR
  1782. "IPv6 routing table\n"
  1783. "IPv6 prefix\n")
  1784. {
  1785. int ret;
  1786. struct prefix_ipv6 p;
  1787. struct route_table *table;
  1788. struct route_node *rn;
  1789. ret = str2prefix_ipv6 (argv[0], &p);
  1790. if (ret <= 0)
  1791. {
  1792. vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
  1793. return CMD_WARNING;
  1794. }
  1795. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1796. if (! table)
  1797. return CMD_SUCCESS;
  1798. rn = route_node_match (table, (struct prefix *) &p);
  1799. if (! rn || rn->p.prefixlen != p.prefixlen)
  1800. {
  1801. vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
  1802. if (rn)
  1803. route_unlock_node (rn);
  1804. return CMD_WARNING;
  1805. }
  1806. vty_show_ip_route_detail (vty, rn, 0);
  1807. route_unlock_node (rn);
  1808. return CMD_SUCCESS;
  1809. }
  1810. /* Show route summary. */
  1811. DEFUN (show_ipv6_route_summary,
  1812. show_ipv6_route_summary_cmd,
  1813. "show ipv6 route summary",
  1814. SHOW_STR
  1815. IP_STR
  1816. "IPv6 routing table\n"
  1817. "Summary of all IPv6 routes\n")
  1818. {
  1819. struct route_table *table;
  1820. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1821. if (! table)
  1822. return CMD_SUCCESS;
  1823. vty_show_ip_route_summary (vty, table);
  1824. return CMD_SUCCESS;
  1825. }
  1826. /* Show ipv6 route summary prefix. */
  1827. DEFUN (show_ipv6_route_summary_prefix,
  1828. show_ipv6_route_summary_prefix_cmd,
  1829. "show ipv6 route summary prefix",
  1830. SHOW_STR
  1831. IP_STR
  1832. "IPv6 routing table\n"
  1833. "Summary of all IPv6 routes\n"
  1834. "Prefix routes\n")
  1835. {
  1836. struct route_table *table;
  1837. table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1838. if (! table)
  1839. return CMD_SUCCESS;
  1840. vty_show_ip_route_summary_prefix (vty, table);
  1841. return CMD_SUCCESS;
  1842. }
  1843. /*
  1844. * Show IPv6 mroute command.Used to dump
  1845. * the Multicast routing table.
  1846. */
  1847. DEFUN (show_ipv6_mroute,
  1848. show_ipv6_mroute_cmd,
  1849. "show ipv6 mroute",
  1850. SHOW_STR
  1851. IP_STR
  1852. "IPv6 Multicast routing table\n")
  1853. {
  1854. struct route_table *table;
  1855. struct route_node *rn;
  1856. struct rib *rib;
  1857. int first = 1;
  1858. table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, VRF_DEFAULT);
  1859. if (! table)
  1860. return CMD_SUCCESS;
  1861. /* Show all IPv6 route. */
  1862. for (rn = route_top (table); rn; rn = route_next (rn))
  1863. RNODE_FOREACH_RIB (rn, rib)
  1864. {
  1865. if (first)
  1866. {
  1867. vty_out (vty, SHOW_ROUTE_V6_HEADER);
  1868. first = 0;
  1869. }
  1870. vty_show_ip_route (vty, rn, rib);
  1871. }
  1872. return CMD_SUCCESS;
  1873. }
  1874. /* Write IPv6 static route configuration. */
  1875. static int
  1876. static_config_ipv6 (struct vty *vty)
  1877. {
  1878. struct route_node *rn;
  1879. struct static_ipv6 *si;
  1880. int write;
  1881. char buf[BUFSIZ];
  1882. struct route_table *stable;
  1883. write = 0;
  1884. /* Lookup table. */
  1885. stable = zebra_vrf_static_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
  1886. if (! stable)
  1887. return -1;
  1888. for (rn = route_top (stable); rn; rn = route_next (rn))
  1889. for (si = rn->info; si; si = si->next)
  1890. {
  1891. vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
  1892. switch (si->type)
  1893. {
  1894. case STATIC_IPV6_GATEWAY:
  1895. vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
  1896. break;
  1897. case STATIC_IPV6_IFNAME:
  1898. vty_out (vty, " %s", si->ifname);
  1899. break;
  1900. case STATIC_IPV6_GATEWAY_IFNAME:
  1901. vty_out (vty, " %s %s",
  1902. inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname);
  1903. break;
  1904. }
  1905. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
  1906. vty_out (vty, " %s", "reject");
  1907. if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
  1908. vty_out (vty, " %s", "blackhole");
  1909. if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
  1910. vty_out (vty, " %d", si->distance);
  1911. vty_out (vty, "%s", VTY_NEWLINE);
  1912. write = 1;
  1913. }
  1914. return write;
  1915. }
  1916. #endif /* HAVE_IPV6 */
  1917. /* Static ip route configuration write function. */
  1918. static int
  1919. zebra_ip_config (struct vty *vty)
  1920. {
  1921. int write = 0;
  1922. write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
  1923. write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
  1924. #ifdef HAVE_IPV6
  1925. write += static_config_ipv6 (vty);
  1926. #endif /* HAVE_IPV6 */
  1927. return write;
  1928. }
  1929. static int config_write_vty(struct vty *vty)
  1930. {
  1931. int i;
  1932. enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
  1933. if (ipv4_multicast_mode != MCAST_NO_CONFIG)
  1934. vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
  1935. ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
  1936. ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
  1937. ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
  1938. ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
  1939. "longer-prefix",
  1940. VTY_NEWLINE);
  1941. for (i=0;i<ZEBRA_ROUTE_MAX;i++)
  1942. {
  1943. if (proto_rm[AFI_IP][i])
  1944. vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
  1945. proto_rm[AFI_IP][i], VTY_NEWLINE);
  1946. }
  1947. if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
  1948. vty_out (vty, "ip protocol %s route-map %s%s", "any",
  1949. proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
  1950. return 1;
  1951. }
  1952. /* table node for protocol filtering */
  1953. static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
  1954. /* IP node for static routes. */
  1955. static struct cmd_node ip_node = { IP_NODE, "", 1 };
  1956. /* Route VTY. */
  1957. void
  1958. zebra_vty_init (void)
  1959. {
  1960. install_node (&ip_node, zebra_ip_config);
  1961. install_node (&protocol_node, config_write_vty);
  1962. install_element (CONFIG_NODE, &ip_mroute_cmd);
  1963. install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
  1964. install_element (CONFIG_NODE, &no_ip_mroute_cmd);
  1965. install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
  1966. install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
  1967. install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
  1968. install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
  1969. install_element (CONFIG_NODE, &ip_protocol_cmd);
  1970. install_element (CONFIG_NODE, &no_ip_protocol_cmd);
  1971. install_element (VIEW_NODE, &show_ip_protocol_cmd);
  1972. install_element (ENABLE_NODE, &show_ip_protocol_cmd);
  1973. install_element (CONFIG_NODE, &ip_route_cmd);
  1974. install_element (CONFIG_NODE, &ip_route_flags_cmd);
  1975. install_element (CONFIG_NODE, &ip_route_flags2_cmd);
  1976. install_element (CONFIG_NODE, &ip_route_mask_cmd);
  1977. install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
  1978. install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
  1979. install_element (CONFIG_NODE, &no_ip_route_cmd);
  1980. install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
  1981. install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
  1982. install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
  1983. install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
  1984. install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
  1985. install_element (CONFIG_NODE, &ip_route_distance_cmd);
  1986. install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
  1987. install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
  1988. install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
  1989. install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
  1990. install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
  1991. install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
  1992. install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
  1993. install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
  1994. install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
  1995. install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
  1996. install_element (VIEW_NODE, &show_ip_route_cmd);
  1997. install_element (VIEW_NODE, &show_ip_route_addr_cmd);
  1998. install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
  1999. install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
  2000. install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
  2001. install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
  2002. install_element (VIEW_NODE, &show_ip_route_summary_cmd);
  2003. install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
  2004. install_element (ENABLE_NODE, &show_ip_route_cmd);
  2005. install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
  2006. install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
  2007. install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
  2008. install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
  2009. install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
  2010. install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
  2011. install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
  2012. install_element (VIEW_NODE, &show_ip_mroute_cmd);
  2013. install_element (ENABLE_NODE, &show_ip_mroute_cmd);
  2014. install_element (VIEW_NODE, &show_ip_rpf_cmd);
  2015. install_element (ENABLE_NODE, &show_ip_rpf_cmd);
  2016. install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
  2017. install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
  2018. #ifdef HAVE_IPV6
  2019. install_element (CONFIG_NODE, &ipv6_route_cmd);
  2020. install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
  2021. install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
  2022. install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
  2023. install_element (CONFIG_NODE, &no_ipv6_route_cmd);
  2024. install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
  2025. install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
  2026. install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
  2027. install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
  2028. install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
  2029. install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
  2030. install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
  2031. install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
  2032. install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
  2033. install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
  2034. install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
  2035. install_element (VIEW_NODE, &show_ipv6_route_cmd);
  2036. install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
  2037. install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
  2038. install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
  2039. install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
  2040. install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
  2041. install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
  2042. install_element (ENABLE_NODE, &show_ipv6_route_cmd);
  2043. install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
  2044. install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
  2045. install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
  2046. install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
  2047. install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
  2048. install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
  2049. install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
  2050. install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
  2051. #endif /* HAVE_IPV6 */
  2052. }