]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_sr.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / ospfd / ospf_sr.c
index 220de3234d2097fb9b0943d1e86a01394725d317..43842e414e007e9fe5bd4d659d9c8ab8da94ca75 100644 (file)
@@ -94,7 +94,7 @@ static unsigned int sr_hash(void *p)
 }
 
 /* Compare 2 Router ID hash entries based on SR Node */
-static int sr_cmp(const void *p1, const void *p2)
+static bool sr_cmp(const void *p1, const void *p2)
 {
        const struct sr_node *srn = p1;
        const struct in_addr *rid = p2;
@@ -165,10 +165,10 @@ static void sr_node_del(struct sr_node *srn)
                return;
 
        /* Clean Extended Link */
-       list_delete_and_null(&srn->ext_link);
+       list_delete(&srn->ext_link);
 
        /* Clean Prefix List */
-       list_delete_and_null(&srn->ext_prefix);
+       list_delete(&srn->ext_prefix);
 
        XFREE(MTYPE_OSPF_SR_PARAMS, srn);
 }
@@ -237,10 +237,6 @@ static int ospf_sr_start(struct ospf *ospf)
        srn = hash_get(OspfSR.neighbors, (void *)&(ospf->router_id),
                       (void *)sr_node_new);
 
-       /* Sanity Check */
-       if (srn == NULL)
-               return rc;
-
        /* Complete & Store self SR Node */
        srn->srgb.range_size = OspfSR.srgb.range_size;
        srn->srgb.lower_bound = OspfSR.srgb.lower_bound;
@@ -287,7 +283,7 @@ static void ospf_sr_stop(void)
 
        /*
         * Remove all SR Nodes from the Hash table. Prefix and Link SID will
-        * be remove though list_delete_and_null() call. See sr_node_del()
+        * be remove though list_delete() call. See sr_node_del()
         */
        hash_clean(OspfSR.neighbors, (void *)sr_node_del);
 }
@@ -825,9 +821,9 @@ 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,
-                                         "SR (%s): Unsupported Algorithm",
-                                         __func__);
+                               flog_err(EC_OSPF_INVALID_ALGORITHM,
+                                        "SR (%s): Unsupported Algorithm",
+                                        __func__);
                                XFREE(MTYPE_OSPF_SR_PARAMS, srp);
                                return NULL;
                        }
@@ -1106,8 +1102,8 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)
                return;
 
        if (OspfSR.neighbors == NULL) {
-               flog_err(OSPF_ERR_SR_INVALID_DB,
-                         "SR (%s): Abort! no valid SR DataBase", __func__);
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Abort! no valid SR DataBase", __func__);
                return;
        }
 
@@ -1117,18 +1113,18 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (srn == NULL) {
-               flog_err(OSPF_ERR_SR_NODE_CREATE,
-                         "SR (%s): Abort! can't create SR node in hash table",
-                         __func__);
+               flog_err(EC_OSPF_SR_NODE_CREATE,
+                        "SR (%s): Abort! can't create SR node in hash table",
+                        __func__);
                return;
        }
 
        if ((srn->instance != 0) && (srn->instance != ntohl(lsah->id.s_addr))) {
-               flog_err(OSPF_ERR_SR_INVALID_LSA_ID,
-                         "SR (%s): Abort! Wrong "
-                         "LSA ID 4.0.0.%u for SR node %s/%u",
-                         __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
-                         inet_ntoa(lsah->adv_router), srn->instance);
+               flog_err(EC_OSPF_SR_INVALID_LSA_ID,
+                        "SR (%s): Abort! Wrong "
+                        "LSA ID 4.0.0.%u for SR node %s/%u",
+                        __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
+                        inet_ntoa(lsah->adv_router), srn->instance);
                return;
        }
 
