]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #11840 from xdxu/master
authorRuss White <russ@riw.us>
Tue, 23 Aug 2022 14:58:57 +0000 (10:58 -0400)
committerGitHub <noreply@github.com>
Tue, 23 Aug 2022 14:58:57 +0000 (10:58 -0400)
ospf6d: Don't remove summary route if it is a range

debian/control
ospfd/ospf_apiserver.c
ospfd/ospf_ia.c
ospfd/ospf_interface.c
tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py
tests/topotests/conftest.py
tests/topotests/lib/topogen.py

index e8bf1a8ffa55ec860edef01d9ba12485b7b9960d..06c16cc9450c5742059781a1255d67f883a616d0 100644 (file)
@@ -30,6 +30,7 @@ Build-Depends: bison,
                python3-pytest <!nocheck>,
                python3-sphinx,
                texinfo (>= 4.7),
+               lua5.3 <pkg.frr.lua>,
                liblua5.3-dev <pkg.frr.lua>
 Standards-Version: 4.5.0.3
 Homepage: https://www.frrouting.org/
index b8567830b1d6edc04570a2457b8e2cb9a5d49cbb..f5ed77dab59099ae18d51a920d495c0374375535 100644 (file)
@@ -378,7 +378,7 @@ void ospf_apiserver_read(struct thread *thread)
                apiserv->t_sync_read = NULL;
 
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug("API: ospf_apiserver_read: Peer: %pI4/%u",
+                       zlog_debug("API: %s: Peer: %pI4/%u", __func__,
                                   &apiserv->peer_sync.sin_addr,
                                   ntohs(apiserv->peer_sync.sin_port));
        }
@@ -388,13 +388,13 @@ void ospf_apiserver_read(struct thread *thread)
                apiserv->t_async_read = NULL;
 
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug("API: ospf_apiserver_read: Peer: %pI4/%u",
+                       zlog_debug("API: %s: Peer: %pI4/%u", __func__,
                                   &apiserv->peer_async.sin_addr,
                                   ntohs(apiserv->peer_async.sin_port));
        }
 #endif /* USE_ASYNC_READ */
        else {
-               zlog_warn("ospf_apiserver_read: Unknown fd(%d)", fd);
+               zlog_warn("%s: Unknown fd(%d)", __func__, fd);
                ospf_apiserver_free(apiserv);
                return;
        }
