From 65dc7dd387744967153a45cb8fe3040a6572727e Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 14 Mar 2019 19:51:32 +0000 Subject: [PATCH] zebra: don't protodown a NULL interface We were running into some problems where VRRP is trying to protodown interfaces that no longer exist. While this is a minor bug in its own right, this was crashing Zebra because Zebra was not doing a null check after its ifindex lookup. Signed-off-by: Quentin Young --- zebra/zapi_msg.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index ca371186b7..6a478560ab 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1352,10 +1352,17 @@ static void zread_interface_set_protodown(ZAPI_HANDLER_ARGS) /* set ifdown */ ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), ifindex); - zlog_info("Setting interface %s (%u): protodown %s", ifp->name, ifindex, - down ? "on" : "off"); - zebra_if_set_protodown(ifp, down); + if (ifp) { + zlog_info("Setting interface %s (%u): protodown %s", ifp->name, + ifindex, down ? "on" : "off"); + zebra_if_set_protodown(ifp, down); + } else { + zlog_warn( + "Cannot set protodown %s for interface %u; does not exist", + down ? "on" : "off", ifindex); + } + stream_failure: return; -- 2.39.5