]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_apiserver.c
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / ospfd / ospf_apiserver.c
index 37735e36119e3129cb091bc5d2d3f06b8312bb80..d0ee8187229535f9c1f060b6028fdc388da94e33 100644 (file)
@@ -54,6 +54,7 @@
 #include "ospfd/ospf_route.h"
 #include "ospfd/ospf_ase.h"
 #include "ospfd/ospf_zebra.h"
+#include "ospfd/ospf_errors.h"
 
 #include "ospfd/ospf_api.h"
 #include "ospfd/ospf_apiserver.h"
@@ -152,7 +153,8 @@ int ospf_apiserver_init(void)
                NULL,             /* ospf_apiserver_lsa_refresher */
                ospf_apiserver_lsa_update, ospf_apiserver_lsa_delete);
        if (rc != 0) {
-               zlog_warn(
+               flog_warn(
+                       EC_OSPF_OPAQUE_REGISTRATION,
                        "ospf_apiserver_init: Failed to register opaque type [0/0]");
        }
 
@@ -180,7 +182,7 @@ void ospf_apiserver_term(void)
 
        /* Free client list itself */
        if (apiserver_list)
-               list_delete_and_null(&apiserver_list);
+               list_delete(&apiserver_list);
 
        /* Free wildcard list */
        /* XXX  */
@@ -867,7 +869,8 @@ int ospf_apiserver_register_opaque_type(struct ospf_apiserver *apiserv,
                NULL /* ospf_apiserver_lsa_delete */);
 
        if (rc != 0) {
-               zlog_warn("Failed to register opaque type [%d/%d]", lsa_type,
+               flog_warn(EC_OSPF_OPAQUE_REGISTRATION,
+                         "Failed to register opaque type [%d/%d]", lsa_type,
                          opaque_type);
                return OSPF_API_OPAQUETYPEINUSE;
        }
@@ -1176,13 +1179,11 @@ int ospf_apiserver_handle_register_event(struct ospf_apiserver *apiserv,
 
        apiserv->filter =
                XMALLOC(MTYPE_OSPF_APISERVER_MSGFILTER, ntohs(msg->hdr.msglen));
-       if (apiserv->filter) {
-               /* copy it over. */
-               memcpy(apiserv->filter, &rmsg->filter, ntohs(msg->hdr.msglen));
-               rc = OSPF_API_OK;
-       } else {
-               rc = OSPF_API_NOMEMORY;
-       }
+
+       /* copy it over. */
+       memcpy(apiserv->filter, &rmsg->filter, ntohs(msg->hdr.msglen));
+       rc = OSPF_API_OK;
+
        /* Send a reply back to client with return code */
        rc = ospf_apiserver_send_reply(apiserv, seqnum, rc);
        return rc;
@@ -1427,19 +1428,7 @@ struct ospf_lsa *ospf_apiserver_opaque_lsa_new(struct ospf_area *area,
        newlsa->length = htons(length);
 
        /* Create OSPF LSA. */
-       if ((new = ospf_lsa_new()) == NULL) {
-               zlog_warn("ospf_apiserver_opaque_lsa_new: ospf_lsa_new() ?");
-               stream_free(s);
-               return NULL;
-       }
-
-       if ((new->data = ospf_lsa_data_new(length)) == NULL) {
-               zlog_warn(
-                       "ospf_apiserver_opaque_lsa_new: ospf_lsa_data_new() ?");
-               ospf_lsa_unlock(&new);
-               stream_free(s);
-               return NULL;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        new->area = area;
        new->oi = oi;
@@ -1676,7 +1665,8 @@ int ospf_apiserver_originate1(struct ospf_lsa *lsa)
 
        /* Install this LSA into LSDB. */
        if (ospf_lsa_install(ospf, lsa->oi, lsa) == NULL) {
-               zlog_warn("ospf_apiserver_originate1: ospf_lsa_install failed");
+               flog_warn(EC_OSPF_LSA_INSTALL_FAILURE,
+                         "ospf_apiserver_originate1: ospf_lsa_install failed");
                return -1;
        }
 
@@ -1741,6 +1731,8 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
        struct ospf_lsa *new = NULL;
        struct ospf *ospf;
 
+       assert(lsa);
+
        ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
        assert(ospf);
 
@@ -1751,6 +1743,7 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
                        dump_lsa_key(lsa));
                lsa->data->ls_age =
                        htons(OSPF_LSA_MAXAGE); /* Flush it anyway. */
+               goto out;
        }
 
        if (IS_LSA_MAXAGE(lsa)) {
@@ -1784,7 +1777,8 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
 
        /* Install LSA into LSDB. */
        if (ospf_lsa_install(ospf, new->oi, new) == NULL) {
-               zlog_warn(
+               flog_warn(
+                       EC_OSPF_LSA_INSTALL_FAILURE,
                        "ospf_apiserver_lsa_refresher: ospf_lsa_install failed");
                ospf_lsa_unlock(&new);
                goto out;