@@ -402,9 +402,8 @@ void ospf_apiserver_read(struct thread *thread)
        /* Read message from fd. */
        msg = msg_read(fd);
        if (msg == NULL) {
-               zlog_warn(
-                       "ospf_apiserver_read: read failed on fd=%d, closing connection",
-                       fd);
+               zlog_warn("%s: read failed on fd=%d, closing connection",
+                         __func__, fd);
 
                /* Perform cleanup. */
                ospf_apiserver_free(apiserv);
@@ -438,20 +437,19 @@ void ospf_apiserver_sync_write(struct thread *thread)
 
        /* Sanity check */
        if (fd != apiserv->fd_sync) {
-               zlog_warn("ospf_apiserver_sync_write: Unknown fd=%d", fd);
+               zlog_warn("%s: Unknown fd=%d", __func__, fd);
                goto out;
        }
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("API: ospf_apiserver_sync_write: Peer: %pI4/%u",
+               zlog_debug("API: %s: Peer: %pI4/%u", __func__,
                           &apiserv->peer_sync.sin_addr,
                           ntohs(apiserv->peer_sync.sin_port));
 
        /* Check whether there is really a message in the fifo. */
        msg = msg_fifo_pop(apiserv->out_sync_fifo);
        if (!msg) {
-               zlog_warn(
-                       "API: ospf_apiserver_sync_write: No message in Sync-FIFO?");
+               zlog_warn("API: %s: No message in Sync-FIFO?", __func__);
                return;
        }
 
@@ -464,8 +462,7 @@ void ospf_apiserver_sync_write(struct thread *thread)
        msg_free(msg);
 
        if (rc < 0) {
-               zlog_warn("ospf_apiserver_sync_write: write failed on fd=%d",
-                         fd);
+               zlog_warn("%s: write failed on fd=%d", __func__, fd);
                goto out;
        }
 
@@ -500,20 +497,19 @@ void ospf_apiserver_async_write(struct thread *thread)
 
        /* Sanity check */
        if (fd != apiserv->fd_async) {
-               zlog_warn("ospf_apiserver_async_write: Unknown fd=%d", fd);
+               zlog_warn("%s: Unknown fd=%d", __func__, fd);
                goto out;
        }
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("API: ospf_apiserver_async_write: Peer: %pI4/%u",
+               zlog_debug("API: %s: Peer: %pI4/%u", __func__,
                           &apiserv->peer_async.sin_addr,
                           ntohs(apiserv->peer_async.sin_port));
 
        /* Check whether there is really a message in the fifo. */
        msg = msg_fifo_pop(apiserv->out_async_fifo);
        if (!msg) {
-               zlog_warn(
-                       "API: ospf_apiserver_async_write: No message in Async-FIFO?");
+               zlog_warn("API: %s: No message in Async-FIFO?", __func__);
                return;
        }
 
@@ -526,8 +522,7 @@ void ospf_apiserver_async_write(struct thread *thread)
        msg_free(msg);
 
        if (rc < 0) {
-               zlog_warn("ospf_apiserver_async_write: write failed on fd=%d",
-                         fd);
+               zlog_warn("%s: write failed on fd=%d", __func__, fd);
                goto out;
        }
 
@@ -575,8 +570,7 @@ int ospf_apiserver_serv_sock_family(unsigned short port, int family)
        /* Listen socket under queue length 3. */
        rc = listen(accept_sock, 3);
        if (rc < 0) {
-               zlog_warn("ospf_apiserver_serv_sock_family: listen: %s",
-                         safe_strerror(errno));
+               zlog_warn("%s: listen: %s", __func__, safe_strerror(errno));
                close(accept_sock); /* Close socket */
                return rc;
        }
@@ -608,8 +602,7 @@ void ospf_apiserver_accept(struct thread *thread)
        /* Accept connection for synchronous messages */
        new_sync_sock = sockunion_accept(accept_sock, &su);
        if (new_sync_sock < 0) {
-               zlog_warn("ospf_apiserver_accept: accept: %s",
-                         safe_strerror(errno));
+               zlog_warn("%s: accept: %s", __func__, safe_strerror(errno));
                return;
        }
 
@@ -622,16 +615,15 @@ void ospf_apiserver_accept(struct thread *thread)
        ret = getpeername(new_sync_sock, (struct sockaddr *)&peer_sync,
                          &peerlen);
        if (ret < 0) {
-               zlog_warn("ospf_apiserver_accept: getpeername: %s",
+               zlog_warn("%s: getpeername: %s", __func__,
                          safe_strerror(errno));
                close(new_sync_sock);
                return;
        }
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("API: ospf_apiserver_accept: New peer: %pI4/%u",
-                          &peer_sync.sin_addr,
-                          ntohs(peer_sync.sin_port));
+               zlog_debug("API: %s: New peer: %pI4/%u", __func__,
+                          &peer_sync.sin_addr, ntohs(peer_sync.sin_port));
 
        /* Create new socket for asynchronous messages. */
        peer_async = peer_sync;
@@ -640,18 +632,16 @@ void ospf_apiserver_accept(struct thread *thread)
        /* Check if remote port number to make reverse connection is valid one.
         */
        if (ntohs(peer_async.sin_port) == ospf_apiserver_getport()) {
-               zlog_warn(
-                       "API: ospf_apiserver_accept: Peer(%pI4/%u): Invalid async port number?",
-                       &peer_async.sin_addr,
-                       ntohs(peer_async.sin_port));
+               zlog_warn("API: %s: Peer(%pI4/%u): Invalid async port number?",
+                         __func__, &peer_async.sin_addr,
+                         ntohs(peer_async.sin_port));
                close(new_sync_sock);
                return;
        }
 
        new_async_sock = socket(AF_INET, SOCK_STREAM, 0);
        if (new_async_sock < 0) {
-               zlog_warn("ospf_apiserver_accept: socket: %s",
-                         safe_strerror(errno));
+               zlog_warn("%s: socket: %s", __func__, safe_strerror(errno));
                close(new_sync_sock);
                return;
        }
@@ -660,8 +650,7 @@ void ospf_apiserver_accept(struct thread *thread)
                      sizeof(struct sockaddr_in));
 
        if (ret < 0) {
-               zlog_warn("ospf_apiserver_accept: connect: %s",
-                         safe_strerror(errno));
+               zlog_warn("%s: connect: %s", __func__, safe_strerror(errno));
                close(new_sync_sock);
                close(new_async_sock);
                return;
@@ -672,8 +661,7 @@ void ospf_apiserver_accept(struct thread *thread)
        /* Make the asynchronous channel write-only. */
        ret = shutdown(new_async_sock, SHUT_RD);
        if (ret < 0) {
-               zlog_warn("ospf_apiserver_accept: shutdown: %s",
-                         safe_strerror(errno));
+               zlog_warn("%s: shutdown: %s", __func__, safe_strerror(errno));
                close(new_sync_sock);
                close(new_async_sock);
                return;
@@ -734,7 +722,7 @@ static int ospf_apiserver_send_msg(struct ospf_apiserver *apiserv,
                event = OSPF_APISERVER_ASYNC_WRITE;
                break;
        default:
-               zlog_warn("ospf_apiserver_send_msg: Unknown message type %d",
+               zlog_warn("%s: Unknown message type %d", __func__,
                          msg->hdr.msgtype);
                return -1;
        }
@@ -759,7 +747,7 @@ int ospf_apiserver_send_reply(struct ospf_apiserver *apiserv, uint32_t seqnr,
        int ret;
 
        if (!msg) {
-               zlog_warn("ospf_apiserver_send_reply: msg_new failed");
+               zlog_warn("%s: msg_new failed", __func__);
 #ifdef NOTYET
                /* Cannot allocate new message. What should we do? */
                ospf_apiserver_free(apiserv);
@@ -815,7 +803,7 @@ int ospf_apiserver_handle_msg(struct ospf_apiserver *apiserv, struct msg *msg)
                rc = ospf_apiserver_handle_sync_router_id(apiserv, msg);
                break;
        default:
-               zlog_warn("ospf_apiserver_handle_msg: Unknown message type: %d",
+               zlog_warn("%s: Unknown message type: %d", __func__,
                          msg->hdr.msgtype);
                rc = -1;
        }
@@ -846,8 +834,7 @@ int ospf_apiserver_register_opaque_type(struct ospf_apiserver *apiserv,
                originator_func = ospf_apiserver_lsa11_originator;
                break;
        default:
-               zlog_warn("ospf_apiserver_register_opaque_type: lsa_type(%d)",
-                         lsa_type);
+               zlog_warn("%s: lsa_type(%d)", __func__, lsa_type);
                return OSPF_API_ILLEGALLSATYPE;
        }
 
@@ -1018,8 +1005,8 @@ void ospf_apiserver_notify_ready_type9(struct ospf_apiserver *apiserv)
                                        0, OSPF_OPAQUE_LINK_LSA, r->opaque_type,
                                        oi->address->u.prefix4);
                                if (!msg) {
-                                       zlog_warn(
-                                               "apiserver_notify_ready_type9: msg_new failed");
+                                       zlog_warn("%s: msg_new failed",
+                                                 __func__);
 #ifdef NOTYET
                                        /* Cannot allocate new message. What
                                         * should we do? */
@@ -1067,8 +1054,8 @@ void ospf_apiserver_notify_ready_type10(struct ospf_apiserver *apiserv)
                                        0, OSPF_OPAQUE_AREA_LSA, r->opaque_type,
                                        area->area_id);
                                if (!msg) {
-                                       zlog_warn(
-                                               "apiserver_notify_ready_type10: msg_new failed");
+                                       zlog_warn("%s: msg_new failed",
+                                                 __func__);
 #ifdef NOTYET
                                        /* Cannot allocate new message. What
                                         * should we do? */
@@ -1110,8 +1097,7 @@ void ospf_apiserver_notify_ready_type11(struct ospf_apiserver *apiserv)
                                                   r->opaque_type, noarea_id);
 
                        if (!msg) {
-                               zlog_warn(
-                                       "apiserver_notify_ready_type11: msg_new failed");
+                               zlog_warn("%s: msg_new failed", __func__);
 #ifdef NOTYET
                                /* Cannot allocate new message. What should we
                                 * do? */
@@ -1234,8 +1220,7 @@ static int apiserver_sync_callback(struct ospf_lsa *lsa, void *p_arg,
                        MSG_LSA_UPDATE_NOTIFY, seqnum, ifaddr, area_id,
                        lsa->flags & OSPF_LSA_SELF, lsa->data);
                if (!msg) {
-                       zlog_warn(
-                               "apiserver_sync_callback: new_msg_update failed");
+                       zlog_warn("%s: new_msg_update failed", __func__);
 #ifdef NOTYET
                        /* Cannot allocate new message. What should we do? */
                        /*        ospf_apiserver_free (apiserv);*/ /* Do nothing
@@ -1534,7 +1519,7 @@ struct ospf_lsa *ospf_apiserver_opaque_lsa_new(struct ospf_area *area,
 
        /* Create a stream for internal opaque LSA */
        if ((s = stream_new(OSPF_MAX_LSA_SIZE)) == NULL) {
-               zlog_warn("ospf_apiserver_opaque_lsa_new: stream_new failed");
+               zlog_warn("%s: stream_new failed", __func__);
                return NULL;
        }
 
@@ -1627,7 +1612,7 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
        case OSPF_OPAQUE_LINK_LSA:
                oi = ospf_apiserver_if_lookup_by_addr(omsg->ifaddr);
                if (!oi) {
-                       zlog_warn("apiserver_originate: unknown interface %pI4",
+                       zlog_warn("%s: unknown interface %pI4", __func__,
                                  &omsg->ifaddr);
                        rc = OSPF_API_NOSUCHINTERFACE;
                        goto out;
@@ -1638,7 +1623,7 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
        case OSPF_OPAQUE_AREA_LSA:
                area = ospf_area_lookup_by_area_id(ospf, omsg->area_id);
                if (!area) {
-                       zlog_warn("apiserver_originate: unknown area %pI4",
+                       zlog_warn("%s: unknown area %pI4", __func__,
                                  &omsg->area_id);
                        rc = OSPF_API_NOSUCHAREA;
                        goto out;
@@ -1650,9 +1635,8 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
                break;
        default:
                /* We can only handle opaque types here */
-               zlog_warn(
-                       "apiserver_originate: Cannot originate non-opaque LSA type %d",
-                       data->type);
+               zlog_warn("%s: Cannot originate non-opaque LSA type %d",
+                         __func__, data->type);
                rc = OSPF_API_ILLEGALLSATYPE;
                goto out;
        }
@@ -1663,9 +1647,8 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
 
        if (!apiserver_is_opaque_type_registered(apiserv, lsa_type,
                                                 opaque_type)) {
-               zlog_warn(
-                       "apiserver_originate: LSA-type(%d)/Opaque-type(%d): Not registered",
-                       lsa_type, opaque_type);
+               zlog_warn("%s: LSA-type(%d)/Opaque-type(%d): Not registered",
+                         __func__, lsa_type, opaque_type);
                rc = OSPF_API_OPAQUETYPENOTREGISTERED;
                goto out;
        }
@@ -1785,9 +1768,8 @@ int ospf_apiserver_originate1(struct ospf_lsa *lsa, struct ospf_lsa *old)
                 */
                assert(!ospf_opaque_is_owned(old));
                if (IS_LSA_MAX_SEQ(old)) {
-                       flog_warn(
-                               EC_OSPF_LSA_INSTALL_FAILURE,
-                               "ospf_apiserver_originate1: old LSA at maxseq");
+                       flog_warn(EC_OSPF_LSA_INSTALL_FAILURE,
+                                 "%s: old LSA at maxseq", __func__);
                        return -1;
                }
                lsa->data->ls_seqnum = lsa_seqnum_increment(old);
@@ -1869,9 +1851,8 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
 
        apiserv = lookup_apiserver_by_lsa(lsa);
        if (!apiserv) {
-               zlog_warn(
-                       "ospf_apiserver_lsa_refresher: LSA[%s]: No apiserver?",
-                       dump_lsa_key(lsa));
+               zlog_warn("%s: LSA[%s]: No apiserver?", __func__,
+                         dump_lsa_key(lsa));
                lsa->data->ls_age =
                        htons(OSPF_LSA_MAXAGE); /* Flush it anyway. */
                goto out;
@@ -1889,8 +1870,7 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
                new = ospf_apiserver_opaque_lsa_new(lsa->area, lsa->oi,
                                                    lsa->data);
                if (!new) {
-                       zlog_warn(
-                               "ospf_apiserver_lsa_refresher: Cannot create a new LSA?");
+                       zlog_warn("%s: Cannot create a new LSA?", __func__);
                        goto out;
                }
        } else {
@@ -1908,9 +1888,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) {
-               flog_warn(
-                       EC_OSPF_LSA_INSTALL_FAILURE,
-                       "ospf_apiserver_lsa_refresher: ospf_lsa_install failed");
+               flog_warn(EC_OSPF_LSA_INSTALL_FAILURE,
+                         "%s: ospf_lsa_install failed", __func__);
                ospf_lsa_unlock(&new);
                goto out;
        }
@@ -1962,7 +1941,7 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
        case OSPF_OPAQUE_AREA_LSA:
                area = ospf_area_lookup_by_area_id(ospf, dmsg->area_id);
                if (!area) {
-                       zlog_warn("ospf_apiserver_lsa_delete: unknown area %pI4",
+                       zlog_warn("%s: unknown area %pI4", __func__,
                                  &dmsg->area_id);
                        rc = OSPF_API_NOSUCHAREA;
                        goto out;
@@ -1973,9 +1952,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
                area = NULL;
                break;
        default:
-               zlog_warn(
-                       "ospf_apiserver_lsa_delete: Cannot delete non-opaque LSA type %d",
-                       dmsg->lsa_type);
+               zlog_warn("%s: Cannot delete non-opaque LSA type %d", __func__,
+                         dmsg->lsa_type);
                rc = OSPF_API_ILLEGALLSATYPE;
                goto out;
        }
@@ -1986,9 +1964,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
 
        if (!apiserver_is_opaque_type_registered(apiserv, lsa_type,
                                                 opaque_type)) {
-               zlog_warn(
-                       "ospf_apiserver_lsa_delete: LSA-type(%d)/Opaque-type(%d): Not registered",
-                       lsa_type, opaque_type);
+               zlog_warn("%s: LSA-type(%d)/Opaque-type(%d): Not registered",
+                         __func__, lsa_type, opaque_type);
                rc = OSPF_API_OPAQUETYPENOTREGISTERED;
                goto out;
        }
@@ -2004,9 +1981,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
         */
        old = ospf_lsa_lookup(ospf, area, dmsg->lsa_type, id, ospf->router_id);
        if (!old) {
-               zlog_warn(
-                       "ospf_apiserver_lsa_delete: LSA[Type%d:%pI4] not in LSDB",
-                       dmsg->lsa_type, &id);
+               zlog_warn("%s: LSA[Type%d:%pI4] not in LSDB", __func__,
+                         dmsg->lsa_type, &id);
                rc = OSPF_API_NOSUCHLSA;
                goto out;
        }
@@ -2114,7 +2090,7 @@ int ospf_apiserver_new_if(struct interface *ifp)
 
        if (ifp->name[0] == '\0') {
                /* interface has empty name */
-               zlog_warn("ospf_apiserver_new_if: interface has no name?");
+               zlog_warn("%s: interface has no name?", __func__);
                return 0;
        }
 
@@ -2125,7 +2101,7 @@ int ospf_apiserver_new_if(struct interface *ifp)
 
        if (ifp->name[0] == '\0') {
                /* interface has empty name */
-               zlog_warn("ospf_apiserver_new_if: interface has no name?");
+               zlog_warn("%s: interface has no name?", __func__);
                return 0;
        }
 
@@ -2134,9 +2110,8 @@ int ospf_apiserver_new_if(struct interface *ifp)
        if (!oi) {
                /* This interface is known to Zebra but not to OSPF daemon yet.
                 */
-               zlog_warn(
-                       "ospf_apiserver_new_if: interface %s not known to OSPFd?",
-                       ifp->name);
+               zlog_warn("%s: interface %s not known to OSPFd?", __func__,
+                         ifp->name);
                return 0;
        }
 
@@ -2154,9 +2129,8 @@ int ospf_apiserver_del_if(struct interface *ifp)
        struct ospf_interface *oi;
 
        /* zlog_warn for debugging */
-       zlog_warn("ospf_apiserver_del_if");
-       zlog_warn("ifp name=%s status=%d index=%d", ifp->name, ifp->status,
-                 ifp->ifindex);
+       zlog_warn("%s ifp name=%s status=%d index=%d", __func__, ifp->name,
+                 ifp->status, ifp->ifindex);
 
        oi = ospf_apiserver_if_lookup_by_ifp(ifp);
 
@@ -2179,20 +2153,19 @@ void ospf_apiserver_ism_change(struct ospf_interface *oi, int old_state)
        /* Tell clients about interface change */
 
        /* zlog_warn for debugging */
-       zlog_warn("ospf_apiserver_ism_change");
+       zlog_warn("%s", __func__);
        if (listcount(apiserver_list) > 0) {
                ospf_apiserver_clients_notify_ism_change(oi);
        }
 
-       zlog_warn("oi->ifp->name=%s", oi->ifp->name);
-       zlog_warn("old_state=%d", old_state);
-       zlog_warn("oi->state=%d", oi->state);
+       zlog_warn("%s oi->ifp->name=%s old_state=%d oi->state=%d", __func__,
+                 oi->ifp->name, old_state, oi->state);
 }
 
 void ospf_apiserver_nsm_change(struct ospf_neighbor *nbr, int old_status)
 {
        /* Neighbor status changed, tell clients about it */
-       zlog_warn("ospf_apiserver_nsm_change");
+       zlog_warn("%s", __func__);
        if (listcount(apiserver_list) > 0) {
                ospf_apiserver_clients_notify_nsm_change(nbr);
        }
@@ -2300,7 +2273,8 @@ void ospf_apiserver_clients_notify_ready_type9(struct ospf_interface *oi)
                                        oi->address->u.prefix4);
                                if (!msg) {
                                        zlog_warn(
-                                               "ospf_apiserver_clients_notify_ready_type9: new_msg_ready_notify failed");
+                                               "%s: new_msg_ready_notify failed",
+                                               __func__);
 #ifdef NOTYET
                                        /* Cannot allocate new message. What
                                         * should we do? */
@@ -2344,7 +2318,8 @@ void ospf_apiserver_clients_notify_ready_type10(struct ospf_area *area)
                                        area->area_id);
                                if (!msg) {
                                        zlog_warn(
-                                               "ospf_apiserver_clients_notify_ready_type10: new_msg_ready_nofity failed");
+                                               "%s: new_msg_ready_nofity failed",
+                                               __func__);
 #ifdef NOTYET
                                        /* Cannot allocate new message. What
                                         * should we do? */
@@ -2390,7 +2365,8 @@ void ospf_apiserver_clients_notify_ready_type11(struct ospf *top)
                                        id_null);
                                if (!msg) {
                                        zlog_warn(
-                                               "ospf_apiserver_clients_notify_ready_type11: new_msg_ready_notify failed");
+                                               "%s: new_msg_ready_notify failed",
+                                               __func__);
 #ifdef NOTYET
                                        /* Cannot allocate new message. What
                                         * should we do? */
@@ -2449,8 +2425,7 @@ void ospf_apiserver_clients_notify_ism_change(struct ospf_interface *oi)
 
        msg = new_msg_ism_change(0, ifaddr, area_id, oi->state);
        if (!msg) {
-               zlog_warn(
-                       "apiserver_clients_notify_ism_change: msg_new failed");
+               zlog_warn("%s: msg_new failed", __func__);
                return;
        }
 
@@ -2473,8 +2448,7 @@ void ospf_apiserver_clients_notify_nsm_change(struct ospf_neighbor *nbr)
        msg = new_msg_nsm_change(0, ifaddr, nbraddr, nbr->router_id,
                                 nbr->state);
        if (!msg) {
-               zlog_warn(
-                       "apiserver_clients_notify_nsm_change: msg_new failed");
+               zlog_warn("%s: msg_new failed", __func__);
                return;
        }
 
@@ -2509,8 +2483,7 @@ static int apiserver_clients_lsa_change_notify(uint8_t msgtype,
                                        ifaddr, area_id,
                                        lsa->flags & OSPF_LSA_SELF, lsa->data);
        if (!msg) {
-               zlog_warn(
-                       "apiserver_clients_lsa_change_notify: msg_new failed");
+               zlog_warn("%s: msg_new failed", __func__);
                return -1;
        }
 
index f805899b81a07e1eb8e42fdbc314e0bcb253c7c4..f9869a673354bbea226712a218a7f1af77d96e14 100644 (file)
@@ -75,9 +75,7 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
        struct ospf_route * or ;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug(
-                       "ospf_ia_network_route(): processing summary route to %pFX",
-                       p);
+               zlog_debug("%s: processing summary route to %pFX", __func__, p);
 
        /* Find a route to the same dest */
        if ((rn1 = route_node_lookup(rt, (struct prefix *)p))) {
@@ -88,7 +86,8 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
                if ((or = rn1->info)) {
                        if (IS_DEBUG_OSPF_EVENT)
                                zlog_debug(
-                                       "ospf_ia_network_route(): Found a route to the same network");
+                                       "%s: Found a route to the same network",
+                                       __func__);
                        /* Check the existing route. */
                        if ((res = ospf_route_cmp(ospf, new_or, or)) < 0) {
                                /* New route is better, so replace old one. */
@@ -112,9 +111,7 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
        }        /*if (rn1)*/
        else {    /* no route */
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_ia_network_route(): add new route to %pFX",
-                               p);
+                       zlog_debug("%s: add new route to %pFX", __func__, p);
                ospf_route_add(rt, p, new_or, abr_or);
        }
 }
@@ -129,7 +126,7 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
        int ret;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_ia_router_route(): considering %pFX", p);
+               zlog_debug("%s: considering %pFX", __func__, p);
 
        /* Find a route to the same dest */
        rn = route_node_get(rtrs, (struct prefix *)p);
@@ -150,7 +147,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
        if (or) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
-                               "ospf_ia_router_route(): a route to the same ABR through the same area exists");
+                               "%s: a route to the same ABR through the same area exists",
+                               __func__);
                /* New route is better */
                if ((ret = ospf_route_cmp(ospf, new_or, or)) < 0) {
                        listnode_delete(rn->info, or);
@@ -160,8 +158,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
                /* Routes are the same */
                else if (ret == 0) {
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_ia_router_route(): merging the new route");
+                               zlog_debug("%s: merging the new route",
+                                          __func__);
 
                        ospf_route_copy_nexthops(or, abr_or->paths);
                        ospf_route_free(new_or);
@@ -170,8 +168,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
                /* New route is worse */
                else {
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_ia_router_route(): skipping the new route");
+                               zlog_debug("%s: skipping the new route",
+                                          __func__);
                        ospf_route_free(new_or);
                        return;
                }
@@ -180,7 +178,7 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
        ospf_route_copy_nexthops(new_or, abr_or->paths);
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_ia_router_route(): adding the new route");
+               zlog_debug("%s: adding the new route", __func__);
 
        listnode_add(rn->info, new_or);
 }
@@ -202,8 +200,7 @@ static int process_summary_lsa(struct ospf_area *area, struct route_table *rt,
        sl = (struct summary_lsa *)lsa->data;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("process_summary_lsa(): LS ID: %pI4",
-                          &sl->header.id);
+               zlog_debug("%s: LS ID: %pI4", __func__, &sl->header.id);
 
        metric = GET_METRIC(sl->metric);
 
@@ -311,8 +308,8 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
 
        if (abr_or == NULL) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_update_network_route(): can't find a route to the ABR");
+                       zlog_debug("%s: can't find a route to the ABR",
+                                  __func__);
                return;
        }
 
@@ -326,8 +323,8 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
                                   installed
                                   backbone paths */
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_update_network_route(): Allowing Shortcut ABR to add new route");
+                       zlog_debug("%s: Allowing Shortcut ABR to add new route",
+                                  __func__);
                new_or = ospf_route_new();
                new_or->type = OSPF_DESTINATION_NETWORK;
                new_or->id = lsa->header.id;
@@ -352,8 +349,7 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
        if (or->path_type != OSPF_PATH_INTRA_AREA &&
            or->path_type != OSPF_PATH_INTER_AREA) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_update_network_route(): ERR: path type is wrong");
+                       zlog_debug("%s: ERR: path type is wrong", __func__);
                return;
        }
 
@@ -364,37 +360,39 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
                                             or->u.std.area_id)) {
                        if (IS_DEBUG_OSPF_EVENT)
                                zlog_debug(
-                                       "ospf_update_network_route(): Shortcut: this intra-area path is not backbone");
+                                       "%s: Shortcut: this intra-area path is not backbone",
+                                       __func__);
                        return;
                }
        } else /* Not Shortcut ABR */
        {
                if (!OSPF_IS_AREA_ID_BACKBONE(or->u.std.area_id)) {
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_update_network_route(): route is not BB-associated");
+                               zlog_debug("%s: route is not BB-associated",
+                                          __func__);
                        return; /* We can update only BB routes */
                }
        }
 
        if (or->cost < cost) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_update_network_route(): new route is worse");
+                       zlog_debug("%s: new route is worse", __func__);
                return;
        }
 
        if (or->cost == cost) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
-                               "ospf_update_network_route(): new route is same distance, adding nexthops");
+                               "%s: new route is same distance, adding nexthops",
+                               __func__);
                ospf_route_copy_nexthops(or, abr_or->paths);
        }
 
        if (or->cost > cost) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
