]> git.proxmox.com Git - mirror_frr.git/blame - staticd/static_vty.c
python: Make FRR build compatible with python 2.7 and 3.x
[mirror_frr.git] / staticd / static_vty.c
CommitLineData
7e24fdf3
DS
1/*
2 * STATICd - vty code
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Donald Sharp
5 *
8d5cbee9
DS
6 * This program 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 Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
7e24fdf3 10 *
8d5cbee9
DS
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
7e24fdf3
DS
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <zebra.h>
21
22#include "command.h"
23#include "vty.h"
24#include "vrf.h"
25#include "prefix.h"
26#include "nexthop.h"
27#include "table.h"
28#include "srcdest_table.h"
29#include "mpls.h"
88fa5104 30#include "northbound.h"
31#include "libfrr.h"
32#include "routing_nb.h"
33#include "northbound_cli.h"
7e24fdf3
DS
34
35#include "static_vrf.h"
36#include "static_memory.h"
37#include "static_vty.h"
38#include "static_routes.h"
31ddf3b7 39#include "static_debug.h"
7e24fdf3
DS
40#ifndef VTYSH_EXTRACT_PL
41#include "staticd/static_vty_clippy.c"
42#endif
88fa5104 43#include "static_nb.h"
31ddf3b7
MS
44
45#define STATICD_STR "Static route daemon\n"
46
88fa5104 47static int static_route_leak(struct vty *vty, const char *svrf,
48 const char *nh_svrf, afi_t afi, safi_t safi,
49 const char *negate, const char *dest_str,
50 const char *mask_str, const char *src_str,
51 const char *gate_str, const char *ifname,
52 const char *flag_str, const char *tag_str,
53 const char *distance_str, const char *label_str,
065276ae
SM
54 const char *table_str, bool onlink,
55 const char *color_str)
7e24fdf3 56{
7e24fdf3 57 int ret;
7e24fdf3 58 struct prefix p, src;
7e24fdf3 59 struct in_addr mask;
7e24fdf3 60 uint8_t type;
88fa5104 61 const char *bh_type;
62 char xpath_prefix[XPATH_MAXLEN];
63 char xpath_nexthop[XPATH_MAXLEN];
64 char xpath_mpls[XPATH_MAXLEN];
65 char xpath_label[XPATH_MAXLEN];
66 char ab_xpath[XPATH_MAXLEN];
67 char buf_prefix[PREFIX_STRLEN];
68 char buf_src_prefix[PREFIX_STRLEN];
69 char buf_nh_type[PREFIX_STRLEN];
70 char buf_tag[PREFIX_STRLEN];
71 char buf_tableid[PREFIX_STRLEN];
72 uint8_t label_stack_id = 0;
73 const char *buf_gate_str;
74 uint8_t distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
75 route_tag_t tag = 0;
7e24fdf3 76 uint32_t table_id = 0;
88fa5104 77 const struct lyd_node *dnode;
78
79 memset(buf_src_prefix, 0, PREFIX_STRLEN);
80 memset(buf_nh_type, 0, PREFIX_STRLEN);
7e24fdf3
DS
81
82 ret = str2prefix(dest_str, &p);
83 if (ret <= 0) {
84 if (vty)
85 vty_out(vty, "%% Malformed address\n");
86 else
15569c58
DA
87 zlog_warn("%s: Malformed address: %s", __func__,
88 dest_str);
7e24fdf3
DS
89 return CMD_WARNING_CONFIG_FAILED;
90 }
91
92 switch (afi) {
93 case AFI_IP:
94 /* Cisco like mask notation. */
95 if (mask_str) {
96 ret = inet_aton(mask_str, &mask);
97 if (ret == 0) {
98 if (vty)
99 vty_out(vty, "%% Malformed address\n");
100 else
101 zlog_warn("%s: Malformed address: %s",
15569c58 102 __func__, mask_str);
7e24fdf3
DS
103 return CMD_WARNING_CONFIG_FAILED;
104 }
105 p.prefixlen = ip_masklen(mask);
106 }
107 break;
108 case AFI_IP6:
109 /* srcdest routing */
110 if (src_str) {
111 ret = str2prefix(src_str, &src);
112 if (ret <= 0 || src.family != AF_INET6) {
113 if (vty)
114 vty_out(vty,
115 "%% Malformed source address\n");
116 else
117 zlog_warn(
8d5cbee9 118 "%s: Malformed source address: %s",
15569c58 119 __func__, src_str);
7e24fdf3
DS
120 return CMD_WARNING_CONFIG_FAILED;
121 }
7e24fdf3
DS
122 }
123 break;
124 default:
125 break;
126 }
127
128 /* Apply mask for given prefix. */
129 apply_mask(&p);
130
88fa5104 131 prefix2str(&p, buf_prefix, sizeof(buf_prefix));
7e24fdf3 132
88fa5104 133 if (src_str)
134 prefix2str(&src, buf_src_prefix, sizeof(buf_src_prefix));
135 if (gate_str)
136 buf_gate_str = gate_str;
137 else
138 buf_gate_str = "";
139
140 if (gate_str == NULL && ifname == NULL)
141 type = STATIC_BLACKHOLE;
142 else if (gate_str && ifname) {
143 if (afi == AFI_IP)
144 type = STATIC_IPV4_GATEWAY_IFNAME;
145 else
146 type = STATIC_IPV6_GATEWAY_IFNAME;
147 } else if (ifname)
148 type = STATIC_IFNAME;
149 else {
150 if (afi == AFI_IP)
151 type = STATIC_IPV4_GATEWAY;
152 else
153 type = STATIC_IPV6_GATEWAY;
7e24fdf3
DS
154 }
155
156 /* Administrative distance. */
157 if (distance_str)
158 distance = atoi(distance_str);
159 else
160 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
161
162 /* tag */
163 if (tag_str)
164 tag = strtoul(tag_str, NULL, 10);
165
7e24fdf3
DS
166 /* TableID */
167 if (table_str)
168 table_id = atol(table_str);
169
88fa5104 170 static_get_nh_type(type, buf_nh_type, PREFIX_STRLEN);
171 if (!negate) {
172 /* route + path procesing */
173 if (src_str)
174 snprintf(xpath_prefix, sizeof(xpath_prefix),
175 FRR_S_ROUTE_SRC_INFO_KEY_XPATH,
176 "frr-staticd:staticd", "staticd", svrf,
177 buf_prefix,
314825ff 178 yang_afi_safi_value2identity(afi, safi),
88fa5104 179 buf_src_prefix, distance);
180 else
181 snprintf(xpath_prefix, sizeof(xpath_prefix),
182 FRR_STATIC_ROUTE_INFO_KEY_XPATH,
183 "frr-staticd:staticd", "staticd", svrf,
184 buf_prefix,
314825ff 185 yang_afi_safi_value2identity(afi, safi),
88fa5104 186 distance);
187
188 nb_cli_enqueue_change(vty, xpath_prefix, NB_OP_CREATE, NULL);
189
190 /* Tag processing */
191 snprintf(buf_tag, sizeof(buf_tag), "%u", tag);
192 strlcpy(ab_xpath, xpath_prefix, sizeof(ab_xpath));
193 strlcat(ab_xpath, FRR_STATIC_ROUTE_PATH_TAG_XPATH,
194 sizeof(ab_xpath));
195 nb_cli_enqueue_change(vty, ab_xpath, NB_OP_MODIFY, buf_tag);
196
197 /* Table-Id processing */
198 snprintf(buf_tableid, sizeof(buf_tableid), "%u", table_id);
199 strlcpy(ab_xpath, xpath_prefix, sizeof(ab_xpath));
200 strlcat(ab_xpath, FRR_STATIC_ROUTE_PATH_TABLEID_XPATH,
201 sizeof(ab_xpath));
202 nb_cli_enqueue_change(vty, ab_xpath, NB_OP_MODIFY, buf_tableid);
203 /* nexthop processing */
204
205 snprintf(ab_xpath, sizeof(ab_xpath),
206 FRR_STATIC_ROUTE_NH_KEY_XPATH, buf_nh_type, nh_svrf,
207 buf_gate_str, ifname);
208 strlcpy(xpath_nexthop, xpath_prefix, sizeof(xpath_nexthop));
209 strlcat(xpath_nexthop, ab_xpath, sizeof(xpath_nexthop));
210 nb_cli_enqueue_change(vty, xpath_nexthop, NB_OP_CREATE, NULL);
211
212 if (type == STATIC_BLACKHOLE) {
213 strlcpy(ab_xpath, xpath_nexthop, sizeof(ab_xpath));
214 strlcat(ab_xpath, FRR_STATIC_ROUTE_NH_BH_XPATH,
215 sizeof(ab_xpath));
216
217 /* Route flags */
218 if (flag_str) {
219 switch (flag_str[0]) {
220 case 'r':
221 bh_type = "reject";
222 break;
223 case 'b':
224 bh_type = "unspec";
225 break;
226 case 'N':
227 bh_type = "null";
228 break;
229 default:
230 bh_type = NULL;
231 break;
232 }
233 nb_cli_enqueue_change(vty, ab_xpath,
234 NB_OP_MODIFY, bh_type);
235 } else {
236 nb_cli_enqueue_change(vty, ab_xpath,
237 NB_OP_MODIFY, "null");
238 }
7e24fdf3 239 }
88fa5104 240 if (type == STATIC_IPV4_GATEWAY_IFNAME
241 || type == STATIC_IPV6_GATEWAY_IFNAME) {
242 strlcpy(ab_xpath, xpath_nexthop, sizeof(ab_xpath));
243 strlcat(ab_xpath, FRR_STATIC_ROUTE_NH_ONLINK_XPATH,
244 sizeof(ab_xpath));
245
246 if (onlink)
247 nb_cli_enqueue_change(vty, ab_xpath,
248 NB_OP_MODIFY, "true");
7e24fdf3 249 else
88fa5104 250 nb_cli_enqueue_change(vty, ab_xpath,
251 NB_OP_MODIFY, "false");
7e24fdf3 252 }
065276ae
SM
253 if (type == STATIC_IPV4_GATEWAY
254 || type == STATIC_IPV6_GATEWAY
255 || type == STATIC_IPV4_GATEWAY_IFNAME
256 || type == STATIC_IPV6_GATEWAY_IFNAME) {
257 strlcpy(ab_xpath, xpath_nexthop, sizeof(ab_xpath));
258 strlcat(ab_xpath, FRR_STATIC_ROUTE_NH_COLOR_XPATH,
259 sizeof(ab_xpath));
260 nb_cli_enqueue_change(vty, ab_xpath, NB_OP_MODIFY,
261 color_str);
262 }
88fa5104 263 if (label_str) {
264 /* copy of label string (start) */
265 char *ostr;
266 /* pointer to next segment */
267 char *nump;
268
269 strlcpy(xpath_mpls, xpath_nexthop, sizeof(xpath_mpls));
270 strlcat(xpath_mpls, FRR_STATIC_ROUTE_NH_LABEL_XPATH,
271 sizeof(xpath_mpls));
272
273 nb_cli_enqueue_change(vty, xpath_mpls, NB_OP_DESTROY,
274 NULL);
275
276 ostr = XSTRDUP(MTYPE_TMP, label_str);
277 while ((nump = strsep(&ostr, "/")) != NULL) {
278 snprintf(ab_xpath, sizeof(ab_xpath),
279 FRR_STATIC_ROUTE_NHLB_KEY_XPATH,
280 label_stack_id);
281 strlcpy(xpath_label, xpath_mpls,
282 sizeof(xpath_label));
283 strlcat(xpath_label, ab_xpath,
284 sizeof(xpath_label));
285 nb_cli_enqueue_change(vty, xpath_label,
286 NB_OP_MODIFY, nump);
287 label_stack_id++;
288 }
289 XFREE(MTYPE_TMP, ostr);
290 } else {
291 strlcpy(xpath_mpls, xpath_nexthop, sizeof(xpath_mpls));
292 strlcat(xpath_mpls, FRR_STATIC_ROUTE_NH_LABEL_XPATH,
293 sizeof(xpath_mpls));
294 nb_cli_enqueue_change(vty, xpath_mpls, NB_OP_DESTROY,
295 NULL);
b1ab2876 296 }
88fa5104 297 ret = nb_cli_apply_changes(vty, xpath_prefix);
7e24fdf3 298 } else {
88fa5104 299 if (src_str)
300 snprintf(ab_xpath, sizeof(ab_xpath),
301 FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH,
302 "frr-staticd:staticd", "staticd", svrf,
303 buf_prefix,
314825ff 304 yang_afi_safi_value2identity(afi, safi),
88fa5104 305 buf_src_prefix, distance, buf_nh_type, nh_svrf,
306 buf_gate_str, ifname);
307 else
308 snprintf(ab_xpath, sizeof(ab_xpath),
309 FRR_DEL_S_ROUTE_NH_KEY_XPATH,
310 "frr-staticd:staticd", "staticd", svrf,
311 buf_prefix,
314825ff 312 yang_afi_safi_value2identity(afi, safi),
88fa5104 313 distance, buf_nh_type, nh_svrf, buf_gate_str,
314 ifname);
315
316 dnode = yang_dnode_get(vty->candidate_config->dnode, ab_xpath);
317 if (!dnode)
318 return ret;
319
320 dnode = yang_get_subtree_with_no_sibling(dnode);
321 assert(dnode);
322 yang_dnode_get_path(dnode, ab_xpath, XPATH_MAXLEN);
323
324 nb_cli_enqueue_change(vty, ab_xpath, NB_OP_DESTROY, NULL);
325 ret = nb_cli_apply_changes(vty, ab_xpath);
7e24fdf3
DS
326 }
327
88fa5104 328 return ret;
7e24fdf3 329}
7e24fdf3
DS
330static int static_route(struct vty *vty, afi_t afi, safi_t safi,
331 const char *negate, const char *dest_str,
332 const char *mask_str, const char *src_str,
333 const char *gate_str, const char *ifname,
334 const char *flag_str, const char *tag_str,
335 const char *distance_str, const char *vrf_name,
336 const char *label_str, const char *table_str)
337{
88fa5104 338 if (!vrf_name)
339 vrf_name = VRF_DEFAULT_NAME;
7e24fdf3 340
88fa5104 341 return static_route_leak(vty, vrf_name, vrf_name, afi, safi, negate,
342 dest_str, mask_str, src_str, gate_str, ifname,
343 flag_str, tag_str, distance_str, label_str,
065276ae 344 table_str, false, NULL);
7e24fdf3
DS
345}
346
347/* Write static route configuration. */
348int static_config(struct vty *vty, struct static_vrf *svrf, afi_t afi,
349 safi_t safi, const char *cmd)
350{
7e24fdf3
DS
351 char spacing[100];
352 struct route_node *rn;
88fa5104 353 struct static_nexthop *nh;
354 struct static_path *pn;
7e24fdf3 355 struct route_table *stable;
88fa5104 356 struct static_route_info *si;
7e24fdf3
DS
357 char buf[SRCDEST2STR_BUFFER];
358 int write = 0;
88fa5104 359 struct stable_info *info;
7e24fdf3
DS
360
361 stable = svrf->stable[afi][safi];
362 if (stable == NULL)
363 return write;
364
772270f3
QY
365 snprintf(spacing, sizeof(spacing), "%s%s",
366 (svrf->vrf->vrf_id == VRF_DEFAULT) ? "" : " ", cmd);
7e24fdf3 367
88fa5104 368 for (rn = route_top(stable); rn; rn = srcdest_route_next(rn)) {
369 si = static_route_info_from_rnode(rn);
370 if (!si)
7e24fdf3 371 continue;
88fa5104 372 info = static_get_stable_info(rn);
373 frr_each(static_path_list, &si->path_list, pn) {
374 frr_each(static_nexthop_list, &pn->nexthop_list, nh) {
375 vty_out(vty, "%s %s", spacing,
376 srcdest_rnode2str(rn, buf,
377 sizeof(buf)));
378
379 switch (nh->type) {
380 case STATIC_IPV4_GATEWAY:
381 vty_out(vty, " %s",
382 inet_ntoa(nh->addr.ipv4));
7e24fdf3 383 break;
88fa5104 384 case STATIC_IPV6_GATEWAY:
385 vty_out(vty, " %s",
386 inet_ntop(AF_INET6,
387 &nh->addr.ipv6, buf,
388 sizeof(buf)));
7e24fdf3 389 break;
88fa5104 390 case STATIC_IFNAME:
391 vty_out(vty, " %s", nh->ifname);
392 break;
393 case STATIC_BLACKHOLE:
394 switch (nh->bh_type) {
395 case STATIC_BLACKHOLE_DROP:
396 vty_out(vty, " blackhole");
397 break;
398 case STATIC_BLACKHOLE_NULL:
399 vty_out(vty, " Null0");
400 break;
401 case STATIC_BLACKHOLE_REJECT:
402 vty_out(vty, " reject");
403 break;
404 }
405 break;
406 case STATIC_IPV4_GATEWAY_IFNAME:
407 vty_out(vty, " %s %s",
408 inet_ntop(AF_INET,
409 &nh->addr.ipv4, buf,
410 sizeof(buf)),
411 nh->ifname);
412 break;
413 case STATIC_IPV6_GATEWAY_IFNAME:
414 vty_out(vty, " %s %s",
415 inet_ntop(AF_INET6,
416 &nh->addr.ipv6, buf,
417 sizeof(buf)),
418 nh->ifname);
7e24fdf3
DS
419 break;
420 }
7e24fdf3 421
88fa5104 422 if (pn->tag)
423 vty_out(vty, " tag %" ROUTE_TAG_PRI,
424 pn->tag);
425
426 if (pn->distance
427 != ZEBRA_STATIC_DISTANCE_DEFAULT)
428 vty_out(vty, " %u", pn->distance);
429
430 /* Label information */
431 if (nh->snh_label.num_labels)
432 vty_out(vty, " label %s",
433 mpls_label2str(
434 nh->snh_label
435 .num_labels,
436 nh->snh_label.label,
437 buf, sizeof(buf), 0));
438
439 if (nh->nh_vrf_id != GET_STABLE_VRF_ID(info))
440 vty_out(vty, " nexthop-vrf %s",
441 nh->nh_vrfname);
442
443 /*
444 * table ID from VRF overrides
445 * configured
446 */
447 if (pn->table_id
448 && svrf->vrf->data.l.table_id
449 == RT_TABLE_MAIN)
450 vty_out(vty, " table %u", pn->table_id);
451
452 if (nh->onlink)
453 vty_out(vty, " onlink");
454
065276ae
SM
455 /*
456 * SR-TE color
457 */
458 if (nh->color != 0)
459 vty_out(vty, " color %u", nh->color);
460
88fa5104 461 vty_out(vty, "\n");
462
463 write = 1;
464 }
7e24fdf3 465 }
88fa5104 466 }
7e24fdf3
DS
467 return write;
468}
469
470/* Static unicast routes for multicast RPF lookup. */
ca77b518 471DEFPY_YANG (ip_mroute_dist,
7e24fdf3
DS
472 ip_mroute_dist_cmd,
473 "[no] ip mroute A.B.C.D/M$prefix <A.B.C.D$gate|INTERFACE$ifname> [(1-255)$distance]",
474 NO_STR
475 IP_STR
476 "Configure static unicast route into MRIB for multicast RPF lookup\n"
477 "IP destination prefix (e.g. 10.0.0.0/8)\n"
478 "Nexthop address\n"
479 "Nexthop interface name\n"
480 "Distance\n")
481{
482 return static_route(vty, AFI_IP, SAFI_MULTICAST, no, prefix_str,
483 NULL, NULL, gate_str, ifname, NULL, NULL,
484 distance_str, NULL, NULL, NULL);
485}
486
487/* Static route configuration. */
ca77b518 488DEFPY_YANG(ip_route_blackhole,
7e24fdf3
DS
489 ip_route_blackhole_cmd,
490 "[no] ip route\
491 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
492 <reject|blackhole>$flag \
493 [{ \
494 tag (1-4294967295) \
495 |(1-255)$distance \
496 |vrf NAME \
497 |label WORD \
498 |table (1-4294967295) \
499 }]",
500 NO_STR IP_STR
501 "Establish static routes\n"
502 "IP destination prefix (e.g. 10.0.0.0/8)\n"
503 "IP destination prefix\n"
504 "IP destination prefix mask\n"
505 "Emit an ICMP unreachable when matched\n"
506 "Silently discard pkts when matched\n"
507 "Set tag for this route\n"
508 "Tag value\n"
509 "Distance value for this route\n"
510 VRF_CMD_HELP_STR
511 MPLS_LABEL_HELPSTR
512 "Table to configure\n"
513 "The table number to configure\n")
514{
81bd033c 515 if (table_str && vrf && !vrf_is_backend_netns()) {
7e24fdf3
DS
516 vty_out(vty,
517 "%% table param only available when running on netns-based vrfs\n");
518 return CMD_WARNING_CONFIG_FAILED;
519 }
520
521 return static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix,
522 mask_str, NULL, NULL, NULL, flag, tag_str,
523 distance_str, vrf, label, table_str);
524}
525
ca77b518 526DEFPY_YANG(ip_route_blackhole_vrf,
7e24fdf3
DS
527 ip_route_blackhole_vrf_cmd,
528 "[no] ip route\
529 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
530 <reject|blackhole>$flag \
531 [{ \
532 tag (1-4294967295) \
533 |(1-255)$distance \
534 |label WORD \
535 |table (1-4294967295) \
536 }]",
537 NO_STR IP_STR
538 "Establish static routes\n"
539 "IP destination prefix (e.g. 10.0.0.0/8)\n"
540 "IP destination prefix\n"
541 "IP destination prefix mask\n"
542 "Emit an ICMP unreachable when matched\n"
543 "Silently discard pkts when matched\n"
544 "Set tag for this route\n"
545 "Tag value\n"
546 "Distance value for this route\n"
547 MPLS_LABEL_HELPSTR
548 "Table to configure\n"
549 "The table number to configure\n")
550{
88fa5104 551 const struct lyd_node *vrf_dnode;
552 const char *vrfname;
7e24fdf3 553
88fa5104 554 vrf_dnode =
555 yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
556 if (!vrf_dnode) {
557 vty_out(vty, "%% Failed to get vrf dnode in candidate db\n");
7e24fdf3
DS
558 return CMD_WARNING_CONFIG_FAILED;
559 }
88fa5104 560 vrfname = yang_dnode_get_string(vrf_dnode, "./name");
7e24fdf3
DS
561 /*
562 * Coverity is complaining that prefix could
563 * be dereferenced, but we know that prefix will
564 * valid. Add an assert to make it happy
565 */
566 assert(prefix);
88fa5104 567 return static_route_leak(vty, vrfname, vrfname, AFI_IP, SAFI_UNICAST,
568 no, prefix, mask_str, NULL, NULL, NULL, flag,
02dc8ba3 569 tag_str, distance_str, label, table_str,
065276ae 570 false, NULL);
7e24fdf3
DS
571}
572
ca77b518 573DEFPY_YANG(ip_route_address_interface,
7e24fdf3
DS
574 ip_route_address_interface_cmd,
575 "[no] ip route\
576 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
577 A.B.C.D$gate \
54a3d7cb 578 <INTERFACE|Null0>$ifname \
7e24fdf3
DS
579 [{ \
580 tag (1-4294967295) \
581 |(1-255)$distance \
582 |vrf NAME \
583 |label WORD \
584 |table (1-4294967295) \
585 |nexthop-vrf NAME \
02dc8ba3 586 |onlink$onlink \
065276ae 587 |color (1-4294967295) \
7e24fdf3
DS
588 }]",
589 NO_STR IP_STR
590 "Establish static routes\n"
591 "IP destination prefix (e.g. 10.0.0.0/8)\n"
592 "IP destination prefix\n"
593 "IP destination prefix mask\n"
594 "IP gateway address\n"
54a3d7cb
QY
595 "IP gateway interface name\n"
596 "Null interface\n"
7e24fdf3
DS
597 "Set tag for this route\n"
598 "Tag value\n"
599 "Distance value for this route\n"
600 VRF_CMD_HELP_STR
601 MPLS_LABEL_HELPSTR
602 "Table to configure\n"
603 "The table number to configure\n"
02dc8ba3 604 VRF_CMD_HELP_STR
065276ae
SM
605 "Treat the nexthop as directly attached to the interface\n"
606 "SR-TE color\n"
607 "The SR-TE color to configure\n")
7e24fdf3 608{
88fa5104 609 const char *nh_vrf;
7e24fdf3
DS
610 const char *flag = NULL;
611
612 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
613 flag = "Null0";
614 ifname = NULL;
615 }
88fa5104 616 if (!vrf)
617 vrf = VRF_DEFAULT_NAME;
7e24fdf3
DS
618
619 if (nexthop_vrf)
88fa5104 620 nh_vrf = nexthop_vrf;
7e24fdf3 621 else
88fa5104 622 nh_vrf = vrf;
7e24fdf3 623
88fa5104 624 return static_route_leak(vty, vrf, nh_vrf, AFI_IP, SAFI_UNICAST, no,
02dc8ba3
QY
625 prefix, mask_str, NULL, gate_str, ifname, flag,
626 tag_str, distance_str, label, table_str,
065276ae 627 !!onlink, color_str);
7e24fdf3
DS
628}
629
ca77b518 630DEFPY_YANG(ip_route_address_interface_vrf,
7e24fdf3
DS
631 ip_route_address_interface_vrf_cmd,
632 "[no] ip route\
633 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
634 A.B.C.D$gate \
54a3d7cb 635 <INTERFACE|Null0>$ifname \
7e24fdf3
DS
636 [{ \
637 tag (1-4294967295) \
638 |(1-255)$distance \
639 |label WORD \
640 |table (1-4294967295) \
641 |nexthop-vrf NAME \
02dc8ba3 642 |onlink$onlink \
065276ae
SM
643 |color (1-4294967295) \
644 }]",
7e24fdf3
DS
645 NO_STR IP_STR
646 "Establish static routes\n"
647 "IP destination prefix (e.g. 10.0.0.0/8)\n"
648 "IP destination prefix\n"
649 "IP destination prefix mask\n"
650 "IP gateway address\n"
54a3d7cb
QY
651 "IP gateway interface name\n"
652 "Null interface\n"
7e24fdf3
DS
653 "Set tag for this route\n"
654 "Tag value\n"
655 "Distance value for this route\n"
656 MPLS_LABEL_HELPSTR
657 "Table to configure\n"
658 "The table number to configure\n"
02dc8ba3 659 VRF_CMD_HELP_STR
065276ae
SM
660 "Treat the nexthop as directly attached to the interface\n"
661 "SR-TE color\n"
662 "The SR-TE color to configure\n")
7e24fdf3 663{
88fa5104 664 const char *nh_vrf;
7e24fdf3 665 const char *flag = NULL;
88fa5104 666 const struct lyd_node *vrf_dnode;
667 const char *vrfname;
7e24fdf3 668
88fa5104 669 vrf_dnode =
670 yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
671 if (!vrf_dnode) {
672 vty_out(vty, "%% Failed to get vrf dnode in candidate db\n");
7e24fdf3
DS
673 return CMD_WARNING_CONFIG_FAILED;
674 }
88fa5104 675 vrfname = yang_dnode_get_string(vrf_dnode, "./name");
7e24fdf3
DS
676
677 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
678 flag = "Null0";
679 ifname = NULL;
680 }
7e24fdf3 681 if (nexthop_vrf)
88fa5104 682 nh_vrf = nexthop_vrf;
7e24fdf3 683 else
88fa5104 684 nh_vrf = vrfname;
7e24fdf3 685
88fa5104 686 return static_route_leak(vty, vrfname, nh_vrf, AFI_IP, SAFI_UNICAST, no,
02dc8ba3
QY
687 prefix, mask_str, NULL, gate_str, ifname, flag,
688 tag_str, distance_str, label, table_str,
065276ae 689 !!onlink, color_str);
7e24fdf3
DS
690}
691
ca77b518 692DEFPY_YANG(ip_route,
7e24fdf3
DS
693 ip_route_cmd,
694 "[no] ip route\
695 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
54a3d7cb 696 <A.B.C.D$gate|<INTERFACE|Null0>$ifname> \
7e24fdf3
DS
697 [{ \
698 tag (1-4294967295) \
699 |(1-255)$distance \
700 |vrf NAME \
701 |label WORD \
702 |table (1-4294967295) \
703 |nexthop-vrf NAME \
065276ae 704 |color (1-4294967295) \
7e24fdf3
DS
705 }]",
706 NO_STR IP_STR
707 "Establish static routes\n"
708 "IP destination prefix (e.g. 10.0.0.0/8)\n"
709 "IP destination prefix\n"
710 "IP destination prefix mask\n"
711 "IP gateway address\n"
712 "IP gateway interface name\n"
54a3d7cb 713 "Null interface\n"
7e24fdf3
DS
714 "Set tag for this route\n"
715 "Tag value\n"
716 "Distance value for this route\n"
717 VRF_CMD_HELP_STR
718 MPLS_LABEL_HELPSTR
719 "Table to configure\n"
720 "The table number to configure\n"
065276ae
SM
721 VRF_CMD_HELP_STR
722 "SR-TE color\n"
723 "The SR-TE color to configure\n")
7e24fdf3 724{
88fa5104 725 const char *nh_vrf;
7e24fdf3
DS
726 const char *flag = NULL;
727
7e24fdf3
DS
728 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
729 flag = "Null0";
730 ifname = NULL;
731 }
732
88fa5104 733 if (!vrf)
734 vrf = VRF_DEFAULT_NAME;
7e24fdf3
DS
735
736 if (nexthop_vrf)
88fa5104 737 nh_vrf = nexthop_vrf;
7e24fdf3 738 else
88fa5104 739 nh_vrf = vrf;
7e24fdf3 740
88fa5104 741 return static_route_leak(vty, vrf, nh_vrf, AFI_IP, SAFI_UNICAST, no,
742 prefix, mask_str, NULL, gate_str, ifname, flag,
743 tag_str, distance_str, label, table_str,
065276ae 744 false, color_str);
7e24fdf3
DS
745}
746
ca77b518 747DEFPY_YANG(ip_route_vrf,
7e24fdf3
DS
748 ip_route_vrf_cmd,
749 "[no] ip route\
750 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
54a3d7cb 751 <A.B.C.D$gate|<INTERFACE|Null0>$ifname> \
7e24fdf3
DS
752 [{ \
753 tag (1-4294967295) \
754 |(1-255)$distance \
755 |label WORD \
756 |table (1-4294967295) \
757 |nexthop-vrf NAME \
065276ae 758 |color (1-4294967295) \
7e24fdf3
DS
759 }]",
760 NO_STR IP_STR
761 "Establish static routes\n"
762 "IP destination prefix (e.g. 10.0.0.0/8)\n"
763 "IP destination prefix\n"
764 "IP destination prefix mask\n"
765 "IP gateway address\n"
766 "IP gateway interface name\n"
54a3d7cb 767 "Null interface\n"
7e24fdf3
DS
768 "Set tag for this route\n"
769 "Tag value\n"
770 "Distance value for this route\n"
771 MPLS_LABEL_HELPSTR
772 "Table to configure\n"
773 "The table number to configure\n"
065276ae
SM
774 VRF_CMD_HELP_STR
775 "SR-TE color\n"
776 "The SR-TE color to configure\n")
7e24fdf3 777{
88fa5104 778 const char *nh_vrf;
51c4ed0a 779 const char *flag = NULL;
88fa5104 780 const struct lyd_node *vrf_dnode;
781 const char *vrfname;
7e24fdf3 782
88fa5104 783 vrf_dnode =
784 yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
785 if (!vrf_dnode) {
786 vty_out(vty, "%% Failed to get vrf dnode in candidate db\n");
7e24fdf3
DS
787 return CMD_WARNING_CONFIG_FAILED;
788 }
789
88fa5104 790 vrfname = yang_dnode_get_string(vrf_dnode, "./name");
791
7e24fdf3
DS
792 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
793 flag = "Null0";
794 ifname = NULL;
795 }
7e24fdf3 796 if (nexthop_vrf)
88fa5104 797 nh_vrf = nexthop_vrf;
7e24fdf3 798 else
88fa5104 799 nh_vrf = vrfname;
7e24fdf3 800
88fa5104 801 return static_route_leak(vty, vrfname, nh_vrf, AFI_IP, SAFI_UNICAST, no,
802 prefix, mask_str, NULL, gate_str, ifname, flag,
803 tag_str, distance_str, label, table_str,
065276ae 804 false, color_str);
7e24fdf3
DS
805}
806
ca77b518 807DEFPY_YANG(ipv6_route_blackhole,
7e24fdf3
DS
808 ipv6_route_blackhole_cmd,
809 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
54a3d7cb 810 <reject|blackhole>$flag \
7e24fdf3
DS
811 [{ \
812 tag (1-4294967295) \
813 |(1-255)$distance \
814 |vrf NAME \
815 |label WORD \
816 |table (1-4294967295) \
817 }]",
818 NO_STR
819 IPV6_STR
820 "Establish static routes\n"
821 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
822 "IPv6 source-dest route\n"
823 "IPv6 source prefix\n"
7e24fdf3
DS
824 "Emit an ICMP unreachable when matched\n"
825 "Silently discard pkts when matched\n"
826 "Set tag for this route\n"
827 "Tag value\n"
828 "Distance value for this prefix\n"
829 VRF_CMD_HELP_STR
830 MPLS_LABEL_HELPSTR
831 "Table to configure\n"
832 "The table number to configure\n")
833{
81bd033c 834 if (table_str && vrf && !vrf_is_backend_netns()) {
7e24fdf3
DS
835 vty_out(vty,
836 "%% table param only available when running on netns-based vrfs\n");
837 return CMD_WARNING_CONFIG_FAILED;
838 }
839
840 return static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str,
841 NULL, from_str, NULL, NULL, flag, tag_str,
842 distance_str, vrf, label, table_str);
843}
844
ca77b518 845DEFPY_YANG(ipv6_route_blackhole_vrf,
7e24fdf3
DS
846 ipv6_route_blackhole_vrf_cmd,
847 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
54a3d7cb 848 <reject|blackhole>$flag \
7e24fdf3
DS
849 [{ \
850 tag (1-4294967295) \
851 |(1-255)$distance \
852 |label WORD \
853 |table (1-4294967295) \
854 }]",
855 NO_STR
856 IPV6_STR
857 "Establish static routes\n"
858 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
859 "IPv6 source-dest route\n"
860 "IPv6 source prefix\n"
7e24fdf3
DS
861 "Emit an ICMP unreachable when matched\n"
862 "Silently discard pkts when matched\n"
863 "Set tag for this route\n"
864 "Tag value\n"
865 "Distance value for this prefix\n"
866 MPLS_LABEL_HELPSTR
867 "Table to configure\n"
868 "The table number to configure\n")
869{
88fa5104 870 const struct lyd_node *vrf_dnode;
871 const char *vrfname;
7e24fdf3 872
88fa5104 873 vrf_dnode =
874 yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
875 if (!vrf_dnode) {
876 vty_out(vty, "%% Failed to get vrf dnode in candidate db\n");
7e24fdf3
DS
877 return CMD_WARNING_CONFIG_FAILED;
878 }
88fa5104 879 vrfname = yang_dnode_get_string(vrf_dnode, "./name");
7e24fdf3
DS
880
881 /*
882 * Coverity is complaining that prefix could
883 * be dereferenced, but we know that prefix will
884 * valid. Add an assert to make it happy
885 */
886 assert(prefix);
88fa5104 887
888 return static_route_leak(vty, vrfname, vrfname, AFI_IP6, SAFI_UNICAST,
889 no, prefix_str, NULL, from_str, NULL, NULL,
890 flag, tag_str, distance_str, label, table_str,
065276ae 891 false, NULL);
7e24fdf3
DS
892}
893
ca77b518 894DEFPY_YANG(ipv6_route_address_interface,
7e24fdf3
DS
895 ipv6_route_address_interface_cmd,
896 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
897 X:X::X:X$gate \
54a3d7cb 898 <INTERFACE|Null0>$ifname \
7e24fdf3
DS
899 [{ \
900 tag (1-4294967295) \
901 |(1-255)$distance \
902 |vrf NAME \
903 |label WORD \
904 |table (1-4294967295) \
905 |nexthop-vrf NAME \
02dc8ba3 906 |onlink$onlink \
065276ae 907 |color (1-4294967295) \
7e24fdf3
DS
908 }]",
909 NO_STR
910 IPV6_STR
911 "Establish static routes\n"
912 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
913 "IPv6 source-dest route\n"
914 "IPv6 source prefix\n"
915 "IPv6 gateway address\n"
916 "IPv6 gateway interface name\n"
54a3d7cb 917 "Null interface\n"
7e24fdf3
DS
918 "Set tag for this route\n"
919 "Tag value\n"
920 "Distance value for this prefix\n"
921 VRF_CMD_HELP_STR
922 MPLS_LABEL_HELPSTR
923 "Table to configure\n"
924 "The table number to configure\n"
02dc8ba3 925 VRF_CMD_HELP_STR
065276ae
SM
926 "Treat the nexthop as directly attached to the interface\n"
927 "SR-TE color\n"
928 "The SR-TE color to configure\n")
7e24fdf3 929{
88fa5104 930 const char *nh_vrf;
c66861af 931 const char *flag = NULL;
7e24fdf3 932
88fa5104 933 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
934 flag = "Null0";
935 ifname = NULL;
7e24fdf3
DS
936 }
937
88fa5104 938 if (!vrf)
939 vrf = VRF_DEFAULT_NAME;
7e24fdf3
DS
940
941 if (nexthop_vrf)
88fa5104 942 nh_vrf = nexthop_vrf;
7e24fdf3 943 else
88fa5104 944 nh_vrf = vrf;
7e24fdf3 945
88fa5104 946 return static_route_leak(vty, vrf, nh_vrf, AFI_IP6, SAFI_UNICAST, no,
947 prefix_str, NULL, from_str, gate_str, ifname,
948 flag, tag_str, distance_str, label, table_str,
065276ae 949 !!onlink, color_str);
7e24fdf3
DS
950}
951
ca77b518 952DEFPY_YANG(ipv6_route_address_interface_vrf,
7e24fdf3
DS
953 ipv6_route_address_interface_vrf_cmd,
954 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
955 X:X::X:X$gate \
54a3d7cb 956 <INTERFACE|Null0>$ifname \
7e24fdf3
DS
957 [{ \
958 tag (1-4294967295) \
959 |(1-255)$distance \
960 |label WORD \
961 |table (1-4294967295) \
962 |nexthop-vrf NAME \
02dc8ba3 963 |onlink$onlink \
065276ae 964 |color (1-4294967295) \
7e24fdf3
DS
965 }]",
966 NO_STR
967 IPV6_STR
968 "Establish static routes\n"
969 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
970 "IPv6 source-dest route\n"
971 "IPv6 source prefix\n"
972 "IPv6 gateway address\n"
973 "IPv6 gateway interface name\n"
54a3d7cb 974 "Null interface\n"
7e24fdf3
DS
975 "Set tag for this route\n"
976 "Tag value\n"
977 "Distance value for this prefix\n"
978 MPLS_LABEL_HELPSTR
979 "Table to configure\n"
980 "The table number to configure\n"
02dc8ba3 981 VRF_CMD_HELP_STR
065276ae
SM
982 "Treat the nexthop as directly attached to the interface\n"
983 "SR-TE color\n"
984 "The SR-TE color to configure\n")
7e24fdf3 985{
88fa5104 986 const char *nh_vrf;
c66861af 987 const char *flag = NULL;
88fa5104 988 const struct lyd_node *vrf_dnode;
989 const char *vrfname;
7e24fdf3 990
88fa5104 991 vrf_dnode =
992 yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
993 if (!vrf_dnode) {
994 vty_out(vty, "%% Failed to get vrf dnode in candidate db\n");
7e24fdf3
DS
995 return CMD_WARNING_CONFIG_FAILED;
996 }
88fa5104 997 vrfname = yang_dnode_get_string(vrf_dnode, "./name");
7e24fdf3
DS
998
999 if (nexthop_vrf)
88fa5104 1000 nh_vrf = nexthop_vrf;
7e24fdf3 1001 else
88fa5104 1002 nh_vrf = vrfname;
7e24fdf3 1003
54a3d7cb
QY
1004 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
1005 flag = "Null0";
1006 ifname = NULL;
1007 }
88fa5104 1008 return static_route_leak(vty, vrfname, nh_vrf, AFI_IP6, SAFI_UNICAST,
1009 no, prefix_str, NULL, from_str, gate_str,
1010 ifname, flag, tag_str, distance_str, label,
065276ae 1011 table_str, !!onlink, color_str);
7e24fdf3
DS
1012}
1013
ca77b518 1014DEFPY_YANG(ipv6_route,
7e24fdf3
DS
1015 ipv6_route_cmd,
1016 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
54a3d7cb 1017 <X:X::X:X$gate|<INTERFACE|Null0>$ifname> \
7e24fdf3
DS
1018 [{ \
1019 tag (1-4294967295) \
1020 |(1-255)$distance \
1021 |vrf NAME \
1022 |label WORD \
1023 |table (1-4294967295) \
1024 |nexthop-vrf NAME \
065276ae 1025 |color (1-4294967295) \
7e24fdf3
DS
1026 }]",
1027 NO_STR
1028 IPV6_STR
1029 "Establish static routes\n"
1030 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1031 "IPv6 source-dest route\n"
1032 "IPv6 source prefix\n"
1033 "IPv6 gateway address\n"
1034 "IPv6 gateway interface name\n"
54a3d7cb 1035 "Null interface\n"
7e24fdf3
DS
1036 "Set tag for this route\n"
1037 "Tag value\n"
1038 "Distance value for this prefix\n"
1039 VRF_CMD_HELP_STR
1040 MPLS_LABEL_HELPSTR
1041 "Table to configure\n"
1042 "The table number to configure\n"
065276ae
SM
1043 VRF_CMD_HELP_STR
1044 "SR-TE color\n"
1045 "The SR-TE color to configure\n")
7e24fdf3 1046{
88fa5104 1047 const char *nh_vrf;
c66861af 1048 const char *flag = NULL;
7e24fdf3 1049
88fa5104 1050 if (!vrf)
1051 vrf = VRF_DEFAULT_NAME;
7e24fdf3
DS
1052
1053 if (nexthop_vrf)
88fa5104 1054 nh_vrf = nexthop_vrf;
7e24fdf3 1055 else
88fa5104 1056 nh_vrf = vrf;
7e24fdf3 1057
54a3d7cb
QY
1058 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
1059 flag = "Null0";
1060 ifname = NULL;
1061 }
88fa5104 1062 return static_route_leak(vty, vrf, nh_vrf, AFI_IP6, SAFI_UNICAST, no,
1063 prefix_str, NULL, from_str, gate_str, ifname,
1064 flag, tag_str, distance_str, label, table_str,
065276ae 1065 false, color_str);
7e24fdf3
DS
1066}
1067
ca77b518 1068DEFPY_YANG(ipv6_route_vrf,
7e24fdf3
DS
1069 ipv6_route_vrf_cmd,
1070 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
54a3d7cb 1071 <X:X::X:X$gate|<INTERFACE|Null0>$ifname> \
7e24fdf3
DS
1072 [{ \
1073 tag (1-4294967295) \
1074 |(1-255)$distance \
1075 |label WORD \
1076 |table (1-4294967295) \
1077 |nexthop-vrf NAME \
065276ae 1078 |color (1-4294967295) \
7e24fdf3
DS
1079 }]",
1080 NO_STR
1081 IPV6_STR
1082 "Establish static routes\n"
1083 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1084 "IPv6 source-dest route\n"
1085 "IPv6 source prefix\n"
1086 "IPv6 gateway address\n"
1087 "IPv6 gateway interface name\n"
54a3d7cb 1088 "Null interface\n"
7e24fdf3
DS
1089 "Set tag for this route\n"
1090 "Tag value\n"
1091 "Distance value for this prefix\n"
1092 MPLS_LABEL_HELPSTR
1093 "Table to configure\n"
1094 "The table number to configure\n"
065276ae
SM
1095 VRF_CMD_HELP_STR
1096 "SR-TE color\n"
1097 "The SR-TE color to configure\n")
7e24fdf3 1098{
88fa5104 1099 const char *nh_vrf;
c66861af 1100 const char *flag = NULL;
88fa5104 1101 const struct lyd_node *vrf_dnode;
1102 const char *vrfname;
7e24fdf3 1103
88fa5104 1104 vrf_dnode =
1105 yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
1106 if (!vrf_dnode) {
1107 vty_out(vty, "%% Failed to get vrf dnode in candidate db\n");
7e24fdf3
DS
1108 return CMD_WARNING_CONFIG_FAILED;
1109 }
88fa5104 1110 vrfname = yang_dnode_get_string(vrf_dnode, "./name");
7e24fdf3
DS
1111
1112 if (nexthop_vrf)
88fa5104 1113 nh_vrf = nexthop_vrf;
7e24fdf3 1114 else
88fa5104 1115 nh_vrf = vrfname;
7e24fdf3 1116
54a3d7cb
QY
1117 if (ifname && !strncasecmp(ifname, "Null0", 5)) {
1118 flag = "Null0";
1119 ifname = NULL;
1120 }
88fa5104 1121 return static_route_leak(vty, vrfname, nh_vrf, AFI_IP6, SAFI_UNICAST,
1122 no, prefix_str, NULL, from_str, gate_str,
1123 ifname, flag, tag_str, distance_str, label,
065276ae 1124 table_str, false, color_str);
7e24fdf3 1125}
ca77b518 1126DEFPY_YANG(debug_staticd,
31ddf3b7
MS
1127 debug_staticd_cmd,
1128 "[no] debug static [{events$events}]",
1129 NO_STR
1130 DEBUG_STR
1131 STATICD_STR
1132 "Debug events\n")
1133{
1134 /* If no specific category, change all */
1135 if (strmatch(argv[argc - 1]->text, "static"))
1136 static_debug_set(vty->node, !no, true);
1137 else
1138 static_debug_set(vty->node, !no, !!events);
7e24fdf3 1139
31ddf3b7
MS
1140 return CMD_SUCCESS;
1141}
1142
1143DEFUN_NOSH (show_debugging_static,
1144 show_debugging_static_cmd,
e60b527e
DS
1145 "show debugging [static]",
1146 SHOW_STR
1147 DEBUG_STR
1148 "Static Information\n")
1149{
31ddf3b7
MS
1150 vty_out(vty, "Staticd debugging status\n");
1151
1152 static_debug_status_write(vty);
e60b527e
DS
1153
1154 return CMD_SUCCESS;
1155}
1156
62b346ee 1157static struct cmd_node debug_node = {
f4b8291f 1158 .name = "debug",
62b346ee
DL
1159 .node = DEBUG_NODE,
1160 .prompt = "",
612c2c15 1161 .config_write = static_config_write_debug,
62b346ee 1162};
31ddf3b7 1163
7e24fdf3
DS
1164void static_vty_init(void)
1165{
612c2c15 1166 install_node(&debug_node);
31ddf3b7 1167
7e24fdf3
DS
1168 install_element(CONFIG_NODE, &ip_mroute_dist_cmd);
1169
1170 install_element(CONFIG_NODE, &ip_route_blackhole_cmd);
1171 install_element(VRF_NODE, &ip_route_blackhole_vrf_cmd);
1172 install_element(CONFIG_NODE, &ip_route_address_interface_cmd);
1173 install_element(VRF_NODE, &ip_route_address_interface_vrf_cmd);
1174 install_element(CONFIG_NODE, &ip_route_cmd);
1175 install_element(VRF_NODE, &ip_route_vrf_cmd);
1176
1177 install_element(CONFIG_NODE, &ipv6_route_blackhole_cmd);
1178 install_element(VRF_NODE, &ipv6_route_blackhole_vrf_cmd);
1179 install_element(CONFIG_NODE, &ipv6_route_address_interface_cmd);
1180 install_element(VRF_NODE, &ipv6_route_address_interface_vrf_cmd);
1181 install_element(CONFIG_NODE, &ipv6_route_cmd);
1182 install_element(VRF_NODE, &ipv6_route_vrf_cmd);
1183
31ddf3b7
MS
1184 install_element(VIEW_NODE, &show_debugging_static_cmd);
1185 install_element(VIEW_NODE, &debug_staticd_cmd);
1186 install_element(CONFIG_NODE, &debug_staticd_cmd);
7e24fdf3 1187}