]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: nbr->oi is never null
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 21 Nov 2019 23:47:13 +0000 (18:47 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 21 Nov 2019 23:47:13 +0000 (18:47 -0500)
We test nbr->oi in a couple of places for null, but
in the majority of places of the nbr->oi data is being
used we just access it.  Touch up code to trust this
assertion and make the code more consistent in others.

Found in Coverity.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
ospfd/ospf_apiserver.c
ospfd/ospf_flood.c
ospfd/ospf_neighbor.c
ospfd/ospf_nsm.c
ospfd/ospf_packet.c
ospfd/ospf_snmp.c

index d6f1fba28b18c9c6505175a7ddf02224ab436ba9..bd703bc89de172eb73a736185b6dbdeaf706c17d 100644 (file)
@@ -2330,9 +2330,7 @@ void ospf_apiserver_clients_notify_nsm_change(struct ospf_neighbor *nbr)
 
        assert(nbr);
 
-       if (nbr->oi) {
-               ifaddr = nbr->oi->address->u.prefix4;
-       }
+       ifaddr = nbr->oi->address->u.prefix4;
 
        nbraddr = nbr->address.u.prefix4;
 
index 381fb6820fbe311ef3c465a412b39835ce5d385f..c29b464cab671ffb40dd2a5985766f8ffc244282 100644 (file)
@@ -328,8 +328,7 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr,
                        ospf_ls_retransmit_delete_nbr_as(ospf, current);
                        break;
                default:
-                       ospf_ls_retransmit_delete_nbr_area(nbr->oi->area,
-                                                          current);
+                       ospf_ls_retransmit_delete_nbr_area(oi->area, current);
                        break;
                }
        }
@@ -345,7 +344,7 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr,
           procedure cannot overwrite the newly installed LSA until
           MinLSArrival seconds have elapsed. */
 
-       if (!(new = ospf_lsa_install(ospf, nbr->oi, new)))
+       if (!(new = ospf_lsa_install(ospf, oi, new)))
                return -1; /* unknown LSA type or any other error condition */
 
        /* Acknowledge the receipt of the LSA by sending a Link State
index a9247dd0ec0ed02fda1c93607fa45192dc7e3cc4..46dfc505ef0f0475968d7419571246632c56c04d 100644 (file)
@@ -141,6 +141,8 @@ void ospf_nbr_free(struct ospf_neighbor *nbr)
        thread_cancel_event(master, nbr);
 
        ospf_bfd_info_free(&nbr->bfd_info);
+
+       nbr->oi = NULL;
        XFREE(MTYPE_OSPF_NEIGHBOR, nbr);
 }
 
@@ -446,7 +448,7 @@ static struct ospf_neighbor *ospf_nbr_add(struct ospf_interface *oi,
                nbr->crypt_seqnum = ospfh->u.crypt.crypt_seqnum;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("NSM[%s:%s]: start", IF_NAME(nbr->oi),
+               zlog_debug("NSM[%s:%s]: start", IF_NAME(oi),
                           inet_ntoa(nbr->router_id));
 
        return nbr;
index 110738802c5db15fe3f7587feb8922a02b96479f..9f6be3cbc74ad80bca9cf27b166dd9722da36485 100644 (file)
@@ -224,7 +224,7 @@ static int ospf_db_summary_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
        case OSPF_OPAQUE_LINK_LSA:
                /* Exclude type-9 LSAs that does not have the same "oi" with
                 * "nbr". */
-               if (nbr->oi && ospf_if_exists(lsa->oi) != nbr->oi)
+               if (ospf_if_exists(lsa->oi) != nbr->oi)
                        return 0;
                break;
        case OSPF_OPAQUE_AREA_LSA:
index 8634589b11c3c5e0b1320d1b8134c80a6024b312..80ffc3f36102e40e7d83bd70d415cc47a6dd9b07 100644 (file)
@@ -3746,8 +3746,6 @@ int ospf_hello_reply_timer(struct thread *thread)
        nbr = THREAD_ARG(thread);
        nbr->t_hello_reply = NULL;
 
-       assert(nbr->oi);
-
        if (IS_DEBUG_OSPF(nsm, NSM_TIMERS))
                zlog_debug("NSM[%s:%s]: Timer (hello-reply timer expire)",
                           IF_NAME(nbr->oi), inet_ntoa(nbr->router_id));
@@ -4335,7 +4333,7 @@ void ospf_proactively_arp(struct ospf_neighbor *nbr)
        char ping_nbr[OSPF_PING_NBR_STR_MAX];
        int ret;
 
-       if (!nbr || !nbr->oi || !nbr->oi->ifp)
+       if (!nbr)
                return;
 
        snprintf(ping_nbr, sizeof(ping_nbr),
index c26545344a9f5818213fb16d2eab3f90e0eb52f7..da3bc6f58112879e370adc8e875ca6e5615a7870 100644 (file)
@@ -2257,8 +2257,6 @@ static uint8_t *ospfNbrEntry(struct variable *v, oid *name, size_t *length,
        if (!nbr)
                return NULL;
        oi = nbr->oi;
-       if (!oi)
-               return NULL;
 
        /* Return the current value of the variable */
        switch (v->magic) {