-                               "ospf_update_network_route(): new route is better, overriding nexthops");
+                               "%s: new route is better, overriding nexthops",
+                               __func__);
                ospf_route_subst_nexthops(or, abr_or->paths);
                or->cost = cost;
 
@@ -431,8 +429,8 @@ static void ospf_update_router_route(struct ospf *ospf,
 
        if (abr_or == NULL) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_update_router_route(): can't find a route to the ABR");
+                       zlog_debug("%s: can't find a route to the ABR",
+                                  __func__);
                return;
        }
 
@@ -481,8 +479,8 @@ static void ospf_update_router_route(struct ospf *ospf,
 
        if (!(or->u.std.flags & ROUTER_LSA_EXTERNAL)) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_upd_router_route(): the remote router is not an ASBR");
+                       zlog_debug("%s: the remote router is not an ASBR",
+                                  __func__);
                return;
        }
 
@@ -524,28 +522,24 @@ static int process_transit_summary_lsa(struct ospf_area *area,
        sl = (struct summary_lsa *)lsa->data;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("process_transit_summaries(): LS ID: %pI4",
-                          &lsa->data->id);
+               zlog_debug("%s: LS ID: %pI4", __func__, &lsa->data->id);
        metric = GET_METRIC(sl->metric);
 
        if (metric == OSPF_LS_INFINITY) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "process_transit_summaries(): metric is infinity, skip");
