]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospfd: Convert ospf_ext.c to use new error-code subsystem
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 21 Aug 2018 01:52:55 +0000 (21:52 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 6 Sep 2018 20:50:58 +0000 (20:50 +0000)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
ospfd/ospf_errors.c
ospfd/ospf_errors.h
ospfd/ospf_ext.c
ospfd/ospf_sr.c

index a597b075dd2ee8faf38c9de1bab000ce4092e389..25c211cf60e85114b27512230a59a36e378490d6 100644 (file)
@@ -79,6 +79,18 @@ static struct log_ref ferr_ospf_warn[] = {
                .description = "During processing of a new lsa and attempting to save the lsa into the OSPF database, this process failed.",
                .suggestion = "Gather log data from this machine and open an Issue",
        },
+       {
+               .code = OSPF_WARN_LSA_NULL,
+               .title = "OSPF has received a NULL lsa pointer",
+               .description = "When processing a LSA update we have found and noticed an internal error where we are passing around a NULL pointer",
+               .suggestion = "Gather data from this machine and it's peer and open an Issue",
+       },
+       {
+               .code = OSPF_WARN_EXT_LSA_UNEXPECTED,
+               .title = "OSPF has received EXT information that leaves it in an unexpected state",
+               .description = "While processing EXT LSA information, OSPF has noticed that the internal state of OSPF has gotten inconsistent",
+               .suggestion = "Gather data from this machine and it's peer and open an Issue",
+       },
        {
                .code = END_FERR,
        }
@@ -128,7 +140,7 @@ static struct log_ref ferr_ospf_err[] = {
                .suggestion = "Restart OSPF instance, If the problem persists, report the problem for troubleshooting"
        },
        {
-               .code = OSPF_ERR_SR_INVALID_ALGORITHM,
+               .code = OSPF_ERR_INVALID_ALGORITHM,
                .title = "OSPF SR Invalid Algorithm",
                .description = "OSPF Segment Routing invalid Algorithm",
                .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting"
index 721d8e08d3f038e63ccfec2f16136d89c96dcc0a..d6f2eb753c32f7a23227da9512790e558ec59a3c 100644 (file)
@@ -31,7 +31,7 @@ enum ospf_log_refs {
        OSPF_ERR_SR_INVALID_DB,
        OSPF_ERR_SR_NODE_CREATE,
        OSPF_ERR_SR_INVALID_LSA_ID,
-       OSPF_ERR_SR_INVALID_ALGORITHM,
+       OSPF_ERR_INVALID_ALGORITHM,
        OSPF_WARN_SET_METRIC_PLUS,
        OSPF_WARN_MD5,
        OSPF_WARN_PACKET,
@@ -41,6 +41,8 @@ enum ospf_log_refs {
        OSPF_WARN_OPAQUE_REGISTRATION,
        OSPF_WARN_TE_UNEXPECTED,
        OSPF_WARN_LSA_INSTALL_FAILURE,
+       OSPF_WARN_LSA_NULL,
+       OSPF_WARN_EXT_LSA_UNEXPECTED,
 };
 
 extern void ospf_error_init(void);
index 280c9b7868580f52ec74f6380ea5e880ee3557d7..018ca5c0faff1cbec9ea542bd5ddf81e5f6376ab 100644 (file)
@@ -177,12 +177,8 @@ int ospf_ext_init(void)
 void ospf_ext_term(void)
 {
 
-       if ((OspfEXT.scope != OSPF_OPAQUE_AREA_LSA)
-           && (OspfEXT.scope != OSPF_OPAQUE_AS_LSA))
-               zlog_warn(
-                       "EXT: Unable to unregister Extended Prefix "
-                       "Opaque LSA functions: Wrong scope!");
-       else
+       if ((OspfEXT.scope == OSPF_OPAQUE_AREA_LSA)
+           || (OspfEXT.scope == OSPF_OPAQUE_AS_LSA))
                ospf_delete_opaque_functab(OspfEXT.scope,
                                           OPAQUE_TYPE_EXTENDED_PREFIX_LSA);
 
@@ -319,8 +315,9 @@ static void set_prefix_sid(struct ext_itf *exti, uint8_t algorithm,
 
        if ((algorithm != SR_ALGORITHM_SPF)
            && (algorithm != SR_ALGORITHM_STRICT_SPF)) {
-               zlog_warn("EXT (%s): unrecognized algorithm, not SPF or S-SPF",
-                         __func__);
+               flog_err(OSPF_ERR_INVALID_ALGORITHM,
+                        "EXT (%s): unrecognized algorithm, not SPF or S-SPF",
+                        __func__);
                return;
        }
 
@@ -574,7 +571,8 @@ static int ospf_ext_link_del_if(struct interface *ifp)
 
                rc = 0;
        } else {
-               zlog_warn("EXT (%s): interface %s is not found", __func__,
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): interface %s is not found", __func__,
                          ifp ? ifp->name : "-");
        }
 
@@ -591,11 +589,8 @@ static void ospf_ext_link_ism_change(struct ospf_interface *oi, int old_status)
 
        /* Get interface information for Segment Routing */
        exti = lookup_ext_by_ifp(oi->ifp);
-       if (exti == NULL) {
-               zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)",
-                         __func__, IF_NAME(oi));
+       if (exti == NULL)
                return;
-       }
 
        /* Determine if interface is related to Adjacency or LAN Adj. SID */
        if (oi->type != OSPF_IFTYPE_LOOPBACK) {
@@ -624,7 +619,8 @@ static void ospf_ext_pref_ism_change(struct ospf_interface *oi, int old_status)
        /* Get interface information for Segment Routing */
        exti = lookup_ext_by_ifp(oi->ifp);
        if (exti == NULL) {
-               zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)",
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Cannot get Extended info. from OI(%s)",
                          __func__, IF_NAME(oi));
                return;
        }
