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 
22 #include <zebra.h>
23 
24 #include "memory.h"
25 #include "if.h"
26 #include "prefix.h"
27 #include "command.h"
28 #include "table.h"
29 #include "rib.h"
30 #include "vrf.h"
31 #include "nexthop.h"
32 
33 #include "zebra/zserv.h"
34 #include "zebra/zebra_rnh.h"
35 
36 static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id);
37 static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
38                                       int mcast);
39 static void vty_show_ip_route (struct vty *vty, struct route_node *rn,
40                                struct rib *rib);
41 
42 /* General function for static route. */
43 static int
zebra_static_ipv4_safi(struct vty * vty,safi_t safi,int add_cmd,const char * dest_str,const char * mask_str,const char * gate_str,const char * flag_str,const char * tag_str,const char * distance_str,const char * vrf_id_str)44 zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
45 			const char *dest_str, const char *mask_str,
46 			const char *gate_str, const char *flag_str,
47 			const char *tag_str, const char *distance_str,
48 			const char *vrf_id_str)
49 {
50   int ret;
51   u_char distance;
52   struct prefix p;
53   struct in_addr gate;
54   struct in_addr mask;
55   const char *ifname;
56   u_char flag = 0;
57   route_tag_t tag = 0;
58   vrf_id_t vrf_id = VRF_DEFAULT;
59 
60   ret = str2prefix (dest_str, &p);
61   if (ret <= 0)
62     {
63       vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
64       return CMD_WARNING;
65     }
66 
67   /* Cisco like mask notation. */
68   if (mask_str)
69     {
70       ret = inet_aton (mask_str, &mask);
71       if (ret == 0)
72         {
73           vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
74           return CMD_WARNING;
75         }
76       p.prefixlen = ip_masklen (mask);
77     }
78 
79   /* Apply mask for given prefix. */
80   apply_mask (&p);
81 
82   /* Administrative distance. */
83   if (distance_str)
84     distance = atoi (distance_str);
85   else
86     distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
87 
88   /* tag */
89   if (tag_str)
90     tag = atoi (tag_str);
91 
92   /* VRF id */
93   if (vrf_id_str)
94     VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
95 
96   /* tag */
97   if (tag_str)
98     tag = atoi(tag_str);
99 
100   /* Null0 static route.  */
101   if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
102     {
103       if (flag_str)
104         {
105           vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
106           return CMD_WARNING;
107         }
108       if (add_cmd)
109         static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, tag, distance, vrf_id);
110       else
111         static_delete_ipv4_safi (safi, &p, NULL, NULL, tag, distance, vrf_id);
112       return CMD_SUCCESS;
113     }
114 
115   /* Route flags */
116   if (flag_str) {
117     switch(flag_str[0]) {
118       case 'r':
119       case 'R': /* XXX */
120         SET_FLAG (flag, ZEBRA_FLAG_REJECT);
121         break;
122       case 'b':
123       case 'B': /* XXX */
124         SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
125         break;
126       default:
127         vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
128         return CMD_WARNING;
129     }
130   }
131 
132   if (gate_str == NULL)
133   {
134     if (add_cmd)
135       static_add_ipv4_safi (safi, &p, NULL, NULL, flag, tag, distance, vrf_id);
136     else
137       static_delete_ipv4_safi (safi, &p, NULL, NULL, tag, distance, vrf_id);
138 
139     return CMD_SUCCESS;
140   }
141 
142   /* When gateway is A.B.C.D format, gate is treated as nexthop
143      address other case gate is treated as interface name. */
144   ret = inet_aton (gate_str, &gate);
145   if (ret)
146     ifname = NULL;
147   else
148     ifname = gate_str;
149 
150   if (add_cmd)
151     static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, tag, distance, vrf_id);
152   else
153     static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, tag, distance, vrf_id);
154 
155   return CMD_SUCCESS;
156 }
157 
158 /* Static unicast routes for multicast RPF lookup. */
159 DEFUN (ip_mroute_dist,
160        ip_mroute_dist_cmd,
161        "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
162        IP_STR
163        "Configure static unicast route into MRIB for multicast RPF lookup\n"
164        "IP destination prefix (e.g. 10.0.0.0/8)\n"
165        "Nexthop address\n"
166        "Nexthop interface name\n"
167        "Distance\n")
168 {
169   VTY_WARN_EXPERIMENTAL();
170   return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
171                                 NULL, NULL, argc > 2 ? argv[2] : NULL, NULL);
172 }
173 
174 ALIAS (ip_mroute_dist,
175        ip_mroute_cmd,
176        "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
177        IP_STR
178        "Configure static unicast route into MRIB for multicast RPF lookup\n"
179        "IP destination prefix (e.g. 10.0.0.0/8)\n"
180        "Nexthop address\n"
181        "Nexthop interface name\n")
182 
183 DEFUN (ip_mroute_dist_vrf,
184        ip_mroute_dist_vrf_cmd,
185        "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
186        IP_STR
187        "Configure static unicast route into MRIB for multicast RPF lookup\n"
188        "IP destination prefix (e.g. 10.0.0.0/8)\n"
189        "Nexthop address\n"
190        "Nexthop interface name\n"
191        "Distance\n"
192        VRF_CMD_HELP_STR)
193 {
194   VTY_WARN_EXPERIMENTAL();
195   return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
196                                 NULL, NULL, argc > 3 ? argv[2] : NULL,
197                                 argc > 3 ? argv[3] : argv[2]);
198 }
199 
200 ALIAS (ip_mroute_dist_vrf,
201        ip_mroute_vrf_cmd,
202        "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) "VRF_CMD_STR,
203        IP_STR
204        "Configure static unicast route into MRIB for multicast RPF lookup\n"
205        "IP destination prefix (e.g. 10.0.0.0/8)\n"
206        "Nexthop address\n"
207        "Nexthop interface name\n"
208        VRF_CMD_HELP_STR)
209 
210 DEFUN (no_ip_mroute_dist,
211        no_ip_mroute_dist_cmd,
212        "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
213        IP_STR
214        "Configure static unicast route into MRIB for multicast RPF lookup\n"
215        "IP destination prefix (e.g. 10.0.0.0/8)\n"
216        "Nexthop address\n"
217        "Nexthop interface name\n"
218        "Distance\n")
219 {
220   VTY_WARN_EXPERIMENTAL();
221   return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
222                                 NULL, NULL, argc > 2 ? argv[2] : NULL, NULL);
223 }
224 
225 ALIAS (no_ip_mroute_dist,
226        no_ip_mroute_cmd,
227        "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
228        NO_STR
229        IP_STR
230        "Configure static unicast route into MRIB for multicast RPF lookup\n"
231        "IP destination prefix (e.g. 10.0.0.0/8)\n"
232        "Nexthop address\n"
233        "Nexthop interface name\n")
234 
235 DEFUN (no_ip_mroute_dist_vrf,
236        no_ip_mroute_dist_vrf_cmd,
237        "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
238        IP_STR
239        "Configure static unicast route into MRIB for multicast RPF lookup\n"
240        "IP destination prefix (e.g. 10.0.0.0/8)\n"
241        "Nexthop address\n"
242        "Nexthop interface name\n"
243        "Distance\n"
244        VRF_CMD_HELP_STR)
245 {
246   VTY_WARN_EXPERIMENTAL();
247   return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
248                                 NULL, NULL, argc > 3 ? argv[2] : NULL,
249                                 argc > 3 ? argv[3] : argv[2]);
250 }
251 
252 ALIAS (no_ip_mroute_dist_vrf,
253        no_ip_mroute_vrf_cmd,
254        "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) " VRF_CMD_STR,
255        NO_STR
256        IP_STR
257        "Configure static unicast route into MRIB for multicast RPF lookup\n"
258        "IP destination prefix (e.g. 10.0.0.0/8)\n"
259        "Nexthop address\n"
260        "Nexthop interface name\n"
261        VRF_CMD_HELP_STR)
262 
263 DEFUN (ip_multicast_mode,
264        ip_multicast_mode_cmd,
265        "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
266        IP_STR
267        "Multicast options\n"
268        "RPF lookup behavior\n"
269        "Lookup in unicast RIB only\n"
270        "Lookup in multicast RIB only\n"
271        "Try multicast RIB first, fall back to unicast RIB\n"
272        "Lookup both, use entry with lower distance\n"
273        "Lookup both, use entry with longer prefix\n")
274 {
275   VTY_WARN_EXPERIMENTAL();
276 
277   if (!strncmp (argv[0], "u", 1))
278     multicast_mode_ipv4_set (MCAST_URIB_ONLY);
279   else if (!strncmp (argv[0], "mrib-o", 6))
280     multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
281   else if (!strncmp (argv[0], "mrib-t", 6))
282     multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
283   else if (!strncmp (argv[0], "low", 3))
284     multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
285   else if (!strncmp (argv[0], "lon", 3))
286     multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
287   else
288     {
289       vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
290       return CMD_WARNING;
291     }
292 
293   return CMD_SUCCESS;
294 }
295 
296 DEFUN (no_ip_multicast_mode,
297        no_ip_multicast_mode_cmd,
298        "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
299        NO_STR
300        IP_STR
301        "Multicast options\n"
302        "RPF lookup behavior\n"
303        "Lookup in unicast RIB only\n"
304        "Lookup in multicast RIB only\n"
305        "Try multicast RIB first, fall back to unicast RIB\n"
306        "Lookup both, use entry with lower distance\n"
307        "Lookup both, use entry with longer prefix\n")
308 {
309   multicast_mode_ipv4_set (MCAST_NO_CONFIG);
310   return CMD_SUCCESS;
311 }
312 
313 ALIAS (no_ip_multicast_mode,
314        no_ip_multicast_mode_noarg_cmd,
315        "no ip multicast rpf-lookup-mode",
316        NO_STR
317        IP_STR
318        "Multicast options\n"
319        "RPF lookup behavior\n")
320 
321 DEFUN (show_ip_rpf,
322        show_ip_rpf_cmd,
323        "show ip rpf",
324        SHOW_STR
325        IP_STR
326        "Display RPF information for multicast source\n")
327 {
328   vrf_id_t vrf_id = VRF_DEFAULT;
329 
330   if (argc > 0)
331     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
332 
333   VTY_WARN_EXPERIMENTAL();
334   return do_show_ip_route(vty, SAFI_MULTICAST, vrf_id);
335 }
336 
337 ALIAS (show_ip_rpf,
338        show_ip_rpf_vrf_cmd,
339        "show ip rpf " VRF_CMD_STR,
340        SHOW_STR
341        IP_STR
342        "Display RPF information for multicast source\n"
343        VRF_CMD_HELP_STR)
344 
345 DEFUN (show_ip_rpf_addr,
346        show_ip_rpf_addr_cmd,
347        "show ip rpf A.B.C.D",
348        SHOW_STR
349        IP_STR
350        "Display RPF information for multicast source\n"
351        "IP multicast source address (e.g. 10.0.0.0)\n")
352 {
353   struct in_addr addr;
354   struct route_node *rn;
355   struct rib *rib;
356   vrf_id_t vrf_id = VRF_DEFAULT;
357   int ret;
358 
359   if (argc > 1)
360     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
361 
362   VTY_WARN_EXPERIMENTAL();
363 
364   ret = inet_aton (argv[0], &addr);
365   if (ret == 0)
366     {
367       vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
368       return CMD_WARNING;
369     }
370 
371   rib = rib_match_ipv4_multicast (addr, &rn, vrf_id);
372 
373   if (rib)
374     vty_show_ip_route_detail (vty, rn, 1);
375   else
376     vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
377 
378   return CMD_SUCCESS;
379 }
380 
381 ALIAS (show_ip_rpf_addr,
382        show_ip_rpf_addr_vrf_cmd,
383        "show ip rpf A.B.C.D " VRF_CMD_STR,
384        SHOW_STR
385        IP_STR
386        "Display RPF information for multicast source\n"
387        "IP multicast source address (e.g. 10.0.0.0)\n"
388        VRF_CMD_HELP_STR)
389 
390 DEFUN (show_ip_rpf_vrf_all,
391        show_ip_rpf_vrf_all_cmd,
392        "show ip rpf " VRF_ALL_CMD_STR,
393        SHOW_STR
394        IP_STR
395        "Display RPF information for multicast source\n"
396        VRF_ALL_CMD_HELP_STR)
397 {
398   struct zebra_vrf *zvrf;
399   struct route_table *table;
400   struct route_node *rn;
401   struct rib *rib;
402   vrf_iter_t iter;
403   int first = 1;
404 
405   VTY_WARN_EXPERIMENTAL();
406 
407   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
408     {
409       if ((zvrf = vrf_iter2info (iter)) == NULL ||
410           (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL)
411         continue;
412 
413       /* Show all IPv4 routes. */
414       for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)415         RNODE_FOREACH_RIB (rn, rib)
416           {
417             if (first)
418               {
419                 vty_out (vty, SHOW_ROUTE_V4_HEADER);
420                 first = 0;
421               }
422             vty_show_ip_route (vty, rn, rib);
423           }
424     }
425 
426   return CMD_SUCCESS;
427 }
428 
429 DEFUN (show_ip_rpf_addr_vrf_all,
430        show_ip_rpf_addr_vrf_all_cmd,
431        "show ip rpf A.B.C.D " VRF_ALL_CMD_STR,
432        SHOW_STR
433        IP_STR
434        "Display RPF information for multicast source\n"
435        "IP multicast source address (e.g. 10.0.0.0)\n"
436        VRF_ALL_CMD_HELP_STR)
437 {
438   struct in_addr addr;
439   struct route_node *rn;
440   vrf_iter_t iter;
441   int ret;
442 
443   VTY_WARN_EXPERIMENTAL();
444 
445   ret = inet_aton (argv[0], &addr);
446   if (ret == 0)
447     {
448       vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
449       return CMD_WARNING;
450     }
451 
452   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
453     {
454       if (rib_match_ipv4_multicast (addr, &rn, vrf_iter2id (iter)))
455         vty_show_ip_route_detail (vty, rn, 1);
456     }
457 
458   return CMD_SUCCESS;
459 }
460 
461 /* Static route configuration.  */
462 DEFUN (ip_route,
463        ip_route_cmd,
464        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
465        IP_STR
466        "Establish static routes\n"
467        "IP destination prefix (e.g. 10.0.0.0/8)\n"
468        "IP gateway address\n"
469        "IP gateway interface name\n"
470        "Null interface\n")
471 {
472   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
473 				 NULL, NULL, NULL, NULL);
474 }
475 
476 DEFUN (ip_route_tag,
477        ip_route_tag_cmd,
478        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295>",
479        IP_STR
480        "Establish static routes\n"
481        "IP destination prefix (e.g. 10.0.0.0/8)\n"
482        "IP gateway address\n"
483        "IP gateway interface name\n"
484        "Null interface\n"
485        "Set tag for this route\n"
486        "Tag value\n")
487 {
488   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
489 				 argv[1], NULL, argv[2], NULL, NULL);
490 }
491 
492 DEFUN (ip_route_tag_vrf,
493        ip_route_tag_vrf_cmd,
494        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295>" VRF_CMD_STR,
495        IP_STR
496        "Establish static routes\n"
497        "IP destination prefix (e.g. 10.0.0.0/8)\n"
498        "IP gateway address\n"
499        "IP gateway interface name\n"
500        "Null interface\n"
501        "Set tag for this route\n"
502        "Tag value\n"
503        VRF_CMD_HELP_STR)
504 {
505   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
506 				 argv[1], NULL, argv[2], NULL, argv[3]);
507 }
508 
509 DEFUN (ip_route_flags,
510        ip_route_flags_cmd,
511        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
512        IP_STR
513        "Establish static routes\n"
514        "IP destination prefix (e.g. 10.0.0.0/8)\n"
515        "IP gateway address\n"
516        "IP gateway interface name\n"
517        "Emit an ICMP unreachable when matched\n"
518        "Silently discard pkts when matched\n")
519 {
520   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
521 				 argv[2], NULL, NULL, NULL);
522 }
523 
524 DEFUN (ip_route_flags_tag,
525        ip_route_flags_tag_cmd,
526        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>",
527        IP_STR
528        "Establish static routes\n"
529        "IP destination prefix (e.g. 10.0.0.0/8)\n"
530        "IP gateway address\n"
531        "IP gateway interface name\n"
532        "Emit an ICMP unreachable when matched\n"
533        "Silently discard pkts when matched\n"
534        "Set tag for this route\n"
535        "Tag value\n")
536 
537 {
538   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
539 				 argv[2], argv[3], NULL, NULL);
540 }
541 
542 DEFUN (ip_route_flags_tag_vrf,
543        ip_route_flags_tag_vrf_cmd,
544        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>" VRF_CMD_STR,
545        IP_STR
546        "Establish static routes\n"
547        "IP destination prefix (e.g. 10.0.0.0/8)\n"
548        "IP gateway address\n"
549        "IP gateway interface name\n"
550        "Emit an ICMP unreachable when matched\n"
551        "Silently discard pkts when matched\n"
552        "Set tag for this route\n"
553        "Tag value\n"
554        VRF_CMD_HELP_STR)
555 {
556   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
557 				 argv[2], argv[3], NULL, argv[4]);
558 }
559 
560 DEFUN (ip_route_flags2,
561        ip_route_flags2_cmd,
562        "ip route A.B.C.D/M (reject|blackhole)",
563        IP_STR
564        "Establish static routes\n"
565        "IP destination prefix (e.g. 10.0.0.0/8)\n"
566        "Emit an ICMP unreachable when matched\n"
567        "Silently discard pkts when matched\n")
568 {
569   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
570 				 NULL, argv[1], NULL, NULL, NULL);
571 }
572 
573 DEFUN (ip_route_flags2_tag,
574        ip_route_flags2_tag_cmd,
575        "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295>",
576        IP_STR
577        "Establish static routes\n"
578        "IP destination prefix (e.g. 10.0.0.0/8)\n"
579        "Emit an ICMP unreachable when matched\n"
580        "Silently discard pkts when matched\n"
581        "Set tag for this route\n"
582        "Tag value\n")
583 {
584   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL,
585 				 argv[1], argv[2], NULL, NULL);
586 }
587 
588 DEFUN (ip_route_flags2_tag_vrf,
589        ip_route_flags2_tag_vrf_cmd,
590        "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295>",
591        IP_STR
592        "Establish static routes\n"
593        "IP destination prefix (e.g. 10.0.0.0/8)\n"
594        "Emit an ICMP unreachable when matched\n"
595        "Silently discard pkts when matched\n"
596        "Set tag for this route\n"
597        "Tag value\n"
598        VRF_CMD_HELP_STR)
599 {
600   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL,
601 				 argv[1], argv[2], NULL, argv[3]);
602 }
603 
604 /* Mask as A.B.C.D format.  */
605 DEFUN (ip_route_mask,
606        ip_route_mask_cmd,
607        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
608        IP_STR
609        "Establish static routes\n"
610        "IP destination prefix\n"
611        "IP destination prefix mask\n"
612        "IP gateway address\n"
613        "IP gateway interface name\n"
614        "Null interface\n")
615 {
616   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
617 				 argv[2], NULL, NULL, NULL, NULL);
618 }
619 
620 DEFUN (ip_route_mask_tag,
621        ip_route_mask_tag_cmd,
622        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295>",
623        IP_STR
624        "Establish static routes\n"
625        "IP destination prefix\n"
626        "IP destination prefix mask\n"
627        "IP gateway address\n"
628        "IP gateway interface name\n"
629        "Null interface\n"
630        "Set tag for this route\n"
631        "Tag value\n")
632 
633 {
634   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
635 				 NULL, argv[3], NULL, NULL);
636 }
637 
638 DEFUN (ip_route_mask_tag_vrf,
639        ip_route_mask_tag_vrf_cmd,
640        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295>" VRF_CMD_STR,
641        IP_STR
642        "Establish static routes\n"
643        "IP destination prefix\n"
644        "IP destination prefix mask\n"
645        "IP gateway address\n"
646        "IP gateway interface name\n"
647        "Null interface\n"
648        "Set tag for this route\n"
649        "Tag value\n"
650        VRF_CMD_HELP_STR)
651 {
652   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
653 				 NULL, argv[3], NULL, argv[4]);
654 }
655 
656 DEFUN (ip_route_mask_flags,
657        ip_route_mask_flags_cmd,
658        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
659        IP_STR
660        "Establish static routes\n"
661        "IP destination prefix\n"
662        "IP destination prefix mask\n"
663        "IP gateway address\n"
664        "IP gateway interface name\n"
665        "Emit an ICMP unreachable when matched\n"
666        "Silently discard pkts when matched\n")
667 {
668   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
669 				 argv[2], argv[3], NULL, NULL, NULL);
670 }
671 
672 DEFUN (ip_route_mask_flags_tag,
673        ip_route_mask_flags_tag_cmd,
674        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>",
675        IP_STR
676        "Establish static routes\n"
677        "IP destination prefix\n"
678        "IP destination prefix mask\n"
679        "IP gateway address\n"
680        "IP gateway interface name\n"
681        "Emit an ICMP unreachable when matched\n"
682        "Silently discard pkts when matched\n"
683        "Set tag for this route\n"
684        "Tag value\n")
685 {
686   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
687 				 argv[2], argv[3], argv[4], NULL, NULL);
688 }
689 
690 DEFUN (ip_route_mask_flags_tag_vrf,
691        ip_route_mask_flags_tag_vrf_cmd,
692        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>" VRF_CMD_STR,
693        IP_STR
694        "Establish static routes\n"
695        "IP destination prefix\n"
696        "IP destination prefix mask\n"
697        "IP gateway address\n"
698        "IP gateway interface name\n"
699        "Emit an ICMP unreachable when matched\n"
700        "Silently discard pkts when matched\n"
701        "Set tag for this route\n"
702        "Tag value\n"
703        VRF_CMD_HELP_STR)
704 {
705   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
706 				 argv[2], argv[3], argv[4], NULL, argv[5]);
707 }
708 
709 DEFUN (ip_route_mask_flags2,
710        ip_route_mask_flags2_cmd,
711        "ip route A.B.C.D A.B.C.D (reject|blackhole)",
712        IP_STR
713        "Establish static routes\n"
714        "IP destination prefix\n"
715        "IP destination prefix mask\n"
716        "Emit an ICMP unreachable when matched\n"
717        "Silently discard pkts when matched\n")
718 {
719   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
720 				 NULL, argv[2], NULL, NULL, NULL);
721 }
722 
723 DEFUN (ip_route_mask_flags2_tag,
724        ip_route_mask_flags2_tag_cmd,
725        "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295>",
726        IP_STR
727        "Establish static routes\n"
728        "IP destination prefix\n"
729        "IP destination prefix mask\n"
730        "Emit an ICMP unreachable when matched\n"
731        "Silently discard pkts when matched\n"
732        "Set tag for this route\n"
733        "Tag value\n")
734 {
735   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL,
736 				 argv[2], argv[3], NULL, NULL);
737 }
738 
739 DEFUN (ip_route_mask_flags2_tag_vrf,
740        ip_route_mask_flags2_tag_vrf_cmd,
741        "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295>" VRF_CMD_STR,
742        IP_STR
743        "Establish static routes\n"
744        "IP destination prefix\n"
745        "IP destination prefix mask\n"
746        "Emit an ICMP unreachable when matched\n"
747        "Silently discard pkts when matched\n"
748        "Set tag for this route\n"
749        "Tag value\n"
750        VRF_CMD_HELP_STR)
751 {
752   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL,
753 				 argv[2], argv[3], NULL, argv[4]);
754 }
755 
756 /* Distance option value.  */
757 DEFUN (ip_route_distance,
758        ip_route_distance_cmd,
759        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
760        IP_STR
761        "Establish static routes\n"
762        "IP destination prefix (e.g. 10.0.0.0/8)\n"
763        "IP gateway address\n"
764        "IP gateway interface name\n"
765        "Null interface\n"
766        "Distance value for this route\n")
767 {
768   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
769 				 argv[1], NULL, NULL, argv[2], NULL);
770 }
771 
772 DEFUN (ip_route_tag_distance,
773        ip_route_tag_distance_cmd,
774        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>",
775        IP_STR
776        "Establish static routes\n"
777        "IP destination prefix (e.g. 10.0.0.0/8)\n"
778        "IP gateway address\n"
779        "IP gateway interface name\n"
780        "Null interface\n"
781        "Set tag for this route\n"
782        "Tag value\n"
783        "Distance value for this route\n")
784 {
785   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
786 				 argv[1], NULL, argv[2], argv[3], NULL);
787 }
788 
789 DEFUN (ip_route_tag_distance_vrf,
790        ip_route_tag_distance_vrf_cmd,
791        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>" VRF_CMD_STR,
792        IP_STR
793        "Establish static routes\n"
794        "IP destination prefix (e.g. 10.0.0.0/8)\n"
795        "IP gateway address\n"
796        "IP gateway interface name\n"
797        "Null interface\n"
798        "Set tag for this route\n"
799        "Tag value\n"
800        "Distance value for this route\n"
801        VRF_CMD_HELP_STR)
802 {
803   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
804 				 argv[1], NULL, argv[2], argv[3], argv[4]);
805 }
806 
807 DEFUN (ip_route_flags_distance,
808        ip_route_flags_distance_cmd,
809        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
810        IP_STR
811        "Establish static routes\n"
812        "IP destination prefix (e.g. 10.0.0.0/8)\n"
813        "IP gateway address\n"
814        "IP gateway interface name\n"
815        "Emit an ICMP unreachable when matched\n"
816        "Silently discard pkts when matched\n"
817        "Distance value for this route\n")
818 {
819   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
820 				 argv[2], NULL, argv[3], NULL);
821 }
822 
823 DEFUN (ip_route_flags_tag_distance,
824        ip_route_flags_tag_distance_cmd,
825        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>",
826        IP_STR
827        "Establish static routes\n"
828        "IP destination prefix (e.g. 10.0.0.0/8)\n"
829        "IP gateway address\n"
830        "IP gateway interface name\n"
831        "Emit an ICMP unreachable when matched\n"
832        "Silently discard pkts when matched\n"
833        "Set tag for this route\n"
834        "Tag value\n"
835        "Distance value for this route\n")
836 {
837   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
838 				 argv[2], argv[3], argv[4], NULL);
839 }
840 
841 DEFUN (ip_route_flags_tag_distance_vrf,
842        ip_route_flags_tag_distance_vrf_cmd,
843        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
844        IP_STR
845        "Establish static routes\n"
846        "IP destination prefix (e.g. 10.0.0.0/8)\n"
847        "IP gateway address\n"
848        "IP gateway interface name\n"
849        "Emit an ICMP unreachable when matched\n"
850        "Silently discard pkts when matched\n"
851        "Set tag for this route\n"
852        "Tag value\n"
853        "Distance value for this route\n"
854        VRF_CMD_HELP_STR)
855 {
856   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
857 				 argv[2], argv[3], argv[4], argv[5]);
858 }
859 
860 DEFUN (ip_route_flags_distance2,
861        ip_route_flags_distance2_cmd,
862        "ip route A.B.C.D/M (reject|blackhole) <1-255>",
863        IP_STR
864        "Establish static routes\n"
865        "IP destination prefix (e.g. 10.0.0.0/8)\n"
866        "Emit an ICMP unreachable when matched\n"
867        "Silently discard pkts when matched\n"
868        "Distance value for this route\n")
869 {
870   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
871 				 NULL, argv[1], NULL, argv[2], NULL);
872 }
873 
874 DEFUN (ip_route_flags_tag_distance2,
875        ip_route_flags_tag_distance2_cmd,
876        "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255>",
877        IP_STR
878        "Establish static routes\n"
879        "IP destination prefix (e.g. 10.0.0.0/8)\n"
880        "Emit an ICMP unreachable when matched\n"
881        "Silently discard pkts when matched\n"
882        "Set tag for this route\n"
883        "Tag value\n"
884        "Distance value for this route\n")
885 {
886   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
887 				 NULL, argv[1], argv[2], argv[3], NULL);
888 }
889 
890 DEFUN (ip_route_flags_tag_distance2_vrf,
891        ip_route_flags_tag_distance2_vrf_cmd,
892        "ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
893        IP_STR
894        "Establish static routes\n"
895        "IP destination prefix (e.g. 10.0.0.0/8)\n"
896        "Emit an ICMP unreachable when matched\n"
897        "Silently discard pkts when matched\n"
898        "Set tag for this route\n"
899        "Tag value\n"
900        "Distance value for this route\n"
901        VRF_CMD_HELP_STR)
902 {
903   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
904 				 NULL, argv[1], argv[2], argv[3], argv[4]);
905 }
906 
907 DEFUN (ip_route_mask_distance,
908        ip_route_mask_distance_cmd,
909        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
910        IP_STR
911        "Establish static routes\n"
912        "IP destination prefix\n"
913        "IP destination prefix mask\n"
914        "IP gateway address\n"
915        "IP gateway interface name\n"
916        "Null interface\n"
917        "Distance value for this route\n")
918 {
919   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
920 				 NULL, NULL, argv[3], NULL);
921 }
922 
923 DEFUN (ip_route_mask_tag_distance,
924        ip_route_mask_tag_distance_cmd,
925        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>",
926        IP_STR
927        "Establish static routes\n"
928        "IP destination prefix\n"
929        "IP destination prefix mask\n"
930        "IP gateway address\n"
931        "IP gateway interface name\n"
932        "Null interface\n"
933        "Set tag for this route\n"
934        "Tag value\n"
935        "Distance value for this route\n")
936 {
937   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
938 				 argv[2], NULL, argv[3], argv[4], NULL);
939 }
940 
941 DEFUN (ip_route_mask_tag_distance_vrf,
942        ip_route_mask_tag_distance_vrf_cmd,
943        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>" VRF_CMD_STR,
944        IP_STR
945        "Establish static routes\n"
946        "IP destination prefix\n"
947        "IP destination prefix mask\n"
948        "IP gateway address\n"
949        "IP gateway interface name\n"
950        "Null interface\n"
951        "Set tag for this route\n"
952        "Tag value\n"
953        "Distance value for this route\n"
954        VRF_CMD_HELP_STR)
955 {
956   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
957 				 argv[2], NULL, argv[3], argv[4], argv[5]);
958 }
959 
960 
961 DEFUN (ip_route_mask_flags_tag_distance,
962        ip_route_mask_flags_tag_distance_cmd,
963        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)  tag <1-4294967295> <1-255>",
964        IP_STR
965        "Establish static routes\n"
966        "IP destination prefix\n"
967        "IP destination prefix mask\n"
968        "IP gateway address\n"
969        "IP gateway interface name\n"
970        "Set tag for this route\n"
971        "Tag value\n"
972        "Distance value for this route\n"
973        "Emit an ICMP unreachable when matched\n"
974        "Silently discard pkts when matched\n")
975 {
976   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
977 				 argv[3], argv[4], argv[5], NULL);
978 }
979 
980 DEFUN (ip_route_mask_flags_tag_distance_vrf,
981        ip_route_mask_flags_tag_distance_vrf_cmd,
982        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)  tag <1-4294967295> <1-255>" VRF_CMD_STR,
983        IP_STR
984        "Establish static routes\n"
985        "IP destination prefix\n"
986        "IP destination prefix mask\n"
987        "IP gateway address\n"
988        "IP gateway interface name\n"
989        "Set tag for this route\n"
990        "Tag value\n"
991        "Distance value for this route\n"
992        "Emit an ICMP unreachable when matched\n"
993        "Silently discard pkts when matched\n"
994        VRF_CMD_HELP_STR)
995 {
996   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
997 				 argv[3], argv[4], argv[5], argv[6]);
998 }
999 
1000 DEFUN (ip_route_mask_flags_distance,
1001        ip_route_mask_flags_distance_cmd,
1002        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
1003        IP_STR
1004        "Establish static routes\n"
1005        "IP destination prefix\n"
1006        "IP destination prefix mask\n"
1007        "IP gateway address\n"
1008        "IP gateway interface name\n"
1009        "Emit an ICMP unreachable when matched\n"
1010        "Silently discard pkts when matched\n"
1011        "Distance value for this route\n")
1012 {
1013   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
1014 				 argv[3], NULL, argv[4], NULL);
1015 }
1016 
1017 DEFUN (ip_route_mask_flags_distance2,
1018        ip_route_mask_flags_distance2_cmd,
1019        "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
1020        IP_STR
1021        "Establish static routes\n"
1022        "IP destination prefix\n"
1023        "IP destination prefix mask\n"
1024        "Emit an ICMP unreachable when matched\n"
1025        "Silently discard pkts when matched\n"
1026        "Distance value for this route\n")
1027 {
1028   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1029 				 NULL, argv[2], NULL, argv[3], NULL);
1030 }
1031 
1032 DEFUN (ip_route_mask_flags_tag_distance2,
1033        ip_route_mask_flags_tag_distance2_cmd,
1034        "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255>",
1035        IP_STR
1036        "Establish static routes\n"
1037        "IP destination prefix\n"
1038        "IP destination prefix mask\n"
1039        "Set tag for this route\n"
1040        "Tag value\n"
1041        "Distance value for this route\n"
1042        "Emit an ICMP unreachable when matched\n"
1043        "Silently discard pkts when matched\n")
1044 {
1045   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL,
1046 				 argv[2], argv[3], argv[4], NULL);
1047 }
1048 
1049 DEFUN (ip_route_mask_flags_tag_distance2_vrf,
1050        ip_route_mask_flags_tag_distance2_vrf_cmd,
1051        "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
1052        IP_STR
1053        "Establish static routes\n"
1054        "IP destination prefix\n"
1055        "IP destination prefix mask\n"
1056        "Set tag for this route\n"
1057        "Tag value\n"
1058        "Distance value for this route\n"
1059        "Emit an ICMP unreachable when matched\n"
1060        "Silently discard pkts when matched\n"
1061        VRF_CMD_HELP_STR)
1062 {
1063   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL,
1064 				 argv[2], argv[3], argv[4], argv[5]);
1065 }
1066 
1067 DEFUN (no_ip_route,
1068        no_ip_route_cmd,
1069        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
1070        NO_STR
1071        IP_STR
1072        "Establish static routes\n"
1073        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1074        "IP gateway address\n"
1075        "IP gateway interface name\n"
1076        "Null interface\n")
1077 {
1078   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
1079 				 argv[1], NULL, NULL, NULL, NULL);
1080 }
1081 
1082 DEFUN (no_ip_route_tag,
1083        no_ip_route_tag_cmd,
1084        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295>",
1085        NO_STR
1086        IP_STR
1087        "Establish static routes\n"
1088        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1089        "IP gateway address\n"
1090        "IP gateway interface name\n"
1091        "Null interface\n"
1092        "Tag of this route\n"
1093        "Tag value\n")
1094 {
1095   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1096 				 NULL, argv[2], NULL, NULL);
1097 }
1098 
1099 DEFUN (no_ip_route_tag_vrf,
1100        no_ip_route_tag_vrf_cmd,
1101        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295>" VRF_CMD_STR,
1102        NO_STR
1103        IP_STR
1104        "Establish static routes\n"
1105        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1106        "IP gateway address\n"
1107        "IP gateway interface name\n"
1108        "Null interface\n"
1109        "Tag of this route\n"
1110        "Tag value\n"
1111        VRF_CMD_HELP_STR)
1112 {
1113   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1114 				 NULL, argv[2], NULL, argv[3]);
1115 }
1116 
1117 ALIAS (no_ip_route,
1118        no_ip_route_flags_cmd,
1119        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
1120        NO_STR
1121        IP_STR
1122        "Establish static routes\n"
1123        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1124        "IP gateway address\n"
1125        "IP gateway interface name\n"
1126        "Emit an ICMP unreachable when matched\n"
1127        "Silently discard pkts when matched\n")
1128 
1129 ALIAS (no_ip_route_tag,
1130        no_ip_route_flags_tag_cmd,
1131        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>",
1132        NO_STR
1133        IP_STR
1134        "Establish static routes\n"
1135        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1136        "IP gateway address\n"
1137        "IP gateway interface name\n"
1138        "Emit an ICMP unreachable when matched\n"
1139        "Silently discard pkts when matched\n"
1140        "Tag of this route\n"
1141        "Tag value\n")
1142 
1143 DEFUN (no_ip_route_flags2,
1144        no_ip_route_flags2_cmd,
1145        "no ip route A.B.C.D/M (reject|blackhole)",
1146        NO_STR
1147        IP_STR
1148        "Establish static routes\n"
1149        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1150        "Emit an ICMP unreachable when matched\n"
1151        "Silently discard pkts when matched\n")
1152 {
1153   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
1154 				 NULL, NULL, NULL, NULL, NULL);
1155 }
1156 
1157 DEFUN (no_ip_route_flags2_tag,
1158        no_ip_route_flags2_tag_cmd,
1159        "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295>",
1160        NO_STR
1161        IP_STR
1162        "Establish static routes\n"
1163        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1164        "Emit an ICMP unreachable when matched\n"
1165        "Silently discard pkts when matched\n"
1166        "Tag of this route\n"
1167        "Tag value\n")
1168 {
1169   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
1170 				 NULL, argv[1], NULL, NULL);
1171 }
1172 
1173 DEFUN (no_ip_route_flags2_tag_vrf,
1174        no_ip_route_flags2_tag_vrf_cmd,
1175        "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295>" VRF_CMD_STR,
1176        NO_STR
1177        IP_STR
1178        "Establish static routes\n"
1179        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1180        "Emit an ICMP unreachable when matched\n"
1181        "Silently discard pkts when matched\n"
1182        "Tag of this route\n"
1183        "Tag value\n"
1184        VRF_CMD_HELP_STR)
1185 {
1186   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
1187 				 NULL, argv[1], NULL, argv[2]);
1188 }
1189 
1190 DEFUN (no_ip_route_mask,
1191        no_ip_route_mask_cmd,
1192        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
1193        NO_STR
1194        IP_STR
1195        "Establish static routes\n"
1196        "IP destination prefix\n"
1197        "IP destination prefix mask\n"
1198        "IP gateway address\n"
1199        "IP gateway interface name\n"
1200        "Null interface\n")
1201 {
1202   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1203 				 argv[2], NULL, NULL, NULL, NULL);
1204 }
1205 
1206 DEFUN (no_ip_route_mask_tag,
1207        no_ip_route_mask_tag_cmd,
1208        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295>",
1209        NO_STR
1210        IP_STR
1211        "Establish static routes\n"
1212        "IP destination prefix\n"
1213        "IP destination prefix mask\n"
1214        "IP gateway address\n"
1215        "IP gateway interface name\n"
1216        "Null interface\n"
1217        "Tag of this route\n"
1218        "Tag value\n")
1219 {
1220   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2],
1221 				 NULL, argv[3], NULL, NULL);
1222 }
1223 
1224 ALIAS (no_ip_route_mask,
1225        no_ip_route_mask_flags_cmd,
1226        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
1227        NO_STR
1228        IP_STR
1229        "Establish static routes\n"
1230        "IP destination prefix\n"
1231        "IP destination prefix mask\n"
1232        "IP gateway address\n"
1233        "IP gateway interface name\n"
1234        "Emit an ICMP unreachable when matched\n"
1235        "Silently discard pkts when matched\n")
1236 
1237 ALIAS (no_ip_route_mask_tag,
1238        no_ip_route_mask_flags_tag_cmd,
1239        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295>",
1240        NO_STR
1241        IP_STR
1242        "Establish static routes\n"
1243        "IP destination prefix\n"
1244        "IP destination prefix mask\n"
1245        "IP gateway address\n"
1246        "IP gateway interface name\n"
1247        "Emit an ICMP unreachable when matched\n"
1248        "Silently discard pkts when matched\n"
1249        "Tag of this route\n"
1250        "Tag value\n")
1251 
1252 DEFUN (no_ip_route_mask_flags2,
1253        no_ip_route_mask_flags2_cmd,
1254        "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
1255        NO_STR
1256        IP_STR
1257        "Establish static routes\n"
1258        "IP destination prefix\n"
1259        "IP destination prefix mask\n"
1260        "Emit an ICMP unreachable when matched\n"
1261        "Silently discard pkts when matched\n")
1262 {
1263   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1264 				 NULL, NULL, NULL, NULL, NULL);
1265 }
1266 
1267 DEFUN (no_ip_route_mask_flags2_tag,
1268        no_ip_route_mask_flags2_tag_cmd,
1269        "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295>",
1270        NO_STR
1271        IP_STR
1272        "Establish static routes\n"
1273        "IP destination prefix\n"
1274        "IP destination prefix mask\n"
1275        "Emit an ICMP unreachable when matched\n"
1276        "Silently discard pkts when matched\n"
1277        "Tag of this route\n"
1278        "Tag value\n")
1279 {
1280   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1281 				 NULL, NULL, argv[2], NULL, NULL);
1282 }
1283 
1284 DEFUN (no_ip_route_mask_flags2_tag_vrf,
1285        no_ip_route_mask_flags2_tag_vrf_cmd,
1286        "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295>" VRF_CMD_STR,
1287        NO_STR
1288        IP_STR
1289        "Establish static routes\n"
1290        "IP destination prefix\n"
1291        "IP destination prefix mask\n"
1292        "Emit an ICMP unreachable when matched\n"
1293        "Silently discard pkts when matched\n"
1294        "Tag of this route\n"
1295        "Tag value\n"
1296        VRF_CMD_HELP_STR)
1297 {
1298   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1299 				 NULL, NULL, argv[2], NULL, argv[3]);
1300 }
1301 
1302 DEFUN (no_ip_route_distance,
1303        no_ip_route_distance_cmd,
1304        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
1305        NO_STR
1306        IP_STR
1307        "Establish static routes\n"
1308        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1309        "IP gateway address\n"
1310        "IP gateway interface name\n"
1311        "Null interface\n"
1312        "Distance value for this route\n")
1313 {
1314   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
1315 				 argv[1], NULL, NULL, argv[2], NULL);
1316 }
1317 
1318 DEFUN (no_ip_route_tag_distance,
1319        no_ip_route_tag_distance_cmd,
1320        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>",
1321        NO_STR
1322        IP_STR
1323        "Establish static routes\n"
1324        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1325        "IP gateway address\n"
1326        "IP gateway interface name\n"
1327        "Null interface\n"
1328        "Tag of this route\n"
1329        "Tag value\n"
1330        "Distance value for this route\n")
1331 {
1332   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1333 				 NULL, argv[2], argv[3], NULL);
1334 }
1335 
1336 DEFUN (no_ip_route_tag_distance_vrf,
1337        no_ip_route_tag_distance_vrf_cmd,
1338        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>" VRF_CMD_STR,
1339        NO_STR
1340        IP_STR
1341        "Establish static routes\n"
1342        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1343        "IP gateway address\n"
1344        "IP gateway interface name\n"
1345        "Null interface\n"
1346        "Tag of this route\n"
1347        "Tag value\n"
1348        "Distance value for this route\n"
1349        VRF_CMD_HELP_STR)
1350 {
1351   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1352 				 NULL, argv[2], argv[3], argv[4]);
1353 }
1354 
1355 DEFUN (no_ip_route_flags_distance,
1356        no_ip_route_flags_distance_cmd,
1357        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
1358        NO_STR
1359        IP_STR
1360        "Establish static routes\n"
1361        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1362        "IP gateway address\n"
1363        "IP gateway interface name\n"
1364        "Emit an ICMP unreachable when matched\n"
1365        "Silently discard pkts when matched\n"
1366        "Distance value for this route\n")
1367 {
1368   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
1369 				 argv[1], argv[2], NULL, argv[3], NULL);
1370 }
1371 
1372 DEFUN (no_ip_route_flags_tag_distance,
1373        no_ip_route_flags_tag_distance_cmd,
1374        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>",
1375        NO_STR
1376        IP_STR
1377        "Establish static routes\n"
1378        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1379        "IP gateway address\n"
1380        "IP gateway interface name\n"
1381        "Emit an ICMP unreachable when matched\n"
1382        "Silently discard pkts when matched\n"
1383        "Tag of this route\n"
1384        "Tag value\n"
1385        "Distance value for this route\n")
1386 {
1387   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1388 				 argv[2], argv[3], argv[4], NULL);
1389 }
1390 
1391 DEFUN (no_ip_route_flags_tag_distance_vrf,
1392        no_ip_route_flags_tag_distance_vrf_cmd,
1393        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
1394        NO_STR
1395        IP_STR
1396        "Establish static routes\n"
1397        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1398        "IP gateway address\n"
1399        "IP gateway interface name\n"
1400        "Emit an ICMP unreachable when matched\n"
1401        "Silently discard pkts when matched\n"
1402        "Tag of this route\n"
1403        "Tag value\n"
1404        "Distance value for this route\n"
1405        VRF_CMD_HELP_STR)
1406 {
1407   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1408 				 argv[2], argv[3], argv[4], argv[5]);
1409 }
1410 
1411 DEFUN (no_ip_route_flags_distance2,
1412        no_ip_route_flags_distance2_cmd,
1413        "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
1414        NO_STR
1415        IP_STR
1416        "Establish static routes\n"
1417        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1418        "Emit an ICMP unreachable when matched\n"
1419        "Silently discard pkts when matched\n"
1420        "Distance value for this route\n")
1421 {
1422   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
1423 				 argv[1], NULL, argv[2], NULL);
1424 }
1425 
1426 DEFUN (no_ip_route_flags_tag_distance2,
1427        no_ip_route_flags_tag_distance2_cmd,
1428        "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255>",
1429        NO_STR
1430        IP_STR
1431        "Establish static routes\n"
1432        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1433        "Emit an ICMP unreachable when matched\n"
1434        "Silently discard pkts when matched\n"
1435        "Tag of this route\n"
1436        "Tag value\n"
1437        "Distance value for this route\n")
1438 {
1439   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
1440 				 argv[1], argv[2] , argv[3], NULL);
1441 }
1442 
1443 DEFUN (no_ip_route_flags_tag_distance2_vrf,
1444        no_ip_route_flags_tag_distance2_vrf_cmd,
1445        "no ip route A.B.C.D/M (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
1446        NO_STR
1447        IP_STR
1448        "Establish static routes\n"
1449        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1450        "Emit an ICMP unreachable when matched\n"
1451        "Silently discard pkts when matched\n"
1452        "Tag of this route\n"
1453        "Tag value\n"
1454        "Distance value for this route\n"
1455        VRF_CMD_HELP_STR)
1456 {
1457   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
1458 				 argv[1], argv[2] , argv[3], argv[4]);
1459 }
1460 
1461 DEFUN (no_ip_route_mask_distance,
1462        no_ip_route_mask_distance_cmd,
1463        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
1464        NO_STR
1465        IP_STR
1466        "Establish static routes\n"
1467        "IP destination prefix\n"
1468        "IP destination prefix mask\n"
1469        "IP gateway address\n"
1470        "IP gateway interface name\n"
1471        "Null interface\n"
1472        "Distance value for this route\n")
1473 {
1474   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1475 				 argv[2], NULL, NULL, argv[3], NULL);
1476 }
1477 
1478 DEFUN (no_ip_route_mask_tag_distance,
1479        no_ip_route_mask_tag_distance_cmd,
1480        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>",
1481        NO_STR
1482        IP_STR
1483        "Establish static routes\n"
1484        "IP destination prefix\n"
1485        "IP destination prefix mask\n"
1486        "IP gateway address\n"
1487        "IP gateway interface name\n"
1488        "Null interface\n"
1489        "Tag of this route\n"
1490        "Tag value\n"
1491        "Distance value for this route\n")
1492 {
1493   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1494 				 argv[2], NULL, argv[3], argv[4], NULL);
1495 }
1496 
1497 DEFUN (no_ip_route_mask_tag_distance_vrf,
1498        no_ip_route_mask_tag_distance_vrf_cmd,
1499        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255>" VRF_CMD_STR,
1500        NO_STR
1501        IP_STR
1502        "Establish static routes\n"
1503        "IP destination prefix\n"
1504        "IP destination prefix mask\n"
1505        "IP gateway address\n"
1506        "IP gateway interface name\n"
1507        "Null interface\n"
1508        "Tag of this route\n"
1509        "Tag value\n"
1510        "Distance value for this route\n"
1511        VRF_CMD_HELP_STR)
1512 {
1513   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1514 				 argv[2], NULL, argv[3], argv[4], argv[5]);
1515 }
1516 
1517 DEFUN (no_ip_route_mask_flags_distance,
1518        no_ip_route_mask_flags_distance_cmd,
1519        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
1520        NO_STR
1521        IP_STR
1522        "Establish static routes\n"
1523        "IP destination prefix\n"
1524        "IP destination prefix mask\n"
1525        "IP gateway address\n"
1526        "IP gateway interface name\n"
1527        "Emit an ICMP unreachable when matched\n"
1528        "Silently discard pkts when matched\n"
1529        "Distance value for this route\n")
1530 {
1531   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1532 				 argv[2], argv[3], NULL, argv[4], NULL);
1533 }
1534 
1535 DEFUN (no_ip_route_mask_flags_tag_distance,
1536        no_ip_route_mask_flags_tag_distance_cmd,
1537        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>",
1538        NO_STR
1539        IP_STR
1540        "Establish static routes\n"
1541        "IP destination prefix\n"
1542        "IP destination prefix mask\n"
1543        "IP gateway address\n"
1544        "IP gateway interface name\n"
1545        "Emit an ICMP unreachable when matched\n"
1546        "Silently discard pkts when matched\n"
1547        "Tag of this route\n"
1548        "Tag value\n"
1549        "Distance value for this route\n")
1550 {
1551   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3],
1552 				 argv[4], argv[5], NULL);
1553 }
1554 
1555 DEFUN (no_ip_route_mask_flags_tag_distance_vrf,
1556        no_ip_route_mask_flags_tag_distance_vrf_cmd,
1557        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
1558        NO_STR
1559        IP_STR
1560        "Establish static routes\n"
1561        "IP destination prefix\n"
1562        "IP destination prefix mask\n"
1563        "IP gateway address\n"
1564        "IP gateway interface name\n"
1565        "Emit an ICMP unreachable when matched\n"
1566        "Silently discard pkts when matched\n"
1567        "Tag of this route\n"
1568        "Tag value\n"
1569        "Distance value for this route\n"
1570        VRF_CMD_HELP_STR)
1571 {
1572   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3],
1573 				 argv[4], argv[5], argv[6]);
1574 }
1575 
1576 DEFUN (no_ip_route_mask_flags_distance2,
1577        no_ip_route_mask_flags_distance2_cmd,
1578        "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
1579        NO_STR
1580        IP_STR
1581        "Establish static routes\n"
1582        "IP destination prefix\n"
1583        "IP destination prefix mask\n"
1584        "Emit an ICMP unreachable when matched\n"
1585        "Silently discard pkts when matched\n"
1586        "Distance value for this route\n")
1587 {
1588   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1589 				 NULL, argv[2], NULL, argv[3], NULL);
1590 }
1591 
1592 DEFUN (ip_route_vrf,
1593        ip_route_vrf_cmd,
1594        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1595        IP_STR
1596        "Establish static routes\n"
1597        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1598        "IP gateway address\n"
1599        "IP gateway interface name\n"
1600        "Null interface\n"
1601        VRF_CMD_HELP_STR)
1602 {
1603   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
1604 				 argv[1], NULL, NULL, NULL, argv[2]);
1605 }
1606 
1607 DEFUN (ip_route_flags_vrf,
1608        ip_route_flags_vrf_cmd,
1609        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1610        IP_STR
1611        "Establish static routes\n"
1612        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1613        "IP gateway address\n"
1614        "IP gateway interface name\n"
1615        "Emit an ICMP unreachable when matched\n"
1616        "Silently discard pkts when matched\n"
1617        VRF_CMD_HELP_STR)
1618 {
1619   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
1620 				 argv[1], argv[2], NULL, NULL, argv[3]);
1621 }
1622 
1623 DEFUN (ip_route_flags2_vrf,
1624        ip_route_flags2_vrf_cmd,
1625        "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1626        IP_STR
1627        "Establish static routes\n"
1628        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1629        "Emit an ICMP unreachable when matched\n"
1630        "Silently discard pkts when matched\n"
1631        VRF_CMD_HELP_STR)
1632 {
1633   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
1634 				 NULL, argv[1], NULL, NULL, argv[2]);
1635 }
1636 
1637 /* Mask as A.B.C.D format.  */
1638 DEFUN (ip_route_mask_vrf,
1639        ip_route_mask_vrf_cmd,
1640        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1641        IP_STR
1642        "Establish static routes\n"
1643        "IP destination prefix\n"
1644        "IP destination prefix mask\n"
1645        "IP gateway address\n"
1646        "IP gateway interface name\n"
1647        "Null interface\n"
1648        VRF_CMD_HELP_STR)
1649 {
1650   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1651 				 argv[2], NULL, NULL, NULL, argv[3]);
1652 }
1653 
1654 DEFUN (ip_route_mask_flags_vrf,
1655        ip_route_mask_flags_vrf_cmd,
1656        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1657        IP_STR
1658        "Establish static routes\n"
1659        "IP destination prefix\n"
1660        "IP destination prefix mask\n"
1661        "IP gateway address\n"
1662        "IP gateway interface name\n"
1663        "Emit an ICMP unreachable when matched\n"
1664        "Silently discard pkts when matched\n"
1665        VRF_CMD_HELP_STR)
1666 {
1667   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1668 				 argv[2], argv[3], NULL, NULL, argv[4]);
1669 }
1670 
1671 DEFUN (ip_route_mask_flags2_vrf,
1672        ip_route_mask_flags2_vrf_cmd,
1673        "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1674        IP_STR
1675        "Establish static routes\n"
1676        "IP destination prefix\n"
1677        "IP destination prefix mask\n"
1678        "Emit an ICMP unreachable when matched\n"
1679        "Silently discard pkts when matched\n"
1680        VRF_CMD_HELP_STR)
1681 {
1682   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1683 				 NULL, argv[2], NULL, NULL, argv[3]);
1684 }
1685 
1686 /* Distance option value.  */
1687 DEFUN (ip_route_distance_vrf,
1688        ip_route_distance_vrf_cmd,
1689        "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1690        IP_STR
1691        "Establish static routes\n"
1692        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1693        "IP gateway address\n"
1694        "IP gateway interface name\n"
1695        "Null interface\n"
1696        "Distance value for this route\n"
1697        VRF_CMD_HELP_STR)
1698 {
1699   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
1700 				 argv[1], NULL, NULL, argv[2], argv[3]);
1701 }
1702 
1703 DEFUN (ip_route_flags_distance_vrf,
1704        ip_route_flags_distance_vrf_cmd,
1705        "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1706        IP_STR
1707        "Establish static routes\n"
1708        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1709        "IP gateway address\n"
1710        "IP gateway interface name\n"
1711        "Emit an ICMP unreachable when matched\n"
1712        "Silently discard pkts when matched\n"
1713        "Distance value for this route\n"
1714        VRF_CMD_HELP_STR)
1715 {
1716   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
1717 				 argv[1], argv[2], NULL, argv[3], argv[4]);
1718 }
1719 
1720 DEFUN (ip_route_flags_distance2_vrf,
1721        ip_route_flags_distance2_vrf_cmd,
1722        "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1723        IP_STR
1724        "Establish static routes\n"
1725        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1726        "Emit an ICMP unreachable when matched\n"
1727        "Silently discard pkts when matched\n"
1728        "Distance value for this route\n"
1729        VRF_CMD_HELP_STR)
1730 {
1731   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
1732 				 NULL, argv[1], NULL, argv[2], argv[3]);
1733 }
1734 
1735 DEFUN (ip_route_mask_distance_vrf,
1736        ip_route_mask_distance_vrf_cmd,
1737        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1738        IP_STR
1739        "Establish static routes\n"
1740        "IP destination prefix\n"
1741        "IP destination prefix mask\n"
1742        "IP gateway address\n"
1743        "IP gateway interface name\n"
1744        "Null interface\n"
1745        "Distance value for this route\n"
1746        VRF_CMD_HELP_STR)
1747 {
1748   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1749 				 argv[2], NULL, NULL, argv[3], argv[4]);
1750 }
1751 
1752 DEFUN (ip_route_mask_flags_distance_vrf,
1753        ip_route_mask_flags_distance_vrf_cmd,
1754        "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1755        IP_STR
1756        "Establish static routes\n"
1757        "IP destination prefix\n"
1758        "IP destination prefix mask\n"
1759        "IP gateway address\n"
1760        "IP gateway interface name\n"
1761        "Emit an ICMP unreachable when matched\n"
1762        "Silently discard pkts when matched\n"
1763        "Distance value for this route\n"
1764        VRF_CMD_HELP_STR)
1765 {
1766   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1767 				 argv[2], argv[3], NULL, argv[4], argv[5]);
1768 }
1769 
1770 DEFUN (ip_route_mask_flags_distance2_vrf,
1771        ip_route_mask_flags_distance2_vrf_cmd,
1772        "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1773        IP_STR
1774        "Establish static routes\n"
1775        "IP destination prefix\n"
1776        "IP destination prefix mask\n"
1777        "Emit an ICMP unreachable when matched\n"
1778        "Silently discard pkts when matched\n"
1779        "Distance value for this route\n"
1780        VRF_CMD_HELP_STR)
1781 {
1782   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1783 				 NULL, argv[2], NULL, argv[3], argv[4]);
1784 }
1785 
1786 DEFUN (no_ip_route_vrf,
1787        no_ip_route_vrf_cmd,
1788        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1789        NO_STR
1790        IP_STR
1791        "Establish static routes\n"
1792        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1793        "IP gateway address\n"
1794        "IP gateway interface name\n"
1795        "Null interface\n"
1796        VRF_CMD_HELP_STR)
1797 {
1798   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0],
1799 				 NULL, argv[1], NULL, NULL, NULL,
1800 				 (argc > 3) ? argv[3] : argv[2]);
1801 }
1802 
1803 ALIAS (no_ip_route_vrf,
1804        no_ip_route_flags_vrf_cmd,
1805        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1806        NO_STR
1807        IP_STR
1808        "Establish static routes\n"
1809        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1810        "IP gateway address\n"
1811        "IP gateway interface name\n"
1812        "Emit an ICMP unreachable when matched\n"
1813        "Silently discard pkts when matched\n"
1814        VRF_CMD_HELP_STR)
1815 
1816 DEFUN (no_ip_route_flags2_vrf,
1817        no_ip_route_flags2_vrf_cmd,
1818        "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1819        NO_STR
1820        IP_STR
1821        "Establish static routes\n"
1822        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1823        "Emit an ICMP unreachable when matched\n"
1824        "Silently discard pkts when matched\n"
1825        VRF_CMD_HELP_STR)
1826 {
1827   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0],
1828 				 NULL, NULL, NULL, NULL, NULL, argv[2]);
1829 }
1830 
1831 DEFUN (no_ip_route_mask_vrf,
1832        no_ip_route_mask_vrf_cmd,
1833        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1834        NO_STR
1835        IP_STR
1836        "Establish static routes\n"
1837        "IP destination prefix\n"
1838        "IP destination prefix mask\n"
1839        "IP gateway address\n"
1840        "IP gateway interface name\n"
1841        "Null interface\n"
1842        VRF_CMD_HELP_STR)
1843 {
1844   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1845 				 argv[2], NULL, NULL, NULL,
1846 				 (argc > 4) ? argv[4] : argv[3]);
1847 }
1848 
1849 ALIAS (no_ip_route_mask_vrf,
1850        no_ip_route_mask_flags_vrf_cmd,
1851        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1852        NO_STR
1853        IP_STR
1854        "Establish static routes\n"
1855        "IP destination prefix\n"
1856        "IP destination prefix mask\n"
1857        "IP gateway address\n"
1858        "IP gateway interface name\n"
1859        "Emit an ICMP unreachable when matched\n"
1860        "Silently discard pkts when matched\n"
1861        VRF_CMD_HELP_STR)
1862 
1863 DEFUN (no_ip_route_mask_flags2_vrf,
1864        no_ip_route_mask_flags2_vrf_cmd,
1865        "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1866        NO_STR
1867        IP_STR
1868        "Establish static routes\n"
1869        "IP destination prefix\n"
1870        "IP destination prefix mask\n"
1871        "Emit an ICMP unreachable when matched\n"
1872        "Silently discard pkts when matched\n"
1873        VRF_CMD_HELP_STR)
1874 {
1875   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1876 				 NULL, NULL, NULL, NULL, argv[2]);
1877 }
1878 
1879 DEFUN (no_ip_route_distance_vrf,
1880        no_ip_route_distance_vrf_cmd,
1881        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1882        NO_STR
1883        IP_STR
1884        "Establish static routes\n"
1885        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1886        "IP gateway address\n"
1887        "IP gateway interface name\n"
1888        "Null interface\n"
1889        "Distance value for this route\n"
1890        VRF_CMD_HELP_STR)
1891 {
1892   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
1893 				 argv[1], NULL, NULL, argv[2], argv[3]);
1894 }
1895 
1896 DEFUN (no_ip_route_flags_distance_vrf,
1897        no_ip_route_flags_distance_vrf_cmd,
1898        "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1899        NO_STR
1900        IP_STR
1901        "Establish static routes\n"
1902        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1903        "IP gateway address\n"
1904        "IP gateway interface name\n"
1905        "Emit an ICMP unreachable when matched\n"
1906        "Silently discard pkts when matched\n"
1907        "Distance value for this route\n"
1908        VRF_CMD_HELP_STR)
1909 {
1910   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1911 				 argv[2], NULL, argv[3], argv[4]);
1912 }
1913 
1914 DEFUN (no_ip_route_flags_distance2_vrf,
1915        no_ip_route_flags_distance2_vrf_cmd,
1916        "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1917        NO_STR
1918        IP_STR
1919        "Establish static routes\n"
1920        "IP destination prefix (e.g. 10.0.0.0/8)\n"
1921        "Emit an ICMP unreachable when matched\n"
1922        "Silently discard pkts when matched\n"
1923        "Distance value for this route\n"
1924        VRF_CMD_HELP_STR)
1925 {
1926   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
1927 				 argv[1], NULL, argv[2], argv[3]);
1928 }
1929 
1930 DEFUN (no_ip_route_mask_distance_vrf,
1931        no_ip_route_mask_distance_vrf_cmd,
1932        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1933        NO_STR
1934        IP_STR
1935        "Establish static routes\n"
1936        "IP destination prefix\n"
1937        "IP destination prefix mask\n"
1938        "IP gateway address\n"
1939        "IP gateway interface name\n"
1940        "Null interface\n"
1941        "Distance value for this route\n"
1942        VRF_CMD_HELP_STR)
1943 {
1944   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1945 				 argv[2], NULL, NULL, argv[3], argv[4]);
1946 }
1947 
1948 DEFUN (no_ip_route_mask_flags_distance_vrf,
1949        no_ip_route_mask_flags_distance_vrf_cmd,
1950        "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1951        NO_STR
1952        IP_STR
1953        "Establish static routes\n"
1954        "IP destination prefix\n"
1955        "IP destination prefix mask\n"
1956        "IP gateway address\n"
1957        "IP gateway interface name\n"
1958        "Emit an ICMP unreachable when matched\n"
1959        "Silently discard pkts when matched\n"
1960        "Distance value for this route\n"
1961        VRF_CMD_HELP_STR)
1962 {
1963   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2],
1964 				 argv[3], NULL, argv[4], argv[5]);
1965 }
1966 
1967 DEFUN (no_ip_route_mask_flags_distance2_vrf,
1968        no_ip_route_mask_flags_distance2_vrf_cmd,
1969        "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1970        NO_STR
1971        IP_STR
1972        "Establish static routes\n"
1973        "IP destination prefix\n"
1974        "IP destination prefix mask\n"
1975        "Emit an ICMP unreachable when matched\n"
1976        "Silently discard pkts when matched\n"
1977        "Distance value for this route\n"
1978        VRF_CMD_HELP_STR)
1979 {
1980   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL,
1981                                  argv[2], NULL, argv[3], argv[4]);
1982 }
1983 
1984 DEFUN (no_ip_route_mask_flags_tag_distance2,
1985        no_ip_route_mask_flags_tag_distance2_cmd,
1986        "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255>",
1987        NO_STR
1988        IP_STR
1989        "Establish static routes\n"
1990        "IP destination prefix\n"
1991        "IP destination prefix mask\n"
1992        "Emit an ICMP unreachable when matched\n"
1993        "Silently discard pkts when matched\n"
1994        "Tag of this route\n"
1995        "Tag value\n"
1996        "Distance value for this route\n")
1997 {
1998   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL,
1999 				 argv[2], argv[3], argv[4], NULL);
2000 }
2001 
2002 DEFUN (no_ip_route_mask_flags_tag_distance2_vrf,
2003        no_ip_route_mask_flags_tag_distance2_vrf_cmd,
2004        "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
2005        NO_STR
2006        IP_STR
2007        "Establish static routes\n"
2008        "IP destination prefix\n"
2009        "IP destination prefix mask\n"
2010        "Emit an ICMP unreachable when matched\n"
2011        "Silently discard pkts when matched\n"
2012        "Tag of this route\n"
2013        "Tag value\n"
2014        "Distance value for this route\n"
2015        VRF_CMD_HELP_STR)
2016 {
2017   return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL,
2018 				 argv[2], argv[3], argv[4], argv[5]);
2019 }
2020 
2021 char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1];	/* "any" == ZEBRA_ROUTE_MAX */
2022 
2023 DEFUN (ip_protocol,
2024        ip_protocol_cmd,
2025        "ip protocol PROTO route-map ROUTE-MAP",
2026        NO_STR
2027        "Apply route map to PROTO\n"
2028        "Protocol name\n"
2029        "Route map name\n")
2030 {
2031   int i;
2032 
2033   if (strcasecmp(argv[0], "any") == 0)
2034     i = ZEBRA_ROUTE_MAX;
2035   else
2036     i = proto_name2num(argv[0]);
2037   if (i < 0)
2038     {
2039       vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
2040                VTY_NEWLINE);
2041       return CMD_WARNING;
2042     }
2043   if (proto_rm[AFI_IP][i])
2044     XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
2045   proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
2046   return CMD_SUCCESS;
2047 }
2048 
2049 DEFUN (no_ip_protocol,
2050        no_ip_protocol_cmd,
2051        "no ip protocol PROTO",
2052        NO_STR
2053        "Remove route map from PROTO\n"
2054        "Protocol name\n")
2055 {
2056   int i;
2057 
2058   if (strcasecmp(argv[0], "any") == 0)
2059     i = ZEBRA_ROUTE_MAX;
2060   else
2061     i = proto_name2num(argv[0]);
2062   if (i < 0)
2063     {
2064       vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
2065                VTY_NEWLINE);
2066      return CMD_WARNING;
2067     }
2068   if (proto_rm[AFI_IP][i])
2069     XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
2070   proto_rm[AFI_IP][i] = NULL;
2071   return CMD_SUCCESS;
2072 }
2073 
2074 /* New RIB.  Detailed information for IPv4 route. */
2075 static void
vty_show_ip_route_detail(struct vty * vty,struct route_node * rn,int mcast)2076 vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
2077 {
2078   struct rib *rib;
2079   struct nexthop *nexthop, *tnexthop;
2080   int recursing;
2081   char buf[PREFIX_STRLEN];
2082 
2083   RNODE_FOREACH_RIB (rn, rib)
2084     {
2085       const char *mcast_info = "";
2086       if (mcast)
2087         {
2088           rib_table_info_t *info = rn->table->info;
2089           mcast_info = (info->safi == SAFI_MULTICAST)
2090                        ? " using Multicast RIB"
2091                        : " using Unicast RIB";
2092         }
2093       vty_out (vty, "Routing entry for %s%s%s",
2094                prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
2095               VTY_NEWLINE);
2096       vty_out (vty, "  Known via \"%s\"", zebra_route_string (rib->type));
2097       vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
2098       if (rib->mtu)
2099         vty_out (vty, ", mtu %u", rib->mtu);
2100       vty_out (vty, ", tag %d", rib->tag);
2101       vty_out (vty, ", vrf %u", rib->vrf_id);
2102       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
2103         vty_out (vty, ", best");
2104       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_FIB_OVERRIDE))
2105         vty_out (vty, ", fib-override");
2106       if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
2107         vty_out (vty, ", fib");
2108       if (rib->refcnt)
2109         vty_out (vty, ", refcnt %ld", rib->refcnt);
2110       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
2111        vty_out (vty, ", blackhole");
2112       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
2113        vty_out (vty, ", reject");
2114       vty_out (vty, "%s", VTY_NEWLINE);
2115 
2116 #define ONE_DAY_SECOND 60*60*24
2117 #define ONE_WEEK_SECOND 60*60*24*7
2118       if (rib->type == ZEBRA_ROUTE_RIP
2119           || rib->type == ZEBRA_ROUTE_RIPNG
2120           || rib->type == ZEBRA_ROUTE_OSPF
2121           || rib->type == ZEBRA_ROUTE_OSPF6
2122           || rib->type == ZEBRA_ROUTE_BABEL
2123           || rib->type == ZEBRA_ROUTE_ISIS
2124           || rib->type == ZEBRA_ROUTE_NHRP
2125           || rib->type == ZEBRA_ROUTE_BGP)
2126 	{
2127 	  time_t uptime;
2128 	  struct tm *tm;
2129 
2130 	  uptime = time (NULL);
2131 	  uptime -= rib->uptime;
2132 	  tm = gmtime (&uptime);
2133 
2134 	  vty_out (vty, "  Last update ");
2135 
2136 	  if (uptime < ONE_DAY_SECOND)
2137 	    vty_out (vty,  "%02d:%02d:%02d",
2138 		     tm->tm_hour, tm->tm_min, tm->tm_sec);
2139 	  else if (uptime < ONE_WEEK_SECOND)
2140 	    vty_out (vty, "%dd%02dh%02dm",
2141 		     tm->tm_yday, tm->tm_hour, tm->tm_min);
2142 	  else
2143 	    vty_out (vty, "%02dw%dd%02dh",
2144 		     tm->tm_yday/7,
2145 		     tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
2146 	  vty_out (vty, " ago%s", VTY_NEWLINE);
2147 	}
2148 
2149       for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
2150         {
2151           vty_out (vty, "  %c%c%s",
2152                    CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE) ? '>' : ' ',
2153                    CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
2154                    recursing ? "  " : "");
2155 
2156           switch (nexthop->type)
2157             {
2158             case NEXTHOP_TYPE_IPV4:
2159             case NEXTHOP_TYPE_IPV4_IFINDEX:
2160               vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
2161               if (nexthop->ifindex)
2162                 vty_out (vty, ", via %s",
2163                          ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2164               break;
2165             case NEXTHOP_TYPE_IPV6:
2166             case NEXTHOP_TYPE_IPV6_IFINDEX:
2167             case NEXTHOP_TYPE_IPV6_IFNAME:
2168               vty_out (vty, " %s",
2169                        inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
2170               if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
2171                 vty_out (vty, ", %s", nexthop->ifname);
2172               else if (nexthop->ifindex)
2173                 vty_out (vty, ", via %s",
2174                          ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2175               break;
2176             case NEXTHOP_TYPE_IFINDEX:
2177               vty_out (vty, " directly connected, %s",
2178                        ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2179               break;
2180             case NEXTHOP_TYPE_IFNAME:
2181               vty_out (vty, " directly connected, %s", nexthop->ifname);
2182               break;
2183             case NEXTHOP_TYPE_BLACKHOLE:
2184               vty_out (vty, " directly connected, Null0");
2185               break;
2186             default:
2187               break;
2188             }
2189           if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
2190             vty_out (vty, " inactive");
2191 
2192           if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
2193             vty_out (vty, " onlink");
2194 
2195           if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
2196             vty_out (vty, " (recursive)");
2197 
2198           switch (nexthop->type)
2199             {
2200             case NEXTHOP_TYPE_IPV4:
2201             case NEXTHOP_TYPE_IPV4_IFINDEX:
2202             case NEXTHOP_TYPE_IPV4_IFNAME:
2203               if (nexthop->src.ipv4.s_addr)
2204                 {
2205                   if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
2206                     vty_out (vty, ", src %s", buf);
2207                 }
2208               break;
2209 #ifdef HAVE_IPV6
2210             case NEXTHOP_TYPE_IPV6:
2211             case NEXTHOP_TYPE_IPV6_IFINDEX:
2212             case NEXTHOP_TYPE_IPV6_IFNAME:
2213               if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
2214                 {
2215                   if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
2216                     vty_out (vty, ", src %s", buf);
2217                 }
2218               break;
2219 #endif /* HAVE_IPV6 */
2220             default:
2221                break;
2222             }
2223           vty_out (vty, "%s", VTY_NEWLINE);
2224         }
2225       vty_out (vty, "%s", VTY_NEWLINE);
2226     }
2227 }
2228 
2229 static void
vty_show_ip_route(struct vty * vty,struct route_node * rn,struct rib * rib)2230 vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
2231 {
2232   struct nexthop *nexthop, *tnexthop;
2233   int recursing;
2234   int len = 0;
2235   char buf[BUFSIZ];
2236 
2237   /* Nexthop information. */
2238   for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
2239     {
2240       if (nexthop == rib->nexthop)
2241 	{
2242 	  /* Prefix information. */
2243 	  len = vty_out (vty, "%c%c%c %s",
2244 			 zebra_route_char (rib->type),
2245 			 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
2246 			 ? '>' : ' ',
2247 			 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
2248 			 ? '*' : ' ',
2249 			 prefix2str (&rn->p, buf, sizeof buf));
2250 
2251 	  /* Distance and metric display. */
2252 	  if (rib->type != ZEBRA_ROUTE_CONNECT
2253 	      && rib->type != ZEBRA_ROUTE_KERNEL)
2254 	    len += vty_out (vty, " [%d/%d]", rib->distance,
2255 			    rib->metric);
2256 
2257           if (rib->vrf_id != VRF_DEFAULT)
2258             len += vty_out (vty, " [vrf %u]", rib->vrf_id);
2259 	}
2260       else
2261 	vty_out (vty, "  %c%*c",
2262 		 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
2263 		 ? '*' : ' ',
2264 		 len - 3 + (2 * recursing), ' ');
2265 
2266       switch (nexthop->type)
2267         {
2268         case NEXTHOP_TYPE_IPV4:
2269         case NEXTHOP_TYPE_IPV4_IFINDEX:
2270           vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
2271           if (nexthop->ifindex)
2272             vty_out (vty, ", %s",
2273                      ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2274           break;
2275         case NEXTHOP_TYPE_IPV6:
2276         case NEXTHOP_TYPE_IPV6_IFINDEX:
2277         case NEXTHOP_TYPE_IPV6_IFNAME:
2278           vty_out (vty, " via %s",
2279                    inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
2280           if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
2281             vty_out (vty, ", %s", nexthop->ifname);
2282           else if (nexthop->ifindex)
2283             vty_out (vty, ", %s",
2284                      ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2285           break;
2286         case NEXTHOP_TYPE_IFINDEX:
2287           vty_out (vty, " is directly connected, %s",
2288                    ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2289           break;
2290         case NEXTHOP_TYPE_IFNAME:
2291           vty_out (vty, " is directly connected, %s", nexthop->ifname);
2292           break;
2293         case NEXTHOP_TYPE_BLACKHOLE:
2294           vty_out (vty, " is directly connected, Null0");
2295           break;
2296         default:
2297           break;
2298         }
2299       if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
2300         vty_out (vty, " inactive");
2301 
2302       if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
2303         vty_out (vty, " onlink");
2304 
2305       if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
2306         vty_out (vty, " (recursive)");
2307 
2308       switch (nexthop->type)
2309         {
2310           case NEXTHOP_TYPE_IPV4:
2311           case NEXTHOP_TYPE_IPV4_IFINDEX:
2312           case NEXTHOP_TYPE_IPV4_IFNAME:
2313             if (nexthop->src.ipv4.s_addr)
2314               {
2315                 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
2316                   vty_out (vty, ", src %s", buf);
2317               }
2318             break;
2319 #ifdef HAVE_IPV6
2320           case NEXTHOP_TYPE_IPV6:
2321           case NEXTHOP_TYPE_IPV6_IFINDEX:
2322           case NEXTHOP_TYPE_IPV6_IFNAME:
2323             if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
2324               {
2325                 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
2326                   vty_out (vty, ", src %s", buf);
2327               }
2328             break;
2329 #endif /* HAVE_IPV6 */
2330           default:
2331             break;
2332         }
2333 
2334       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
2335                vty_out (vty, ", bh");
2336       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
2337                vty_out (vty, ", rej");
2338 
2339       if (rib->type == ZEBRA_ROUTE_RIP
2340           || rib->type == ZEBRA_ROUTE_RIPNG
2341           || rib->type == ZEBRA_ROUTE_OSPF
2342           || rib->type == ZEBRA_ROUTE_OSPF6
2343           || rib->type == ZEBRA_ROUTE_BABEL
2344           || rib->type == ZEBRA_ROUTE_ISIS
2345           || rib->type == ZEBRA_ROUTE_NHRP
2346           || rib->type == ZEBRA_ROUTE_BGP)
2347 	{
2348 	  time_t uptime;
2349 	  struct tm *tm;
2350 
2351 	  uptime = time (NULL);
2352 	  uptime -= rib->uptime;
2353 	  tm = gmtime (&uptime);
2354 
2355 #define ONE_DAY_SECOND 60*60*24
2356 #define ONE_WEEK_SECOND 60*60*24*7
2357 
2358 	  if (uptime < ONE_DAY_SECOND)
2359 	    vty_out (vty,  ", %02d:%02d:%02d",
2360 		     tm->tm_hour, tm->tm_min, tm->tm_sec);
2361 	  else if (uptime < ONE_WEEK_SECOND)
2362 	    vty_out (vty, ", %dd%02dh%02dm",
2363 		     tm->tm_yday, tm->tm_hour, tm->tm_min);
2364 	  else
2365 	    vty_out (vty, ", %02dw%dd%02dh",
2366 		     tm->tm_yday/7,
2367 		     tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
2368 	}
2369       vty_out (vty, "%s", VTY_NEWLINE);
2370     }
2371 }
2372 
2373 DEFUN (show_ip_route,
2374        show_ip_route_cmd,
2375        "show ip route",
2376        SHOW_STR
2377        IP_STR
2378        "IP routing table\n")
2379 {
2380   vrf_id_t vrf_id = VRF_DEFAULT;
2381 
2382   if (argc > 0)
2383     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2384 
2385   return do_show_ip_route(vty, SAFI_UNICAST, vrf_id);
2386 }
2387 
do_show_ip_route(struct vty * vty,safi_t safi,vrf_id_t vrf_id)2388 static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id)
2389 {
2390   struct route_table *table;
2391   struct route_node *rn;
2392   struct rib *rib;
2393   int first = 1;
2394 
2395   table = zebra_vrf_table (AFI_IP, safi, vrf_id);
2396   if (! table)
2397     return CMD_SUCCESS;
2398 
2399   /* Show all IPv4 routes. */
2400   for (rn = route_top (table); rn; rn = route_next (rn))
2401     RNODE_FOREACH_RIB (rn, rib)
2402       {
2403 	if (first)
2404 	  {
2405 	    vty_out (vty, SHOW_ROUTE_V4_HEADER);
2406 	    first = 0;
2407 	  }
2408 	vty_show_ip_route (vty, rn, rib);
2409       }
2410   return CMD_SUCCESS;
2411 }
2412 
2413 ALIAS (show_ip_route,
2414        show_ip_route_vrf_cmd,
2415        "show ip route " VRF_CMD_STR,
2416        SHOW_STR
2417        IP_STR
2418        "IP routing table\n"
2419        VRF_CMD_HELP_STR)
2420 
2421 DEFUN (show_ip_nht,
2422        show_ip_nht_cmd,
2423        "show ip nht",
2424        SHOW_STR
2425        IP_STR
2426        "IP nexthop tracking table\n")
2427 {
2428   zebra_print_rnh_table(0, AF_INET, vty);
2429   return CMD_SUCCESS;
2430 }
2431 
2432 DEFUN (show_ipv6_nht,
2433        show_ipv6_nht_cmd,
2434        "show ipv6 nht",
2435        SHOW_STR
2436        IP_STR
2437        "IPv6 nexthop tracking table\n")
2438 {
2439   zebra_print_rnh_table(0, AF_INET6, vty);
2440   return CMD_SUCCESS;
2441 }
2442 
2443 DEFUN (show_ip_route_tag,
2444        show_ip_route_tag_cmd,
2445        "show ip route tag <1-4294967295>",
2446        SHOW_STR
2447        IP_STR
2448        "IP routing table\n"
2449        "Show only routes with tag\n"
2450        "Tag value\n")
2451 {
2452   struct route_table *table;
2453   struct route_node *rn;
2454   struct rib *rib;
2455   int first = 1;
2456   route_tag_t tag = 0;
2457   vrf_id_t vrf_id = VRF_DEFAULT;
2458 
2459   if (argv[0])
2460     tag = atoi(argv[0]);
2461 
2462   if (argc == 2)
2463     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
2464 
2465   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2466   if (! table)
2467     return CMD_SUCCESS;
2468 
2469   /* Show all IPv4 routes with matching tag value. */
2470   for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)2471     RNODE_FOREACH_RIB (rn, rib)
2472       {
2473         if (rib->tag != tag)
2474           continue;
2475 
2476         if (first)
2477           {
2478             vty_out (vty, SHOW_ROUTE_V4_HEADER);
2479             first = 0;
2480           }
2481         vty_show_ip_route (vty, rn, rib);
2482       }
2483   return CMD_SUCCESS;
2484 }
2485 
2486 ALIAS (show_ip_route_tag,
2487        show_ip_route_tag_vrf_cmd,
2488        "show ip route tag <1-4294967295>" VRF_CMD_STR,
2489        SHOW_STR
2490        IP_STR
2491        "IP routing table\n"
2492        "Show only routes with tag\n"
2493        "Tag value\n"
2494        VRF_CMD_HELP_STR)
2495 
2496 DEFUN (show_ip_route_prefix_longer,
2497        show_ip_route_prefix_longer_cmd,
2498        "show ip route A.B.C.D/M longer-prefixes",
2499        SHOW_STR
2500        IP_STR
2501        "IP routing table\n"
2502        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2503        "Show route matching the specified Network/Mask pair only\n")
2504 {
2505   struct route_table *table;
2506   struct route_node *rn;
2507   struct rib *rib;
2508   struct prefix p;
2509   int ret;
2510   int first = 1;
2511   vrf_id_t vrf_id = VRF_DEFAULT;
2512 
2513   ret = str2prefix (argv[0], &p);
2514   if (! ret)
2515     {
2516       vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2517       return CMD_WARNING;
2518     }
2519 
2520   if (argc > 1)
2521     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
2522 
2523   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2524   if (! table)
2525     return CMD_SUCCESS;
2526 
2527   /* Show matched type IPv4 routes. */
2528   for (rn = route_top (table); rn; rn = route_next (rn))
2529     RNODE_FOREACH_RIB (rn, rib)
2530       if (prefix_match (&p, &rn->p))
2531 	{
2532 	  if (first)
2533 	    {
2534 	      vty_out (vty, SHOW_ROUTE_V4_HEADER);
2535 	      first = 0;
2536 	    }
2537 	  vty_show_ip_route (vty, rn, rib);
2538 	}
2539   return CMD_SUCCESS;
2540 }
2541 
2542 ALIAS (show_ip_route_prefix_longer,
2543        show_ip_route_prefix_longer_vrf_cmd,
2544        "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
2545        SHOW_STR
2546        IP_STR
2547        "IP routing table\n"
2548        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2549        "Show route matching the specified Network/Mask pair only\n"
2550        VRF_CMD_HELP_STR)
2551 
2552 DEFUN (show_ip_route_supernets,
2553        show_ip_route_supernets_cmd,
2554        "show ip route supernets-only",
2555        SHOW_STR
2556        IP_STR
2557        "IP routing table\n"
2558        "Show supernet entries only\n")
2559 {
2560   struct route_table *table;
2561   struct route_node *rn;
2562   struct rib *rib;
2563   u_int32_t addr;
2564   int first = 1;
2565   vrf_id_t vrf_id = VRF_DEFAULT;
2566 
2567   if (argc > 0)
2568     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2569 
2570   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2571   if (! table)
2572     return CMD_SUCCESS;
2573 
2574   /* Show matched type IPv4 routes. */
2575   for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)2576     RNODE_FOREACH_RIB (rn, rib)
2577       {
2578 	addr = ntohl (rn->p.u.prefix4.s_addr);
2579 
2580 	if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2581 	   || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2582 	   || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2583 	  {
2584 	    if (first)
2585 	      {
2586 		vty_out (vty, SHOW_ROUTE_V4_HEADER);
2587 		first = 0;
2588 	      }
2589 	    vty_show_ip_route (vty, rn, rib);
2590 	  }
2591       }
2592   return CMD_SUCCESS;
2593 }
2594 
2595 ALIAS (show_ip_route_supernets,
2596        show_ip_route_supernets_vrf_cmd,
2597        "show ip route supernets-only " VRF_CMD_STR,
2598        SHOW_STR
2599        IP_STR
2600        "IP routing table\n"
2601        "Show supernet entries only\n"
2602        VRF_CMD_HELP_STR)
2603 
2604 DEFUN (show_ip_route_protocol,
2605        show_ip_route_protocol_cmd,
2606        "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
2607        SHOW_STR
2608        IP_STR
2609        "IP routing table\n"
2610        QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
2611 {
2612   int type;
2613   struct route_table *table;
2614   struct route_node *rn;
2615   struct rib *rib;
2616   int first = 1;
2617   vrf_id_t vrf_id = VRF_DEFAULT;
2618 
2619   type = proto_redistnum (AFI_IP, argv[0]);
2620   if (type < 0)
2621     {
2622       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2623       return CMD_WARNING;
2624     }
2625 
2626   if (argc > 1)
2627     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
2628 
2629   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2630   if (! table)
2631     return CMD_SUCCESS;
2632 
2633   /* Show matched type IPv4 routes. */
2634   for (rn = route_top (table); rn; rn = route_next (rn))
2635     RNODE_FOREACH_RIB (rn, rib)
2636       if (rib->type == type)
2637 	{
2638 	  if (first)
2639 	    {
2640 	      vty_out (vty, SHOW_ROUTE_V4_HEADER);
2641 	      first = 0;
2642 	    }
2643 	  vty_show_ip_route (vty, rn, rib);
2644 	}
2645   return CMD_SUCCESS;
2646 }
2647 
2648 ALIAS (show_ip_route_protocol,
2649        show_ip_route_protocol_vrf_cmd,
2650        "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
2651        SHOW_STR
2652        IP_STR
2653        "IP routing table\n"
2654        QUAGGA_IP_REDIST_HELP_STR_ZEBRA
2655        VRF_CMD_HELP_STR)
2656 
2657 DEFUN (show_ip_route_addr,
2658        show_ip_route_addr_cmd,
2659        "show ip route A.B.C.D",
2660        SHOW_STR
2661        IP_STR
2662        "IP routing table\n"
2663        "Network in the IP routing table to display\n")
2664 {
2665   int ret;
2666   struct prefix_ipv4 p;
2667   struct route_table *table;
2668   struct route_node *rn;
2669   vrf_id_t vrf_id = VRF_DEFAULT;
2670 
2671   ret = str2prefix_ipv4 (argv[0], &p);
2672   if (ret <= 0)
2673     {
2674       vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2675       return CMD_WARNING;
2676     }
2677 
2678   if (argc > 1)
2679     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
2680 
2681   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2682   if (! table)
2683     return CMD_SUCCESS;
2684 
2685   rn = route_node_match (table, (struct prefix *) &p);
2686   if (! rn)
2687     {
2688       vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
2689       return CMD_WARNING;
2690     }
2691 
2692   vty_show_ip_route_detail (vty, rn, 0);
2693 
2694   route_unlock_node (rn);
2695 
2696   return CMD_SUCCESS;
2697 }
2698 
2699 ALIAS (show_ip_route_addr,
2700        show_ip_route_addr_vrf_cmd,
2701        "show ip route A.B.C.D " VRF_CMD_STR,
2702        SHOW_STR
2703        IP_STR
2704        "IP routing table\n"
2705        "Network in the IP routing table to display\n"
2706        VRF_CMD_HELP_STR)
2707 
2708 DEFUN (show_ip_route_prefix,
2709        show_ip_route_prefix_cmd,
2710        "show ip route A.B.C.D/M",
2711        SHOW_STR
2712        IP_STR
2713        "IP routing table\n"
2714        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2715 {
2716   int ret;
2717   struct prefix_ipv4 p;
2718   struct route_table *table;
2719   struct route_node *rn;
2720   vrf_id_t vrf_id = VRF_DEFAULT;
2721 
2722   ret = str2prefix_ipv4 (argv[0], &p);
2723   if (ret <= 0)
2724     {
2725       vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2726       return CMD_WARNING;
2727     }
2728 
2729   if (argc > 1)
2730     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
2731 
2732   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2733   if (! table)
2734     return CMD_SUCCESS;
2735 
2736   rn = route_node_match (table, (struct prefix *) &p);
2737   if (! rn || rn->p.prefixlen != p.prefixlen)
2738     {
2739       vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
2740       if (rn)
2741         route_unlock_node (rn);
2742       return CMD_WARNING;
2743     }
2744 
2745   vty_show_ip_route_detail (vty, rn, 0);
2746 
2747   route_unlock_node (rn);
2748 
2749   return CMD_SUCCESS;
2750 }
2751 
2752 ALIAS (show_ip_route_prefix,
2753        show_ip_route_prefix_vrf_cmd,
2754        "show ip route A.B.C.D/M " VRF_CMD_STR,
2755        SHOW_STR
2756        IP_STR
2757        "IP routing table\n"
2758        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2759        VRF_CMD_HELP_STR)
2760 
2761 static void
vty_show_ip_route_summary(struct vty * vty,struct route_table * table)2762 vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
2763 {
2764   struct route_node *rn;
2765   struct rib *rib;
2766   struct nexthop *nexthop;
2767 #define ZEBRA_ROUTE_IBGP  ZEBRA_ROUTE_MAX
2768 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
2769   u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
2770   u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
2771   u_int32_t i;
2772 
2773   memset (&rib_cnt, 0, sizeof(rib_cnt));
2774   memset (&fib_cnt, 0, sizeof(fib_cnt));
2775   for (rn = route_top (table); rn; rn = route_next (rn))
2776     RNODE_FOREACH_RIB (rn, rib)
2777       for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
2778         {
2779 	  rib_cnt[ZEBRA_ROUTE_TOTAL]++;
2780 	  rib_cnt[rib->type]++;
2781 	  if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
2782 	      || nexthop_has_fib_child(nexthop))
2783 	    {
2784 	      fib_cnt[ZEBRA_ROUTE_TOTAL]++;
2785 	      fib_cnt[rib->type]++;
2786 	    }
2787 	  if (rib->type == ZEBRA_ROUTE_BGP &&
2788 	      CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
2789 	    {
2790 	      rib_cnt[ZEBRA_ROUTE_IBGP]++;
2791 	      if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
2792 		  || nexthop_has_fib_child(nexthop))
2793 		fib_cnt[ZEBRA_ROUTE_IBGP]++;
2794 	    }
2795 	}
2796 
2797   vty_out (vty, "%-20s %-20s %s  (vrf %u)%s",
2798            "Route Source", "Routes", "FIB",
2799            ((rib_table_info_t *)table->info)->zvrf->vrf_id,
2800            VTY_NEWLINE);
2801 
2802   for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
2803     {
2804       if (rib_cnt[i] > 0)
2805 	{
2806 	  if (i == ZEBRA_ROUTE_BGP)
2807 	    {
2808 	      vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2809 		       rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2810 		       fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2811 		       VTY_NEWLINE);
2812 	      vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2813 		       rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2814 		       VTY_NEWLINE);
2815 	    }
2816 	  else
2817 	    vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2818 		     rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2819 	}
2820     }
2821 
2822   vty_out (vty, "------%s", VTY_NEWLINE);
2823   vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2824 	   fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
2825   vty_out (vty, "%s", VTY_NEWLINE);
2826 }
2827 
2828 /*
2829  * Implementation of the ip route summary prefix command.
2830  *
2831  * This command prints the primary prefixes that have been installed by various
2832  * protocols on the box.
2833  *
2834  */
2835 static void
vty_show_ip_route_summary_prefix(struct vty * vty,struct route_table * table)2836 vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
2837 {
2838   struct route_node *rn;
2839   struct rib *rib;
2840   struct nexthop *nexthop;
2841 #define ZEBRA_ROUTE_IBGP  ZEBRA_ROUTE_MAX
2842 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
2843   u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
2844   u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
2845   u_int32_t i;
2846   int       cnt;
2847 
2848   memset (&rib_cnt, 0, sizeof(rib_cnt));
2849   memset (&fib_cnt, 0, sizeof(fib_cnt));
2850   for (rn = route_top (table); rn; rn = route_next (rn))
2851     RNODE_FOREACH_RIB (rn, rib)
2852       {
2853 
2854        /*
2855         * In case of ECMP, count only once.
2856         */
2857        cnt = 0;
2858        for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
2859          {
2860           cnt++;
2861           rib_cnt[ZEBRA_ROUTE_TOTAL]++;
2862           rib_cnt[rib->type]++;
2863           if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
2864 	        {
2865 	         fib_cnt[ZEBRA_ROUTE_TOTAL]++;
2866              fib_cnt[rib->type]++;
2867             }
2868 	      if (rib->type == ZEBRA_ROUTE_BGP &&
2869 	          CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
2870             {
2871 	         rib_cnt[ZEBRA_ROUTE_IBGP]++;
2872 		     if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
2873 		        fib_cnt[ZEBRA_ROUTE_IBGP]++;
2874             }
2875 	     }
2876       }
2877 
2878   vty_out (vty, "%-20s %-20s %s  (vrf %u)%s",
2879            "Route Source", "Prefix Routes", "FIB",
2880            ((rib_table_info_t *)table->info)->zvrf->vrf_id,
2881            VTY_NEWLINE);
2882 
2883   for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
2884     {
2885       if (rib_cnt[i] > 0)
2886 	{
2887 	  if (i == ZEBRA_ROUTE_BGP)
2888 	    {
2889 	      vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2890 		       rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2891 		       fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2892 		       VTY_NEWLINE);
2893 	      vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2894 		       rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2895 		       VTY_NEWLINE);
2896 	    }
2897 	  else
2898 	    vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2899 		     rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2900 	}
2901     }
2902 
2903   vty_out (vty, "------%s", VTY_NEWLINE);
2904   vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2905 	   fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
2906   vty_out (vty, "%s", VTY_NEWLINE);
2907 }
2908 
2909 /* Show route summary.  */
2910 DEFUN (show_ip_route_summary,
2911        show_ip_route_summary_cmd,
2912        "show ip route summary",
2913        SHOW_STR
2914        IP_STR
2915        "IP routing table\n"
2916        "Summary of all routes\n")
2917 {
2918   struct route_table *table;
2919   vrf_id_t vrf_id = VRF_DEFAULT;
2920 
2921   if (argc > 0)
2922     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2923 
2924   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2925   if (! table)
2926     return CMD_SUCCESS;
2927 
2928   vty_show_ip_route_summary (vty, table);
2929 
2930   return CMD_SUCCESS;
2931 }
2932 
2933 ALIAS (show_ip_route_summary,
2934        show_ip_route_summary_vrf_cmd,
2935        "show ip route summary " VRF_CMD_STR,
2936        SHOW_STR
2937        IP_STR
2938        "IP routing table\n"
2939        "Summary of all routes\n"
2940        VRF_CMD_HELP_STR)
2941 
2942 /* Show route summary prefix.  */
2943 DEFUN (show_ip_route_summary_prefix,
2944        show_ip_route_summary_prefix_cmd,
2945        "show ip route summary prefix",
2946        SHOW_STR
2947        IP_STR
2948        "IP routing table\n"
2949        "Summary of all routes\n"
2950        "Prefix routes\n")
2951 {
2952   struct route_table *table;
2953   vrf_id_t vrf_id = VRF_DEFAULT;
2954 
2955   if (argc > 0)
2956     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2957 
2958   table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2959   if (! table)
2960     return CMD_SUCCESS;
2961 
2962   vty_show_ip_route_summary_prefix (vty, table);
2963 
2964   return CMD_SUCCESS;
2965 }
2966 
2967 ALIAS (show_ip_route_summary_prefix,
2968        show_ip_route_summary_prefix_vrf_cmd,
2969        "show ip route summary prefix " VRF_CMD_STR,
2970        SHOW_STR
2971        IP_STR
2972        "IP routing table\n"
2973        "Summary of all routes\n"
2974        "Prefix routes\n"
2975        VRF_CMD_HELP_STR)
2976 
2977 DEFUN (show_ip_route_vrf_all,
2978        show_ip_route_vrf_all_cmd,
2979        "show ip route " VRF_ALL_CMD_STR,
2980        SHOW_STR
2981        IP_STR
2982        "IP routing table\n"
2983        VRF_ALL_CMD_HELP_STR)
2984 {
2985   struct route_table *table;
2986   struct route_node *rn;
2987   struct rib *rib;
2988   struct zebra_vrf *zvrf;
2989   vrf_iter_t iter;
2990   int first = 1;
2991 
2992   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2993     {
2994       if ((zvrf = vrf_iter2info (iter)) == NULL ||
2995           (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2996         continue;
2997 
2998       /* Show all IPv4 routes. */
2999       for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)3000         RNODE_FOREACH_RIB (rn, rib)
3001           {
3002             if (first)
3003               {
3004                 vty_out (vty, SHOW_ROUTE_V4_HEADER);
3005                 first = 0;
3006               }
3007             vty_show_ip_route (vty, rn, rib);
3008           }
3009     }
3010 
3011   return CMD_SUCCESS;
3012 }
3013 
3014 DEFUN (show_ip_route_prefix_longer_vrf_all,
3015        show_ip_route_prefix_longer_vrf_all_cmd,
3016        "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
3017        SHOW_STR
3018        IP_STR
3019        "IP routing table\n"
3020        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3021        "Show route matching the specified Network/Mask pair only\n"
3022        VRF_ALL_CMD_HELP_STR)
3023 {
3024   struct route_table *table;
3025   struct route_node *rn;
3026   struct rib *rib;
3027   struct prefix p;
3028   struct zebra_vrf *zvrf;
3029   vrf_iter_t iter;
3030   int ret;
3031   int first = 1;
3032 
3033   ret = str2prefix (argv[0], &p);
3034   if (! ret)
3035     {
3036       vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3037       return CMD_WARNING;
3038     }
3039 
3040   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3041     {
3042       if ((zvrf = vrf_iter2info (iter)) == NULL ||
3043           (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3044         continue;
3045 
3046       /* Show matched type IPv4 routes. */
3047       for (rn = route_top (table); rn; rn = route_next (rn))
3048         RNODE_FOREACH_RIB (rn, rib)
3049           if (prefix_match (&p, &rn->p))
3050             {
3051               if (first)
3052                 {
3053                   vty_out (vty, SHOW_ROUTE_V4_HEADER);
3054                   first = 0;
3055                 }
3056               vty_show_ip_route (vty, rn, rib);
3057             }
3058     }
3059 
3060   return CMD_SUCCESS;
3061 }
3062 
3063 DEFUN (show_ip_route_supernets_vrf_all,
3064        show_ip_route_supernets_vrf_all_cmd,
3065        "show ip route supernets-only " VRF_ALL_CMD_STR,
3066        SHOW_STR
3067        IP_STR
3068        "IP routing table\n"
3069        "Show supernet entries only\n"
3070        VRF_ALL_CMD_HELP_STR)
3071 {
3072   struct route_table *table;
3073   struct route_node *rn;
3074   struct rib *rib;
3075   struct zebra_vrf *zvrf;
3076   vrf_iter_t iter;
3077   u_int32_t addr;
3078   int first = 1;
3079 
3080   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3081     {
3082       if ((zvrf = vrf_iter2info (iter)) == NULL ||
3083           (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3084         continue;
3085 
3086       /* Show matched type IPv4 routes. */
3087       for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)3088         RNODE_FOREACH_RIB (rn, rib)
3089           {
3090             addr = ntohl (rn->p.u.prefix4.s_addr);
3091 
3092             if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
3093                || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
3094                || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
3095               {
3096                 if (first)
3097                   {
3098                     vty_out (vty, SHOW_ROUTE_V4_HEADER);
3099                     first = 0;
3100                   }
3101                 vty_show_ip_route (vty, rn, rib);
3102               }
3103           }
3104     }
3105 
3106   return CMD_SUCCESS;
3107 }
3108 
3109 DEFUN (show_ip_route_protocol_vrf_all,
3110        show_ip_route_protocol_vrf_all_cmd,
3111        "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
3112        SHOW_STR
3113        IP_STR
3114        "IP routing table\n"
3115        QUAGGA_IP_REDIST_HELP_STR_ZEBRA
3116        VRF_ALL_CMD_HELP_STR)
3117 {
3118   int type;
3119   struct route_table *table;
3120   struct route_node *rn;
3121   struct rib *rib;
3122   struct zebra_vrf *zvrf;
3123   vrf_iter_t iter;
3124   int first = 1;
3125 
3126   type = proto_redistnum (AFI_IP, argv[0]);
3127   if (type < 0)
3128     {
3129       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3130       return CMD_WARNING;
3131     }
3132 
3133   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3134     {
3135       if ((zvrf = vrf_iter2info (iter)) == NULL ||
3136           (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3137         continue;
3138 
3139       /* Show matched type IPv4 routes. */
3140       for (rn = route_top (table); rn; rn = route_next (rn))
3141         RNODE_FOREACH_RIB (rn, rib)
3142           if (rib->type == type)
3143             {
3144               if (first)
3145                 {
3146                   vty_out (vty, SHOW_ROUTE_V4_HEADER);
3147                   first = 0;
3148                 }
3149               vty_show_ip_route (vty, rn, rib);
3150             }
3151     }
3152 
3153   return CMD_SUCCESS;
3154 }
3155 
3156 DEFUN (show_ip_route_addr_vrf_all,
3157        show_ip_route_addr_vrf_all_cmd,
3158        "show ip route A.B.C.D " VRF_ALL_CMD_STR,
3159        SHOW_STR
3160        IP_STR
3161        "IP routing table\n"
3162        "Network in the IP routing table to display\n"
3163        VRF_ALL_CMD_HELP_STR)
3164 {
3165   int ret;
3166   struct prefix_ipv4 p;
3167   struct route_table *table;
3168   struct route_node *rn;
3169   struct zebra_vrf *zvrf;
3170   vrf_iter_t iter;
3171 
3172   ret = str2prefix_ipv4 (argv[0], &p);
3173   if (ret <= 0)
3174     {
3175       vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
3176       return CMD_WARNING;
3177     }
3178 
3179   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3180     {
3181       if ((zvrf = vrf_iter2info (iter)) == NULL ||
3182           (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3183         continue;
3184 
3185       rn = route_node_match (table, (struct prefix *) &p);
3186       if (! rn)
3187         continue;
3188 
3189       vty_show_ip_route_detail (vty, rn, 0);
3190 
3191       route_unlock_node (rn);
3192     }
3193 
3194   return CMD_SUCCESS;
3195 }
3196 
3197 DEFUN (show_ip_route_prefix_vrf_all,
3198        show_ip_route_prefix_vrf_all_cmd,
3199        "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
3200        SHOW_STR
3201        IP_STR
3202        "IP routing table\n"
3203        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3204        VRF_ALL_CMD_HELP_STR)
3205 {
3206   int ret;
3207   struct prefix_ipv4 p;
3208   struct route_table *table;
3209   struct route_node *rn;
3210   struct zebra_vrf *zvrf;
3211   vrf_iter_t iter;
3212 
3213   ret = str2prefix_ipv4 (argv[0], &p);
3214   if (ret <= 0)
3215     {
3216       vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
3217       return CMD_WARNING;
3218     }
3219 
3220   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3221     {
3222       if ((zvrf = vrf_iter2info (iter)) == NULL ||
3223           (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3224         continue;
3225 
3226       rn = route_node_match (table, (struct prefix *) &p);
3227       if (! rn)
3228         continue;
3229       if (rn->p.prefixlen != p.prefixlen)
3230         {
3231           route_unlock_node (rn);
3232           continue;
3233         }
3234 
3235       vty_show_ip_route_detail (vty, rn, 0);
3236 
3237       route_unlock_node (rn);
3238     }
3239 
3240   return CMD_SUCCESS;
3241 }
3242 
3243 DEFUN (show_ip_route_summary_vrf_all,
3244        show_ip_route_summary_vrf_all_cmd,
3245        "show ip route summary " VRF_ALL_CMD_STR,
3246        SHOW_STR
3247        IP_STR
3248        "IP routing table\n"
3249        "Summary of all routes\n"
3250        VRF_ALL_CMD_HELP_STR)
3251 {
3252   struct zebra_vrf *zvrf;
3253   vrf_iter_t iter;
3254 
3255   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3256     if ((zvrf = vrf_iter2info (iter)) != NULL)
3257       vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
3258 
3259   return CMD_SUCCESS;
3260 }
3261 
3262 DEFUN (show_ip_route_summary_prefix_vrf_all,
3263        show_ip_route_summary_prefix_vrf_all_cmd,
3264        "show ip route summary prefix " VRF_ALL_CMD_STR,
3265        SHOW_STR
3266        IP_STR
3267        "IP routing table\n"
3268        "Summary of all routes\n"
3269        "Prefix routes\n"
3270        VRF_ALL_CMD_HELP_STR)
3271 {
3272   struct zebra_vrf *zvrf;
3273   vrf_iter_t iter;
3274 
3275   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3276     if ((zvrf = vrf_iter2info (iter)) != NULL)
3277       vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
3278 
3279   return CMD_SUCCESS;
3280 }
3281 
3282 /* Write IPv4 static route configuration. */
3283 static int
static_config_ipv4(struct vty * vty,safi_t safi,const char * cmd)3284 static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
3285 {
3286   struct route_node *rn;
3287   struct static_route *si;
3288   struct route_table *stable;
3289   struct zebra_vrf *zvrf;
3290   vrf_iter_t iter;
3291   int write;
3292 
3293   write = 0;
3294 
3295   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3296     {
3297       if ((zvrf = vrf_iter2info (iter)) == NULL ||
3298           (stable = zvrf->stable[AFI_IP][safi]) == NULL)
3299         continue;
3300 
3301       for (rn = route_top (stable); rn; rn = route_next (rn))
3302         for (si = rn->info; si; si = si->next)
3303           {
3304             vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
3305                      rn->p.prefixlen);
3306 
3307             switch (si->type)
3308               {
3309                 case STATIC_IPV4_GATEWAY:
3310                   vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
3311                   break;
3312                 case STATIC_IPV4_IFNAME:
3313                   vty_out (vty, " %s", si->ifname);
3314                   break;
3315                 case STATIC_IPV4_BLACKHOLE:
3316                   vty_out (vty, " Null0");
3317                   break;
3318               }
3319 
3320             /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
3321             if (si->type != STATIC_IPV4_BLACKHOLE)
3322               {
3323                 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3324                   vty_out (vty, " %s", "reject");
3325 
3326                 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3327                   vty_out (vty, " %s", "blackhole");
3328               }
3329 
3330 	    if (si->tag)
3331 	      vty_out (vty, " tag %d", si->tag);
3332 
3333             if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3334               vty_out (vty, " %d", si->distance);
3335 
3336             if (si->vrf_id != VRF_DEFAULT)
3337               vty_out (vty, " vrf %u", si->vrf_id);
3338 
3339             vty_out (vty, "%s", VTY_NEWLINE);
3340 
3341             write = 1;
3342           }
3343     }
3344   return write;
3345 }
3346 
3347 DEFUN (show_ip_protocol,
3348        show_ip_protocol_cmd,
3349        "show ip protocol",
3350         SHOW_STR
3351         IP_STR
3352        "IP protocol filtering status\n")
3353 {
3354     int i;
3355 
3356     vty_out(vty, "Protocol    : route-map %s", VTY_NEWLINE);
3357     vty_out(vty, "------------------------%s", VTY_NEWLINE);
3358     for (i=0;i<ZEBRA_ROUTE_MAX;i++)
3359     {
3360         if (proto_rm[AFI_IP][i])
3361           vty_out (vty, "%-10s  : %-10s%s", zebra_route_string(i),
3362 					proto_rm[AFI_IP][i],
3363 					VTY_NEWLINE);
3364         else
3365           vty_out (vty, "%-10s  : none%s", zebra_route_string(i), VTY_NEWLINE);
3366     }
3367     if (proto_rm[AFI_IP][i])
3368       vty_out (vty, "%-10s  : %-10s%s", "any", proto_rm[AFI_IP][i],
3369 					VTY_NEWLINE);
3370     else
3371       vty_out (vty, "%-10s  : none%s", "any", VTY_NEWLINE);
3372 
3373     return CMD_SUCCESS;
3374 }
3375 
3376 /* General fucntion for IPv6 static route. */
3377 static int
static_ipv6_func(struct vty * vty,int add_cmd,const char * dest_str,const char * gate_str,const char * ifname,const char * flag_str,const char * tag_str,const char * distance_str,const char * vrf_id_str)3378 static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
3379 		  const char *gate_str, const char *ifname,
3380 		  const char *flag_str, const char *tag_str,
3381 		  const char *distance_str, const char *vrf_id_str)
3382 {
3383   int ret;
3384   u_char distance;
3385   struct prefix p;
3386   struct in6_addr *gate = NULL;
3387   struct in6_addr gate_addr;
3388   u_char type = 0;
3389   vrf_id_t vrf_id = VRF_DEFAULT;
3390   u_char flag = 0;
3391   route_tag_t tag = 0;
3392 
3393   ret = str2prefix (dest_str, &p);
3394   if (ret <= 0)
3395     {
3396       vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
3397       return CMD_WARNING;
3398     }
3399 
3400   /* Apply mask for given prefix. */
3401   apply_mask (&p);
3402 
3403   /* Route flags */
3404   if (flag_str) {
3405     switch(flag_str[0]) {
3406       case 'r':
3407       case 'R': /* XXX */
3408         SET_FLAG (flag, ZEBRA_FLAG_REJECT);
3409         break;
3410       case 'b':
3411       case 'B': /* XXX */
3412         SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
3413         break;
3414       default:
3415         vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
3416         return CMD_WARNING;
3417     }
3418   }
3419 
3420   /* Administrative distance. */
3421   if (distance_str)
3422     distance = atoi (distance_str);
3423   else
3424     distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
3425 
3426   /* tag */
3427   if (tag_str)
3428     tag = atoi (tag_str);
3429 
3430   /* tag */
3431   if (tag_str)
3432     tag = atoi(tag_str);
3433 
3434   /* When gateway is valid IPv6 addrees, then gate is treated as
3435      nexthop address other case gate is treated as interface name. */
3436   ret = inet_pton (AF_INET6, gate_str, &gate_addr);
3437 
3438   if (ifname)
3439     {
3440       /* When ifname is specified.  It must be come with gateway
3441          address. */
3442       if (ret != 1)
3443 	{
3444 	  vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
3445 	  return CMD_WARNING;
3446 	}
3447       type = STATIC_IPV6_GATEWAY_IFNAME;
3448       gate = &gate_addr;
3449     }
3450   else
3451     {
3452       if (ret == 1)
3453 	{
3454 	  type = STATIC_IPV6_GATEWAY;
3455 	  gate = &gate_addr;
3456 	}
3457       else
3458 	{
3459 	  type = STATIC_IPV6_IFNAME;
3460 	  ifname = gate_str;
3461 	}
3462     }
3463 
3464   /* VRF id */
3465   if (vrf_id_str)
3466     VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
3467 
3468   if (add_cmd)
3469     static_add_ipv6 (&p, type, gate, ifname, flag, tag, distance, vrf_id);
3470   else
3471     static_delete_ipv6 (&p, type, gate, ifname, tag, distance, vrf_id);
3472 
3473   return CMD_SUCCESS;
3474 }
3475 
3476 DEFUN (ipv6_route,
3477        ipv6_route_cmd,
3478        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
3479        IP_STR
3480        "Establish static routes\n"
3481        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3482        "IPv6 gateway address\n"
3483        "IPv6 gateway interface name\n")
3484 {
3485   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
3486                            NULL, NULL);
3487 }
3488 
3489 DEFUN (ipv6_route_tag,
3490        ipv6_route_tag_cmd,
3491        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295>",
3492        IP_STR
3493        "Establish static routes\n"
3494        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3495        "IPv6 gateway address\n"
3496        "IPv6 gateway interface name\n"
3497        "Set tag for this route\n"
3498        "Tag value\n")
3499 {
3500   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL);
3501 }
3502 
3503 DEFUN (ipv6_route_tag_vrf,
3504        ipv6_route_tag_vrf_cmd,
3505        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295>" VRF_CMD_STR,
3506        IP_STR
3507        "Establish static routes\n"
3508        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3509        "IPv6 gateway address\n"
3510        "IPv6 gateway interface name\n"
3511        "Set tag for this route\n"
3512        "Tag value\n"
3513        VRF_CMD_HELP_STR)
3514 {
3515   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, argv[3]);
3516 }
3517 
3518 DEFUN (ipv6_route_flags,
3519        ipv6_route_flags_cmd,
3520        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
3521        IP_STR
3522        "Establish static routes\n"
3523        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3524        "IPv6 gateway address\n"
3525        "IPv6 gateway interface name\n"
3526        "Emit an ICMP unreachable when matched\n"
3527        "Silently discard pkts when matched\n")
3528 {
3529   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
3530                            NULL, NULL);
3531 }
3532 
3533 DEFUN (ipv6_route_flags_tag,
3534        ipv6_route_flags_tag_cmd,
3535        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295>",
3536        IP_STR
3537        "Establish static routes\n"
3538        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3539        "IPv6 gateway address\n"
3540        "IPv6 gateway interface name\n"
3541        "Emit an ICMP unreachable when matched\n"
3542        "Silently discard pkts when matched\n"
3543        "Set tag for this route\n"
3544        "Tag value\n")
3545 {
3546   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL, NULL);
3547 }
3548 
3549 DEFUN (ipv6_route_flags_tag_vrf,
3550        ipv6_route_flags_tag_vrf_cmd,
3551        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295>" VRF_CMD_STR,
3552        IP_STR
3553        "Establish static routes\n"
3554        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3555        "IPv6 gateway address\n"
3556        "IPv6 gateway interface name\n"
3557        "Emit an ICMP unreachable when matched\n"
3558        "Silently discard pkts when matched\n"
3559        "Set tag for this route\n"
3560        "Tag value\n"
3561        VRF_CMD_HELP_STR)
3562 {
3563   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL, argv[4]);
3564 }
3565 
3566 DEFUN (ipv6_route_ifname,
3567        ipv6_route_ifname_cmd,
3568        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
3569        IP_STR
3570        "Establish static routes\n"
3571        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3572        "IPv6 gateway address\n"
3573        "IPv6 gateway interface name\n")
3574 {
3575   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
3576                            NULL, NULL);
3577 }
3578 
3579 DEFUN (ipv6_route_ifname_tag,
3580        ipv6_route_ifname_tag_cmd,
3581        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295>",
3582        IP_STR
3583        "Establish static routes\n"
3584        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3585        "IPv6 gateway address\n"
3586        "IPv6 gateway interface name\n"
3587        "Set tag for this route\n"
3588        "Tag value\n")
3589 {
3590   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL);
3591 }
3592 
3593 DEFUN (ipv6_route_ifname_tag_vrf,
3594        ipv6_route_ifname_tag_vrf_cmd,
3595        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295>" VRF_CMD_STR,
3596        IP_STR
3597        "Establish static routes\n"
3598        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3599        "IPv6 gateway address\n"
3600        "IPv6 gateway interface name\n"
3601        "Set tag for this route\n"
3602        "Tag value\n"
3603        VRF_CMD_HELP_STR)
3604 {
3605   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4]);
3606 }
3607 
3608 DEFUN (ipv6_route_ifname_flags,
3609        ipv6_route_ifname_flags_cmd,
3610        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
3611        IP_STR
3612        "Establish static routes\n"
3613        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3614        "IPv6 gateway address\n"
3615        "IPv6 gateway interface name\n"
3616        "Emit an ICMP unreachable when matched\n"
3617        "Silently discard pkts when matched\n")
3618 {
3619   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
3620                            NULL, NULL);
3621 }
3622 
3623 DEFUN (ipv6_route_ifname_flags_tag,
3624        ipv6_route_ifname_flags_tag_cmd,
3625        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295>",
3626        IP_STR
3627        "Establish static routes\n"
3628        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3629        "IPv6 gateway address\n"
3630        "IPv6 gateway interface name\n"
3631        "Emit an ICMP unreachable when matched\n"
3632        "Silently discard pkts when matched\n"
3633        "Set tag for this route\n"
3634        "Tag value\n")
3635 {
3636   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, NULL);
3637 }
3638 
3639 DEFUN (ipv6_route_ifname_flags_tag_vrf,
3640        ipv6_route_ifname_flags_tag_vrf_cmd,
3641        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295>" VRF_CMD_STR,
3642        IP_STR
3643        "Establish static routes\n"
3644        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3645        "IPv6 gateway address\n"
3646        "IPv6 gateway interface name\n"
3647        "Emit an ICMP unreachable when matched\n"
3648        "Silently discard pkts when matched\n"
3649        "Set tag for this route\n"
3650        "Tag value\n"
3651        VRF_CMD_HELP_STR)
3652 {
3653   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, argv[5]);
3654 }
3655 
3656 DEFUN (ipv6_route_pref,
3657        ipv6_route_pref_cmd,
3658        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
3659        IP_STR
3660        "Establish static routes\n"
3661        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3662        "IPv6 gateway address\n"
3663        "IPv6 gateway interface name\n"
3664        "Distance value for this prefix\n")
3665 {
3666   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2],
3667                            NULL);
3668 }
3669 
3670 DEFUN (ipv6_route_pref_tag,
3671        ipv6_route_pref_tag_cmd,
3672        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255>",
3673        IP_STR
3674        "Establish static routes\n"
3675        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3676        "IPv6 gateway address\n"
3677        "IPv6 gateway interface name\n"
3678        "Set tag for this route\n"
3679        "Tag value\n"
3680        "Distance value for this prefix\n")
3681 {
3682   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL);
3683 }
3684 
3685 DEFUN (ipv6_route_pref_tag_vrf,
3686        ipv6_route_pref_tag_vrf_cmd,
3687        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255>" VRF_CMD_STR,
3688        IP_STR
3689        "Establish static routes\n"
3690        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3691        "IPv6 gateway address\n"
3692        "IPv6 gateway interface name\n"
3693        "Set tag for this route\n"
3694        "Tag value\n"
3695        "Distance value for this prefix\n"
3696        VRF_CMD_HELP_STR)
3697 {
3698   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], argv[4]);
3699 }
3700 
3701 DEFUN (ipv6_route_flags_pref,
3702        ipv6_route_flags_pref_cmd,
3703        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
3704        IP_STR
3705        "Establish static routes\n"
3706        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3707        "IPv6 gateway address\n"
3708        "IPv6 gateway interface name\n"
3709        "Emit an ICMP unreachable when matched\n"
3710        "Silently discard pkts when matched\n"
3711        "Distance value for this prefix\n")
3712 {
3713   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
3714                            NULL);
3715 }
3716 
3717 DEFUN (ipv6_route_flags_pref_tag,
3718        ipv6_route_flags_pref_tag_cmd,
3719        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>",
3720        IP_STR
3721        "Establish static routes\n"
3722        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3723        "IPv6 gateway address\n"
3724        "IPv6 gateway interface name\n"
3725        "Emit an ICMP unreachable when matched\n"
3726        "Silently discard pkts when matched\n"
3727        "Set tag for this route\n"
3728        "Tag value\n"
3729        "Distance value for this prefix\n")
3730 {
3731   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], NULL);
3732 }
3733 
3734 DEFUN (ipv6_route_flags_pref_tag_vrf,
3735        ipv6_route_flags_pref_tag_vrf_cmd,
3736        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
3737        IP_STR
3738        "Establish static routes\n"
3739        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3740        "IPv6 gateway address\n"
3741        "IPv6 gateway interface name\n"
3742        "Emit an ICMP unreachable when matched\n"
3743        "Silently discard pkts when matched\n"
3744        "Set tag for this route\n"
3745        "Tag value\n"
3746        "Distance value for this prefix\n"
3747        VRF_CMD_HELP_STR)
3748 {
3749   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5]);
3750 }
3751 
3752 DEFUN (ipv6_route_ifname_pref,
3753        ipv6_route_ifname_pref_cmd,
3754        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
3755        IP_STR
3756        "Establish static routes\n"
3757        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3758        "IPv6 gateway address\n"
3759        "IPv6 gateway interface name\n"
3760        "Distance value for this prefix\n")
3761 {
3762   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
3763                            NULL);
3764 }
3765 
3766 DEFUN (ipv6_route_ifname_pref_tag,
3767        ipv6_route_ifname_pref_tag_cmd,
3768        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255>",
3769        IP_STR
3770        "Establish static routes\n"
3771        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3772        "IPv6 gateway address\n"
3773        "IPv6 gateway interface name\n"
3774        "Set tag for this route\n"
3775        "Tag value\n"
3776        "Distance value for this prefix\n")
3777 {
3778   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL);
3779 }
3780 
3781 DEFUN (ipv6_route_ifname_pref_tag_vrf,
3782        ipv6_route_ifname_pref_tag_vrf_cmd,
3783        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255>" VRF_CMD_STR,
3784        IP_STR
3785        "Establish static routes\n"
3786        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3787        "IPv6 gateway address\n"
3788        "IPv6 gateway interface name\n"
3789        "Set tag for this route\n"
3790        "Tag value\n"
3791        "Distance value for this prefix\n"
3792        VRF_CMD_HELP_STR)
3793 {
3794   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5]);
3795 }
3796 
3797 DEFUN (ipv6_route_ifname_flags_pref,
3798        ipv6_route_ifname_flags_pref_cmd,
3799        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
3800        IP_STR
3801        "Establish static routes\n"
3802        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3803        "IPv6 gateway address\n"
3804        "IPv6 gateway interface name\n"
3805        "Emit an ICMP unreachable when matched\n"
3806        "Silently discard pkts when matched\n"
3807        "Distance value for this prefix\n")
3808 {
3809   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
3810                            NULL);
3811 }
3812 
3813 DEFUN (ipv6_route_ifname_flags_pref_tag,
3814        ipv6_route_ifname_flags_pref_tag_cmd,
3815        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255>",
3816        IP_STR
3817        "Establish static routes\n"
3818        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3819        "IPv6 gateway address\n"
3820        "IPv6 gateway interface name\n"
3821        "Emit an ICMP unreachable when matched\n"
3822        "Silently discard pkts when matched\n"
3823        "Set tag for this route\n"
3824        "Tag value\n"
3825        "Distance value for this prefix\n")
3826 {
3827   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL);
3828 }
3829 
3830 DEFUN (ipv6_route_ifname_flags_pref_tag_vrf,
3831        ipv6_route_ifname_flags_pref_tag_vrf_cmd,
3832        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
3833        IP_STR
3834        "Establish static routes\n"
3835        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3836        "IPv6 gateway address\n"
3837        "IPv6 gateway interface name\n"
3838        "Emit an ICMP unreachable when matched\n"
3839        "Silently discard pkts when matched\n"
3840        "Set tag for this route\n"
3841        "Tag value\n"
3842        "Distance value for this prefix\n"
3843        VRF_CMD_HELP_STR)
3844 {
3845   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
3846 }
3847 
3848 DEFUN (no_ipv6_route,
3849        no_ipv6_route_cmd,
3850        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
3851        NO_STR
3852        IP_STR
3853        "Establish static routes\n"
3854        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3855        "IPv6 gateway address\n"
3856        "IPv6 gateway interface name\n")
3857 {
3858   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL,
3859                            NULL);
3860 }
3861 
3862 DEFUN (no_ipv6_route_tag,
3863        no_ipv6_route_tag_cmd,
3864        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295>",
3865        NO_STR
3866        IP_STR
3867        "Establish static routes\n"
3868        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3869        "IPv6 gateway address\n"
3870        "IPv6 gateway interface name\n"
3871        "Set tag for this route\n"
3872        "Tag value\n")
3873 {
3874   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL);
3875 }
3876 
3877 DEFUN (no_ipv6_route_tag_vrf,
3878        no_ipv6_route_tag_vrf_cmd,
3879        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295>" VRF_CMD_STR,
3880        NO_STR
3881        IP_STR
3882        "Establish static routes\n"
3883        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3884        "IPv6 gateway address\n"
3885        "IPv6 gateway interface name\n"
3886        "Set tag for this route\n"
3887        "Tag value\n"
3888        VRF_CMD_HELP_STR)
3889 {
3890   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, argv[3]);
3891 }
3892 
3893 ALIAS (no_ipv6_route,
3894        no_ipv6_route_flags_cmd,
3895        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
3896        NO_STR
3897        IP_STR
3898        "Establish static routes\n"
3899        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3900        "IPv6 gateway address\n"
3901        "IPv6 gateway interface name\n"
3902        "Emit an ICMP unreachable when matched\n"
3903        "Silently discard pkts when matched\n")
3904 
3905 ALIAS (no_ipv6_route_tag,
3906        no_ipv6_route_flags_tag_cmd,
3907        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295>",
3908        NO_STR
3909        IP_STR
3910        "Establish static routes\n"
3911        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3912        "IPv6 gateway address\n"
3913        "IPv6 gateway interface name\n"
3914        "Emit an ICMP unreachable when matched\n"
3915        "Silently discard pkts when matched\n"
3916        "Set tag for this route\n"
3917        "Tag value\n")
3918 
3919 DEFUN (no_ipv6_route_ifname,
3920        no_ipv6_route_ifname_cmd,
3921        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
3922        NO_STR
3923        IP_STR
3924        "Establish static routes\n"
3925        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3926        "IPv6 gateway address\n"
3927        "IPv6 gateway interface name\n")
3928 {
3929   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL,
3930                            NULL);
3931 }
3932 
3933 DEFUN (no_ipv6_route_ifname_tag,
3934        no_ipv6_route_ifname_tag_cmd,
3935        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295>",
3936        NO_STR
3937        IP_STR
3938        "Establish static routes\n"
3939        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3940        "IPv6 gateway address\n"
3941        "IPv6 gateway interface name\n"
3942        "Set tag for this route\n"
3943        "Tag value\n")
3944 {
3945   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL);
3946 }
3947 
3948 DEFUN (no_ipv6_route_ifname_tag_vrf,
3949        no_ipv6_route_ifname_tag_vrf_cmd,
3950        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295>" VRF_CMD_STR,
3951        NO_STR
3952        IP_STR
3953        "Establish static routes\n"
3954        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3955        "IPv6 gateway address\n"
3956        "IPv6 gateway interface name\n"
3957        "Set tag for this route\n"
3958        "Tag value\n"
3959        VRF_CMD_HELP_STR)
3960 {
3961   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4]);
3962 }
3963 
3964 ALIAS (no_ipv6_route_ifname,
3965        no_ipv6_route_ifname_flags_cmd,
3966        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
3967        NO_STR
3968        IP_STR
3969        "Establish static routes\n"
3970        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3971        "IPv6 gateway address\n"
3972        "IPv6 gateway interface name\n"
3973        "Emit an ICMP unreachable when matched\n"
3974        "Silently discard pkts when matched\n")
3975 
3976 ALIAS (no_ipv6_route_ifname_tag,
3977        no_ipv6_route_ifname_flags_tag_cmd,
3978        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295>",
3979        NO_STR
3980        IP_STR
3981        "Establish static routes\n"
3982        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3983        "IPv6 gateway address\n"
3984        "IPv6 gateway interface name\n"
3985        "Emit an ICMP unreachable when matched\n"
3986        "Silently discard pkts when matched\n"
3987        "Set tag for this route\n"
3988        "Tag value\n")
3989 
3990 DEFUN (no_ipv6_route_pref,
3991        no_ipv6_route_pref_cmd,
3992        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
3993        NO_STR
3994        IP_STR
3995        "Establish static routes\n"
3996        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3997        "IPv6 gateway address\n"
3998        "IPv6 gateway interface name\n"
3999        "Distance value for this prefix\n")
4000 {
4001   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2],
4002                            NULL);
4003 }
4004 
4005 DEFUN (no_ipv6_route_pref_tag,
4006        no_ipv6_route_pref_tag_cmd,
4007        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255>",
4008        NO_STR
4009        IP_STR
4010        "Establish static routes\n"
4011        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4012        "IPv6 gateway address\n"
4013        "IPv6 gateway interface name\n"
4014        "Set tag for this route\n"
4015        "Tag value\n"
4016        "Distance value for this prefix\n")
4017 {
4018   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL);
4019 }
4020 
4021 DEFUN (no_ipv6_route_pref_tag_vrf,
4022        no_ipv6_route_pref_tag_vrf_cmd,
4023        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255>" VRF_CMD_STR,
4024        NO_STR
4025        IP_STR
4026        "Establish static routes\n"
4027        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4028        "IPv6 gateway address\n"
4029        "IPv6 gateway interface name\n"
4030        "Set tag for this route\n"
4031        "Tag value\n"
4032        "Distance value for this prefix\n"
4033        VRF_CMD_HELP_STR)
4034 {
4035   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], argv[4]);
4036 }
4037 
4038 DEFUN (no_ipv6_route_flags_pref,
4039        no_ipv6_route_flags_pref_cmd,
4040        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
4041        NO_STR
4042        IP_STR
4043        "Establish static routes\n"
4044        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4045        "IPv6 gateway address\n"
4046        "IPv6 gateway interface name\n"
4047        "Emit an ICMP unreachable when matched\n"
4048        "Silently discard pkts when matched\n"
4049        "Distance value for this prefix\n")
4050 {
4051   /* We do not care about argv[2] */
4052   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
4053                            NULL);
4054 }
4055 
4056 DEFUN (no_ipv6_route_flags_pref_tag,
4057        no_ipv6_route_flags_pref_tag_cmd,
4058        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>",
4059        NO_STR
4060        IP_STR
4061        "Establish static routes\n"
4062        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4063        "IPv6 gateway address\n"
4064        "IPv6 gateway interface name\n"
4065        "Emit an ICMP unreachable when matched\n"
4066        "Silently discard pkts when matched\n"
4067        "Set tag for this route\n"
4068        "Tag value\n"
4069        "Distance value for this prefix\n")
4070 {
4071   /* We do not care about argv[2] */
4072   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], NULL);
4073 }
4074 
4075 DEFUN (no_ipv6_route_flags_pref_tag_vrf,
4076        no_ipv6_route_flags_pref_tag_vrf_cmd,
4077        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
4078        NO_STR
4079        IP_STR
4080        "Establish static routes\n"
4081        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4082        "IPv6 gateway address\n"
4083        "IPv6 gateway interface name\n"
4084        "Emit an ICMP unreachable when matched\n"
4085        "Silently discard pkts when matched\n"
4086        "Set tag for this route\n"
4087        "Tag value\n"
4088        "Distance value for this prefix\n"
4089        VRF_CMD_HELP_STR)
4090 {
4091   /* We do not care about argv[2] */
4092   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5]);
4093 }
4094 
4095 DEFUN (no_ipv6_route_ifname_pref,
4096        no_ipv6_route_ifname_pref_cmd,
4097        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
4098        NO_STR
4099        IP_STR
4100        "Establish static routes\n"
4101        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4102        "IPv6 gateway address\n"
4103        "IPv6 gateway interface name\n"
4104        "Distance value for this prefix\n")
4105 {
4106   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
4107                            NULL);
4108 }
4109 
4110 DEFUN (no_ipv6_route_ifname_pref_tag,
4111        no_ipv6_route_ifname_pref_tag_cmd,
4112        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255>",
4113        NO_STR
4114        IP_STR
4115        "Establish static routes\n"
4116        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4117        "IPv6 gateway address\n"
4118        "IPv6 gateway interface name\n"
4119        "Set tag for this route\n"
4120        "Tag value\n"
4121        "Distance value for this prefix\n")
4122 {
4123   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL);
4124 }
4125 
4126 DEFUN (no_ipv6_route_ifname_pref_tag_vrf,
4127        no_ipv6_route_ifname_pref_tag_vrf_cmd,
4128        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255>" VRF_CMD_STR,
4129        NO_STR
4130        IP_STR
4131        "Establish static routes\n"
4132        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4133        "IPv6 gateway address\n"
4134        "IPv6 gateway interface name\n"
4135        "Set tag for this route\n"
4136        "Tag value\n"
4137        "Distance value for this prefix\n"
4138        VRF_CMD_HELP_STR)
4139 {
4140   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5]);
4141 }
4142 
4143 DEFUN (no_ipv6_route_ifname_flags_pref,
4144        no_ipv6_route_ifname_flags_pref_cmd,
4145        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
4146        NO_STR
4147        IP_STR
4148        "Establish static routes\n"
4149        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4150        "IPv6 gateway address\n"
4151        "IPv6 gateway interface name\n"
4152        "Emit an ICMP unreachable when matched\n"
4153        "Silently discard pkts when matched\n"
4154        "Distance value for this prefix\n")
4155 {
4156   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
4157                            NULL);
4158 }
4159 
4160 DEFUN (no_ipv6_route_ifname_flags_pref_tag,
4161        no_ipv6_route_ifname_flags_pref_tag_cmd,
4162        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255>",
4163        NO_STR
4164        IP_STR
4165        "Establish static routes\n"
4166        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4167        "IPv6 gateway address\n"
4168        "IPv6 gateway interface name\n"
4169        "Emit an ICMP unreachable when matched\n"
4170        "Silently discard pkts when matched\n"
4171        "Set tag for this route\n"
4172        "Tag value\n"
4173        "Distance value for this prefix\n")
4174 {
4175   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL);
4176 }
4177 
4178 DEFUN (no_ipv6_route_ifname_flags_pref_tag_vrf,
4179        no_ipv6_route_ifname_flags_pref_tag_vrf_cmd,
4180        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-4294967295> <1-255>" VRF_CMD_STR,
4181        NO_STR
4182        IP_STR
4183        "Establish static routes\n"
4184        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4185        "IPv6 gateway address\n"
4186        "IPv6 gateway interface name\n"
4187        "Emit an ICMP unreachable when matched\n"
4188        "Silently discard pkts when matched\n"
4189        "Set tag for this route\n"
4190        "Tag value\n"
4191        "Distance value for this prefix\n"
4192        VRF_CMD_HELP_STR)
4193 {
4194   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
4195 }
4196 
4197 DEFUN (ipv6_route_vrf,
4198        ipv6_route_vrf_cmd,
4199        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
4200        IP_STR
4201        "Establish static routes\n"
4202        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4203        "IPv6 gateway address\n"
4204        "IPv6 gateway interface name\n"
4205        VRF_CMD_HELP_STR)
4206 {
4207   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL,
4208                            argv[2]);
4209 }
4210 
4211 DEFUN (ipv6_route_flags_vrf,
4212        ipv6_route_flags_vrf_cmd,
4213        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
4214        IP_STR
4215        "Establish static routes\n"
4216        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4217        "IPv6 gateway address\n"
4218        "IPv6 gateway interface name\n"
4219        "Emit an ICMP unreachable when matched\n"
4220        "Silently discard pkts when matched\n"
4221        VRF_CMD_HELP_STR)
4222 {
4223   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL,
4224                            argv[3]);
4225 }
4226 
4227 DEFUN (ipv6_route_ifname_vrf,
4228        ipv6_route_ifname_vrf_cmd,
4229        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
4230        IP_STR
4231        "Establish static routes\n"
4232        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4233        "IPv6 gateway address\n"
4234        "IPv6 gateway interface name\n"
4235        VRF_CMD_HELP_STR)
4236 {
4237   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL,
4238                            argv[3]);
4239 }
4240 
4241 DEFUN (ipv6_route_ifname_flags_vrf,
4242        ipv6_route_ifname_flags_vrf_cmd,
4243        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
4244        IP_STR
4245        "Establish static routes\n"
4246        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4247        "IPv6 gateway address\n"
4248        "IPv6 gateway interface name\n"
4249        "Emit an ICMP unreachable when matched\n"
4250        "Silently discard pkts when matched\n"
4251        VRF_CMD_HELP_STR)
4252 {
4253   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL,
4254                            argv[4]);
4255 }
4256 
4257 DEFUN (ipv6_route_pref_vrf,
4258        ipv6_route_pref_vrf_cmd,
4259        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
4260        IP_STR
4261        "Establish static routes\n"
4262        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4263        "IPv6 gateway address\n"
4264        "IPv6 gateway interface name\n"
4265        "Distance value for this prefix\n"
4266        VRF_CMD_HELP_STR)
4267 {
4268   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2],
4269                            argv[3]);
4270 }
4271 
4272 DEFUN (ipv6_route_flags_pref_vrf,
4273        ipv6_route_flags_pref_vrf_cmd,
4274        "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
4275        IP_STR
4276        "Establish static routes\n"
4277        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4278        "IPv6 gateway address\n"
4279        "IPv6 gateway interface name\n"
4280        "Emit an ICMP unreachable when matched\n"
4281        "Silently discard pkts when matched\n"
4282        "Distance value for this prefix\n"
4283        VRF_CMD_HELP_STR)
4284 {
4285   return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
4286                            argv[4]);
4287 }
4288 
4289 DEFUN (ipv6_route_ifname_pref_vrf,
4290        ipv6_route_ifname_pref_vrf_cmd,
4291        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
4292        IP_STR
4293        "Establish static routes\n"
4294        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4295        "IPv6 gateway address\n"
4296        "IPv6 gateway interface name\n"
4297        "Distance value for this prefix\n"
4298        VRF_CMD_HELP_STR)
4299 {
4300   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
4301                            argv[4]);
4302 }
4303 
4304 DEFUN (ipv6_route_ifname_flags_pref_vrf,
4305        ipv6_route_ifname_flags_pref_vrf_cmd,
4306        "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
4307        IP_STR
4308        "Establish static routes\n"
4309        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4310        "IPv6 gateway address\n"
4311        "IPv6 gateway interface name\n"
4312        "Emit an ICMP unreachable when matched\n"
4313        "Silently discard pkts when matched\n"
4314        "Distance value for this prefix\n"
4315        VRF_CMD_HELP_STR)
4316 {
4317   return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
4318                            argv[5]);
4319 }
4320 
4321 DEFUN (no_ipv6_route_vrf,
4322        no_ipv6_route_vrf_cmd,
4323        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
4324        NO_STR
4325        IP_STR
4326        "Establish static routes\n"
4327        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4328        "IPv6 gateway address\n"
4329        "IPv6 gateway interface name\n"
4330        VRF_CMD_HELP_STR)
4331 {
4332   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL,
4333                            (argc > 3) ? argv[3] : argv[2]);
4334 }
4335 
4336 ALIAS (no_ipv6_route_vrf,
4337        no_ipv6_route_flags_vrf_cmd,
4338        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
4339        NO_STR
4340        IP_STR
4341        "Establish static routes\n"
4342        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4343        "IPv6 gateway address\n"
4344        "IPv6 gateway interface name\n"
4345        "Emit an ICMP unreachable when matched\n"
4346        "Silently discard pkts when matched\n"
4347        VRF_CMD_HELP_STR)
4348 
4349 DEFUN (no_ipv6_route_ifname_vrf,
4350        no_ipv6_route_ifname_vrf_cmd,
4351        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
4352        NO_STR
4353        IP_STR
4354        "Establish static routes\n"
4355        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4356        "IPv6 gateway address\n"
4357        "IPv6 gateway interface name\n"
4358        VRF_CMD_HELP_STR)
4359 {
4360   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL,
4361                            (argc > 4) ? argv[4] : argv[3]);
4362 }
4363 
4364 ALIAS (no_ipv6_route_ifname_vrf,
4365        no_ipv6_route_ifname_flags_vrf_cmd,
4366        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
4367        NO_STR
4368        IP_STR
4369        "Establish static routes\n"
4370        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4371        "IPv6 gateway address\n"
4372        "IPv6 gateway interface name\n"
4373        "Emit an ICMP unreachable when matched\n"
4374        "Silently discard pkts when matched\n"
4375        VRF_CMD_HELP_STR)
4376 
4377 DEFUN (no_ipv6_route_pref_vrf,
4378        no_ipv6_route_pref_vrf_cmd,
4379        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
4380        NO_STR
4381        IP_STR
4382        "Establish static routes\n"
4383        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4384        "IPv6 gateway address\n"
4385        "IPv6 gateway interface name\n"
4386        "Distance value for this prefix\n"
4387        VRF_CMD_HELP_STR)
4388 {
4389   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2],
4390                            argv[3]);
4391 }
4392 
4393 DEFUN (no_ipv6_route_flags_pref_vrf,
4394        no_ipv6_route_flags_pref_vrf_cmd,
4395        "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
4396        NO_STR
4397        IP_STR
4398        "Establish static routes\n"
4399        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4400        "IPv6 gateway address\n"
4401        "IPv6 gateway interface name\n"
4402        "Emit an ICMP unreachable when matched\n"
4403        "Silently discard pkts when matched\n"
4404        "Distance value for this prefix\n"
4405        VRF_CMD_HELP_STR)
4406 {
4407   /* We do not care about argv[2] */
4408   return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
4409                            argv[4]);
4410 }
4411 
4412 DEFUN (no_ipv6_route_ifname_pref_vrf,
4413        no_ipv6_route_ifname_pref_vrf_cmd,
4414        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
4415        NO_STR
4416        IP_STR
4417        "Establish static routes\n"
4418        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4419        "IPv6 gateway address\n"
4420        "IPv6 gateway interface name\n"
4421        "Distance value for this prefix\n"
4422        VRF_CMD_HELP_STR)
4423 {
4424   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
4425                            argv[4]);
4426 }
4427 
4428 DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
4429        no_ipv6_route_ifname_flags_pref_vrf_cmd,
4430        "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
4431        NO_STR
4432        IP_STR
4433        "Establish static routes\n"
4434        "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4435        "IPv6 gateway address\n"
4436        "IPv6 gateway interface name\n"
4437        "Emit an ICMP unreachable when matched\n"
4438        "Silently discard pkts when matched\n"
4439        "Distance value for this prefix\n"
4440        VRF_CMD_HELP_STR)
4441 {
4442   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
4443                            argv[5]);
4444 }
4445 
4446 DEFUN (show_ipv6_route,
4447        show_ipv6_route_cmd,
4448        "show ipv6 route",
4449        SHOW_STR
4450        IP_STR
4451        "IPv6 routing table\n")
4452 {
4453   struct route_table *table;
4454   struct route_node *rn;
4455   struct rib *rib;
4456   int first = 1;
4457   vrf_id_t vrf_id = VRF_DEFAULT;
4458 
4459   if (argc > 0)
4460     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
4461 
4462   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4463   if (! table)
4464     return CMD_SUCCESS;
4465 
4466   /* Show all IPv6 route. */
4467   for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)4468     RNODE_FOREACH_RIB (rn, rib)
4469       {
4470 	if (first)
4471 	  {
4472 	    vty_out (vty, SHOW_ROUTE_V6_HEADER);
4473 	    first = 0;
4474 	  }
4475 	vty_show_ip_route (vty, rn, rib);
4476       }
4477   return CMD_SUCCESS;
4478 }
4479 
4480 ALIAS (show_ipv6_route,
4481        show_ipv6_route_vrf_cmd,
4482        "show ipv6 route " VRF_CMD_STR,
4483        SHOW_STR
4484        IP_STR
4485        "IPv6 routing table\n"
4486        VRF_CMD_HELP_STR)
4487 
4488 DEFUN (show_ipv6_route_tag,
4489        show_ipv6_route_tag_cmd,
4490        "show ipv6 route tag <1-4294967295>",
4491        SHOW_STR
4492        IP_STR
4493        "IPv6 routing table\n"
4494        "Show only routes with tag\n"
4495        "Tag value\n")
4496 {
4497   struct route_table *table;
4498   struct route_node *rn;
4499   struct rib *rib;
4500   int first = 1;
4501   route_tag_t tag = 0;
4502   vrf_id_t vrf_id = VRF_DEFAULT;
4503 
4504   if (argv[0])
4505     tag = atoi(argv[0]);
4506 
4507   if (argc == 2)
4508     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
4509 
4510   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4511   if (! table)
4512     return CMD_SUCCESS;
4513 
4514   /* Show all IPv6 routes with matching tag value. */
4515   for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)4516     RNODE_FOREACH_RIB (rn, rib)
4517       {
4518         if (rib->tag != tag)
4519           continue;
4520 
4521 	if (first)
4522 	  {
4523 	    vty_out (vty, SHOW_ROUTE_V6_HEADER);
4524 	    first = 0;
4525 	  }
4526 	vty_show_ip_route (vty, rn, rib);
4527       }
4528   return CMD_SUCCESS;
4529 }
4530 
4531 ALIAS (show_ipv6_route_tag,
4532        show_ipv6_route_tag_vrf_cmd,
4533        "show ipv6 route tag <1-4294967295>" VRF_CMD_STR,
4534        SHOW_STR
4535        IP_STR
4536        "IPv6 routing table\n"
4537        "Show only routes with tag\n"
4538        "Tag value\n"
4539        VRF_CMD_HELP_STR)
4540 
4541 DEFUN (show_ipv6_route_prefix_longer,
4542        show_ipv6_route_prefix_longer_cmd,
4543        "show ipv6 route X:X::X:X/M longer-prefixes",
4544        SHOW_STR
4545        IP_STR
4546        "IPv6 routing table\n"
4547        "IPv6 prefix\n"
4548        "Show route matching the specified Network/Mask pair only\n")
4549 {
4550   struct route_table *table;
4551   struct route_node *rn;
4552   struct rib *rib;
4553   struct prefix p;
4554   int ret;
4555   int first = 1;
4556   vrf_id_t vrf_id = VRF_DEFAULT;
4557 
4558   ret = str2prefix (argv[0], &p);
4559   if (! ret)
4560     {
4561       vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
4562       return CMD_WARNING;
4563     }
4564 
4565   if (argc > 1)
4566     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
4567 
4568   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4569   if (! table)
4570     return CMD_SUCCESS;
4571 
4572   /* Show matched type IPv6 routes. */
4573   for (rn = route_top (table); rn; rn = route_next (rn))
4574     RNODE_FOREACH_RIB (rn, rib)
4575       if (prefix_match (&p, &rn->p))
4576 	{
4577 	  if (first)
4578 	    {
4579 	      vty_out (vty, SHOW_ROUTE_V6_HEADER);
4580 	      first = 0;
4581 	    }
4582 	  vty_show_ip_route (vty, rn, rib);
4583 	}
4584   return CMD_SUCCESS;
4585 }
4586 
4587 ALIAS (show_ipv6_route_prefix_longer,
4588        show_ipv6_route_prefix_longer_vrf_cmd,
4589        "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
4590        SHOW_STR
4591        IP_STR
4592        "IPv6 routing table\n"
4593        "IPv6 prefix\n"
4594        "Show route matching the specified Network/Mask pair only\n"
4595        VRF_CMD_HELP_STR)
4596 
4597 DEFUN (show_ipv6_route_protocol,
4598        show_ipv6_route_protocol_cmd,
4599        "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
4600        SHOW_STR
4601        IP_STR
4602        "IP routing table\n"
4603 	QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
4604 {
4605   int type;
4606   struct route_table *table;
4607   struct route_node *rn;
4608   struct rib *rib;
4609   int first = 1;
4610   vrf_id_t vrf_id = VRF_DEFAULT;
4611 
4612   type = proto_redistnum (AFI_IP6, argv[0]);
4613   if (type < 0)
4614     {
4615       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
4616       return CMD_WARNING;
4617     }
4618 
4619   if (argc > 1)
4620     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
4621 
4622   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4623   if (! table)
4624     return CMD_SUCCESS;
4625 
4626   /* Show matched type IPv6 routes. */
4627   for (rn = route_top (table); rn; rn = route_next (rn))
4628     RNODE_FOREACH_RIB (rn, rib)
4629       if (rib->type == type)
4630 	{
4631 	  if (first)
4632 	    {
4633 	      vty_out (vty, SHOW_ROUTE_V6_HEADER);
4634 	      first = 0;
4635 	    }
4636 	  vty_show_ip_route (vty, rn, rib);
4637 	}
4638   return CMD_SUCCESS;
4639 }
4640 
4641 ALIAS (show_ipv6_route_protocol,
4642        show_ipv6_route_protocol_vrf_cmd,
4643        "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
4644        SHOW_STR
4645        IP_STR
4646        "IP routing table\n"
4647        QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
4648        VRF_CMD_HELP_STR)
4649 
4650 DEFUN (show_ipv6_route_addr,
4651        show_ipv6_route_addr_cmd,
4652        "show ipv6 route X:X::X:X",
4653        SHOW_STR
4654        IP_STR
4655        "IPv6 routing table\n"
4656        "IPv6 Address\n")
4657 {
4658   int ret;
4659   struct prefix_ipv6 p;
4660   struct route_table *table;
4661   struct route_node *rn;
4662   vrf_id_t vrf_id = VRF_DEFAULT;
4663 
4664   ret = str2prefix_ipv6 (argv[0], &p);
4665   if (ret <= 0)
4666     {
4667       vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
4668       return CMD_WARNING;
4669     }
4670 
4671   if (argc > 1)
4672     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
4673 
4674   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4675   if (! table)
4676     return CMD_SUCCESS;
4677 
4678   rn = route_node_match (table, (struct prefix *) &p);
4679   if (! rn)
4680     {
4681       vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
4682       return CMD_WARNING;
4683     }
4684 
4685   vty_show_ip_route_detail (vty, rn, 0);
4686 
4687   route_unlock_node (rn);
4688 
4689   return CMD_SUCCESS;
4690 }
4691 
4692 ALIAS (show_ipv6_route_addr,
4693        show_ipv6_route_addr_vrf_cmd,
4694        "show ipv6 route X:X::X:X " VRF_CMD_STR,
4695        SHOW_STR
4696        IP_STR
4697        "IPv6 routing table\n"
4698        "IPv6 Address\n"
4699        VRF_CMD_HELP_STR)
4700 
4701 DEFUN (show_ipv6_route_prefix,
4702        show_ipv6_route_prefix_cmd,
4703        "show ipv6 route X:X::X:X/M",
4704        SHOW_STR
4705        IP_STR
4706        "IPv6 routing table\n"
4707        "IPv6 prefix\n")
4708 {
4709   int ret;
4710   struct prefix_ipv6 p;
4711   struct route_table *table;
4712   struct route_node *rn;
4713   vrf_id_t vrf_id = VRF_DEFAULT;
4714 
4715   ret = str2prefix_ipv6 (argv[0], &p);
4716   if (ret <= 0)
4717     {
4718       vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
4719       return CMD_WARNING;
4720     }
4721 
4722   if (argc > 1)
4723     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
4724 
4725   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4726   if (! table)
4727     return CMD_SUCCESS;
4728 
4729   rn = route_node_match (table, (struct prefix *) &p);
4730   if (! rn || rn->p.prefixlen != p.prefixlen)
4731     {
4732       vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
4733       if (rn)
4734         route_unlock_node (rn);
4735       return CMD_WARNING;
4736     }
4737 
4738   vty_show_ip_route_detail (vty, rn, 0);
4739 
4740   route_unlock_node (rn);
4741 
4742   return CMD_SUCCESS;
4743 }
4744 
4745 ALIAS (show_ipv6_route_prefix,
4746        show_ipv6_route_prefix_vrf_cmd,
4747        "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
4748        SHOW_STR
4749        IP_STR
4750        "IPv6 routing table\n"
4751        "IPv6 prefix\n"
4752        VRF_CMD_HELP_STR)
4753 
4754 /* Show route summary.  */
4755 DEFUN (show_ipv6_route_summary,
4756        show_ipv6_route_summary_cmd,
4757        "show ipv6 route summary",
4758        SHOW_STR
4759        IP_STR
4760        "IPv6 routing table\n"
4761        "Summary of all IPv6 routes\n")
4762 {
4763   struct route_table *table;
4764   vrf_id_t vrf_id = VRF_DEFAULT;
4765 
4766   if (argc > 0)
4767     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
4768 
4769   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4770   if (! table)
4771     return CMD_SUCCESS;
4772 
4773   vty_show_ip_route_summary (vty, table);
4774 
4775   return CMD_SUCCESS;
4776 }
4777 
4778 ALIAS (show_ipv6_route_summary,
4779        show_ipv6_route_summary_vrf_cmd,
4780        "show ipv6 route summary " VRF_CMD_STR,
4781        SHOW_STR
4782        IP_STR
4783        "IPv6 routing table\n"
4784        "Summary of all IPv6 routes\n"
4785        VRF_CMD_HELP_STR)
4786 
4787 /* Show ipv6 route summary prefix.  */
4788 DEFUN (show_ipv6_route_summary_prefix,
4789        show_ipv6_route_summary_prefix_cmd,
4790        "show ipv6 route summary prefix",
4791        SHOW_STR
4792        IP_STR
4793        "IPv6 routing table\n"
4794        "Summary of all IPv6 routes\n"
4795        "Prefix routes\n")
4796 {
4797   struct route_table *table;
4798   vrf_id_t vrf_id = VRF_DEFAULT;
4799 
4800   if (argc > 0)
4801     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
4802 
4803   table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4804   if (! table)
4805     return CMD_SUCCESS;
4806 
4807   vty_show_ip_route_summary_prefix (vty, table);
4808 
4809   return CMD_SUCCESS;
4810 }
4811 
4812 ALIAS (show_ipv6_route_summary_prefix,
4813        show_ipv6_route_summary_prefix_vrf_cmd,
4814        "show ipv6 route summary prefix " VRF_CMD_STR,
4815        SHOW_STR
4816        IP_STR
4817        "IPv6 routing table\n"
4818        "Summary of all IPv6 routes\n"
4819        "Prefix routes\n"
4820        VRF_CMD_HELP_STR)
4821 
4822 /*
4823  * Show IPv6 mroute command.Used to dump
4824  * the Multicast routing table.
4825  */
4826 
4827 DEFUN (show_ipv6_mroute,
4828        show_ipv6_mroute_cmd,
4829        "show ipv6 mroute",
4830        SHOW_STR
4831        IP_STR
4832        "IPv6 Multicast routing table\n")
4833 {
4834   struct route_table *table;
4835   struct route_node *rn;
4836   struct rib *rib;
4837   int first = 1;
4838   vrf_id_t vrf_id = VRF_DEFAULT;
4839 
4840   if (argc > 0)
4841     VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
4842 
4843   table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
4844   if (! table)
4845     return CMD_SUCCESS;
4846 
4847   /* Show all IPv6 route. */
4848   for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)4849     RNODE_FOREACH_RIB (rn, rib)
4850       {
4851        if (first)
4852          {
4853 	   vty_out (vty, SHOW_ROUTE_V6_HEADER);
4854            first = 0;
4855          }
4856        vty_show_ip_route (vty, rn, rib);
4857       }
4858   return CMD_SUCCESS;
4859 }
4860 
4861 ALIAS (show_ipv6_mroute,
4862        show_ipv6_mroute_vrf_cmd,
4863        "show ipv6 mroute " VRF_CMD_STR,
4864        SHOW_STR
4865        IP_STR
4866        "IPv6 Multicast routing table\n"
4867        VRF_CMD_HELP_STR)
4868 
4869 DEFUN (show_ipv6_route_vrf_all,
4870        show_ipv6_route_vrf_all_cmd,
4871        "show ipv6 route " VRF_ALL_CMD_STR,
4872        SHOW_STR
4873        IP_STR
4874        "IPv6 routing table\n"
4875        VRF_ALL_CMD_HELP_STR)
4876 {
4877   struct route_table *table;
4878   struct route_node *rn;
4879   struct rib *rib;
4880   struct zebra_vrf *zvrf;
4881   vrf_iter_t iter;
4882   int first = 1;
4883 
4884   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
4885     {
4886       if ((zvrf = vrf_iter2info (iter)) == NULL ||
4887           (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
4888         continue;
4889 
4890       /* Show all IPv6 route. */
4891       for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)4892         RNODE_FOREACH_RIB (rn, rib)
4893           {
4894             if (first)
4895               {
4896                 vty_out (vty, SHOW_ROUTE_V6_HEADER);
4897                 first = 0;
4898               }
4899             vty_show_ip_route (vty, rn, rib);
4900           }
4901     }
4902 
4903   return CMD_SUCCESS;
4904 }
4905 
4906 DEFUN (show_ipv6_route_prefix_longer_vrf_all,
4907        show_ipv6_route_prefix_longer_vrf_all_cmd,
4908        "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
4909        SHOW_STR
4910        IP_STR
4911        "IPv6 routing table\n"
4912        "IPv6 prefix\n"
4913        "Show route matching the specified Network/Mask pair only\n"
4914        VRF_ALL_CMD_HELP_STR)
4915 {
4916   struct route_table *table;
4917   struct route_node *rn;
4918   struct rib *rib;
4919   struct prefix p;
4920   struct zebra_vrf *zvrf;
4921   vrf_iter_t iter;
4922   int ret;
4923   int first = 1;
4924 
4925   ret = str2prefix (argv[0], &p);
4926   if (! ret)
4927     {
4928       vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
4929       return CMD_WARNING;
4930     }
4931 
4932   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
4933     {
4934       if ((zvrf = vrf_iter2info (iter)) == NULL ||
4935           (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
4936         continue;
4937 
4938       /* Show matched type IPv6 routes. */
4939       for (rn = route_top (table); rn; rn = route_next (rn))
4940         RNODE_FOREACH_RIB (rn, rib)
4941           if (prefix_match (&p, &rn->p))
4942             {
4943               if (first)
4944                 {
4945                   vty_out (vty, SHOW_ROUTE_V6_HEADER);
4946                   first = 0;
4947                 }
4948               vty_show_ip_route (vty, rn, rib);
4949             }
4950     }
4951 
4952   return CMD_SUCCESS;
4953 }
4954 
4955 DEFUN (show_ipv6_route_protocol_vrf_all,
4956        show_ipv6_route_protocol_vrf_all_cmd,
4957        "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
4958        SHOW_STR
4959        IP_STR
4960        "IP routing table\n"
4961        QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
4962        VRF_ALL_CMD_HELP_STR)
4963 {
4964   int type;
4965   struct route_table *table;
4966   struct route_node *rn;
4967   struct rib *rib;
4968   struct zebra_vrf *zvrf;
4969   vrf_iter_t iter;
4970   int first = 1;
4971 
4972   type = proto_redistnum (AFI_IP6, argv[0]);
4973   if (type < 0)
4974     {
4975       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
4976       return CMD_WARNING;
4977     }
4978 
4979   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
4980     {
4981       if ((zvrf = vrf_iter2info (iter)) == NULL ||
4982           (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
4983         continue;
4984 
4985       /* Show matched type IPv6 routes. */
4986       for (rn = route_top (table); rn; rn = route_next (rn))
4987         RNODE_FOREACH_RIB (rn, rib)
4988           if (rib->type == type)
4989             {
4990               if (first)
4991                 {
4992                   vty_out (vty, SHOW_ROUTE_V6_HEADER);
4993                   first = 0;
4994                 }
4995               vty_show_ip_route (vty, rn, rib);
4996             }
4997     }
4998 
4999   return CMD_SUCCESS;
5000 }
5001 
5002 DEFUN (show_ipv6_route_addr_vrf_all,
5003        show_ipv6_route_addr_vrf_all_cmd,
5004        "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
5005        SHOW_STR
5006        IP_STR
5007        "IPv6 routing table\n"
5008        "IPv6 Address\n"
5009        VRF_ALL_CMD_HELP_STR)
5010 {
5011   int ret;
5012   struct prefix_ipv6 p;
5013   struct route_table *table;
5014   struct route_node *rn;
5015   struct zebra_vrf *zvrf;
5016   vrf_iter_t iter;
5017 
5018   ret = str2prefix_ipv6 (argv[0], &p);
5019   if (ret <= 0)
5020     {
5021       vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
5022       return CMD_WARNING;
5023     }
5024 
5025   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5026     {
5027       if ((zvrf = vrf_iter2info (iter)) == NULL ||
5028           (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5029         continue;
5030 
5031       rn = route_node_match (table, (struct prefix *) &p);
5032       if (! rn)
5033         continue;
5034 
5035       vty_show_ip_route_detail (vty, rn, 0);
5036 
5037       route_unlock_node (rn);
5038     }
5039 
5040   return CMD_SUCCESS;
5041 }
5042 
5043 DEFUN (show_ipv6_route_prefix_vrf_all,
5044        show_ipv6_route_prefix_vrf_all_cmd,
5045        "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
5046        SHOW_STR
5047        IP_STR
5048        "IPv6 routing table\n"
5049        "IPv6 prefix\n"
5050        VRF_ALL_CMD_HELP_STR)
5051 {
5052   int ret;
5053   struct prefix_ipv6 p;
5054   struct route_table *table;
5055   struct route_node *rn;
5056   struct zebra_vrf *zvrf;
5057   vrf_iter_t iter;
5058 
5059   ret = str2prefix_ipv6 (argv[0], &p);
5060   if (ret <= 0)
5061     {
5062       vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
5063       return CMD_WARNING;
5064     }
5065 
5066   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5067     {
5068       if ((zvrf = vrf_iter2info (iter)) == NULL ||
5069           (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5070         continue;
5071 
5072       rn = route_node_match (table, (struct prefix *) &p);
5073       if (! rn)
5074         continue;
5075       if (rn->p.prefixlen != p.prefixlen)
5076         {
5077           route_unlock_node (rn);
5078           continue;
5079         }
5080 
5081       vty_show_ip_route_detail (vty, rn, 0);
5082 
5083       route_unlock_node (rn);
5084     }
5085 
5086   return CMD_SUCCESS;
5087 }
5088 
5089 /* Show route summary.  */
5090 DEFUN (show_ipv6_route_summary_vrf_all,
5091        show_ipv6_route_summary_vrf_all_cmd,
5092        "show ipv6 route summary " VRF_ALL_CMD_STR,
5093        SHOW_STR
5094        IP_STR
5095        "IPv6 routing table\n"
5096        "Summary of all IPv6 routes\n"
5097        VRF_ALL_CMD_HELP_STR)
5098 {
5099   struct zebra_vrf *zvrf;
5100   vrf_iter_t iter;
5101 
5102   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5103     if ((zvrf = vrf_iter2info (iter)) != NULL)
5104       vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
5105 
5106   return CMD_SUCCESS;
5107 }
5108 
5109 DEFUN (show_ipv6_mroute_vrf_all,
5110        show_ipv6_mroute_vrf_all_cmd,
5111        "show ipv6 mroute " VRF_ALL_CMD_STR,
5112        SHOW_STR
5113        IP_STR
5114        "IPv6 Multicast routing table\n"
5115        VRF_ALL_CMD_HELP_STR)
5116 {
5117   struct route_table *table;
5118   struct route_node *rn;
5119   struct rib *rib;
5120   struct zebra_vrf *zvrf;
5121   vrf_iter_t iter;
5122   int first = 1;
5123 
5124   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5125     {
5126       if ((zvrf = vrf_iter2info (iter)) == NULL ||
5127           (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5128         continue;
5129 
5130       /* Show all IPv6 route. */
5131       for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB(rn,rib)5132         RNODE_FOREACH_RIB (rn, rib)
5133           {
5134            if (first)
5135              {
5136                vty_out (vty, SHOW_ROUTE_V6_HEADER);
5137                first = 0;
5138              }
5139            vty_show_ip_route (vty, rn, rib);
5140           }
5141     }
5142   return CMD_SUCCESS;
5143 }
5144 
5145 DEFUN (show_ipv6_route_summary_prefix_vrf_all,
5146        show_ipv6_route_summary_prefix_vrf_all_cmd,
5147        "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
5148        SHOW_STR
5149        IP_STR
5150        "IPv6 routing table\n"
5151        "Summary of all IPv6 routes\n"
5152        "Prefix routes\n"
5153        VRF_ALL_CMD_HELP_STR)
5154 {
5155   struct zebra_vrf *zvrf;
5156   vrf_iter_t iter;
5157 
5158   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5159     if ((zvrf = vrf_iter2info (iter)) != NULL)
5160       vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
5161 
5162   return CMD_SUCCESS;
5163 }
5164 
5165 /* Write IPv6 static route configuration. */
5166 static int
static_config_ipv6(struct vty * vty)5167 static_config_ipv6 (struct vty *vty)
5168 {
5169   struct route_node *rn;
5170   struct static_route *si;
5171   int write;
5172   char buf[BUFSIZ];
5173   struct route_table *stable;
5174   struct zebra_vrf *zvrf;
5175   vrf_iter_t iter;
5176 
5177   write = 0;
5178 
5179   for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5180     {
5181       if ((zvrf = vrf_iter2info (iter)) == NULL ||
5182           (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
5183         continue;
5184 
5185       for (rn = route_top (stable); rn; rn = route_next (rn))
5186         for (si = rn->info; si; si = si->next)
5187           {
5188             vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
5189 
5190             switch (si->type)
5191               {
5192               case STATIC_IPV6_GATEWAY:
5193                 vty_out (vty, " %s",
5194                          inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
5195                 break;
5196               case STATIC_IPV6_IFNAME:
5197                 vty_out (vty, " %s", si->ifname);
5198                 break;
5199               case STATIC_IPV6_GATEWAY_IFNAME:
5200                 vty_out (vty, " %s %s",
5201                          inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
5202                          si->ifname);
5203                 break;
5204               }
5205 
5206             if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
5207               vty_out (vty, " %s", "reject");
5208 
5209             if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
5210               vty_out (vty, " %s", "blackhole");
5211 
5212 	    if (si->tag)
5213 	      vty_out (vty, " tag %d", si->tag);
5214 
5215             if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
5216               vty_out (vty, " %d", si->distance);
5217 
5218             if (si->vrf_id != VRF_DEFAULT)
5219               vty_out (vty, " vrf %u", si->vrf_id);
5220 
5221             vty_out (vty, "%s", VTY_NEWLINE);
5222 
5223             write = 1;
5224           }
5225     }
5226   return write;
5227 }
5228 
5229 /* Static ip route configuration write function. */
5230 static int
zebra_ip_config(struct vty * vty)5231 zebra_ip_config (struct vty *vty)
5232 {
5233   int write = 0;
5234 
5235   write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
5236   write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
5237 #ifdef HAVE_IPV6
5238   write += static_config_ipv6 (vty);
5239 #endif /* HAVE_IPV6 */
5240 
5241   return write;
5242 }
5243 
config_write_vty(struct vty * vty)5244 static int config_write_vty(struct vty *vty)
5245 {
5246   int i;
5247   enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
5248 
5249   if (ipv4_multicast_mode != MCAST_NO_CONFIG)
5250     vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
5251              ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
5252              ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
5253              ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
5254              ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
5255              "longer-prefix",
5256              VTY_NEWLINE);
5257 
5258   for (i=0;i<ZEBRA_ROUTE_MAX;i++)
5259     {
5260       if (proto_rm[AFI_IP][i])
5261         vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
5262                  proto_rm[AFI_IP][i], VTY_NEWLINE);
5263     }
5264   if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
5265       vty_out (vty, "ip protocol %s route-map %s%s", "any",
5266                proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
5267 
5268   return 1;
5269 }
5270 
5271 /* table node for protocol filtering */
5272 static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
5273 
5274 /* IP node for static routes. */
5275 static struct cmd_node ip_node = { IP_NODE,  "",  1 };
5276 
5277 /* Route VTY.  */
5278 void
zebra_vty_init(void)5279 zebra_vty_init (void)
5280 {
5281   install_node (&ip_node, zebra_ip_config);
5282   install_node (&protocol_node, config_write_vty);
5283 
5284   install_element (CONFIG_NODE, &ip_mroute_cmd);
5285   install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
5286   install_element (CONFIG_NODE, &no_ip_mroute_cmd);
5287   install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
5288   install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
5289   install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
5290   install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
5291   install_element (CONFIG_NODE, &ip_protocol_cmd);
5292   install_element (CONFIG_NODE, &no_ip_protocol_cmd);
5293   install_element (VIEW_NODE, &show_ip_protocol_cmd);
5294   install_element (CONFIG_NODE, &ip_route_cmd);
5295   install_element (CONFIG_NODE, &ip_route_tag_cmd);
5296   install_element (CONFIG_NODE, &ip_route_flags_cmd);
5297   install_element (CONFIG_NODE, &ip_route_flags_tag_cmd);
5298   install_element (CONFIG_NODE, &ip_route_flags_tag_vrf_cmd);
5299   install_element (CONFIG_NODE, &ip_route_flags2_cmd);
5300   install_element (CONFIG_NODE, &ip_route_flags2_tag_cmd);
5301   install_element (CONFIG_NODE, &ip_route_flags2_tag_vrf_cmd);
5302   install_element (CONFIG_NODE, &ip_route_mask_cmd);
5303   install_element (CONFIG_NODE, &ip_route_mask_tag_cmd);
5304   install_element (CONFIG_NODE, &ip_route_mask_tag_vrf_cmd);
5305   install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
5306   install_element (CONFIG_NODE, &ip_route_mask_flags_tag_cmd);
5307   install_element (CONFIG_NODE, &ip_route_mask_flags_tag_vrf_cmd);
5308   install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
5309   install_element (CONFIG_NODE, &ip_route_mask_flags2_tag_cmd);
5310   install_element (CONFIG_NODE, &ip_route_mask_flags2_tag_vrf_cmd);
5311   install_element (CONFIG_NODE, &no_ip_route_cmd);
5312   install_element (CONFIG_NODE, &no_ip_route_tag_cmd);
5313   install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
5314   install_element (CONFIG_NODE, &no_ip_route_flags_tag_cmd);
5315   install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
5316   install_element (CONFIG_NODE, &no_ip_route_flags2_tag_cmd);
5317   install_element (CONFIG_NODE, &no_ip_route_flags2_tag_vrf_cmd);
5318   install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
5319   install_element (CONFIG_NODE, &no_ip_route_mask_tag_cmd);
5320   install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
5321   install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_cmd);
5322   install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
5323   install_element (CONFIG_NODE, &no_ip_route_mask_flags2_tag_cmd);
5324   install_element (CONFIG_NODE, &no_ip_route_mask_flags2_tag_vrf_cmd);
5325   install_element (CONFIG_NODE, &ip_route_distance_cmd);
5326   install_element (CONFIG_NODE, &ip_route_tag_distance_cmd);
5327   install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
5328   install_element (CONFIG_NODE, &ip_route_flags_tag_distance_cmd);
5329   install_element (CONFIG_NODE, &ip_route_flags_tag_distance_vrf_cmd);
5330   install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
5331   install_element (CONFIG_NODE, &ip_route_flags_tag_distance2_cmd);
5332   install_element (CONFIG_NODE, &ip_route_flags_tag_distance2_vrf_cmd);
5333   install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
5334   install_element (CONFIG_NODE, &ip_route_mask_tag_distance_cmd);
5335   install_element (CONFIG_NODE, &ip_route_mask_tag_distance_vrf_cmd);
5336   install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
5337   install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance_cmd);
5338   install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance_vrf_cmd);
5339   install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
5340   install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance2_cmd);
5341   install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance2_vrf_cmd);
5342   install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
5343   install_element (CONFIG_NODE, &no_ip_route_tag_distance_cmd);
5344   install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
5345   install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance_cmd);
5346   install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance_vrf_cmd);
5347   install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
5348   install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance2_cmd);
5349   install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance2_vrf_cmd);
5350   install_element (CONFIG_NODE, &no_ip_route_mask_distance_cmd);
5351   install_element (CONFIG_NODE, &no_ip_route_mask_tag_distance_cmd);
5352   install_element (CONFIG_NODE, &no_ip_route_mask_tag_distance_vrf_cmd);
5353   install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
5354   install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance_cmd);
5355   install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance_vrf_cmd);
5356   install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
5357   install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance2_cmd);
5358   install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance2_vrf_cmd);
5359 
5360   install_element (VIEW_NODE, &show_ip_route_cmd);
5361   install_element (VIEW_NODE, &show_ip_route_tag_cmd);
5362   install_element (VIEW_NODE, &show_ip_route_tag_vrf_cmd);
5363   install_element (VIEW_NODE, &show_ip_nht_cmd);
5364   install_element (VIEW_NODE, &show_ipv6_nht_cmd);
5365   install_element (VIEW_NODE, &show_ip_route_addr_cmd);
5366   install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
5367   install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
5368   install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
5369   install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
5370   install_element (VIEW_NODE, &show_ip_route_summary_cmd);
5371   install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
5372 
5373   install_element (VIEW_NODE, &show_ip_rpf_cmd);
5374   install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
5375 
5376   /* Commands for VRF */
5377 
5378   install_element (CONFIG_NODE, &ip_mroute_vrf_cmd);
5379   install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd);
5380   install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd);
5381   install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd);
5382 
5383   install_element (CONFIG_NODE, &ip_route_vrf_cmd);
5384   install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
5385   install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
5386   install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
5387   install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
5388   install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
5389   install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
5390   install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
5391   install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
5392   install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
5393   install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
5394   install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
5395   install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
5396   install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
5397   install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
5398   install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
5399   install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
5400   install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
5401   install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
5402   install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
5403   install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
5404   install_element (CONFIG_NODE, &no_ip_route_mask_distance_vrf_cmd);
5405   install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
5406   install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
5407 
5408   install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
5409   install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
5410   install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
5411   install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
5412   install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
5413   install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
5414   install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
5415   install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
5416 
5417   install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
5418   install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
5419   install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
5420   install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
5421   install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
5422   install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
5423   install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
5424   install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
5425 
5426   install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd);
5427   install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd);
5428   install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd);
5429   install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd);
5430 
5431   install_element (CONFIG_NODE, &ipv6_route_cmd);
5432   install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
5433   install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
5434   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
5435   install_element (CONFIG_NODE, &no_ipv6_route_cmd);
5436   install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
5437   install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
5438   install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
5439   install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
5440   install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
5441   install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
5442   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
5443   install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
5444   install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
5445   install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
5446   install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
5447   install_element (CONFIG_NODE, &ipv6_route_tag_cmd);
5448   install_element (CONFIG_NODE, &ipv6_route_tag_vrf_cmd);
5449   install_element (CONFIG_NODE, &ipv6_route_flags_tag_cmd);
5450   install_element (CONFIG_NODE, &ipv6_route_flags_tag_vrf_cmd);
5451   install_element (CONFIG_NODE, &ipv6_route_ifname_tag_cmd);
5452   install_element (CONFIG_NODE, &ipv6_route_ifname_tag_vrf_cmd);
5453   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_tag_cmd);
5454   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_tag_vrf_cmd);
5455   install_element (CONFIG_NODE, &ipv6_route_pref_tag_cmd);
5456   install_element (CONFIG_NODE, &ipv6_route_pref_tag_vrf_cmd);
5457   install_element (CONFIG_NODE, &ipv6_route_flags_pref_tag_cmd);
5458   install_element (CONFIG_NODE, &ipv6_route_flags_pref_tag_vrf_cmd);
5459   install_element (CONFIG_NODE, &ipv6_route_ifname_pref_tag_cmd);
5460   install_element (CONFIG_NODE, &ipv6_route_ifname_pref_tag_vrf_cmd);
5461   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_tag_cmd);
5462   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_tag_vrf_cmd);
5463   install_element (CONFIG_NODE, &no_ipv6_route_tag_cmd);
5464   install_element (CONFIG_NODE, &no_ipv6_route_tag_vrf_cmd);
5465   install_element (CONFIG_NODE, &no_ipv6_route_flags_tag_cmd);
5466   install_element (CONFIG_NODE, &no_ipv6_route_ifname_tag_cmd);
5467   install_element (CONFIG_NODE, &no_ipv6_route_ifname_tag_vrf_cmd);
5468   install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_tag_cmd);
5469   install_element (CONFIG_NODE, &no_ipv6_route_pref_tag_cmd);
5470   install_element (CONFIG_NODE, &no_ipv6_route_pref_tag_vrf_cmd);
5471   install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_tag_cmd);
5472   install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_tag_vrf_cmd);
5473   install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_cmd);
5474   install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_vrf_cmd);
5475   install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_tag_cmd);
5476   install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_tag_vrf_cmd);
5477   install_element (VIEW_NODE, &show_ipv6_route_cmd);
5478   install_element (VIEW_NODE, &show_ipv6_route_tag_cmd);
5479   install_element (VIEW_NODE, &show_ipv6_route_tag_vrf_cmd);
5480   install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
5481   install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
5482   install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
5483   install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
5484   install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
5485   install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
5486 
5487   install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
5488 
5489   /* Commands for VRF */
5490 
5491   install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
5492   install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
5493   install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
5494   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
5495   install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
5496   install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
5497   install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
5498   install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
5499   install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
5500   install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
5501   install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
5502   install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
5503   install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
5504   install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
5505   install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
5506   install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
5507 
5508   install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
5509   install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
5510   install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
5511   install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
5512   install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
5513   install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
5514   install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
5515 
5516   install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
5517   install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
5518   install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
5519   install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
5520   install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
5521   install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
5522   install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
5523 
5524   install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
5525 
5526   install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
5527   install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
5528 }
5529