+                       zlog_debug("%s: metric is infinity, skip", __func__);
                return 0;
        }
 
        if (IS_LSA_MAXAGE(lsa)) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "process_transit_summaries(): This LSA is too old");
+                       zlog_debug("%s: This LSA is too old", __func__);
                return 0;
        }
 
        if (ospf_lsa_is_self_originated(area->ospf, lsa)) {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "process_transit_summaries(): This LSA is mine, skip");
+                       zlog_debug("%s: This LSA is mine, skip", __func__);
                return 0;
        }
 
@@ -586,20 +580,19 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
        struct ospf_area *area;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_ia_routing():start");
+               zlog_debug("%s:start", __func__);
 
        if (IS_OSPF_ABR(ospf)) {
                switch (ospf->abr_type) {
                case OSPF_ABR_STAND:
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug("ospf_ia_routing():Standard ABR");
+                               zlog_debug("%s:Standard ABR", __func__);
 
                        if ((area = ospf->backbone)) {
                                if (IS_DEBUG_OSPF_EVENT) {
                                        zlog_debug(
-                                               "ospf_ia_routing():backbone area found");
-                                       zlog_debug(
-                                               "ospf_ia_routing():examining summaries");
+                                               "%s:backbone area found, examining summaries",
+                                               __func__);
                                }
 
                                OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
@@ -611,23 +604,22 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
                                                        OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL(
                                                                area, rt, rtrs);
                        } else if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_ia_routing():backbone area NOT found");
+                               zlog_debug("%s:backbone area NOT found",
+                                          __func__);
                        break;
                case OSPF_ABR_IBM:
                case OSPF_ABR_CISCO:
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_ia_routing():Alternative Cisco/IBM ABR");
+                               zlog_debug("%s:Alternative Cisco/IBM ABR",
+                                          __func__);
                        area = ospf->backbone; /* Find the BB */
 
                        /* If we have an active BB connection */
                        if (area && ospf_act_bb_connection(ospf)) {
                                if (IS_DEBUG_OSPF_EVENT) {
                                        zlog_debug(
-                                               "ospf_ia_routing(): backbone area found");
-                                       zlog_debug(
-                                               "ospf_ia_routing(): examining BB summaries");
+                                               "%s: backbone area found, examining BB summaries",
+                                               __func__);
                                }
 
                                OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
@@ -642,7 +634,8 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
                                    */
                                if (IS_DEBUG_OSPF_EVENT)
                                        zlog_debug(
-                                               "ospf_ia_routing(): Active BB connection not found");
+                                               "%s: Active BB connection not found",
+                                               __func__);
                                for (ALL_LIST_ELEMENTS_RO(ospf->areas, node,
                                                          area))
                                        OSPF_EXAMINE_SUMMARIES_ALL(area, rt,
@@ -651,17 +644,15 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
                        break;
                case OSPF_ABR_SHORTCUT:
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_ia_routing():Alternative Shortcut");
+                               zlog_debug("%s:Alternative Shortcut", __func__);
                        area = ospf->backbone; /* Find the BB */
 
                        /* If we have an active BB connection */
                        if (area && ospf_act_bb_connection(ospf)) {
                                if (IS_DEBUG_OSPF_EVENT) {
                                        zlog_debug(
-                                               "ospf_ia_routing(): backbone area found");
-                                       zlog_debug(
-                                               "ospf_ia_routing(): examining BB summaries");
+                                               "%s: backbone area found, examining BB summaries",
+                                               __func__);
                                }
                                OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
                        }
