]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: if_lookup_by_index can fail handle it appropriately
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 17 Apr 2020 00:26:00 +0000 (20:26 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 17 Apr 2020 00:28:15 +0000 (20:28 -0400)
It is possible that a if_lookup_by_index can return NULL
ensure that we handle this appropriately.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_nht.c
pimd/pim_zlookup.c

index 60b7c73d43aa0fab1a925a7b518497cde8c203a9..68d43c0556bde494f074e19b25250f5bbc16a81b 100644 (file)
@@ -788,7 +788,11 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
                        case NEXTHOP_TYPE_IPV6_IFINDEX:
                                ifp1 = if_lookup_by_index(nexthop->ifindex,
                                                          pim->vrf_id);
-                               nbr = pim_neighbor_find_if(ifp1);
+
+                               if (!ifp1)
+                                       nbr = NULL;
+                               else
+                                       nbr = pim_neighbor_find_if(ifp1);
                                /* Overwrite with Nbr address as NH addr */
                                if (nbr)
                                        nexthop->gate.ipv4 = nbr->source_addr;
index 84fac4f951bd70520573a8e088d58947d0fdd31a..49c221f8ed6c77c86100ac61d4e17215379c29e9 100644 (file)
@@ -285,17 +285,17 @@ static int zclient_read_nexthop(struct pim_instance *pim,
                         * If we are sending v6 secondary assume we receive v6
                         * secondary
                         */
-                       if (pim->send_v6_secondary)
-                               nbr = pim_neighbor_find_by_secondary(
-                                       if_lookup_by_index(
-                                               nexthop_tab[num_ifindex]
-                                                       .ifindex,
-                                               nexthop_vrf_id),
-                                       &p);
+                       struct interface *ifp = if_lookup_by_index(
+                               nexthop_tab[num_ifindex].ifindex,
+                               nexthop_vrf_id);
+
+                       if (!ifp)
+                               nbr = NULL;
+                       else if (pim->send_v6_secondary)
+                               nbr = pim_neighbor_find_by_secondary(ifp, &p);
                        else
-                               nbr = pim_neighbor_find_if(if_lookup_by_index(
-                                       nexthop_tab[num_ifindex].ifindex,
-                                       nexthop_vrf_id));
+                               nbr = pim_neighbor_find_if(ifp);
+
                        if (nbr) {
                                nexthop_tab[num_ifindex].nexthop_addr.family =
                                        AF_INET;