2 * Copyright (C) 2020 Cumulus Networks, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "northbound.h"
24 #include "zebra/interface.h"
25 #include "zebra/zebra_router.h"
26 #include "zebra/debug.h"
30 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/up-count
33 lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args
*args
)
35 const struct interface
*ifp
= args
->list_entry
;
36 struct zebra_if
*zebra_if
;
40 return yang_data_new_uint16(args
->xpath
, zebra_if
->up_count
);
44 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/down-count
47 lib_interface_zebra_state_down_count_get_elem(struct nb_cb_get_elem_args
*args
)
49 const struct interface
*ifp
= args
->list_entry
;
50 struct zebra_if
*zebra_if
;
54 return yang_data_new_uint16(args
->xpath
, zebra_if
->down_count
);
58 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/zif-type
61 lib_interface_zebra_state_zif_type_get_elem(struct nb_cb_get_elem_args
*args
)
63 /* TODO: implement me. */
68 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/ptm-status
71 lib_interface_zebra_state_ptm_status_get_elem(struct nb_cb_get_elem_args
*args
)
73 /* TODO: implement me. */
78 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/vlan-id
81 lib_interface_zebra_state_vlan_id_get_elem(struct nb_cb_get_elem_args
*args
)
83 const struct interface
*ifp
= args
->list_entry
;
84 struct zebra_if
*zebra_if
;
85 struct zebra_l2info_vlan
*vlan_info
;
87 if (!IS_ZEBRA_IF_VLAN(ifp
))
91 vlan_info
= &zebra_if
->l2info
.vl
;
93 return yang_data_new_uint16(args
->xpath
, vlan_info
->vid
);
97 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/vni-id
100 lib_interface_zebra_state_vni_id_get_elem(struct nb_cb_get_elem_args
*args
)
102 const struct interface
*ifp
= args
->list_entry
;
103 struct zebra_if
*zebra_if
;
104 struct zebra_l2info_vxlan
*vxlan_info
;
106 if (!IS_ZEBRA_IF_VXLAN(ifp
))
109 zebra_if
= ifp
->info
;
110 vxlan_info
= &zebra_if
->l2info
.vxl
;
112 return yang_data_new_uint32(args
->xpath
, vxlan_info
->vni
);
116 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/remote-vtep
119 lib_interface_zebra_state_remote_vtep_get_elem(struct nb_cb_get_elem_args
*args
)
121 const struct interface
*ifp
= args
->list_entry
;
122 struct zebra_if
*zebra_if
;
123 struct zebra_l2info_vxlan
*vxlan_info
;
125 if (!IS_ZEBRA_IF_VXLAN(ifp
))
128 zebra_if
= ifp
->info
;
129 vxlan_info
= &zebra_if
->l2info
.vxl
;
131 return yang_data_new_ipv4(args
->xpath
, &vxlan_info
->vtep_ip
);
135 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/mcast-group
138 lib_interface_zebra_state_mcast_group_get_elem(struct nb_cb_get_elem_args
*args
)
140 const struct interface
*ifp
= args
->list_entry
;
141 struct zebra_if
*zebra_if
;
142 struct zebra_l2info_vxlan
*vxlan_info
;
144 if (!IS_ZEBRA_IF_VXLAN(ifp
))
147 zebra_if
= ifp
->info
;
148 vxlan_info
= &zebra_if
->l2info
.vxl
;
150 return yang_data_new_ipv4(args
->xpath
, &vxlan_info
->mcast_grp
);
153 const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args
*args
)
155 struct vrf
*vrf
= (struct vrf
*)args
->parent_list_entry
;
156 struct zebra_router_table
*zrt
=
157 (struct zebra_router_table
*)args
->list_entry
;
159 struct zebra_vrf
*zvrf
;
163 zvrf
= zebra_vrf_lookup_by_id(vrf
->vrf_id
);
165 if (args
->list_entry
== NULL
) {
169 zrt
= zebra_router_find_zrt(zvrf
, zvrf
->table_id
, afi
, safi
);
173 zrt
= RB_NEXT(zebra_router_table_head
, zrt
);
174 /* vrf_id/ns_id do not match, only walk for the given VRF */
175 while (zrt
&& zrt
->ns_id
!= zvrf
->zns
->ns_id
)
176 zrt
= RB_NEXT(zebra_router_table_head
, zrt
);
182 int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args
*args
)
184 const struct zebra_router_table
*zrt
= args
->list_entry
;
188 snprintfrr(args
->keys
->key
[0], sizeof(args
->keys
->key
[0]), "%s",
189 yang_afi_safi_value2identity(zrt
->afi
, zrt
->safi
));
190 snprintfrr(args
->keys
->key
[1], sizeof(args
->keys
->key
[1]), "%u",
197 lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args
*args
)
199 struct vrf
*vrf
= (struct vrf
*)args
->parent_list_entry
;
200 struct zebra_vrf
*zvrf
;
203 uint32_t table_id
= 0;
205 zvrf
= zebra_vrf_lookup_by_id(vrf
->vrf_id
);
207 yang_afi_safi_identity2value(args
->keys
->key
[0], &afi
, &safi
);
208 table_id
= yang_str2uint32(args
->keys
->key
[1]);
209 /* table_id 0 assume vrf's table_id. */
211 table_id
= zvrf
->table_id
;
213 return zebra_router_find_zrt(zvrf
, table_id
, afi
, safi
);
217 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route
220 lib_vrf_zebra_ribs_rib_route_get_next(struct nb_cb_get_next_args
*args
)
222 const struct zebra_router_table
*zrt
= args
->parent_list_entry
;
223 struct route_node
*rn
= (struct route_node
*)args
->list_entry
;
225 if (args
->list_entry
== NULL
)
226 rn
= route_top(zrt
->table
);
228 rn
= srcdest_route_next((struct route_node
*)rn
);
229 /* Optimization: skip empty route nodes. */
230 while (rn
&& rn
->info
== NULL
)
233 /* Skip link-local routes. */
234 if (rn
&& rn
->p
.family
== AF_INET6
235 && IN6_IS_ADDR_LINKLOCAL(&rn
->p
.u
.prefix6
))
241 int lib_vrf_zebra_ribs_rib_route_get_keys(struct nb_cb_get_keys_args
*args
)
243 const struct route_node
*rn
= args
->list_entry
;
246 prefix2str(&rn
->p
, args
->keys
->key
[0], sizeof(args
->keys
->key
[0]));
252 lib_vrf_zebra_ribs_rib_route_lookup_entry(struct nb_cb_lookup_entry_args
*args
)
254 const struct zebra_router_table
*zrt
= args
->parent_list_entry
;
256 struct route_node
*rn
;
258 yang_str2prefix(args
->keys
->key
[0], &p
);
260 rn
= route_node_lookup(zrt
->table
, &p
);
265 route_unlock_node(rn
);
271 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/prefix
274 lib_vrf_zebra_ribs_rib_route_prefix_get_elem(struct nb_cb_get_elem_args
*args
)
276 const struct route_node
*rn
= args
->list_entry
;
278 return yang_data_new_prefix(args
->xpath
, &rn
->p
);
282 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry
284 const void *lib_vrf_zebra_ribs_rib_route_route_entry_get_next(
285 struct nb_cb_get_next_args
*args
)
287 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
288 struct route_node
*rn
= (struct route_node
*)args
->parent_list_entry
;
290 if (args
->list_entry
== NULL
)
291 RNODE_FIRST_RE(rn
, re
);
293 RNODE_NEXT_RE(rn
, re
);
298 int lib_vrf_zebra_ribs_rib_route_route_entry_get_keys(
299 struct nb_cb_get_keys_args
*args
)
301 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
305 strlcpy(args
->keys
->key
[0], zebra_route_string(re
->type
),
306 sizeof(args
->keys
->key
[0]));
311 const void *lib_vrf_zebra_ribs_rib_route_route_entry_lookup_entry(
312 struct nb_cb_lookup_entry_args
*args
)
314 struct route_node
*rn
= (struct route_node
*)args
->parent_list_entry
;
315 struct route_entry
*re
= NULL
;
319 afi
= family2afi(rn
->p
.family
);
320 proto_type
= proto_redistnum(afi
, args
->keys
->key
[0]);
322 RNODE_FOREACH_RE (rn
, re
) {
323 if (proto_type
== re
->type
)
331 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/protocol
333 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_protocol_get_elem(
334 struct nb_cb_get_elem_args
*args
)
336 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
338 return yang_data_new_enum(args
->xpath
, re
->type
);
342 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/instance
344 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_instance_get_elem(
345 struct nb_cb_get_elem_args
*args
)
347 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
350 return yang_data_new_uint16(args
->xpath
, re
->instance
);
356 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/distance
358 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_distance_get_elem(
359 struct nb_cb_get_elem_args
*args
)
361 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
363 return yang_data_new_uint8(args
->xpath
, re
->distance
);
367 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/metric
369 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_metric_get_elem(
370 struct nb_cb_get_elem_args
*args
)
372 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
374 return yang_data_new_uint32(args
->xpath
, re
->metric
);
378 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/tag
380 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_tag_get_elem(
381 struct nb_cb_get_elem_args
*args
)
383 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
386 return yang_data_new_uint32(args
->xpath
, re
->tag
);
392 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/selected
394 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_selected_get_elem(
395 struct nb_cb_get_elem_args
*args
)
397 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
399 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
))
400 return yang_data_new_empty(args
->xpath
);
406 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/installed
408 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_installed_get_elem(
409 struct nb_cb_get_elem_args
*args
)
411 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
413 if (CHECK_FLAG(re
->status
, ROUTE_ENTRY_INSTALLED
))
414 return yang_data_new_empty(args
->xpath
);
420 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/failed
422 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_failed_get_elem(
423 struct nb_cb_get_elem_args
*args
)
425 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
427 if (CHECK_FLAG(re
->status
, ROUTE_ENTRY_FAILED
))
428 return yang_data_new_empty(args
->xpath
);
434 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/queued
436 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_queued_get_elem(
437 struct nb_cb_get_elem_args
*args
)
439 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
441 if (CHECK_FLAG(re
->status
, ROUTE_ENTRY_QUEUED
))
442 return yang_data_new_empty(args
->xpath
);
449 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/internal-flags
452 lib_vrf_zebra_ribs_rib_route_route_entry_internal_flags_get_elem(
453 struct nb_cb_get_elem_args
*args
)
455 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
458 return yang_data_new_int32(args
->xpath
, re
->flags
);
465 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/internal-status
468 lib_vrf_zebra_ribs_rib_route_route_entry_internal_status_get_elem(
469 struct nb_cb_get_elem_args
*args
)
471 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
474 return yang_data_new_int32(args
->xpath
, re
->status
);
480 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/uptime
482 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_uptime_get_elem(
483 struct nb_cb_get_elem_args
*args
)
485 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
487 return yang_data_new_date_and_time(args
->xpath
, re
->uptime
);
492 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/id
495 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_id_get_elem(
496 struct nb_cb_get_elem_args
*args
)
498 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
500 return yang_data_new_uint32(args
->xpath
, re
->nhe
->id
);
505 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop
508 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_get_next(
509 struct nb_cb_get_next_args
*args
)
511 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
512 struct route_entry
*re
= (struct route_entry
*)args
->parent_list_entry
;
513 struct nhg_hash_entry
*nhe
= re
->nhe
;
515 if (args
->list_entry
== NULL
) {
516 nexthop
= nhe
->nhg
.nexthop
;
518 nexthop
= nexthop_next(nexthop
);
523 int lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_get_keys(
524 struct nb_cb_get_keys_args
*args
)
526 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
530 strlcpy(args
->keys
->key
[0], yang_nexthop_type2str(nexthop
->type
),
531 sizeof(args
->keys
->key
[0]));
533 snprintfrr(args
->keys
->key
[1], sizeof(args
->keys
->key
[1]), "%" PRIu32
,
536 switch (nexthop
->type
) {
537 case NEXTHOP_TYPE_IPV4
:
538 case NEXTHOP_TYPE_IPV4_IFINDEX
:
539 snprintfrr(args
->keys
->key
[2], sizeof(args
->keys
->key
[2]),
540 "%pI4", &nexthop
->gate
.ipv4
);
541 if (nexthop
->ifindex
)
542 strlcpy(args
->keys
->key
[3],
543 ifindex2ifname(nexthop
->ifindex
,
545 sizeof(args
->keys
->key
[3]));
548 strlcpy(args
->keys
->key
[3], " ",
549 sizeof(args
->keys
->key
[3]));
552 case NEXTHOP_TYPE_IPV6
:
553 case NEXTHOP_TYPE_IPV6_IFINDEX
:
554 snprintfrr(args
->keys
->key
[2], sizeof(args
->keys
->key
[2]),
555 "%pI6", &nexthop
->gate
.ipv6
);
557 if (nexthop
->ifindex
)
558 strlcpy(args
->keys
->key
[3],
559 ifindex2ifname(nexthop
->ifindex
,
561 sizeof(args
->keys
->key
[3]));
564 strlcpy(args
->keys
->key
[3], " ",
565 sizeof(args
->keys
->key
[3]));
568 case NEXTHOP_TYPE_IFINDEX
:
569 strlcpy(args
->keys
->key
[2], "", sizeof(args
->keys
->key
[2]));
570 strlcpy(args
->keys
->key
[3],
571 ifindex2ifname(nexthop
->ifindex
, nexthop
->vrf_id
),
572 sizeof(args
->keys
->key
[3]));
575 case NEXTHOP_TYPE_BLACKHOLE
:
577 strlcpy(args
->keys
->key
[2], "", sizeof(args
->keys
->key
[2]));
578 strlcpy(args
->keys
->key
[3], " ", sizeof(args
->keys
->key
[3]));
588 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_lookup_entry(
589 struct nb_cb_lookup_entry_args
*args
)
591 struct nhg_hash_entry
*nhe
;
592 struct nexthop nexthop_lookup
= {};
593 struct nexthop
*nexthop
;
594 const char *nh_type_str
;
596 nhe
= (struct nhg_hash_entry
*)args
->parent_list_entry
;
597 nexthop_lookup
.vrf_id
= nhe
->vrf_id
;
601 * TODO: use yang_str2enum() instead.
603 nh_type_str
= args
->keys
->key
[0];
604 if (strmatch(nh_type_str
, "ifindex"))
605 nexthop_lookup
.type
= NEXTHOP_TYPE_IFINDEX
;
606 else if (strmatch(nh_type_str
, "ip4"))
607 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV4
;
608 else if (strmatch(nh_type_str
, "ip4-ifindex"))
609 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV4_IFINDEX
;
610 else if (strmatch(nh_type_str
, "ip6"))
611 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV6
;
612 else if (strmatch(nh_type_str
, "ip6-ifindex"))
613 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV6_IFINDEX
;
614 else if (strmatch(nh_type_str
, "blackhole"))
615 nexthop_lookup
.type
= NEXTHOP_TYPE_BLACKHOLE
;
620 /* Get nexthop address. */
621 switch (nexthop_lookup
.type
) {
622 case NEXTHOP_TYPE_IPV4
:
623 case NEXTHOP_TYPE_IPV4_IFINDEX
:
624 yang_str2ipv4(args
->keys
->key
[1], &nexthop_lookup
.gate
.ipv4
);
626 case NEXTHOP_TYPE_IPV6
:
627 case NEXTHOP_TYPE_IPV6_IFINDEX
:
628 yang_str2ipv6(args
->keys
->key
[1], &nexthop_lookup
.gate
.ipv6
);
630 case NEXTHOP_TYPE_IFINDEX
:
631 case NEXTHOP_TYPE_BLACKHOLE
:
635 /* Get nexthop interface. */
636 switch (nexthop_lookup
.type
) {
637 case NEXTHOP_TYPE_IPV4_IFINDEX
:
638 case NEXTHOP_TYPE_IPV6_IFINDEX
:
639 case NEXTHOP_TYPE_IFINDEX
:
640 nexthop_lookup
.ifindex
=
641 ifname2ifindex(args
->keys
->key
[2], nhe
->vrf_id
);
643 case NEXTHOP_TYPE_IPV4
:
644 case NEXTHOP_TYPE_IPV6
:
645 case NEXTHOP_TYPE_BLACKHOLE
:
649 /* Lookup requested nexthop (ignore weight and metric). */
650 for (ALL_NEXTHOPS(nhe
->nhg
, nexthop
)) {
651 nexthop_lookup
.weight
= nexthop
->weight
;
652 nexthop_lookup
.src
= nexthop
->src
;
653 if (nexthop_same_no_labels(&nexthop_lookup
, nexthop
))
662 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/nh-type
665 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_nh_type_get_elem(
666 struct nb_cb_get_elem_args
*args
)
668 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
670 switch (nexthop
->type
) {
671 case NEXTHOP_TYPE_IFINDEX
:
672 return yang_data_new_string(args
->xpath
, "ifindex");
674 case NEXTHOP_TYPE_IPV4
:
675 return yang_data_new_string(args
->xpath
, "ip4");
677 case NEXTHOP_TYPE_IPV4_IFINDEX
:
678 return yang_data_new_string(args
->xpath
, "ip4-ifindex");
680 case NEXTHOP_TYPE_IPV6
:
681 return yang_data_new_string(args
->xpath
, "ip6");
683 case NEXTHOP_TYPE_IPV6_IFINDEX
:
684 return yang_data_new_string(args
->xpath
, "ip6-ifindex");
695 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/vrf
698 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_vrf_get_elem(
699 struct nb_cb_get_elem_args
*args
)
701 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
703 return yang_data_new_string(args
->xpath
,
704 vrf_id_to_name(nexthop
->vrf_id
));
709 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/gateway
712 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_gateway_get_elem(
713 struct nb_cb_get_elem_args
*args
)
715 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
718 switch (nexthop
->type
) {
719 case NEXTHOP_TYPE_IPV4
:
720 case NEXTHOP_TYPE_IPV4_IFINDEX
:
721 addr
.ipa_type
= IPADDR_V4
;
722 memcpy(&addr
.ipaddr_v4
, &(nexthop
->gate
.ipv4
),
723 sizeof(struct in_addr
));
725 case NEXTHOP_TYPE_IPV6
:
726 case NEXTHOP_TYPE_IPV6_IFINDEX
:
727 addr
.ipa_type
= IPADDR_V6
;
728 memcpy(&addr
.ipaddr_v6
, &(nexthop
->gate
.ipv6
),
729 sizeof(struct in6_addr
));
731 case NEXTHOP_TYPE_BLACKHOLE
:
732 case NEXTHOP_TYPE_IFINDEX
:
734 return yang_data_new_string(args
->xpath
, "");
740 return yang_data_new_ip(args
->xpath
, &addr
);
745 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/interface
748 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_interface_get_elem(
749 struct nb_cb_get_elem_args
*args
)
751 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
753 if (nexthop
->ifindex
)
754 return yang_data_new_string(
756 ifindex2ifname(nexthop
->ifindex
, nexthop
->vrf_id
));
763 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/bh-type
766 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_bh_type_get_elem(
767 struct nb_cb_get_elem_args
*args
)
769 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
770 const char *type_str
= "";
772 if (nexthop
->type
!= NEXTHOP_TYPE_BLACKHOLE
)
775 switch (nexthop
->bh_type
) {
779 case BLACKHOLE_REJECT
:
782 case BLACKHOLE_ADMINPROHIB
:
783 type_str
= "prohibited";
785 case BLACKHOLE_UNSPEC
:
790 return yang_data_new_string(args
->xpath
, type_str
);
795 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/onlink
798 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_onlink_get_elem(
799 struct nb_cb_get_elem_args
*args
)
801 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
803 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
804 return yang_data_new_bool(args
->xpath
, true);
811 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/srte-color
814 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_color_get_elem(
815 struct nb_cb_get_elem_args
*args
)
817 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
819 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_SRTE
))
820 return yang_data_new_uint32(args
->xpath
, nexthop
->srte_color
);
827 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry
830 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_get_next(
831 struct nb_cb_get_next_args
*args
)
833 /* TODO: implement me. */
837 int lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_get_keys(
838 struct nb_cb_get_keys_args
*args
)
840 /* TODO: implement me. */
845 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_lookup_entry(
846 struct nb_cb_lookup_entry_args
*args
)
848 /* TODO: implement me. */
854 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/id
857 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_id_get_elem(
858 struct nb_cb_get_elem_args
*args
)
860 /* TODO: implement me. */
866 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/label
869 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_label_get_elem(
870 struct nb_cb_get_elem_args
*args
)
872 /* TODO: implement me. */
878 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/ttl
881 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_ttl_get_elem(
882 struct nb_cb_get_elem_args
*args
)
884 /* TODO: implement me. */
890 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/traffic-class
893 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_traffic_class_get_elem(
894 struct nb_cb_get_elem_args
*args
)
896 /* TODO: implement me. */
902 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/duplicate
905 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_duplicate_get_elem(
906 struct nb_cb_get_elem_args
*args
)
908 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
910 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
911 return yang_data_new_empty(args
->xpath
);
918 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/recursive
921 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_recursive_get_elem(
922 struct nb_cb_get_elem_args
*args
)
924 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
926 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
927 return yang_data_new_empty(args
->xpath
);
934 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/active
937 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_active_get_elem(
938 struct nb_cb_get_elem_args
*args
)
940 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
942 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
943 return yang_data_new_empty(args
->xpath
);
950 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/fib
953 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_fib_get_elem(
954 struct nb_cb_get_elem_args
*args
)
956 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
958 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
))
959 return yang_data_new_empty(args
->xpath
);
966 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/weight
969 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_weight_get_elem(
970 struct nb_cb_get_elem_args
*args
)
972 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
975 return yang_data_new_uint8(args
->xpath
, nexthop
->weight
);