@@ -683,8 +674,8 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
                }
        } else {
                if (IS_DEBUG_OSPF_EVENT)
-                       zlog_debug(
-                               "ospf_ia_routing():not ABR, considering all areas");
+                       zlog_debug("%s:not ABR, considering all areas",
+                                  __func__);
 
                for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
                        OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
index 2a758d55838e63f9dcf59b00779c216baaabe068..646d3183627df87bb912f285023ee12198e7e371 100644 (file)
@@ -909,18 +909,19 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
        struct prefix_ipv4 *p;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new()(%s): Start", ospf_get_name(ospf));
+               zlog_debug("%s: (%s): Start", __func__, ospf_get_name(ospf));
        if (vlink_count == OSPF_VL_MAX_COUNT) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
-                               "ospf_vl_new(): Alarm: cannot create more than OSPF_MAX_VL_COUNT virtual links");
+                               "%s: Alarm: cannot create more than OSPF_MAX_VL_COUNT virtual links",
+                               __func__);
+
                return NULL;
        }
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug(
-                       "ospf_vl_new(): creating pseudo zebra interface vrf id %u",
-                       ospf->vrf_id);
+               zlog_debug("%s: creating pseudo zebra interface vrf id %u",
+                          __func__, ospf->vrf_id);
 
        snprintf(ifname, sizeof(ifname), "VLINK%u", vlink_count);
        vi = if_get_by_name(ifname, ospf->vrf_id, ospf->name);
