1 /* A generic nexthop structure
2 * Copyright (C) 2013 Cumulus Networks, Inc.
4 * This file is part of Quagga.
6 * Quagga 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
11 * Quagga 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.
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
27 #include "sockunion.h"
35 #include "nexthop_group.h"
37 DEFINE_MTYPE_STATIC(LIB
, NEXTHOP
, "Nexthop");
38 DEFINE_MTYPE_STATIC(LIB
, NH_LABEL
, "Nexthop label");
40 static int _nexthop_labels_cmp(const struct nexthop
*nh1
,
41 const struct nexthop
*nh2
)
43 const struct mpls_label_stack
*nhl1
= NULL
;
44 const struct mpls_label_stack
*nhl2
= NULL
;
49 /* No labels is a match */
59 if (nhl1
->num_labels
> nhl2
->num_labels
)
62 if (nhl1
->num_labels
< nhl2
->num_labels
)
65 return memcmp(nhl1
->label
, nhl2
->label
,
66 (nhl1
->num_labels
* sizeof(mpls_label_t
)));
69 int nexthop_g_addr_cmp(enum nexthop_types_t type
, const union g_addr
*addr1
,
70 const union g_addr
*addr2
)
75 case NEXTHOP_TYPE_IPV4
:
76 case NEXTHOP_TYPE_IPV4_IFINDEX
:
77 ret
= IPV4_ADDR_CMP(&addr1
->ipv4
, &addr2
->ipv4
);
79 case NEXTHOP_TYPE_IPV6
:
80 case NEXTHOP_TYPE_IPV6_IFINDEX
:
81 ret
= IPV6_ADDR_CMP(&addr1
->ipv6
, &addr2
->ipv6
);
83 case NEXTHOP_TYPE_IFINDEX
:
84 case NEXTHOP_TYPE_BLACKHOLE
:
92 static int _nexthop_gateway_cmp(const struct nexthop
*nh1
,
93 const struct nexthop
*nh2
)
95 return nexthop_g_addr_cmp(nh1
->type
, &nh1
->gate
, &nh2
->gate
);
98 static int _nexthop_source_cmp(const struct nexthop
*nh1
,
99 const struct nexthop
*nh2
)
101 return nexthop_g_addr_cmp(nh1
->type
, &nh1
->src
, &nh2
->src
);
104 static int _nexthop_cmp_no_labels(const struct nexthop
*next1
,
105 const struct nexthop
*next2
)
109 if (next1
->vrf_id
< next2
->vrf_id
)
112 if (next1
->vrf_id
> next2
->vrf_id
)
115 if (next1
->type
< next2
->type
)
118 if (next1
->type
> next2
->type
)
121 if (next1
->weight
< next2
->weight
)
124 if (next1
->weight
> next2
->weight
)
127 switch (next1
->type
) {
128 case NEXTHOP_TYPE_IPV4
:
129 case NEXTHOP_TYPE_IPV6
:
130 ret
= _nexthop_gateway_cmp(next1
, next2
);
134 case NEXTHOP_TYPE_IPV4_IFINDEX
:
135 case NEXTHOP_TYPE_IPV6_IFINDEX
:
136 ret
= _nexthop_gateway_cmp(next1
, next2
);
139 /* Intentional Fall-Through */
140 case NEXTHOP_TYPE_IFINDEX
:
141 if (next1
->ifindex
< next2
->ifindex
)
144 if (next1
->ifindex
> next2
->ifindex
)
147 case NEXTHOP_TYPE_BLACKHOLE
:
148 if (next1
->bh_type
< next2
->bh_type
)
151 if (next1
->bh_type
> next2
->bh_type
)
156 if (next1
->srte_color
< next2
->srte_color
)
158 if (next1
->srte_color
> next2
->srte_color
)
161 ret
= _nexthop_source_cmp(next1
, next2
);
165 if (!CHECK_FLAG(next1
->flags
, NEXTHOP_FLAG_HAS_BACKUP
) &&
166 !CHECK_FLAG(next2
->flags
, NEXTHOP_FLAG_HAS_BACKUP
))
169 if (!CHECK_FLAG(next1
->flags
, NEXTHOP_FLAG_HAS_BACKUP
) &&
170 CHECK_FLAG(next2
->flags
, NEXTHOP_FLAG_HAS_BACKUP
))
173 if (CHECK_FLAG(next1
->flags
, NEXTHOP_FLAG_HAS_BACKUP
) &&
174 !CHECK_FLAG(next2
->flags
, NEXTHOP_FLAG_HAS_BACKUP
))
177 if (next1
->backup_num
== 0 && next2
->backup_num
== 0)
180 if (next1
->backup_num
< next2
->backup_num
)
183 if (next1
->backup_num
> next2
->backup_num
)
186 ret
= memcmp(next1
->backup_idx
,
187 next2
->backup_idx
, next1
->backup_num
);
193 int nexthop_cmp(const struct nexthop
*next1
, const struct nexthop
*next2
)
197 ret
= _nexthop_cmp_no_labels(next1
, next2
);
201 ret
= _nexthop_labels_cmp(next1
, next2
);
207 * More-limited comparison function used to detect duplicate
208 * nexthops. This is used in places where we don't need the full
209 * comparison of 'nexthop_cmp()'.
211 int nexthop_cmp_basic(const struct nexthop
*nh1
,
212 const struct nexthop
*nh2
)
215 const struct mpls_label_stack
*nhl1
= NULL
;
216 const struct mpls_label_stack
*nhl2
= NULL
;
218 if (nh1
== NULL
&& nh2
== NULL
)
227 if (nh1
->vrf_id
< nh2
->vrf_id
)
230 if (nh1
->vrf_id
> nh2
->vrf_id
)
233 if (nh1
->type
< nh2
->type
)
236 if (nh1
->type
> nh2
->type
)
239 if (nh1
->weight
< nh2
->weight
)
242 if (nh1
->weight
> nh2
->weight
)
246 case NEXTHOP_TYPE_IPV4
:
247 case NEXTHOP_TYPE_IPV6
:
248 ret
= nexthop_g_addr_cmp(nh1
->type
, &nh1
->gate
, &nh2
->gate
);
252 case NEXTHOP_TYPE_IPV4_IFINDEX
:
253 case NEXTHOP_TYPE_IPV6_IFINDEX
:
254 ret
= nexthop_g_addr_cmp(nh1
->type
, &nh1
->gate
, &nh2
->gate
);
257 /* Intentional Fall-Through */
258 case NEXTHOP_TYPE_IFINDEX
:
259 if (nh1
->ifindex
< nh2
->ifindex
)
262 if (nh1
->ifindex
> nh2
->ifindex
)
265 case NEXTHOP_TYPE_BLACKHOLE
:
266 if (nh1
->bh_type
< nh2
->bh_type
)
269 if (nh1
->bh_type
> nh2
->bh_type
)
274 /* Compare source addr */
275 ret
= nexthop_g_addr_cmp(nh1
->type
, &nh1
->src
, &nh2
->src
);
279 nhl1
= nh1
->nh_label
;
280 nhl2
= nh2
->nh_label
;
282 /* No labels is a match */
292 if (nhl1
->num_labels
> nhl2
->num_labels
)
295 if (nhl1
->num_labels
< nhl2
->num_labels
)
298 ret
= memcmp(nhl1
->label
, nhl2
->label
,
299 (nhl1
->num_labels
* sizeof(mpls_label_t
)));
306 * nexthop_type_to_str
308 const char *nexthop_type_to_str(enum nexthop_types_t nh_type
)
310 static const char *const desc
[] = {
311 "none", "Directly connected",
312 "IPv4 nexthop", "IPv4 nexthop with ifindex",
313 "IPv6 nexthop", "IPv6 nexthop with ifindex",
317 return desc
[nh_type
];
321 * Check if the labels match for the 2 nexthops specified.
323 bool nexthop_labels_match(const struct nexthop
*nh1
, const struct nexthop
*nh2
)
325 if (_nexthop_labels_cmp(nh1
, nh2
) != 0)
331 struct nexthop
*nexthop_new(void)
335 nh
= XCALLOC(MTYPE_NEXTHOP
, sizeof(struct nexthop
));
338 * Default the weight to 1 here for all nexthops.
339 * The linux kernel does some weird stuff with adding +1 to
340 * all nexthop weights it gets over netlink.
341 * To handle this, just default everything to 1 right from
342 * from the beginning so we don't have to special case
343 * default weights in the linux netlink code.
345 * 1 should be a valid on all platforms anyway.
353 void nexthop_free(struct nexthop
*nexthop
)
355 nexthop_del_labels(nexthop
);
356 if (nexthop
->resolved
)
357 nexthops_free(nexthop
->resolved
);
358 XFREE(MTYPE_NEXTHOP
, nexthop
);
361 /* Frees a list of nexthops */
362 void nexthops_free(struct nexthop
*nexthop
)
364 struct nexthop
*nh
, *next
;
366 for (nh
= nexthop
; nh
; nh
= next
) {
372 bool nexthop_same(const struct nexthop
*nh1
, const struct nexthop
*nh2
)
383 if (nexthop_cmp(nh1
, nh2
) != 0)
389 bool nexthop_same_no_labels(const struct nexthop
*nh1
,
390 const struct nexthop
*nh2
)
401 if (_nexthop_cmp_no_labels(nh1
, nh2
) != 0)
408 * Allocate a new nexthop object and initialize it from various args.
410 struct nexthop
*nexthop_from_ifindex(ifindex_t ifindex
, vrf_id_t vrf_id
)
412 struct nexthop
*nexthop
;
414 nexthop
= nexthop_new();
415 nexthop
->type
= NEXTHOP_TYPE_IFINDEX
;
416 nexthop
->ifindex
= ifindex
;
417 nexthop
->vrf_id
= vrf_id
;
422 struct nexthop
*nexthop_from_ipv4(const struct in_addr
*ipv4
,
423 const struct in_addr
*src
,
426 struct nexthop
*nexthop
;
428 nexthop
= nexthop_new();
429 nexthop
->type
= NEXTHOP_TYPE_IPV4
;
430 nexthop
->vrf_id
= vrf_id
;
431 nexthop
->gate
.ipv4
= *ipv4
;
433 nexthop
->src
.ipv4
= *src
;
438 struct nexthop
*nexthop_from_ipv4_ifindex(const struct in_addr
*ipv4
,
439 const struct in_addr
*src
,
440 ifindex_t ifindex
, vrf_id_t vrf_id
)
442 struct nexthop
*nexthop
;
444 nexthop
= nexthop_new();
445 nexthop
->type
= NEXTHOP_TYPE_IPV4_IFINDEX
;
446 nexthop
->vrf_id
= vrf_id
;
447 nexthop
->gate
.ipv4
= *ipv4
;
449 nexthop
->src
.ipv4
= *src
;
450 nexthop
->ifindex
= ifindex
;
455 struct nexthop
*nexthop_from_ipv6(const struct in6_addr
*ipv6
,
458 struct nexthop
*nexthop
;
460 nexthop
= nexthop_new();
461 nexthop
->vrf_id
= vrf_id
;
462 nexthop
->type
= NEXTHOP_TYPE_IPV6
;
463 nexthop
->gate
.ipv6
= *ipv6
;
468 struct nexthop
*nexthop_from_ipv6_ifindex(const struct in6_addr
*ipv6
,
469 ifindex_t ifindex
, vrf_id_t vrf_id
)
471 struct nexthop
*nexthop
;
473 nexthop
= nexthop_new();
474 nexthop
->vrf_id
= vrf_id
;
475 nexthop
->type
= NEXTHOP_TYPE_IPV6_IFINDEX
;
476 nexthop
->gate
.ipv6
= *ipv6
;
477 nexthop
->ifindex
= ifindex
;
482 struct nexthop
*nexthop_from_blackhole(enum blackhole_type bh_type
)
484 struct nexthop
*nexthop
;
486 nexthop
= nexthop_new();
487 nexthop
->vrf_id
= VRF_DEFAULT
;
488 nexthop
->type
= NEXTHOP_TYPE_BLACKHOLE
;
489 nexthop
->bh_type
= bh_type
;
494 /* Update nexthop with label information. */
495 void nexthop_add_labels(struct nexthop
*nexthop
, enum lsp_types_t ltype
,
496 uint8_t num_labels
, const mpls_label_t
*labels
)
498 struct mpls_label_stack
*nh_label
;
504 /* Enforce limit on label stack size */
505 if (num_labels
> MPLS_MAX_LABELS
)
506 num_labels
= MPLS_MAX_LABELS
;
508 nexthop
->nh_label_type
= ltype
;
510 nh_label
= XCALLOC(MTYPE_NH_LABEL
,
511 sizeof(struct mpls_label_stack
)
512 + num_labels
* sizeof(mpls_label_t
));
513 nh_label
->num_labels
= num_labels
;
514 for (i
= 0; i
< num_labels
; i
++)
515 nh_label
->label
[i
] = *(labels
+ i
);
516 nexthop
->nh_label
= nh_label
;
519 /* Free label information of nexthop, if present. */
520 void nexthop_del_labels(struct nexthop
*nexthop
)
522 XFREE(MTYPE_NH_LABEL
, nexthop
->nh_label
);
523 nexthop
->nh_label_type
= ZEBRA_LSP_NONE
;
526 const char *nexthop2str(const struct nexthop
*nexthop
, char *str
, int size
)
528 switch (nexthop
->type
) {
529 case NEXTHOP_TYPE_IFINDEX
:
530 snprintf(str
, size
, "if %u", nexthop
->ifindex
);
532 case NEXTHOP_TYPE_IPV4
:
533 case NEXTHOP_TYPE_IPV4_IFINDEX
:
534 snprintfrr(str
, size
, "%pI4 if %u", &nexthop
->gate
.ipv4
,
537 case NEXTHOP_TYPE_IPV6
:
538 case NEXTHOP_TYPE_IPV6_IFINDEX
:
539 snprintfrr(str
, size
, "%pI6 if %u", &nexthop
->gate
.ipv6
,
542 case NEXTHOP_TYPE_BLACKHOLE
:
543 snprintf(str
, size
, "blackhole");
546 snprintf(str
, size
, "unknown");
554 * Iteration step for ALL_NEXTHOPS macro:
555 * This is the tricky part. Check if `nexthop' has
556 * NEXTHOP_FLAG_RECURSIVE set. If yes, this implies that `nexthop' has
557 * at least one nexthop attached to `nexthop->resolved', which will be
560 * If NEXTHOP_FLAG_RECURSIVE is not set, `nexthop' will progress in its
561 * current chain. In case its current chain end is reached, it will move
562 * upwards in the recursion levels and progress there. Whenever a step
563 * forward in a chain is done, recursion will be checked again.
564 * In a nustshell, it's equivalent to a pre-traversal order assuming that
565 * left branch is 'resolved' and right branch is 'next':
566 * https://en.wikipedia.org/wiki/Tree_traversal#/media/File:Sorted_binary_tree_preorder.svg
568 struct nexthop
*nexthop_next(const struct nexthop
*nexthop
)
570 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
571 return nexthop
->resolved
;
574 return nexthop
->next
;
576 for (struct nexthop
*par
= nexthop
->rparent
; par
; par
= par
->rparent
)
583 /* Return the next nexthop in the tree that is resolved and active */
584 struct nexthop
*nexthop_next_active_resolved(const struct nexthop
*nexthop
)
586 struct nexthop
*next
= nexthop_next(nexthop
);
589 && (CHECK_FLAG(next
->flags
, NEXTHOP_FLAG_RECURSIVE
)
590 || !CHECK_FLAG(next
->flags
, NEXTHOP_FLAG_ACTIVE
)))
591 next
= nexthop_next(next
);
596 unsigned int nexthop_level(const struct nexthop
*nexthop
)
600 for (const struct nexthop
*par
= nexthop
->rparent
;
601 par
; par
= par
->rparent
)
607 /* Only hash word-sized things, let cmp do the rest. */
608 uint32_t nexthop_hash_quick(const struct nexthop
*nexthop
)
610 uint32_t key
= 0x45afe398;
613 key
= jhash_3words(nexthop
->type
, nexthop
->vrf_id
,
614 nexthop
->nh_label_type
, key
);
616 if (nexthop
->nh_label
) {
617 int labels
= nexthop
->nh_label
->num_labels
;
621 while (labels
>= 3) {
622 key
= jhash_3words(nexthop
->nh_label
->label
[i
],
623 nexthop
->nh_label
->label
[i
+ 1],
624 nexthop
->nh_label
->label
[i
+ 2],
631 key
= jhash_2words(nexthop
->nh_label
->label
[i
],
632 nexthop
->nh_label
->label
[i
+ 1],
639 key
= jhash_1word(nexthop
->nh_label
->label
[i
], key
);
642 key
= jhash_2words(nexthop
->ifindex
,
643 CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
),
646 /* Include backup nexthops, if present */
647 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_HAS_BACKUP
)) {
648 int backups
= nexthop
->backup_num
;
652 while (backups
>= 3) {
653 key
= jhash_3words(nexthop
->backup_idx
[i
],
654 nexthop
->backup_idx
[i
+ 1],
655 nexthop
->backup_idx
[i
+ 2], key
);
660 while (backups
>= 2) {
661 key
= jhash_2words(nexthop
->backup_idx
[i
],
662 nexthop
->backup_idx
[i
+ 1], key
);
668 key
= jhash_1word(nexthop
->backup_idx
[i
], key
);
675 #define GATE_SIZE 4 /* Number of uint32_t words in struct g_addr */
677 /* For a more granular hash */
678 uint32_t nexthop_hash(const struct nexthop
*nexthop
)
680 uint32_t gate_src_rmap_raw
[GATE_SIZE
* 3] = {};
681 /* Get all the quick stuff */
682 uint32_t key
= nexthop_hash_quick(nexthop
);
684 assert(((sizeof(nexthop
->gate
) + sizeof(nexthop
->src
)
685 + sizeof(nexthop
->rmap_src
))
687 == (GATE_SIZE
* sizeof(uint32_t)));
689 memcpy(gate_src_rmap_raw
, &nexthop
->gate
, GATE_SIZE
);
690 memcpy(gate_src_rmap_raw
+ GATE_SIZE
, &nexthop
->src
, GATE_SIZE
);
691 memcpy(gate_src_rmap_raw
+ (2 * GATE_SIZE
), &nexthop
->rmap_src
,
694 key
= jhash2(gate_src_rmap_raw
, (GATE_SIZE
* 3), key
);
699 void nexthop_copy_no_recurse(struct nexthop
*copy
,
700 const struct nexthop
*nexthop
,
701 struct nexthop
*rparent
)
703 copy
->vrf_id
= nexthop
->vrf_id
;
704 copy
->ifindex
= nexthop
->ifindex
;
705 copy
->type
= nexthop
->type
;
706 copy
->flags
= nexthop
->flags
;
707 copy
->weight
= nexthop
->weight
;
709 assert(nexthop
->backup_num
< NEXTHOP_MAX_BACKUPS
);
710 copy
->backup_num
= nexthop
->backup_num
;
711 if (copy
->backup_num
> 0)
712 memcpy(copy
->backup_idx
, nexthop
->backup_idx
, copy
->backup_num
);
714 copy
->srte_color
= nexthop
->srte_color
;
715 memcpy(©
->gate
, &nexthop
->gate
, sizeof(nexthop
->gate
));
716 memcpy(©
->src
, &nexthop
->src
, sizeof(nexthop
->src
));
717 memcpy(©
->rmap_src
, &nexthop
->rmap_src
, sizeof(nexthop
->rmap_src
));
718 copy
->rparent
= rparent
;
719 if (nexthop
->nh_label
)
720 nexthop_add_labels(copy
, nexthop
->nh_label_type
,
721 nexthop
->nh_label
->num_labels
,
722 &nexthop
->nh_label
->label
[0]);
725 void nexthop_copy(struct nexthop
*copy
, const struct nexthop
*nexthop
,
726 struct nexthop
*rparent
)
728 nexthop_copy_no_recurse(copy
, nexthop
, rparent
);
730 /* Bit of a special case here, we need to handle the case
731 * of a nexthop resolving to a group. Hence, we need to
732 * use a nexthop_group API.
734 if (CHECK_FLAG(copy
->flags
, NEXTHOP_FLAG_RECURSIVE
))
735 copy_nexthops(©
->resolved
, nexthop
->resolved
, copy
);
738 struct nexthop
*nexthop_dup_no_recurse(const struct nexthop
*nexthop
,
739 struct nexthop
*rparent
)
741 struct nexthop
*new = nexthop_new();
743 nexthop_copy_no_recurse(new, nexthop
, rparent
);
747 struct nexthop
*nexthop_dup(const struct nexthop
*nexthop
,
748 struct nexthop
*rparent
)
750 struct nexthop
*new = nexthop_new();
752 nexthop_copy(new, nexthop
, rparent
);
757 * Parse one or more backup index values, as comma-separated numbers,
758 * into caller's array of uint8_ts. The array must be NEXTHOP_MAX_BACKUPS
759 * in size. Mails back the number of values converted, and returns 0 on
760 * success, <0 if an error in parsing.
762 int nexthop_str2backups(const char *str
, int *num_backups
,
765 char *ostr
; /* copy of string (start) */
766 char *lstr
; /* working copy of string */
767 char *nump
; /* pointer to next segment */
768 char *endp
; /* end pointer */
770 uint8_t tmp
[NEXTHOP_MAX_BACKUPS
];
773 /* Copy incoming string; the parse is destructive */
774 lstr
= ostr
= XSTRDUP(MTYPE_TMP
, str
);
778 for (i
= 0; i
< NEXTHOP_MAX_BACKUPS
&& lstr
; i
++) {
779 nump
= strsep(&lstr
, ",");
780 lval
= strtoul(nump
, &endp
, 10);
794 /* Limit to one octet */
804 if (ret
== 0 && i
== NEXTHOP_MAX_BACKUPS
&& lstr
)
809 memcpy(backups
, tmp
, i
);
812 XFREE(MTYPE_TMP
, ostr
);
818 * nexthop printing variants:
822 * is directly connected, eth0
823 * unreachable (blackhole)
827 * directly connected, eth0
828 * unreachable (blackhole)
832 printfrr_ext_autoreg_p("NH", printfrr_nh
)
833 static ssize_t
printfrr_nh(struct fbuf
*buf
, struct printfrr_eargs
*ea
,
836 const struct nexthop
*nexthop
= ptr
;
838 const char *v_is
= "", *v_via
= "", *v_viaif
= "via ";
844 if (*ea
->fmt
== 'v') {
852 return bputs(buf
, "(null)");
854 switch (nexthop
->type
) {
855 case NEXTHOP_TYPE_IPV4
:
856 case NEXTHOP_TYPE_IPV4_IFINDEX
:
857 ret
+= bprintfrr(buf
, "%s%pI4", v_via
,
858 &nexthop
->gate
.ipv4
);
861 case NEXTHOP_TYPE_IPV6
:
862 case NEXTHOP_TYPE_IPV6_IFINDEX
:
863 ret
+= bprintfrr(buf
, "%s%pI6", v_via
,
864 &nexthop
->gate
.ipv6
);
867 case NEXTHOP_TYPE_IFINDEX
:
868 ret
+= bprintfrr(buf
, "%sdirectly connected, %s", v_is
,
869 ifindex2ifname(nexthop
->ifindex
,
872 case NEXTHOP_TYPE_BLACKHOLE
:
873 ret
+= bputs(buf
, "unreachable");
875 switch (nexthop
->bh_type
) {
876 case BLACKHOLE_REJECT
:
877 ret
+= bputs(buf
, " (ICMP unreachable)");
879 case BLACKHOLE_ADMINPROHIB
:
880 ret
+= bputs(buf
, " (ICMP admin-prohibited)");
883 ret
+= bputs(buf
, " (blackhole)");
892 if (do_ifi
&& nexthop
->ifindex
)
893 ret
+= bprintfrr(buf
, ", %s%s", v_viaif
,
894 ifindex2ifname(nexthop
->ifindex
,
902 return bputs(buf
, "(null)");
904 switch (nexthop
->type
) {
905 case NEXTHOP_TYPE_IFINDEX
:
906 ret
+= bprintfrr(buf
, "if %u", nexthop
->ifindex
);
908 case NEXTHOP_TYPE_IPV4
:
909 case NEXTHOP_TYPE_IPV4_IFINDEX
:
910 ret
+= bprintfrr(buf
, "%pI4 if %u", &nexthop
->gate
.ipv4
,
913 case NEXTHOP_TYPE_IPV6
:
914 case NEXTHOP_TYPE_IPV6_IFINDEX
:
915 ret
+= bprintfrr(buf
, "%pI6 if %u", &nexthop
->gate
.ipv6
,
918 case NEXTHOP_TYPE_BLACKHOLE
:
919 ret
+= bputs(buf
, "blackhole");
922 ret
+= bputs(buf
, "unknown");