From 04b6c83d56688355d7998ae24d101d8ccab4e98f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 25 Jan 2019 11:57:09 -0500 Subject: [PATCH 1/2] pimd: Prevent crash from using pim static mroutes If you have an interface being added to a static mroute and that interface has been configured w/ pim but does not have a valid ip address yet, we do not create a VIF for that device yet. As such when we attempt to assign the vif array in the pim static data structure we attempt to write into -1 of that array. Signed-off-by: Donald Sharp --- pimd/pim_static.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pimd/pim_static.c b/pimd/pim_static.c index 7334353c37..f7f6ea17c1 100644 --- a/pimd/pim_static.c +++ b/pimd/pim_static.c @@ -76,7 +76,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif, ifindex_t iif_index = pim_iif ? pim_iif->mroute_vif_index : 0; ifindex_t oif_index = pim_oif ? pim_oif->mroute_vif_index : 0; - if (!iif_index || !oif_index) { + if (!iif_index || !oif_index || iif_index == -1 || oif_index == -1) { zlog_warn( "%s %s: Unable to add static route: Invalid interface index(iif=%d,oif=%d)", __FILE__, __PRETTY_FUNCTION__, iif_index, oif_index); From 9981117a40d743bea26c7a3936f7613d618f7860 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 25 Jan 2019 12:05:33 -0500 Subject: [PATCH 2/2] pimd: Convert to using an ifindex_t for the vif Let's stay consistent in the data type for the vif index Signed-off-by: Donald Sharp --- pimd/pim_static.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pimd/pim_static.c b/pimd/pim_static.c index f7f6ea17c1..442b22e06f 100644 --- a/pimd/pim_static.c +++ b/pimd/pim_static.c @@ -42,7 +42,7 @@ static struct static_route *static_route_alloc(void) return XCALLOC(MTYPE_PIM_STATIC_ROUTE, sizeof(struct static_route)); } -static struct static_route *static_route_new(unsigned int iif, unsigned int oif, +static struct static_route *static_route_new(ifindex_t iif, ifindex_t oif, struct in_addr group, struct in_addr source) {