From 229d0d4edc06e0b5fb38efd08f2c6b6378de2287 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sun, 1 Mar 2020 17:44:12 -0500 Subject: [PATCH] lib: don't crash on iface add for unknown vrf If Zebra sends us an interface add notification with a garbage VRF we crash on an assert(vrf_get(vrf_id, NULL)); let's not Signed-off-by: Quentin Young --- lib/zclient.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/zclient.c b/lib/zclient.c index ba4070ffee..e5336d8ec2 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1763,6 +1763,13 @@ static int zclient_interface_add(struct zclient *zclient, vrf_id_t vrf_id) STREAM_GET(ifname_tmp, s, INTERFACE_NAMSIZ); /* Lookup/create interface by name. */ + if (!vrf_get(vrf_id, NULL)) { + zlog_debug( + "Rx'd interface add from Zebra, but VRF %u does not exist", + vrf_id); + return -1; + } + ifp = if_get_by_name(ifname_tmp, vrf_id); zebra_interface_if_set_value(s, ifp);