summaryrefslogtreecommitdiff
path: root/lib/nexthop.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r--lib/nexthop.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index b2fa945690..17ef95c687 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -34,8 +34,8 @@
#include "vrf.h"
#include "nexthop_group.h"
-DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop")
-DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label")
+DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop");
+DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label");
static int _nexthop_labels_cmp(const struct nexthop *nh1,
const struct nexthop *nh2)
@@ -739,6 +739,16 @@ static ssize_t printfrr_nh(char *buf, size_t bsz, const char *fmt,
const char *s, *v_is = "", *v_via = "", *v_viaif = "via ";
ssize_t ret = 3;
+ /* NULL-check */
+ if (nexthop == NULL) {
+ if (fmt[2] == 'v' && fmt[3] == 'v')
+ ret++;
+
+ strlcpy(buf, "NULL", bsz);
+
+ return ret;
+ }
+
switch (fmt[2]) {
case 'v':
if (fmt[3] == 'v') {