@@ -1171,8 +1167,9 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)
        /* Check that we collect mandatory parameters */
        if (srn->algo[0] == SR_ALGORITHM_UNSET || srgb.range_size == 0
            || srgb.lower_bound == 0) {
-               zlog_warn("SR (%s): Missing mandatory parameters. Abort!",
-                         __func__);
+               flog_err(EC_OSPF_SR_NODE_CREATE,
+                        "SR (%s): Missing mandatory parameters. Abort!",
+                        __func__);
                hash_release(OspfSR.neighbors, &(srn->adv_router));
                XFREE(MTYPE_OSPF_SR_PARAMS, srn);
                return;
@@ -1217,8 +1214,8 @@ void ospf_sr_ri_lsa_delete(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (OspfSR.neighbors == NULL) {
-               flog_err(OSPF_ERR_SR_INVALID_DB,
-                         "SR (%s): Abort! no valid SR Data Base", __func__);
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Abort! no valid SR Data Base", __func__);
                return;
        }
 
@@ -1227,18 +1224,17 @@ void ospf_sr_ri_lsa_delete(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (srn == NULL) {
-               flog_err(OSPF_ERR_SR_NODE_CREATE,
-                         "SR (%s): Abort! no entry in SRDB for SR Node %s",
-                         __func__, inet_ntoa(lsah->adv_router));
+               flog_err(EC_OSPF_SR_NODE_CREATE,
+                        "SR (%s): Abort! no entry in SRDB for SR Node %s",
+                        __func__, inet_ntoa(lsah->adv_router));
                return;
        }
 
        if ((srn->instance != 0) && (srn->instance != ntohl(lsah->id.s_addr))) {
-               flog_err(
-                       OSPF_ERR_SR_INVALID_LSA_ID,
-                       "SR (%s): Abort! Wrong LSA ID 4.0.0.%u for SR node %s",
-                       __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
-                       inet_ntoa(lsah->adv_router));
+               flog_err(EC_OSPF_SR_INVALID_LSA_ID,
+                        "SR (%s): Abort! Wrong LSA ID 4.0.0.%u for SR node %s",
+                        __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
+                        inet_ntoa(lsah->adv_router));
                return;
        }
 
@@ -1264,8 +1260,8 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (OspfSR.neighbors == NULL) {
-               flog_err(OSPF_ERR_SR_INVALID_DB,
-                         "SR (%s): Abort! no valid SR DataBase", __func__);
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Abort! no valid SR DataBase", __func__);
                return;
        }
 
@@ -1276,9 +1272,9 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (srn == NULL) {
-               flog_err(OSPF_ERR_SR_NODE_CREATE,
-                         "SR (%s): Abort! can't create SR node in hash table",
-                         __func__);
+               flog_err(EC_OSPF_SR_NODE_CREATE,
+                        "SR (%s): Abort! can't create SR node in hash table",
+                        __func__);
                return;
        }
 
@@ -1316,8 +1312,8 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (OspfSR.neighbors == NULL) {
-               flog_err(OSPF_ERR_SR_INVALID_DB,
-                         "SR (%s): Abort! no valid SR DataBase", __func__);
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Abort! no valid SR DataBase", __func__);
                return;
        }
 
@@ -1330,8 +1326,9 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)
         * processing Router Information LSA deletion
         */
        if (srn == NULL) {
-               zlog_warn("SR (%s): Stop! no entry in SRDB for SR Node %s",
-                         __func__, inet_ntoa(lsah->adv_router));
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Stop! no entry in SRDB for SR Node %s",
+                        __func__, inet_ntoa(lsah->adv_router));
                return;
        }
 
@@ -1347,11 +1344,11 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)
                listnode_delete(srn->ext_link, srl);
                XFREE(MTYPE_OSPF_SR_PARAMS, srl);
        } else {
-               zlog_warn(
-                       "SR (%s): Didn't found corresponding SR Link 8.0.0.%u "
-                       "for SR Node %s",
-                       __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
-                       inet_ntoa(lsah->adv_router));
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Didn't found corresponding SR Link 8.0.0.%u "
+                        "for SR Node %s",
+                        __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
+                        inet_ntoa(lsah->adv_router));
        }
 }
 
@@ -1374,8 +1371,8 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (OspfSR.neighbors == NULL) {
-               flog_err(OSPF_ERR_SR_INVALID_DB,
-                         "SR (%s): Abort! no valid SR DataBase", __func__);
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Abort! no valid SR DataBase", __func__);
                return;
        }
 
@@ -1386,9 +1383,9 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (srn == NULL) {
-               flog_err(OSPF_ERR_SR_NODE_CREATE,
-                         "SR (%s): Abort! can't create SR node in hash table",
-                         __func__);
+               flog_err(EC_OSPF_SR_NODE_CREATE,
+                        "SR (%s): Abort! can't create SR node in hash table",
+                        __func__);
                return;
        }
 
@@ -1427,8 +1424,8 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)
 
        /* Sanity check */
        if (OspfSR.neighbors == NULL) {
-               flog_err(OSPF_ERR_SR_INVALID_DB,
-                         "SR (%s): Abort! no valid SR DataBase", __func__);
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s): Abort! no valid SR DataBase", __func__);
                return;
        }
 
@@ -1441,8 +1438,9 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)
         * processing Router Information LSA deletion
         */
        if (srn == NULL) {
-               zlog_warn("SR (%s):  Stop! no entry in SRDB for SR Node %s",
-                         __func__, inet_ntoa(lsah->adv_router));
+               flog_err(EC_OSPF_SR_INVALID_DB,
+                        "SR (%s):  Stop! no entry in SRDB for SR Node %s",
+                        __func__, inet_ntoa(lsah->adv_router));
                return;
        }
 
@@ -1457,9 +1455,9 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)
                listnode_delete(srn->ext_link, srp);
                XFREE(MTYPE_OSPF_SR_PARAMS, srp);
        } else {
-               zlog_warn(
-                       "SR (%s): Didn't found corresponding SR Prefix "
-                       "7.0.0.%u for SR Node %s",
+               flog_err(
+                       EC_OSPF_SR_INVALID_DB,
+                       "SR (%s): Didn't found corresponding SR Prefix 7.0.0.%u for SR Node %s",
                        __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
                        inet_ntoa(lsah->adv_router));
        }
@@ -1706,10 +1704,7 @@ DEFUN(ospf_sr_enable,
 
        /* Start Segment Routing */
        OspfSR.enabled = true;
-       if (!ospf_sr_start(ospf)) {
-               zlog_warn("SR: Unable to start Segment Routing. Abort!");
-               return CMD_WARNING;
-       }
+       ospf_sr_start(ospf);
 
        /* Set Router Information SR parameters */
        if (IS_DEBUG_OSPF_EVENT)
@@ -1994,7 +1989,7 @@ DEFUN (sr_prefix_sid,
                 * update of this Extended Prefix
                 */
                listnode_add(OspfSR.self->ext_prefix, new);
-               zlog_warn(
+               zlog_info(
                        "Interface for prefix %s/%u not found. Deferred LSA "
                        "flooding",
                        inet_ntoa(p.u.prefix4), p.prefixlen);
@@ -2058,6 +2053,9 @@ DEFUN (no_sr_prefix_sid,
        bool found = false;
        int rc;
 
+       if (!ospf_sr_enabled(vty))
+               return CMD_WARNING_CONFIG_FAILED;
+
        /* Get network prefix */
        argv_find(argv, argc, "A.B.C.D/M", &idx);
        rc = str2prefix(argv[idx]->arg, &p);