@@ -661,13 +657,15 @@ static void ospf_ext_link_nsm_change(struct ospf_neighbor *nbr, int old_status)
        /* Get interface information for Segment Routing */
        exti = lookup_ext_by_ifp(oi->ifp);
        if (exti == NULL) {
-               zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)",
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Cannot get Extended info. from OI(%s)",
                          __func__, IF_NAME(oi));
                return;
        }
 
        if (oi->area == NULL || oi->area->ospf == NULL) {
-               zlog_warn("EXT (%s): Cannot refer to OSPF from OI(%s)",
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Cannot refer to OSPF from OI(%s)",
                          __func__, IF_NAME(oi));
                return;
        }
@@ -762,7 +760,8 @@ static int ospf_ext_link_lsa_update(struct ospf_lsa *lsa)
 {
        /* Sanity Check */
        if (lsa == NULL) {
-               zlog_warn("EXT (%s): Abort! LSA is NULL", __func__);
+               flog_warn(OSPF_WARN_LSA_NULL,
+                         "EXT (%s): Abort! LSA is NULL", __func__);
                return -1;
        }
 
@@ -795,7 +794,8 @@ static int ospf_ext_pref_lsa_update(struct ospf_lsa *lsa)
 
        /* Sanity Check */
        if (lsa == NULL) {
-               zlog_warn("EXT (%s): Abort! LSA is NULL", __func__);
+               flog_warn(OSPF_WARN_LSA_NULL,
+                         "EXT (%s): Abort! LSA is NULL", __func__);
                return -1;
        }
 
@@ -1062,7 +1062,8 @@ static int ospf_ext_pref_lsa_originate1(struct ospf_area *area,
        /* Create new Opaque-LSA/Extended Prefix Opaque LSA instance. */
        new = ospf_ext_pref_lsa_new(area, exti);
        if (new == NULL) {
-               zlog_warn("EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
                return rc;
        }
 
@@ -1115,7 +1116,8 @@ static int ospf_ext_link_lsa_originate1(struct ospf_area *area,
        /* Create new Opaque-LSA/Extended Link Opaque LSA instance. */
        new = ospf_ext_link_lsa_new(area, exti);
        if (new == NULL) {
-               zlog_warn("EXT (%s): ospf_ext_link_lsa_new() error", __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): ospf_ext_link_lsa_new() error", __func__);
                return rc;
        }
 
@@ -1188,9 +1190,8 @@ static int ospf_ext_pref_lsa_originate(void *arg)
                if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) {
                        if (CHECK_FLAG(exti->flags,
                                       EXT_LPFLG_LSA_FORCED_REFRESH)) {
-                               zlog_warn(
-                                       "EXT (%s): Refresh instead of "
-                                       "Originate",
+                               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                                         "EXT (%s): Refresh instead of Originate",
                                        __func__);
                                UNSET_FLAG(exti->flags,
                                           EXT_LPFLG_LSA_FORCED_REFRESH);
@@ -1246,10 +1247,9 @@ static int ospf_ext_link_lsa_originate(void *arg)
                if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) {
                        if (CHECK_FLAG(exti->flags,
                                       EXT_LPFLG_LSA_FORCED_REFRESH)) {
-                               zlog_warn(
-                                       "EXT (%s): Refresh instead of "
-                                       "Originate",
-                                       __func__);
+                               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                                         "EXT (%s): Refresh instead of Originate",
+                                         __func__);
                                UNSET_FLAG(exti->flags,
                                           EXT_LPFLG_LSA_FORCED_REFRESH);
                                ospf_ext_link_lsa_schedule(exti,
@@ -1298,14 +1298,16 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)
        /* Lookup this lsa corresponding Extended parameters */
        exti = lookup_ext_by_instance(lsa);
        if (exti == NULL) {
-               zlog_warn("EXT (%s): Invalid parameter LSA ID", __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Invalid parameter LSA ID", __func__);
                /* Flush it anyway. */
                lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
        }
 
        /* Check if Interface was not disable in the interval */
        if ((exti != NULL) && !CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)) {
-               zlog_warn("EXT (%s): Interface was Disabled: Flush it!",
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Interface was Disabled: Flush it!",
                          __func__);
                /* Flush it anyway. */
                lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
@@ -1323,7 +1325,8 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)
        new = ospf_ext_pref_lsa_new(area, exti);
 
        if (new == NULL) {
-               zlog_warn("EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
                return NULL;
        }
        new->data->ls_seqnum = lsa_seqnum_increment(lsa);
@@ -1382,14 +1385,16 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)
        /* Lookup this LSA corresponding Extended parameters */
        exti = lookup_ext_by_instance(lsa);
        if (exti == NULL) {
-               zlog_warn("EXT (%s): Invalid parameter LSA ID", __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Invalid parameter LSA ID", __func__);
                /* Flush it anyway. */
                lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
        }
 
        /* Check if Interface was not disable in the interval */
        if ((exti != NULL) && !CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)) {
-               zlog_warn("EXT (%s): Interface was Disabled: Flush it!",
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Interface was Disabled: Flush it!",
                          __func__);
                lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
        }
@@ -1405,7 +1410,8 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)
        /* Create new Opaque-LSA/Extended Link instance */
        new = ospf_ext_link_lsa_new(area, exti);
        if (new == NULL) {
-               zlog_warn("EXT (%s): Error creating new LSA", __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Error creating new LSA", __func__);
                return NULL;
        }
        new->data->ls_seqnum = lsa_seqnum_increment(lsa);
@@ -1461,10 +1467,9 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,
 
        /* Set LSA header information */
        if (exti->area == NULL) {
-               zlog_warn(
-                       "EXT (%s): Flooding is Area scope but area is not yet "
-                       "set",
-                       __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Flooding is Area scope but area is not yet set",
+                         __func__);
                if (OspfEXT.area == NULL) {
                        top = ospf_lookup_by_vrf_id(VRF_DEFAULT);
                        OspfEXT.area = ospf_area_lookup_by_area_id(
@@ -1491,9 +1496,6 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,
                UNSET_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED);
                ospf_opaque_lsa_flush_schedule(&lsa);
                break;
-       default:
-               zlog_warn("EXT (%s): Unknown opcode", __func__);
-               break;
        }
 }
 
@@ -1525,10 +1527,9 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,
 
        /* Set LSA header information */
        if (exti->area == NULL) {
-               zlog_warn(
-                       "EXT (%s): Flooding is Area scope but area is not "
-                       "yet set",
-                       __func__);
+               flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+                         "EXT (%s): Flooding is Area scope but area is not yet set",
+                         __func__);
                if (OspfEXT.area == NULL) {
                        top = ospf_lookup_by_vrf_id(VRF_DEFAULT);
                        OspfEXT.area = ospf_area_lookup_by_area_id(
@@ -1555,9 +1556,6 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,
                UNSET_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED);
                ospf_opaque_lsa_flush_schedule(&lsa);
                break;
-       default:
-               zlog_warn("EXT (%s): Unknown opcode", __func__);
-               break;
        }
 }
 
index fc8899cc855d079a686a00740cb9fef832f91259..2c6b3499e0742520a6fef21dcbb483ff092cc165 100644 (file)
@@ -817,7 +817,7 @@ static struct sr_prefix *get_ext_prefix_sid(struct tlv_header *tlvh)
                case EXT_SUBTLV_PREFIX_SID:
                        psid = (struct ext_subtlv_prefix_sid *)sub_tlvh;
                        if (psid->algorithm != SR_ALGORITHM_SPF) {
-                               flog_err(OSPF_ERR_SR_INVALID_ALGORITHM,
+                               flog_err(OSPF_ERR_INVALID_ALGORITHM,
                                          "SR (%s): Unsupported Algorithm",
                                          __func__);
                                XFREE(MTYPE_OSPF_SR_PARAMS, srp);