@@ -944,7 +945,9 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
        if (voi == NULL) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
-                               "ospf_vl_new(): Alarm: OSPF int structure is not created");
+                               "%s: Alarm: OSPF int structure is not created",
+                               __func__);
+
                return NULL;
        }
        voi->connected = co;
@@ -954,17 +957,15 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
 
        vlink_count++;
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new(): Created name: %s", ifname);
-       if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new(): set if->name to %s", vi->name);
+               zlog_debug("%s: Created name: %s set if->name to %s", __func__,
+                          ifname, vi->name);
 
        area_id.s_addr = INADDR_ANY;
        area = ospf_area_get(ospf, area_id);
        voi->area = area;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug(
-                       "ospf_vl_new(): set associated area to the backbone");
+               zlog_debug("%s: set associated area to the backbone", __func__);
 
        /* Add pseudo neighbor. */
        ospf_nbr_self_reset(voi, voi->ospf->router_id);
@@ -972,7 +973,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
        ospf_area_add_if(voi->area, voi);
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new(): Stop");
+               zlog_debug("%s: Stop", __func__);
        return voi;
 }
 
@@ -1167,10 +1168,8 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
        struct ospf_interface *oi;
 
        if (IS_DEBUG_OSPF_EVENT) {
-               zlog_debug("ospf_vl_up_check(): Start");
-               zlog_debug("ospf_vl_up_check(): Router ID is %pI4",
-                          &rid);
-               zlog_debug("ospf_vl_up_check(): Area is %pI4",
+               zlog_debug("%s: Start", __func__);
+               zlog_debug("%s: Router ID is %pI4 Area is %pI4", __func__, &rid,
                           &area->area_id);
        }
 
@@ -1189,13 +1188,13 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
                        SET_FLAG(vl_data->flags, OSPF_VL_FLAG_APPROVED);
 
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_vl_up_check(): this VL matched");
+                               zlog_debug("%s: this VL matched", __func__);
 
                        if (oi->state == ISM_Down) {
                                if (IS_DEBUG_OSPF_EVENT)
                                        zlog_debug(
-                                               "ospf_vl_up_check(): VL is down, waking it up");
+                                               "%s: VL is down, waking it up",
+                                               __func__);
                                SET_FLAG(oi->ifp->flags, IFF_UP);
                                OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceUp);
                        }
@@ -1203,13 +1202,15 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
                        if (ospf_vl_set_params(area, vl_data, v)) {
                                if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
                                        zlog_debug(
-                                               "ospf_vl_up_check: VL cost change, scheduling router lsa refresh");
+                                               "%s: VL cost change, scheduling router lsa refresh",
+                                               __func__);
                                if (ospf->backbone)
                                        ospf_router_lsa_update_area(
                                                ospf->backbone);
                                else if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
                                        zlog_debug(
-                                               "ospf_vl_up_check: VL cost change, no backbone!");
+                                               "%s: VL cost change, no backbone!",
+                                               __func__);
                        }
                }
        }
index c8cdc7ec5c7cb8fc2c65f19651616bc907b97856..4d7f436eac3f439e3c694fe70f26d4eccc19fe21 100644 (file)
@@ -22,6 +22,7 @@
 Following tests are covered.
 1. Verify default-originate route with default static and network command
 2. Verify default-originate route with aggregate summary command
+3. Verfiy  default-originate behaviour in ecmp
 """
 import os
 import sys
@@ -48,7 +49,10 @@ from lib.bgp import (
 from lib.common_config import (
     verify_fib_routes,
     step,
+    create_prefix_lists,
     run_frr_cmd,
+    create_route_maps,
+    shutdown_bringup_interface,
     get_frr_ipv6_linklocal,
     start_topology,
     apply_raw_config,
@@ -296,6 +300,78 @@ def verify_the_uptime(time_stamp_before, time_stamp_after, incremented=None):
         return True
 
 
+def get_best_path_route_in_FIB(tgen, topo, dut, network):
+    """
+    API to verify the best route in FIB and return the ipv4 and ipv6 nexthop for the given route
+    command
+    =======
+    show ip route
+    show ipv6 route
+    params
+    ======
+    dut : device under test :
+    network ; route (ip) to which the best route to be retrieved
+    Returns
+    ========
+    on success : return dict with next hops for the best hop
+    on failure : return error message with boolean False
+    """
+    is_ipv4_best_path_found = False
+    is_ipv6_best_path_found = False
+    rnode = tgen.routers()[dut]
+    ipv4_show_bgp_json = run_frr_cmd(rnode, "sh ip bgp  json ", isjson=True)
+    ipv6_show_bgp_json = run_frr_cmd(
+        rnode, "sh ip bgp ipv6 unicast  json ", isjson=True
+    )
+    output_dict = {"ipv4": None, "ipv6": None}
+    ipv4_nxt_hop_count = len(ipv4_show_bgp_json["routes"][network["ipv4"]])
+    for index in range(ipv4_nxt_hop_count):
+        if "bestpath" in ipv4_show_bgp_json["routes"][network["ipv4"]][index].keys():
+            best_path_ip = ipv4_show_bgp_json["routes"][network["ipv4"]][index][
+                "nexthops"
+            ][0]["ip"]
+            output_dict["ipv4"] = best_path_ip
+            logger.info(
+                "[DUT [{}]] Best path for the route {} is  {} ".format(
+                    dut, network["ipv4"], best_path_ip
+                )
+            )
+            is_ipv4_best_path_found = True
+        else:
+            logger.error("ERROR....! No Best Path  Found in BGP RIB.... FAILED")
+
+    ipv6_nxt_hop_count = len(ipv6_show_bgp_json["routes"][network["ipv6"]])
+    for index in range(ipv6_nxt_hop_count):
+        if "bestpath" in ipv6_show_bgp_json["routes"][network["ipv6"]][index].keys():
+            ip_add_count = len(
+                ipv6_show_bgp_json["routes"][network["ipv6"]][index]["nexthops"]
+            )
+            for i_index in range(ip_add_count):
+                if (
+                    "global"
+                    in ipv6_show_bgp_json["routes"][network["ipv6"]][index]["nexthops"][
+                        i_index
+                    ]["scope"]
+                ):
+                    best_path_ip = ipv6_show_bgp_json["routes"][network["ipv6"]][index][
+                        "nexthops"
+                    ][i_index]["ip"]
+                    output_dict["ipv6"] = best_path_ip
+                    logger.info(
+                        "[DUT [{}]] Best path for the route {} is  {} ".format(
+                            dut, network["ipv6"], best_path_ip
+                        )
+                    )
+
+        else:
+            logger.error("ERROR....! No Best Path  Found in BGP RIB.... FAILED")
+    if is_ipv4_best_path_found:
+        return output_dict
+    else:
+        logger.error("ERROR...! Unable to find the Best Path in the RIB")
+        return False
+
+
 #####################################################
 #
 #                      Testcases
@@ -1409,6 +1485,326 @@ def test_verify_bgp_default_originate_with_aggregate_summary_p1(request):
     write_test_footer(tc_name)
 
 
+def test_verify_default_originate_with_2way_ecmp_p2(request):
+    """
+    Summary: "Verify default-originate route with 3 way ECMP and traffic "
+    """
+
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global DEFAULT_ROUTES
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    step("Populating next-hops details")
+    r1_r2_ipv4_neighbor_ips = []
+    r1_r2_ipv6_neighbor_ips = []
+    r1_link = None
+    for index in range(1, 3):
+        r1_link = "r1-link" + str(index)
+        r1_r2_ipv4_neighbor_ips.append(
+            topo["routers"]["r2"]["links"][r1_link]["ipv4"].split("/")[0]
+        )
+        r1_r2_ipv6_neighbor_ips.append(
+            topo["routers"]["r2"]["links"][r1_link]["ipv6"].split("/")[0]
+        )
+
+    step(
+        "Configure default-originate on R1 for all the neighbor of IPv4 and IPv6 peers "
+    )
+    local_as = get_dut_as_number(tgen, dut="r1")
+    for index in range(2):
+        raw_config = {
+            "r1": {
+                "raw_config": [
+                    "router bgp {}".format(local_as),
+                    "address-family ipv4 unicast",
+                    "neighbor {} default-originate".format(
+                        r1_r2_ipv4_neighbor_ips[index]
+                    ),
+                    "exit-address-family",
+                    "address-family ipv6 unicast",
+                    "neighbor {} default-originate ".format(
+                        r1_r2_ipv6_neighbor_ips[index]
+                    ),
+                    "exit-address-family",
+                ]
+            }
+        }
+        result = apply_raw_config(tgen, raw_config)
+        assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+    step(
+        "After configuring default-originate command , verify default  routes are advertised on R2 "
+    )
+
+    r2_link = None
+    for index in range(1, 3):
+        r2_link = "r2-link" + str(index)
+        ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+        interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+        ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+        DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+
+        result = verify_rib_default_route(
+            tgen,
+            topo,
+            dut="r2",
+            routes=DEFAULT_ROUTES,
+            expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Ping R1 configure IPv4 and IPv6 loopback address from R2")
+    pingaddr = topo["routers"]["r1"]["links"]["lo"]["ipv4"].split("/")[0]
+    router = tgen.gears["r2"]
+    output = router.run("ping -c 4 -w 4 {}".format(pingaddr))
+    assert " 0% packet loss" in output, "Ping R1->R2  FAILED"
+    logger.info("Ping from R1 to R2 ... success")
+
+    step("Shuting up the active route")
+    network = {"ipv4": "0.0.0.0/0", "ipv6": "::/0"}
+    ipv_dict = get_best_path_route_in_FIB(tgen, topo, dut="r2", network=network)
+    dut_links = topo["routers"]["r1"]["links"]
+    active_interface = None
+    for key, values in dut_links.items():
+        ipv4_address = dut_links[key]["ipv4"].split("/")[0]
+        ipv6_address = dut_links[key]["ipv6"].split("/")[0]
+        if ipv_dict["ipv4"] == ipv4_address and ipv_dict["ipv6"] == ipv6_address:
+            active_interface = dut_links[key]["interface"]
+
+    logger.info(
+        "Shutting down the interface {} on router {} ".format(active_interface, "r1")
+    )
+    shutdown_bringup_interface(tgen, "r1", active_interface, False)
+
+    step("Verify the complete convergence  to fail after  shutting  the interface")
+    result = verify_bgp_convergence(tgen, topo, expected=False)
+    assert (
+        result is not True
+    ), " Testcase {} : After shuting down the interface  Convergence is expected to be Failed".format(
+        tc_name
+    )
+
+    step(
+        "Verify  routes from active best path is not received from  r1 after  shuting the interface"
+    )
+    r2_link = None
+    for index in range(1, 3):
+        r2_link = "r2-link" + str(index)
+        ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+        interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+        ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+        DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+        if index == 1:
+            result = verify_rib_default_route(
+                tgen,
+                topo,
+                dut="r2",
+                routes=DEFAULT_ROUTES,
+                expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+                expected=False,
+            )
+            assert result is not True, "Testcase {} : Failed \n Error: {}".format(
+                tc_name, result
+            )
+        else:
+            result = verify_rib_default_route(
+                tgen,
+                topo,
+                dut="r2",
+                routes=DEFAULT_ROUTES,
+                expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+            )
+            assert result is True, "Testcase {} : Failed \n Error: {}".format(
+                tc_name, result
+            )
+
+    step("Ping R1 configure IPv4 and IPv6 loopback address from R2")
+    pingaddr = topo["routers"]["r1"]["links"]["lo"]["ipv4"].split("/")[0]
+    router = tgen.gears["r2"]
+    output = router.run("ping -c 4 -w 4 {}".format(pingaddr))
+    assert " 0% packet loss" in output, "Ping R1->R2  FAILED"
+    logger.info("Ping from R1 to R2 ... success")
+
+    step("No Shuting up the active route")
+
+    shutdown_bringup_interface(tgen, "r1", active_interface, True)
+
+    step("Verify the complete convergence after bringup the interface")
+    result = verify_bgp_convergence(tgen, topo)
+    assert (
+        result is True
+    ), " Testcase {} : After bringing up  the interface  complete convergence is expected ".format(
+        tc_name
+    )
+
+    step("Verify all the routes are received from  r1 after no shuting the interface")
+    r2_link = None
+    for index in range(1, 3):
+        r2_link = "r2-link" + str(index)
+        ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+        interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+        ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+        DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+        if index == 1:
+            result = verify_rib_default_route(
+                tgen,
+                topo,
+                dut="r2",
+                routes=DEFAULT_ROUTES,
+                expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+            )
+            assert result is True, "Testcase {} : Failed \n Error: {}".format(
+                tc_name, result
+            )
+        else:
+            result = verify_rib_default_route(
+                tgen,
+                topo,
+                dut="r2",
+                routes=DEFAULT_ROUTES,
+                expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+            )
+            assert result is True, "Testcase {} : Failed \n Error: {}".format(
+                tc_name, result
+            )
+
+    step(
+        "Configure IPv4 and IPv6  route-map with deny option on R2 to filter default route  0.0.0.0/0 and 0::0/0"
+    )
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    input_dict_3 = {
+        "r2": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": DEFAULT_ROUTES["ipv4"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": DEFAULT_ROUTES["ipv6"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    input_dict_3 = {
+        "r2": {
+            "route_maps": {
+                "RMv4": [
+                    {
+                        "action": "deny",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv4"}},
+                    },
+                ],
+                "RMv6": [
+                    {
+                        "action": "deny",
+                        "seq_id": "1",
+                        "match": {"ipv6": {"prefix_lists": "Pv6"}},
+                    },
+                ],
+            }
+        }
+    }
+    result = create_route_maps(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("Apply route-map IN direction of R2 ( R2-R1) for IPv4 and IPv6 BGP neighbors")
+    r2_link = None
+    for index in range(1, 3):
+        r2_link = "r2-link" + str(index)
+        input_dict_4 = {
+            "r2": {
+                "bgp": {
+                    "address_family": {
+                        "ipv4": {
+                            "unicast": {
+                                "neighbor": {
+                                    "r1": {
+                                        "dest_link": {
+                                            r2_link: {
+                                                "route_maps": [
+                                                    {"name": "RMv4", "direction": "in"}
+                                                ]
+                                            },
+                                        }
+                                    }
+                                }
+                            }
+                        },
+                        "ipv6": {
+                            "unicast": {
+                                "neighbor": {
+                                    "r1": {
+                                        "dest_link": {
+                                            r2_link: {
+                                                "route_maps": [
+                                                    {"name": "RMv6", "direction": "in"}
+                                                ]
+                                            },
+                                        }
+                                    }
+                                }
+                            }
+                        },
+                    }
+                }
+            }
+        }
+        result = create_router_bgp(tgen, topo, input_dict_4)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("After applying the route-map the routes are not expected in RIB ")
+    r2_link = None
+    for index in range(1, 3):
+        r2_link = "r2-link" + str(index)
+        ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+        interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+        ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+        DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+
+        result = verify_rib_default_route(
+            tgen,
+            topo,
+            dut="r2",
+            routes=DEFAULT_ROUTES,
+            expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+            expected=False,
+        )
+        assert result is not True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    write_test_footer(tc_name)
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))
index 120a3e82e4096d714ba70ace75fb3684b66458b4..f79ca71a6482077fdbb3671d4eba2a49f7dc9e66 100755 (executable)
@@ -363,7 +363,7 @@ def pytest_configure(config):
 
     # Check environment now that we have config
     if not diagnose_env(rundir):
-        pytest.exit("environment has errors, please read the logs")
+        pytest.exit("environment has errors, please read the logs in %s" % rundir)
 
 
 @pytest.fixture(autouse=True, scope="session")
index c51a187f285900d2ac3c5e2d5103f1e9609b6122..04712eda874065e2ae6d7c72455adf61067b4d08 100644 (file)
@@ -1293,7 +1293,7 @@ def diagnose_env_linux(rundir):
                     )
                     continue
 
-                logger.warning("could not find {} in {}".format(fname, frrdir))
+                logger.error("could not find {} in {}".format(fname, frrdir))
                 ret = False
             else:
                 if fname != "zebra":