]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #11351 from kuldeepkash/uplink_mcast_tests
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 21 Jun 2022 15:37:40 +0000 (18:37 +0300)
committerGitHub <noreply@github.com>
Tue, 21 Jun 2022 15:37:40 +0000 (18:37 +0300)
tests: Add multicast-pim-multi-uplink test suite

59 files changed:
.github/workflows/stale.yml
bgpd/bgp_bfd.c
bgpd/bgp_bmp.c
bgpd/bgp_bmp.h
bgpd/bgp_debug.c
bgpd/bgp_network.c
bgpd/bgp_network.h
bgpd/bgp_route.c
bgpd/bgp_updgrp.c
bgpd/bgp_vty.c
bgpd/bgpd.h
doc/user/bmp.rst
doc/user/ldpd.rst
doc/user/routeserver.rst
eigrpd/eigrp_vty.c
lib/command.c
lib/if.c
lib/libfrr.c
lib/nexthop.c
lib/nexthop.h
lib/sockunion.c
lib/stream.c
lib/vty.c
nhrpd/zbuf.c
ospf6d/ospf6_interface.c
ospfd/ospf_dump.c
pimd/pim_addr.h
pimd/pim_cmd_common.c
pimd/pim_iface.c
pimd/pim_oil.c
pimd/pim_rp.c
python/tiabwarfo.py
tests/topotests/bgp_default_originate/bgp_default_originate_topo1.json [new file with mode: 0644]
tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_1.py [new file with mode: 0644]
tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_2.py [new file with mode: 0644]
tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json [new file with mode: 0644]
tests/topotests/ldp_topo1/test_ldp_topo1.py
tests/topotests/ldp_vpls_topo1/r1/ldpd.conf
tests/topotests/ldp_vpls_topo1/r2/ldpd.conf
tests/topotests/ldp_vpls_topo1/r3/ldpd.conf
tests/topotests/lib/bgp.py
tests/topotests/lib/common_config.py
tests/topotests/lib/pim.py
tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py
tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py
tools/etc/frr/daemons
tools/frrcommon.sh.in
vtysh/vtysh.c
zebra/interface.c
zebra/ioctl.c
zebra/zebra_evpn_mac.c
zebra/zebra_nb_config.c
zebra/zebra_netns_id.c
zebra/zebra_nhg.c
zebra/zebra_nhg.h
zebra/zebra_ptm.c

index df9f5ce5b3a891b7b32f2715240dfba133057fe9..aea81e9e139a90c74f352c7a83d12c919169c881 100644 (file)
@@ -14,7 +14,9 @@ jobs:
         repo-token: ${{ secrets.GITHUB_TOKEN }}
         stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Comment or remove the `autoclose` label in order to avoid having this issue closed.'
         stale-issue-label: autoclose
+        stale-pr-message: 'This PR is stale because it has been open 180 days with no activity. Comment or remove the `autoclose` label in order to avoid having this PR closed.'
+        stale-pr-label: autoclose
         days-before-stale: 180
-        days-before-close: -1
-        days-before-pr-stale: -1
-        days-before-pr-close: -1
+        days-before-close: 194
+        days-before-pr-stale: 180
+        days-before-pr-close: 194
index a859b7ad0f3c3965ebed5e1c8232e5c07a889681..d66b916b95240188292359cd9529bb5fa4625dce 100644 (file)
@@ -63,7 +63,7 @@ static void bfd_session_status_update(struct bfd_session_params *bsp,
                if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_MODE)
                    && bfd_sess_cbit(bsp) && !bss->remote_cbit) {
                        if (BGP_DEBUG(bfd, BFD_LIB))
-                               zlog_info(
+                               zlog_debug(
                                        "%s BFD DOWN message ignored in the process of graceful restart when C bit is cleared",
                                        peer->host);
                        return;
index 109f70f78f4ce990241c54b292a612371dcfe705..25712908df0ebb8b1a8639a2db6965b75d68c5be 100644 (file)
@@ -50,6 +50,7 @@
 #include "bgpd/bgp_updgrp.h"
 #include "bgpd/bgp_vty.h"
 #include "bgpd/bgp_trace.h"
+#include "bgpd/bgp_network.h"
 
 static void bmp_close(struct bmp *bmp);
 static struct bmp_bgp *bmp_bgp_find(struct bgp *bgp);
@@ -1763,6 +1764,7 @@ static void bmp_active_put(struct bmp_active *ba)
        if (ba->socket != -1)
                close(ba->socket);
 
+       XFREE(MTYPE_TMP, ba->ifsrc);
        XFREE(MTYPE_TMP, ba->hostname);
        XFREE(MTYPE_BMP_ACTIVE, ba);
 }
@@ -1772,9 +1774,34 @@ static void bmp_active_setup(struct bmp_active *ba);
 static void bmp_active_connect(struct bmp_active *ba)
 {
        enum connect_result res;
-       char buf[SU_ADDRSTRLEN];
+       struct interface *ifp;
+       vrf_id_t vrf_id = VRF_DEFAULT;
+       int res_bind;
 
        for (; ba->addrpos < ba->addrtotal; ba->addrpos++) {
+               if (ba->ifsrc) {
+                       if (ba->targets && ba->targets->bgp)
+                               vrf_id = ba->targets->bgp->vrf_id;
+
+                       /* find interface and related */
+                       /* address with same family   */
+                       ifp = if_lookup_by_name(ba->ifsrc, vrf_id);
+                       if (!ifp) {
+                               zlog_warn("bmp[%s]: failed to find interface",
+                                         ba->ifsrc);
+                               continue;
+                       }
+
+                       if (bgp_update_address(ifp, &ba->addrs[ba->addrpos],
+                                              &ba->addrsrc)){
+                               zlog_warn("bmp[%s]: failed to find matching address",
+                                         ba->ifsrc);
+                               continue;
+                       }
+                       zlog_info("bmp[%s]: selected source address : %pSU",
+                                 ba->ifsrc, &ba->addrsrc);
+               }
+
                ba->socket = sockunion_socket(&ba->addrs[ba->addrpos]);
                if (ba->socket < 0) {
                        zlog_warn("bmp[%s]: failed to create socket",
@@ -1783,20 +1810,42 @@ static void bmp_active_connect(struct bmp_active *ba)
                }
 
                set_nonblocking(ba->socket);
+
+               if (!sockunion_is_null(&ba->addrsrc)) {
+                       res_bind = sockunion_bind(ba->socket, &ba->addrsrc, 0,
+                                                 &ba->addrsrc);
+                       if (res_bind < 0) {
+                               zlog_warn(
+                                       "bmp[%s]: no bind currently to source address %pSU:%d",
+                                       ba->hostname, &ba->addrsrc, ba->port);
+                               close(ba->socket);
+                               ba->socket = -1;
+                               sockunion_init(&ba->addrsrc);
+                               continue;
+                       }
+               }
+
+
                res = sockunion_connect(ba->socket, &ba->addrs[ba->addrpos],
                                      htons(ba->port), 0);
                switch (res) {
                case connect_error:
-                       sockunion2str(&ba->addrs[ba->addrpos], buf,
-                                     sizeof(buf));
-                       zlog_warn("bmp[%s]: failed to connect to %s:%d",
-                                 ba->hostname, buf, ba->port);
+                       zlog_warn("bmp[%s]: failed to connect to %pSU:%d",
+                                 ba->hostname, &ba->addrs[ba->addrpos],
+                                 ba->port);
                        close(ba->socket);
                        ba->socket = -1;
+                       sockunion_init(&ba->addrsrc);
                        continue;
                case connect_success:
+                       zlog_info("bmp[%s]: connected to  %pSU:%d",
+                                 ba->hostname, &ba->addrs[ba->addrpos],
+                                 ba->port);
                        break;
                case connect_in_progress:
+                       zlog_warn("bmp[%s]: connect in progress  %pSU:%d",
+                                 ba->hostname, &ba->addrs[ba->addrpos],
+                                 ba->port);
                        bmp_active_setup(ba);
                        return;
                }
@@ -2041,7 +2090,7 @@ DEFPY(no_bmp_listener_main,
 
 DEFPY(bmp_connect,
       bmp_connect_cmd,
-      "[no] bmp connect HOSTNAME port (1-65535) {min-retry (100-86400000)|max-retry (100-86400000)}",
+      "[no] bmp connect HOSTNAME port (1-65535) {min-retry (100-86400000)|max-retry (100-86400000)} [source-interface <WORD$srcif>]",
       NO_STR
       BMP_STR
       "Actively establish connection to monitoring station\n"
@@ -2051,7 +2100,9 @@ DEFPY(bmp_connect,
       "Minimum connection retry interval\n"
       "Minimum connection retry interval (milliseconds)\n"
       "Maximum connection retry interval\n"
-      "Maximum connection retry interval (milliseconds)\n")
+      "Maximum connection retry interval (milliseconds)\n"
+      "Source interface to use\n"
+      "Define an interface\n")
 {
        VTY_DECLVAR_CONTEXT_SUB(bmp_targets, bt);
        struct bmp_active *ba;
@@ -2062,11 +2113,21 @@ DEFPY(bmp_connect,
                        vty_out(vty, "%% No such active connection found\n");
                        return CMD_WARNING;
                }
+               /* connection deletion need same hostname port and interface */
+               if (ba->ifsrc || srcif)
+                       if ((!ba->ifsrc) || (!srcif) ||
+                           !strcmp(ba->ifsrc, srcif)) {
+                               vty_out(vty,
+                                       "%% No such active connection found\n");
+                               return CMD_WARNING;
+                       }
                bmp_active_put(ba);
                return CMD_SUCCESS;
        }
 
        ba = bmp_active_get(bt, hostname, port);
+       if (srcif)
+               ba->ifsrc = XSTRDUP(MTYPE_TMP, srcif);
        if (min_retry_str)
                ba->minretry = min_retry;
        if (max_retry_str)
@@ -2309,7 +2370,7 @@ DEFPY(show_bmp,
 
                        vty_out(vty, "\n    Outbound connections:\n");
                        tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
-                       ttable_add_row(tt, "remote|state||timer");
+                       ttable_add_row(tt, "remote|state||timer|local");
                        ttable_rowseps(tt, 0, BOTTOM, true, '-');
                        frr_each (bmp_actives, &bt->actives, ba) {
                                const char *state_str = "?";
@@ -2318,9 +2379,13 @@ DEFPY(show_bmp,
                                        peer_uptime(ba->bmp->t_up.tv_sec,
                                                    uptime, sizeof(uptime),
                                                    false, NULL);
-                                       ttable_add_row(tt, "%s:%d|Up|%s|%s",
+                                       ttable_add_row(tt, "%s:%d|Up|%s|%s|%s",
                                                       ba->hostname, ba->port,
-                                                      ba->bmp->remote, uptime);
+                                                      ba->bmp->remote, uptime,
+                                                      sockunion2str(
+                                                               &ba->addrsrc,
+                                                               buf,
+                                                               SU_ADDRSTRLEN));
                                        continue;
                                }
 
@@ -2340,11 +2405,15 @@ DEFPY(show_bmp,
                                        state_str = "Resolving";
                                }
 
-                               ttable_add_row(tt, "%s:%d|%s|%s|%s",
+                               sockunion2str(&ba->addrsrc,
+                                             buf,
+                                             SU_ADDRSTRLEN);
+                               ttable_add_row(tt, "%s:%d|%s|%s|%s|%s",
                                               ba->hostname, ba->port,
                                               state_str,
                                               ba->last_err ? ba->last_err : "",
-                                              uptime);
+                                              uptime,
+                                              buf);
                                continue;
                        }
                        out = ttable_dump(tt, "\n");
@@ -2432,10 +2501,16 @@ static int bmp_config_write(struct bgp *bgp, struct vty *vty)
                                sockunion2str(&bl->addr, buf, SU_ADDRSTRLEN),
                                bl->port);
 
-               frr_each (bmp_actives, &bt->actives, ba)
-                       vty_out(vty, "  bmp connect %s port %u min-retry %u max-retry %u\n",
-                               ba->hostname, ba->port, ba->minretry, ba->maxretry);
+               frr_each (bmp_actives, &bt->actives, ba) {
+                       vty_out(vty, "  bmp connect %s port %u min-retry %u max-retry %u",
+                               ba->hostname, ba->port,
+                               ba->minretry, ba->maxretry);
 
+                       if (ba->ifsrc)
+                               vty_out(vty, " source-interface %s\n", ba->ifsrc);
+                       else
+                               vty_out(vty, "\n");
+               }
                vty_out(vty, " exit\n");
        }
 
index 899840e582de2e1cd2158ec24bf563a01049956d..1693b443eff7b06b6f0ddb091f391ed71af3adc4 100644 (file)
@@ -179,6 +179,8 @@ struct bmp_active {
        char *hostname;
        int port;
        unsigned minretry, maxretry;
+       char *ifsrc;
+       union sockunion addrsrc;
 
        struct resolver_query resq;
 
index 51e12cb64edd105cf2803c7ff1056ba1e296b017..8976b3b674eb00960d4e4fbaf1235920fba3a8f5 100644 (file)
@@ -2277,7 +2277,6 @@ DEFUN_NOSH (show_debugging_bgp,
        if (BGP_DEBUG(bfd, BFD_LIB))
                vty_out(vty, "  BGP BFD library debugging is on\n");
 
-       vty_out(vty, "\n");
        return CMD_SUCCESS;
 }
 
index bdd7ae04c2eb8be1c2d2e3ddde93a2f768404e55..9417b7d59a09e6fa8866f7da0c7441c480665efe 100644 (file)
@@ -631,7 +631,7 @@ static char *bgp_get_bound_name(struct peer *peer)
        return peer->bgp->name;
 }
 
-static int bgp_update_address(struct interface *ifp, const union sockunion *dst,
+int bgp_update_address(struct interface *ifp, const union sockunion *dst,
                              union sockunion *addr)
 {
        struct prefix *p, *sel, d;
index 22e34110bc446e0829bb9053d18e0c54bfa991a2..7420397a9337f055a48791d63e06006bc3a5316a 100644 (file)
@@ -45,5 +45,7 @@ extern int bgp_md5_unset_prefix(struct bgp *bgp, struct prefix *p);
 extern int bgp_md5_set(struct peer *);
 extern int bgp_md5_unset(struct peer *);
 extern int bgp_set_socket_ttl(struct peer *, int fd);
+extern int bgp_update_address(struct interface *ifp, const union sockunion *dst,
+                             union sockunion *addr);
 
 #endif /* _QUAGGA_BGP_NETWORK_H */
index f9d01913a8b82ff8dc6a92b13f835a8ed010f8c3..7b9e662b67710943da6c147513cd4fc225dd1057 100644 (file)
@@ -12812,6 +12812,11 @@ static const char *table_stats_strs[][2] = {
 struct bgp_table_stats {
        struct bgp_table *table;
        unsigned long long counts[BGP_STATS_MAX];
+
+       unsigned long long
+               prefix_len_count[MAX(EVPN_ROUTE_PREFIXLEN, IPV6_MAX_BITLEN) +
+                                1];
+
        double total_space;
 };
 
@@ -12829,6 +12834,7 @@ static void bgp_table_stats_rn(struct bgp_dest *dest, struct bgp_dest *top,
        ts->counts[BGP_STATS_PREFIXES]++;
        ts->counts[BGP_STATS_TOTPLEN] += rn_p->prefixlen;
 
+       ts->prefix_len_count[rn_p->prefixlen]++;
        /* check if the prefix is included by any other announcements */
        while (pdest && !bgp_dest_has_bgp_path_info_data(pdest))
                pdest = bgp_dest_parent_nolock(pdest);
@@ -12935,6 +12941,8 @@ static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi,
        int ret = CMD_SUCCESS;
        char temp_buf[20];
        struct json_object *json = NULL;
+       uint32_t bitlen = 0;
+       struct json_object *json_bitlen;
 
        if (json_array)
                json = json_object_new_object();
@@ -13133,6 +13141,38 @@ static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi,
                if (!json)
                        vty_out(vty, "\n");
        }
+
+       switch (afi) {
+       case AFI_IP:
+               bitlen = IPV4_MAX_BITLEN;
+               break;
+       case AFI_IP6:
+               bitlen = IPV6_MAX_BITLEN;
+               break;
+       case AFI_L2VPN:
+               bitlen = EVPN_ROUTE_PREFIXLEN;
+               break;
+       default:
+               break;
+       }
+
+       if (json) {
+               json_bitlen = json_object_new_array();
+
+               for (i = 0; i <= bitlen; i++) {
+                       struct json_object *ind_bit = json_object_new_object();
+
+                       if (!ts.prefix_len_count[i])
+                               continue;
+
+                       snprintf(temp_buf, sizeof(temp_buf), "%u", i);
+                       json_object_int_add(ind_bit, temp_buf,
+                                           ts.prefix_len_count[i]);
+                       json_object_array_add(json_bitlen, ind_bit);
+               }
+               json_object_object_add(json, "prefixLength", json_bitlen);
+       }
+
 end_table_stats:
        if (json)
                json_object_array_add(json_array, json);
index c5d049f36316b3882cc27190291baf322dd344c9..443c5d8a13dffb52809050e5e140514e53271f22 100644 (file)
@@ -414,8 +414,10 @@ static unsigned int updgrp_hash_key_make(const void *p)
 
        if (bgp_debug_neighbor_events(peer)) {
                zlog_debug(
-                       "%pBP Update Group Hash: sort: %d UpdGrpFlags: %u UpdGrpAFFlags: %u",
-                       peer, peer->sort, peer->flags & PEER_UPDGRP_FLAGS,
+                       "%pBP Update Group Hash: sort: %d UpdGrpFlags: %" PRIu64
+                       " UpdGrpAFFlags: %u",
+                       peer, peer->sort,
+                       (uint64_t)(peer->flags & PEER_UPDGRP_FLAGS),
                        flags & PEER_UPDGRP_AF_FLAGS);
                zlog_debug(
                        "%pBP Update Group Hash: addpath: %u UpdGrpCapFlag: %u UpdGrpCapAFFlag: %u route_adv: %u change local as: %u",
@@ -455,8 +457,10 @@ static unsigned int updgrp_hash_key_make(const void *p)
                        peer->shared_network &&
                                peer_afi_active_nego(peer, AFI_IP6));
                zlog_debug(
-                       "%pBP Update Group Hash: Lonesoul: %u ORF prefix: %u ORF old: %u max prefix out: %u",
-                       peer, CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL),
+                       "%pBP Update Group Hash: Lonesoul: %" PRIu64
+                       " ORF prefix: %u ORF old: %u max prefix out: %u",
+                       peer,
+                       (uint64_t)CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL),
                        CHECK_FLAG(peer->af_cap[afi][safi],
                                   PEER_CAP_ORF_PREFIX_SM_RCV),
                        CHECK_FLAG(peer->af_cap[afi][safi],
index bb88adbfc2513c004f26a106f1fd47d62e187ff8..95530c8cfeba37e3ce98cb0eb5cd8b2809d5d2ac 100644 (file)
@@ -13998,6 +13998,12 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                        vty_out(vty, "Local host: %s, Local port: %d\n",
                                sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN),
                                ntohs(p->su_local->sin.sin_port));
+       } else {
+               if (use_json) {
+                       json_object_string_add(json_neigh, "hostLocal",
+                                              "Unknown");
+                       json_object_int_add(json_neigh, "portLocal", -1);
+               }
        }
 
        /* Remote address. */
@@ -14013,6 +14019,12 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                sockunion2str(p->su_remote, buf1,
                                              SU_ADDRSTRLEN),
                                ntohs(p->su_remote->sin.sin_port));
+       } else {
+               if (use_json) {
+                       json_object_string_add(json_neigh, "hostForeign",
+                                              "Unknown");
+                       json_object_int_add(json_neigh, "portForeign", -1);
+               }
        }
 
        /* Nexthop display. */
index 98e59bcc85755e35c30745b480bd852496287ae8..a6a13a9a6e8493286937f5d33031a145c07b8acf 100644 (file)
@@ -1281,7 +1281,7 @@ struct peer {
         * peer-group, the peer-specific overrides (see flags_override and
         * flags_invert) must be respected.
         */
-       uint32_t flags;
+       uint64_t flags;
 #define PEER_FLAG_PASSIVE                   (1U << 0) /* passive mode */
 #define PEER_FLAG_SHUTDOWN                  (1U << 1) /* shutdown */
 #define PEER_FLAG_DONT_CAPABILITY           (1U << 2) /* dont-capability */
index f925910d4583d05fdcca7773b13773a4fe9c57b2..764584f89ce532d4a02c52104802aa3e2e1885c5 100644 (file)
@@ -108,13 +108,15 @@ BMP session configuration
 Inside a ``bmp targets`` block, the following commands control session
 establishment:
 
-.. clicmd:: bmp connect HOSTNAME port (1-65535) {min-retry MSEC|max-retry MSEC}
+
+.. clicmd:: bmp connect HOSTNAME port (1-65535) {min-retry MSEC|max-retry MSEC} [source-interface WORD]
 
    Add/remove an active outbound BMP session.  HOSTNAME is resolved via DNS,
    if multiple addresses are returned they are tried in nondeterministic
    order.  Only one connection will be established even if multiple addresses
    are returned.  ``min-retry`` and ``max-retry`` specify (in milliseconds)
-   bounds for exponential backoff.
+   bounds for exponential backoff. ``source-interface`` is the local interface on
+   which the connection has to bind.
 
 .. warning::
 
index 149e851891be8d4728c14ed3e3eb6e39b9bf4c05..682443a456676469a723934e97811dc60984d6d1 100644 (file)
@@ -128,6 +128,21 @@ LDP Configuration
    the IPv4 or IPv6 transport-address used by the LDP protocol to talk on this
    interface.
 
+.. clicmd:: ttl-security disable
+
+   Located under the LDP address-family node, use this command to disable the
+   GTSM procedures described in RFC 6720 (for the IPv4 address-family) and
+   RFC 7552 (for the IPv6 address-family).
+
+   Since GTSM is mandatory for LDPv6, the only effect of disabling GTSM for the
+   IPv6 address-family is that *ldpd* will not discard packets with a hop limit
+   below 255. This may be necessary to interoperate with older implementations.
+   Outgoing packets will still be sent using a hop limit of 255 for maximum
+   compatibility.
+
+   If GTSM is enabled, multi-hop neighbors should have either GTSM disabled
+   individually or configured with an appropriate ttl-security hops distance.
+
 .. clicmd:: neighbor A.B.C.D password PASSWORD
 
    The following command located under MPLS router node configures the router
@@ -143,6 +158,19 @@ LDP Configuration
    this time of non response, the LDP established session will be considered as
    set to down. By default, no holdtime is configured for the LDP devices.
 
+.. clicmd:: neighbor A.B.C.D ttl-security disable
+
+   Located under the MPLS LDP node, use this command to override the global
+   configuration and enable/disable GTSM for the specified neighbor.
+
+.. clicmd:: neighbor A.B.C.D ttl-security hops (1-254)
+
+   Located under the MPLS LDP node, use this command to set the maximum number
+   of hops the specified neighbor may be away. When GTSM is enabled for this
+   neighbor, incoming packets are required to have a TTL/hop limit of 256
+   minus this value, ensuring they have not passed through more than the
+   expected number of hops. The default value is 1.
+
 .. clicmd:: discovery hello holdtime HOLDTIME
 
 .. clicmd:: discovery hello interval INTERVAL
index 5100d679f704c96165369cad61fa70b7927b88db..969cd17920b44a43e4bec65b899e6cbbed96782b 100644 (file)
@@ -183,7 +183,7 @@ in order to support the route server features.
    that moment, every announcement received by the route server will be also
    considered for the new Loc-RIB.
 
-.. clicmd:: neigbor A.B.C.D|X.X::X.X|peer-group route-map WORD import|export
+.. clicmd:: neigbor A.B.C.D|X.X::X.X|peer-group route-map WORD in|out
 
    This set of commands can be used to specify the route-map that represents
    the Import or Export policy of a peer which is configured as a RS-client
@@ -372,20 +372,20 @@ the policies for client RA):
      address-family ipv6
        neighbor 2001:0DB8::A activate
        neighbor 2001:0DB8::A route-server-client
-       neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT import
-       neighbor 2001:0DB8::A route-map RSCLIENT-A-EXPORT export
+       neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT in
+       neighbor 2001:0DB8::A route-map RSCLIENT-A-EXPORT out
        neighbor 2001:0DB8::A soft-reconfiguration inbound
 
        neighbor 2001:0DB8::B activate
        neighbor 2001:0DB8::B route-server-client
-       neighbor 2001:0DB8::B route-map RSCLIENT-B-IMPORT import
-       neighbor 2001:0DB8::B route-map RSCLIENT-B-EXPORT export
+       neighbor 2001:0DB8::B route-map RSCLIENT-B-IMPORT in
+       neighbor 2001:0DB8::B route-map RSCLIENT-B-EXPORT out
        neighbor 2001:0DB8::B soft-reconfiguration inbound
 
        neighbor 2001:0DB8::C activate
        neighbor 2001:0DB8::C route-server-client
-       neighbor 2001:0DB8::C route-map RSCLIENT-C-IMPORT import
-       neighbor 2001:0DB8::C route-map RSCLIENT-C-EXPORT export
+       neighbor 2001:0DB8::C route-map RSCLIENT-C-IMPORT in
+       neighbor 2001:0DB8::C route-map RSCLIENT-C-EXPORT out
        neighbor 2001:0DB8::C soft-reconfiguration inbound
      exit-address-family
    !
@@ -501,7 +501,7 @@ do it:
 
 .. code-block:: frr
 
-   neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT import
+   neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT in
    ...
    !
    ...
index 0809ac2cf08e63cb07dec3de540433d419a2b0c0..3d61294b22bd9989f8be7ef7c5ac99e56dd7fb80 100644 (file)
@@ -240,14 +240,14 @@ DEFPY (show_ip_eigrp_interfaces,
        struct eigrp *eigrp;
 
        if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) {
-               struct vrf *vrf;
+               struct vrf *v;
 
-               RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-                       eigrp = eigrp_lookup(vrf->vrf_id);
+               RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
+                       eigrp = eigrp_lookup(v->vrf_id);
                        if (!eigrp)
                                continue;
 
-                       vty_out(vty, "VRF %s:\n", vrf->name);
+                       vty_out(vty, "VRF %s:\n", v->name);
 
                        eigrp_interface_helper(vty, eigrp, ifname, detail);
                }
index c4db0456339312f72a5e741057ef7c2ade4232cc..cbecc815741e3e94bb4cd39f3be3407aaddcb813 100644 (file)
@@ -429,7 +429,6 @@ static char *zencrypt(const char *passwd)
 {
        char salt[6];
        struct timeval tv;
-       char *crypt(const char *, const char *);
 
        gettimeofday(&tv, 0);
 
index 83fa85ecc1eedf509cc3bd491862fa77c17fd1bb..fa4fdb82d38af2f01bba2717f256af4e1a7d0a91 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -82,6 +82,8 @@ int if_cmp_name_func(const char *p1, const char *p2)
        int res;
 
        while (*p1 && *p2) {
+               char *tmp1, *tmp2;
+
                /* look up to any number */
                l1 = strcspn(p1, "0123456789");
                l2 = strcspn(p2, "0123456789");
@@ -111,8 +113,8 @@ int if_cmp_name_func(const char *p1, const char *p2)
                if (!*p2)
                        return 1;
 
-               x1 = strtol(p1, (char **)&p1, 10);
-               x2 = strtol(p2, (char **)&p2, 10);
+               x1 = strtol(p1, (char **)&tmp1, 10);
+               x2 = strtol(p2, (char **)&tmp2, 10);
 
                /* let's compare numbers now */
                if (x1 < x2)
@@ -120,6 +122,16 @@ int if_cmp_name_func(const char *p1, const char *p2)
                if (x1 > x2)
                        return 1;
 
+               /* Compare string if numbers are equal (distinguish foo-1 from foo-001) */
+               l1 = strspn(p1, "0123456789");
+               l2 = strspn(p2, "0123456789");
+               if (l1 != l2)
+                       return (strcmp(p1, p2));
+
+               /* Continue to parse the rest of the string */
+               p1 = (const char *)tmp1;
+               p2 = (const char *)tmp2;
+
                /* numbers were equal, lets do it again..
                (it happens with name like "eth123.456:789") */
        }
@@ -711,7 +723,7 @@ int if_is_broadcast(const struct interface *ifp)
        return ifp->flags & IFF_BROADCAST;
 }
 
-/* Does this interface support broadcast ? */
+/* Does this interface support pointopoint ? */
 int if_is_pointopoint(const struct interface *ifp)
 {
        return ifp->flags & IFF_POINTOPOINT;
index 042c9d370491569108c03f893df03bfcc1612ce3..f5aecd9f75a3ec4c14260661a94cb56a26f5cdf0 100644 (file)
@@ -963,6 +963,8 @@ static void frr_daemonize(void)
        }
 
        close(fds[1]);
+       nb_terminate();
+       yang_terminate();
        frr_daemon_wait(fds[0]);
 }
 
index e17eeb8303ac2abbccb649ada315d1417dd93f14..248acd270078d1594ae615864c6786f9fb6f99f0 100644 (file)
@@ -922,6 +922,34 @@ int nexthop_str2backups(const char *str, int *num_backups,
        return ret;
 }
 
+ssize_t printfrr_nhs(struct fbuf *buf, const struct nexthop *nexthop)
+{
+       ssize_t ret = 0;
+
+       if (!nexthop)
+               return bputs(buf, "(null)");
+
+       switch (nexthop->type) {
+       case NEXTHOP_TYPE_IFINDEX:
+               ret += bprintfrr(buf, "if %u", nexthop->ifindex);
+               break;
+       case NEXTHOP_TYPE_IPV4:
+       case NEXTHOP_TYPE_IPV4_IFINDEX:
+               ret += bprintfrr(buf, "%pI4 if %u", &nexthop->gate.ipv4,
+                                nexthop->ifindex);
+               break;
+       case NEXTHOP_TYPE_IPV6:
+       case NEXTHOP_TYPE_IPV6_IFINDEX:
+               ret += bprintfrr(buf, "%pI6 if %u", &nexthop->gate.ipv6,
+                                nexthop->ifindex);
+               break;
+       case NEXTHOP_TYPE_BLACKHOLE:
+               ret += bputs(buf, "blackhole");
+               break;
+       }
+       return ret;
+}
+
 /*
  * nexthop printing variants:
  *     %pNHvv
@@ -1010,27 +1038,7 @@ static ssize_t printfrr_nh(struct fbuf *buf, struct printfrr_eargs *ea,
        case 's':
                ea->fmt++;
 
-               if (!nexthop)
-                       return bputs(buf, "(null)");
-
-               switch (nexthop->type) {
-               case NEXTHOP_TYPE_IFINDEX:
-                       ret += bprintfrr(buf, "if %u", nexthop->ifindex);
-                       break;
-               case NEXTHOP_TYPE_IPV4:
-               case NEXTHOP_TYPE_IPV4_IFINDEX:
-                       ret += bprintfrr(buf, "%pI4 if %u", &nexthop->gate.ipv4,
-                                        nexthop->ifindex);
-                       break;
-               case NEXTHOP_TYPE_IPV6:
-               case NEXTHOP_TYPE_IPV6_IFINDEX:
-                       ret += bprintfrr(buf, "%pI6 if %u", &nexthop->gate.ipv6,
-                                        nexthop->ifindex);
-                       break;
-               case NEXTHOP_TYPE_BLACKHOLE:
-                       ret += bputs(buf, "blackhole");
-                       break;
-               }
+               ret += printfrr_nhs(buf, nexthop);
                return ret;
        case 'c':
                ea->fmt++;
index 320b46315e1c653ad4fb4fe977d3504338fc98ae..c13f1b137686be0c8f0b3c118a84d93c9b429a38 100644 (file)
@@ -260,6 +260,7 @@ int nexthop_str2backups(const char *str, int *num_backups,
 #pragma FRR printfrr_ext "%pNH"  (struct nexthop *)
 #endif
 
+ssize_t printfrr_nhs(struct fbuf *buf, const struct nexthop *nh);
 #ifdef __cplusplus
 }
 #endif
index 97b198c0189e34ebbbbe08020169b73d07803abe..eff38798cc786bde9e578b2dd41e197a5af3053b 100644 (file)
@@ -525,6 +525,11 @@ union sockunion *sockunion_getsockname(int fd)
                sockunion_normalise_mapped(su);
                return su;
        }
+
+       flog_err(
+               EC_LIB_SOCKET,
+               "Unexpected AFI received(%d) for sockunion_getsockname call for fd: %d",
+               name.sa.sa_family, fd);
        return NULL;
 }
 
@@ -561,6 +566,11 @@ union sockunion *sockunion_getpeername(int fd)
                sockunion_normalise_mapped(su);
                return su;
        }
+
+       flog_err(
+               EC_LIB_SOCKET,
+               "Unexpected AFI received(%d) for sockunion_getpeername call for fd: %d",
+               name.sa.sa_family, fd);
        return NULL;
 }
 
index c15baa0a2ccf1b098640d089b4ce77d752860e17..83ed015bc905c0358f658ad197814ee7c6100079 100644 (file)
@@ -145,8 +145,7 @@ struct stream *stream_dup(const struct stream *s)
 
        STREAM_VERIFY_SANE(s);
 
-       if ((snew = stream_new(s->endp)) == NULL)
-               return NULL;
+       snew = stream_new(s->endp);
 
        return (stream_copy(snew, s));
 }
@@ -691,7 +690,7 @@ double stream_getd(struct stream *s)
        return u.r;
 }
 
-/* Copy to source to stream.
+/* Copy from source to stream.
  *
  * XXX: This uses CHECK_SIZE and hence has funny semantics -> Size will wrap
  * around. This should be fixed once the stream updates are working.
index e0e2f39229d19bdbcde5c32821ba76ebfaaea40c..92db07677ae06f5b8b71b993a4e4ea142e98373c 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -382,7 +382,6 @@ static void vty_auth(struct vty *vty, char *buf)
        char *passwd = NULL;
        enum node_type next_node = 0;
        int fail;
-       char *crypt(const char *, const char *);
 
        switch (vty->node) {
        case AUTH_NODE:
index 9cc2b56245ca4dd9a5405cba509bdaeb18090d8f..3d54f4ed50213edcd2efb520fc1fe8ea069b865e 100644 (file)
@@ -89,7 +89,7 @@ ssize_t zbuf_read(struct zbuf *zb, int fd, size_t maxlen)
                zb->tail += r;
        else if (r == 0)
                r = -2;
-       else if (r < 0 && ERRNO_IO_RETRY(errno))
+       else if (ERRNO_IO_RETRY(errno))
                r = 0;
 
        return r;
@@ -109,7 +109,7 @@ ssize_t zbuf_write(struct zbuf *zb, int fd)
                        zbuf_reset(zb);
        } else if (r == 0)
                r = -2;
-       else if (r < 0 && ERRNO_IO_RETRY(errno))
+       else if (ERRNO_IO_RETRY(errno))
                r = 0;
 
        return r;
@@ -128,7 +128,7 @@ ssize_t zbuf_recv(struct zbuf *zb, int fd)
                zb->tail += r;
        else if (r == 0)
                r = -2;
-       else if (r < 0 && ERRNO_IO_RETRY(errno))
+       else if (ERRNO_IO_RETRY(errno))
                r = 0;
        return r;
 }
index 2a503c62334856369e903dd423af71facca36b7e..efa5d2b7ab91392ea02a4300d48a36594724efef 100644 (file)
@@ -165,8 +165,6 @@ static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
                cost = (uint32_t)((double)refbw / (double)bw + (double)0.5);
                if (cost < 1)
                        cost = 1;
-               else if (cost > UINT32_MAX)
-                       cost = UINT32_MAX;
        }
 
        return cost;
index 4d76181c6af3f1ce2acf3d857fc5672919af9b12..258a93fb16fc92943488af27f0f7c7692cd4b119 100644 (file)
@@ -1850,8 +1850,6 @@ static int show_debugging_ospf_common(struct vty *vty)
        if (IS_DEBUG_OSPF(client_api, CLIENT_API) == OSPF_DEBUG_CLIENT_API)
                vty_out(vty, "  OSPF client-api debugging is on\n");
 
-       vty_out(vty, "\n");
-
        return CMD_SUCCESS;
 }
 
index 90862520aff214a730e0688188619facb8196da5..cb868bc7e13afa14e135493d6b621a7b9e03b73a 100644 (file)
@@ -35,6 +35,7 @@ typedef struct in_addr pim_addr;
 #define ipaddr_pim     ipaddr_v4
 #define PIM_MAX_BITLEN IPV4_MAX_BITLEN
 #define PIM_AF_NAME     "ip"
+#define PIMREG          "pimreg"
 
 #define PIM_ADDR_FUNCNAME(name) ipv4_##name
 
@@ -58,6 +59,7 @@ typedef struct in6_addr pim_addr;
 #define ipaddr_pim     ipaddr_v6
 #define PIM_MAX_BITLEN IPV6_MAX_BITLEN
 #define PIM_AF_NAME     "ipv6"
+#define PIMREG          "pim6reg"
 
 #define PIM_ADDR_FUNCNAME(name) ipv6_##name
 
index 2e03bac945846b434ef839d9d55d79165ec43ab9..6b132ee6b01f3e45f3f72e5c9aeab4fdfb27580c 100644 (file)
@@ -3305,11 +3305,7 @@ void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim, struct vty *vty)
        vty_out(vty, "\n");
 
        pim_zebra_zclient_update(vty);
-#if PIM_IPV == 4
        pim_zlookup_show_ip_multicast(vty);
-#else
-       /* TBD */
-#endif
 
        vty_out(vty, "\n");
        vty_out(vty, "Maximum highest VifIndex: %d\n", PIM_MAX_USABLE_VIFS);
index 65889fd57bc9357b0f6714871f5111658cfc9f23..4e92a2c5dc5e2c61722e4474798d434dcbf85b91 100644 (file)
@@ -1040,7 +1040,8 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term)
 
        pim_ifp->pim->iface_vif_index[pim_ifp->mroute_vif_index] = 1;
 
-       gm_ifp_update(ifp);
+       if (!ispimreg)
+               gm_ifp_update(ifp);
 
        /* if the device qualifies as pim_vxlan iif/oif update vxlan entries */
        pim_vxlan_add_vif(ifp);
@@ -1546,9 +1547,9 @@ void pim_if_create_pimreg(struct pim_instance *pim)
 
        if (!pim->regiface) {
                if (pim->vrf->vrf_id == VRF_DEFAULT)
-                       strlcpy(pimreg_name, "pimreg", sizeof(pimreg_name));
+                       strlcpy(pimreg_name, PIMREG, sizeof(pimreg_name));
                else
-                       snprintf(pimreg_name, sizeof(pimreg_name), "pimreg%u",
+                       snprintf(pimreg_name, sizeof(pimreg_name), PIMREG "%u",
                                 pim->vrf->data.l.table_id);
 
                pim->regiface = if_get_by_name(pimreg_name, pim->vrf->vrf_id,
@@ -1718,7 +1719,7 @@ static int pim_ifp_up(struct interface *ifp)
         * If we have a pimreg device callback and it's for a specific
         * table set the master appropriately
         */
-       if (sscanf(ifp->name, "pimreg%" SCNu32, &table_id) == 1) {
+       if (sscanf(ifp->name, "" PIMREG "%" SCNu32, &table_id) == 1) {
                struct vrf *vrf;
                RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                        if ((table_id == vrf->data.l.table_id)
index 8fa2c96034c0123042f751daf9f427bd2c40d126..3bfb31e0c6978d6a83588e95b3d8577bd21002d0 100644 (file)
@@ -429,6 +429,8 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
        /* Prevent single protocol from subscribing same interface to
           channel (S,G) multiple times */
        if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask) {
+               channel_oil->oif_flags[pim_ifp->mroute_vif_index] |= proto_mask;
+
                if (PIM_DEBUG_MROUTE) {
                        zlog_debug(
                                "%s %s: existing protocol mask %u requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%pPAs,%pPAs)",
index 3da0a3530361284f43ad1cec729bee8968d15b66..2b798b14b2f054c37692cb1e7cb1afee6333f527 100644 (file)
@@ -267,10 +267,15 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
        }
 
        rp_info = rn->info;
-       if (PIM_DEBUG_PIM_TRACE)
-               zlog_debug("Lookedup: %p for rp_info: %p(%pFX) Lock: %d", rn,
-                          rp_info, &rp_info->group,
-                          route_node_get_lock_count(rn));
+       if (PIM_DEBUG_PIM_TRACE) {
+               if (best)
+                       zlog_debug(
+                               "Lookedup(%pFX): prefix_list match %s, rn %p found: %pFX",
+                               group, best->plist, rn, &rp_info->group);
+               else
+                       zlog_debug("Lookedup(%pFX): rn %p found:%pFX", group,
+                                  rn, &rp_info->group);
+       }
 
        route_unlock_node(rn);
 
index 265173e314f9d8723af99335b4e5564e46c63241..4a6cd6ad77f10f3bfd0b0c985a9ef60ebb650bc7 100644 (file)
@@ -21,7 +21,6 @@ import os
 import subprocess
 import re
 import argparse
-import subprocess
 import json
 
 structs = ['xref', 'xref_logmsg', 'xref_threadsched', 'xref_install_element', 'xrefdata', 'xrefdata_logmsg', 'cmd_element']
diff --git a/tests/topotests/bgp_default_originate/bgp_default_originate_topo1.json b/tests/topotests/bgp_default_originate/bgp_default_originate_topo1.json
new file mode 100644 (file)
index 0000000..5fae34d
--- /dev/null
@@ -0,0 +1,294 @@
+{
+    "address_types": [
+        "ipv4",
+        "ipv6"
+    ],
+    "ipv4base": "192.168.0.0",
+    "ipv4mask": 3024,
+    "ipv6base": "fd00::",
+    "ipv6mask": 64,
+    "link_ip_start": {
+        "ipv4": "192.168.0.0",
+        "v4mask": 24,
+        "ipv6": "fd00::",
+        "v6mask": 64
+    },
+    "lo_prefix": {
+        "ipv4": "1.0.",
+        "v4mask": 32,
+        "ipv6": "2001:db8:f::",
+        "v6mask": 128
+    },
+    "routers": {
+        "r0": {
+            "links": {
+                "lo": {
+                    "ipv4": "auto",
+                    "ipv6": "auto",
+                    "type": "loopback"
+                },
+                "r1": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                }
+            },
+            "bgp": {
+                "local_as": "100",
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "neighbor": {
+                                "r1": {
+                                    "dest_link": {
+                                        "r0": {
+                                            "keepalivetimer": 1,
+                                            "holddowntimer": 3
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "neighbor": {
+                                "r1": {
+                                    "dest_link": {
+                                        "r0": {
+                                            "keepalivetimer": 1,
+                                            "holddowntimer": 3
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        "r1": {
+            "links": {
+                "lo": {
+                    "ipv4": "auto",
+                    "ipv6": "auto",
+                    "type": "loopback"
+                },
+                "r0": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                },
+                "r2": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                }
+            },
+            "bgp": {
+                "local_as": "200",
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "neighbor": {
+                                "r0": {
+                                    "dest_link": {
+                                        "r1": {
+                                            "keepalivetimer": 1,
+                                            "holddowntimer": 3
+                                        }
+                                    }
+                                },
+                                "r2": {
+                                    "dest_link": {
+                                        "r1": {
+                                            "keepalivetimer": 1,
+                                            "holddowntimer": 3
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "neighbor": {
+                                "r0": {
+                                    "dest_link": {
+                                        "r1": {
+                                            "keepalivetimer": 1,
+                                            "holddowntimer": 3
+                                        }
+                                    }
+                                },
+                                "r2": {
+                                    "dest_link": {
+                                        "r1": {
+                                            "keepalivetimer": 1,
+                                            "holddowntimer": 3
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        "r2": {
+            "links": {
+                "lo": {
+                    "ipv4": "auto",
+                    "ipv6": "auto",
+                    "type": "loopback"
+                },
+                "r1": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                },
+                "r3": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                }
+            },
+            "bgp": {
+                "local_as": "300",
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "neighbor": {
+                                "r1": {
+                                    "dest_link": {
+                                        "r2": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                },
+                                "r3": {
+                                    "dest_link": {
+                                        "r2": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "neighbor": {
+                                "r1": {
+                                    "dest_link": {
+                                        "r2": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                },
+                                "r3": {
+                                    "dest_link": {
+                                        "r2": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        "r3": {
+            "links": {
+                "lo": {
+                    "ipv4": "auto",
+                    "ipv6": "auto",
+                    "type": "loopback"
+                },
+                "r2": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                },
+                "r4": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                }
+            },
+            "bgp": {
+                "local_as": "400",
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "neighbor": {
+                                "r2": {
+                                    "dest_link": {
+                                        "r3": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                },
+                                "r4": {
+                                    "dest_link": {
+                                        "r3": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "neighbor": {
+                                "r2": {
+                                    "dest_link": {
+                                        "r3": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                },
+                                "r4": {
+                                    "dest_link": {
+                                        "r3": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        "r4": {
+            "links": {
+                "lo": {
+                    "ipv4": "auto",
+                    "ipv6": "auto",
+                    "type": "loopback"
+                },
+                "r3": {
+                    "ipv4": "auto",
+                    "ipv6": "auto"
+                }
+            },
+            "bgp": {
+                "local_as": "500",
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "neighbor": {
+                                "r3": {
+                                    "dest_link": {
+                                        "r4": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "neighbor": {
+                                "r3": {
+                                    "dest_link": {
+                                        "r4": {"keepalivetimer": 1,
+                                            "holddowntimer": 3}
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_1.py b/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_1.py
new file mode 100644 (file)
index 0000000..ee71ae1
--- /dev/null
@@ -0,0 +1,2537 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2022 by VMware, Inc. ("VMware")
+# Used Copyright (c) 2018 by Network Device Education Foundation, Inc. ("NetDEF")
+# in this file.
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+# Shreenidhi A R <rshreenidhi@vmware.com>
+# THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+"""
+Following tests are covered.
+1. Verify BGP default-originate route with IBGP peer
+2. Verify BGP default-originate route with EBGP peer
+3. Verify BGP default route when default-originate configured with route-map over IBGP peer
+4. Verify BGP default route when default-originate configured with route-map over EBGP peer"
+
+"""
+import os
+import sys
+import time
+import pytest
+from time import sleep
+from copy import deepcopy
+from lib.topolog import logger
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+from lib.topogen import Topogen, get_topogen
+from lib.topojson import build_config_from_json
+from lib.topolog import logger
+
+from lib.bgp import (
+    verify_bgp_convergence,
+    verify_graceful_restart,
+    create_router_bgp,
+    verify_router_id,
+    modify_as_number,
+    verify_as_numbers,
+    clear_bgp_and_verify,
+    clear_bgp,
+    verify_bgp_rib,
+    get_prefix_count_route,
+    get_dut_as_number,
+    verify_rib_default_route,
+    verify_fib_default_route,
+    verify_bgp_advertised_routes_from_neighbor,
+    verify_bgp_received_routes_from_neighbor,
+)
+from lib.common_config import (
+    interface_status,
+    verify_prefix_lists,
+    verify_fib_routes,
+    kill_router_daemons,
+    start_router_daemons,
+    shutdown_bringup_interface,
+    step,
+    required_linux_kernel_version,
+    stop_router,
+    start_router,
+    create_route_maps,
+    create_prefix_lists,
+    get_frr_ipv6_linklocal,
+    start_topology,
+    write_test_header,
+    check_address_types,
+    write_test_footer,
+    reset_config_on_routers,
+    create_static_routes,
+    check_router_status,
+    delete_route_maps,
+)
+
+
+# Save the Current Working Directory to find configuration files.
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+sys.path.append(os.path.join(CWD, "../lib/"))
+
+# Required to instantiate the topology builder class.
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+
+# Global variables
+topo = None
+KEEPALIVETIMER = 1
+HOLDDOWNTIMER = 3
+# Global variables
+NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
+NETWORK1_2 = {"ipv4": "1.1.1.2/32", "ipv6": "1::2/128"}
+NETWORK2_1 = {"ipv4": "2.1.1.1/32", "ipv6": "2::1/128"}
+NETWORK2_2 = {"ipv4": "2.1.1.2/32", "ipv6": "2::2/128"}
+NETWORK3_1 = {"ipv4": "3.1.1.1/32", "ipv6": "3::1/128"}
+NETWORK3_2 = {"ipv4": "3.1.1.2/32", "ipv6": "3::2/128"}
+NETWORK4_1 = {"ipv4": "4.1.1.1/32", "ipv6": "4::1/128"}
+NETWORK4_2 = {"ipv4": "4.1.1.2/32", "ipv6": "4::2/128"}
+NETWORK5_1 = {"ipv4": "5.1.1.1/32", "ipv6": "5::1/128"}
+NETWORK5_2 = {"ipv4": "5.1.1.2/32", "ipv6": "5::2/128"}
+DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
+
+IPV4_RM = "RMVIPV4"
+IPV6_RM = "RMVIPV6"
+
+IPV4_RM1 = "RMVIPV41"
+IPV6_RM1 = "RMVIPV61"
+
+IPV4_RM2 = "RMVIPV42"
+IPV6_RM2 = "RMVIPV62"
+
+IPV4_PL_1 = "PV41"
+IPV4_PL_2 = "PV42"
+
+IPV6_PL_1 = "PV61"
+IPV6_PL_2 = "PV62"
+
+
+r1_ipv4_loopback = "1.0.1.0/24"
+r2_ipv4_loopback = "1.0.2.0/24"
+r3_ipv4_loopback = "1.0.3.0/24"
+r4_ipv4_loopback = "1.0.4.0/24"
+r1_ipv6_loopback = "2001:db8:f::1:0/120"
+r2_ipv6_loopback = "2001:db8:f::2:0/120"
+r3_ipv6_loopback = "2001:db8:f::3:0/120"
+r4_ipv6_loopback = "2001:db8:f::4:0/120"
+
+r0_connected_address_ipv4 = "192.168.0.0/24"
+r0_connected_address_ipv6 = "fd00::/64"
+r1_connected_address_ipv4 = "192.168.1.0/24"
+r1_connected_address_ipv6 = "fd00:0:0:1::/64"
+r3_connected_address_ipv4 = "192.168.2.0/24"
+r3_connected_address_ipv6 = "fd00:0:0:2::/64"
+r4_connected_address_ipv4 = "192.168.3.0/24"
+r4_connected_address_ipv6 = "fd00:0:0:3::/64"
+
+
+def setup_module(mod):
+    """
+    Sets up the pytest environment
+
+    * `mod`: module name
+    """
+
+    # Required linux kernel version for this suite to run.
+    result = required_linux_kernel_version("4.15")
+    if result is not True:
+        pytest.skip("Kernel requirements are not met")
+
+    testsuite_run_time = time.asctime(time.localtime(time.time()))
+    logger.info("Testsuite start time: {}".format(testsuite_run_time))
+    logger.info("=" * 40)
+
+    logger.info("Running setup_module to create topology")
+
+    # This function initiates the topology build with Topogen...
+    json_file = "{}/bgp_default_originate_topo1.json".format(CWD)
+    tgen = Topogen(json_file, mod.__name__)
+    global topo
+    topo = tgen.json_topo
+    # ... and here it calls Mininet initialization functions.
+
+    # Starting topology, create tmp files which are loaded to routers
+    #  to start daemons and then start routers
+    start_topology(tgen)
+
+    # Creating configuration from JSON
+    build_config_from_json(tgen, topo)
+
+    global ADDR_TYPES
+    global BGP_CONVERGENCE
+    global DEFAULT_ROUTES
+    global DEFAULT_ROUTE_NXT_HOP_R1, DEFAULT_ROUTE_NXT_HOP_R3
+    global R0_NETWORK_LOOPBACK, R0_NETWORK_LOOPBACK_NXTHOP, R1_NETWORK_LOOPBACK, R1_NETWORK_LOOPBACK_NXTHOP
+    global R0_NETWORK_CONNECTED, R0_NETWORK_CONNECTED_NXTHOP, R1_NETWORK_CONNECTED, R1_NETWORK_CONNECTED_NXTHOP
+    global R4_NETWORK_LOOPBACK, R4_NETWORK_LOOPBACK_NXTHOP, R3_NETWORK_LOOPBACK, R3_NETWORK_LOOPBACK_NXTHOP
+    global R4_NETWORK_CONNECTED, R4_NETWORK_CONNECTED_NXTHOP, R3_NETWORK_CONNECTED, R3_NETWORK_CONNECTED_NXTHOP
+
+    ADDR_TYPES = check_address_types()
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+    # There are the global varibles used through out the file these are acheived only after building the topology.
+
+    r0_loopback_address_ipv4 = topo["routers"]["r0"]["links"]["lo"]["ipv4"]
+    r0_loopback_address_ipv4_nxt_hop = topo["routers"]["r0"]["links"]["r1"][
+        "ipv4"
+    ].split("/")[0]
+    r0_loopback_address_ipv6 = topo["routers"]["r0"]["links"]["lo"]["ipv6"]
+    r0_loopback_address_ipv6_nxt_hop = topo["routers"]["r0"]["links"]["r1"][
+        "ipv6"
+    ].split("/")[0]
+
+    r1_loopback_address_ipv4 = topo["routers"]["r1"]["links"]["lo"]["ipv4"]
+    r1_loopback_address_ipv4_nxt_hop = topo["routers"]["r1"]["links"]["r2"][
+        "ipv4"
+    ].split("/")[0]
+    r1_loopback_address_ipv6 = topo["routers"]["r1"]["links"]["lo"]["ipv6"]
+    r1_loopback_address_ipv6_nxt_hop = topo["routers"]["r1"]["links"]["r2"][
+        "ipv6"
+    ].split("/")[0]
+
+    r4_loopback_address_ipv4 = topo["routers"]["r4"]["links"]["lo"]["ipv4"]
+    r4_loopback_address_ipv4_nxt_hop = topo["routers"]["r4"]["links"]["r3"][
+        "ipv4"
+    ].split("/")[0]
+    r4_loopback_address_ipv6 = topo["routers"]["r4"]["links"]["lo"]["ipv6"]
+    r4_loopback_address_ipv6_nxt_hop = topo["routers"]["r4"]["links"]["r3"][
+        "ipv6"
+    ].split("/")[0]
+
+    r3_loopback_address_ipv4 = topo["routers"]["r3"]["links"]["lo"]["ipv4"]
+    r3_loopback_address_ipv4_nxt_hop = topo["routers"]["r3"]["links"]["r2"][
+        "ipv4"
+    ].split("/")[0]
+    r3_loopback_address_ipv6 = topo["routers"]["r3"]["links"]["lo"]["ipv6"]
+    r3_loopback_address_ipv6_nxt_hop = topo["routers"]["r3"]["links"]["r2"][
+        "ipv6"
+    ].split("/")[0]
+
+    R0_NETWORK_LOOPBACK = {
+        "ipv4": r0_loopback_address_ipv4,
+        "ipv6": r0_loopback_address_ipv6,
+    }
+    R0_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r0_loopback_address_ipv4_nxt_hop,
+        "ipv6": r0_loopback_address_ipv6_nxt_hop,
+    }
+
+    R1_NETWORK_LOOPBACK = {
+        "ipv4": r1_loopback_address_ipv4,
+        "ipv6": r1_loopback_address_ipv6,
+    }
+    R1_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r1_loopback_address_ipv4_nxt_hop,
+        "ipv6": r1_loopback_address_ipv6_nxt_hop,
+    }
+
+    R0_NETWORK_CONNECTED = {
+        "ipv4": r0_connected_address_ipv4,
+        "ipv6": r0_connected_address_ipv6,
+    }
+    R0_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r0_loopback_address_ipv4_nxt_hop,
+        "ipv6": r0_loopback_address_ipv6_nxt_hop,
+    }
+
+    R1_NETWORK_CONNECTED = {
+        "ipv4": r1_connected_address_ipv4,
+        "ipv6": r1_connected_address_ipv6,
+    }
+    R1_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r1_loopback_address_ipv4_nxt_hop,
+        "ipv6": r1_loopback_address_ipv6_nxt_hop,
+    }
+
+    R4_NETWORK_LOOPBACK = {
+        "ipv4": r4_loopback_address_ipv4,
+        "ipv6": r4_loopback_address_ipv6,
+    }
+    R4_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r4_loopback_address_ipv4_nxt_hop,
+        "ipv6": r4_loopback_address_ipv6_nxt_hop,
+    }
+
+    R3_NETWORK_LOOPBACK = {
+        "ipv4": r3_loopback_address_ipv4,
+        "ipv6": r3_loopback_address_ipv6,
+    }
+    R3_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r3_loopback_address_ipv4_nxt_hop,
+        "ipv6": r3_loopback_address_ipv6_nxt_hop,
+    }
+
+    R4_NETWORK_CONNECTED = {
+        "ipv4": r4_connected_address_ipv4,
+        "ipv6": r4_connected_address_ipv6,
+    }
+    R4_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r4_loopback_address_ipv4_nxt_hop,
+        "ipv6": r4_loopback_address_ipv6_nxt_hop,
+    }
+
+    R3_NETWORK_CONNECTED = {
+        "ipv4": r3_connected_address_ipv4,
+        "ipv6": r3_connected_address_ipv6,
+    }
+    R3_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r3_loopback_address_ipv4_nxt_hop,
+        "ipv6": r3_loopback_address_ipv6_nxt_hop,
+    }
+
+    # populating the nexthop for default routes
+
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+
+    interface = topo["routers"]["r1"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv4"].split("/")[0]
+    ipv6_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv6"].split("/")[0]
+    DEFAULT_ROUTE_NXT_HOP_R1 = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+
+    interface = topo["routers"]["r3"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r3", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r3"]["links"]["r2"]["ipv4"].split("/")[0]
+    ipv6_nxt_hop = topo["routers"]["r3"]["links"]["r2"]["ipv6"].split("/")[0]
+    DEFAULT_ROUTE_NXT_HOP_R3 = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+
+    logger.info("Running setup_module() done")
+
+
+def teardown_module():
+    """Teardown the pytest environment"""
+
+    logger.info("Running teardown_module to delete topology")
+
+    tgen = get_topogen()
+
+    # Stop toplogy and Remove tmp files
+    tgen.stop_topology()
+
+    logger.info(
+        "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
+    )
+    logger.info("=" * 40)
+
+#####################################################
+#
+#                      Testcases
+#
+#####################################################
+
+def test_verify_bgp_default_originate_in_IBGP_p0(request):
+    """
+    Verify BGP default-originate route with IBGP peer
+    """
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+    step("Configure IPv4 and IPv6 , IBGP neighbor between R1 and R2")
+    step("Configure IPv4 and IPv6 Loopback interface on R1, R0 and R2")
+    step("Configure IPv4 and IPv6 EBGP neighbor between R0 and R1")
+
+    r0_local_as = topo["routers"]["r0"]["bgp"]["local_as"]
+    r1_local_as = topo["routers"]["r1"]["bgp"]["local_as"]
+    r2_local_as = topo["routers"]["r2"]["bgp"]["local_as"]
+    r3_local_as = topo["routers"]["r3"]["bgp"]["local_as"]
+    r4_local_as = topo["routers"]["r4"]["bgp"]["local_as"]
+
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": 1000,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": 2000,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": 2000,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": r3_local_as,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": r4_local_as,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, " Complete Convergence is expected after changing the ASN but failed to converge --> :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step("Configure IPv4 and IPv6 static route on R1 next-hop as NULL0")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r1": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+        result = create_static_routes(tgen, static_routes_input)
+        assert result is True, "Testcase {} : Failed to configure the static routes {} on router R1 \n Error: {}".format(
+            tc_name,static_routes_input, result
+        )
+    step("verify IPv4 and IPv6 static route are configured and up on R1")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r1": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n After configuring the static routes {} , the routes are not found in FIB   \n Error: {}".format(
+            tc_name,static_routes_input, result
+        )
+
+    step(
+        "Configure redistribute static and connected on R0 and R1,  for IPv4 and IPv6 address family "
+    )
+    redistribute_static = {
+        "r0": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                }
+            }
+        },
+        "r1": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                }
+            }
+        },
+    }
+    result = create_router_bgp(tgen, topo, redistribute_static)
+    assert result is True, "Testcase {} : Failed to configure the redistribute static configuration \n Error: {}".format(tc_name, result)
+
+    step(
+        "After configuring redistribute command , verify static and connected routes ( loopback connected routes)  are advertised on R2"
+    )
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R0_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R0_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R1_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R1_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : After redistributing static routes the routes {} expected in FIB but NOT FOUND ......! \n Error: {}".format(
+            tc_name, static_routes_input,result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : After redistributing static routes the routes {} expected in RIB but NOT FOUND ......!   \n Error: {}".format(
+            tc_name, static_routes_input , result
+        )
+
+    step(
+        "Taking the snapshot of the prefix count before configuring the default originate"
+    )
+    snapshot1 = get_prefix_count_route(tgen, topo, dut="r2", peer="r1")
+
+    step(
+        "Configure Default originate on R1 for R1 to R2, for  IPv4 and IPv6 BGP address family "
+    )
+    local_as = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {"unicast": {"default_originate": {"r2": {}}}},
+                    "ipv6": {"unicast": {"default_originate": {"r2": {}}}},
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed Configuring default originate configuration. \n Error: {}".format(tc_name, result)
+
+    step(
+        "After configuring default-originate command , verify default  routes are advertised on R2 "
+        " R1 static and loopback routes received on R2 BGP and FIB"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R1_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R1_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : post configuring the BGP Default originate configuration static and connected routes should not be effected but impacted on FIB .......! FAILED \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failedpost configuring the BGP Default originate configuration static and connected routes should not be effected but impacted on RIB......! FAILED \n Error: {}".format(
+            tc_name, result
+        )
+    step(
+        "Verify default route for IPv4 and IPv6  present with path=igp   metric =0 , local-preference= 100 "
+    )
+    result = verify_rib_default_route(
+        tgen,
+        topo,
+        dut="r2",
+        routes=DEFAULT_ROUTES,
+        expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R1,
+        metric=0,
+        locPrf=100,
+    )
+    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+    step(
+        "Taking the snapshot2 of the prefix count after configuring the default originate"
+    )
+    snapshot2 = get_prefix_count_route(tgen, topo, dut="r2", peer="r1")
+
+    step("verifying the prefix count incrementing or not ")
+    isIPv4prefix_incremented = False
+    isIPv6prefix_incremented = False
+    if snapshot1["ipv4_count"] < snapshot2["ipv4_count"]:
+        isIPv4prefix_incremented = True
+    if snapshot1["ipv6_count"] < snapshot2["ipv6_count"]:
+        isIPv6prefix_incremented = True
+
+    assert (
+        isIPv4prefix_incremented is True
+    ), "Testcase {} : Failed Error: IPV4 Prefix is not incremented on receiveing ".format(
+        tc_name
+    )
+
+    assert (
+        isIPv6prefix_incremented is True
+    ), "Testcase {} : Failed Error: IPV6 Prefix is not incremented on receiveing ".format(
+        tc_name
+    )
+    write_test_footer(tc_name)
+
+
+def test_verify_bgp_default_originate_in_EBGP_p0(request):
+    """
+    Verify BGP default-originate route with EBGP peer
+    """
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+    step("Configure IPv4 and IPv6 , EBGP neighbor between R3 and R2")
+    step("Configure lPv4 and IPv6 Loopback interface on R3, R4  and R2")
+    step("Configure IPv4 and IPv6 IBGP neighbor between R4 and R3")
+    r0_local_as = topo["routers"]["r0"]["bgp"]["local_as"]
+    r1_local_as = topo["routers"]["r1"]["bgp"]["local_as"]
+    r2_local_as = topo["routers"]["r2"]["bgp"]["local_as"]
+    r3_local_as = topo["routers"]["r3"]["bgp"]["local_as"]
+    r4_local_as = topo["routers"]["r4"]["bgp"]["local_as"]
+
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": r0_local_as,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": r1_local_as,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": r2_local_as,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": 4000,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": 4000,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "Complete convergence is expeceted after changing the ASN os the routes ..!  :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step(" Configure IPv4 and IPv6 static route on R3 next-hop on R4 interface")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r3": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+        result = create_static_routes(tgen, static_routes_input)
+        assert result is True, "Testcase {} : Failed to configure the static routes ....! Failed \n Error: {}".format(
+            tc_name, result
+        )
+    step("verify IPv4 and IPv6 static route are configured and up on R1")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r3": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r3", static_routes_input)
+        assert result is True, "Testcase {} : Route is not found in {} in FIB ......! Failed \n Error: {}".format(
+            tc_name, static_routes_input,result
+        )
+
+    step(
+        "Configure redistribute static and connected on R3 and R4 for IPv4 and IPv6 address family  "
+    )
+    redistribute_static = {
+        "r3": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                }
+            }
+        },
+        "r4": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                }
+            }
+        },
+    }
+    result = create_router_bgp(tgen, topo, redistribute_static)
+    assert result is True, "Testcase {} : Failed to configure redistribute configuratin \n Error: {}".format(tc_name, result)
+
+    step(
+        "After configuring redistribute command , verify static and connected routes ( loopback connected routes)  are advertised on R2"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R3_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R3_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R4_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R4_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} :  static & and connected routes are expected but not found in FIB .... ! \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : static & and connected routes are expected but not found in RIB .... ! \n Error: {}".format(
+            tc_name, result
+        )
+    snapshot1 = get_prefix_count_route(tgen, topo, dut="r2", peer="r3")
+    step(
+        "Configure Default originate on R3 for R3 to R2, on  IPv4 and IPv6 BGP address family"
+    )
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {"unicast": {"default_originate": {"r2": {}}}},
+                    "ipv6": {"unicast": {"default_originate": {"r2": {}}}},
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed to configure the default originate configuration \n Error: {}".format(tc_name, result)
+
+    step(
+        "After configuring default-originate command , verify default  routes are advertised on R2 on both BGP RIB and FIB"
+    )
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : static route from R1 {} and default  route from R3 is expected in R2 FIB .....! NOT FOUND  \n Error: {}".format(
+            tc_name, NETWORK1_1,result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : static route from R1 {} and default  route from R3 is expected in R2 RIB .....! NOT FOUND \n Error: {}".format(
+            tc_name,NETWORK1_1, result
+        )
+
+    step(
+        "Verify default route for IPv4 and IPv6 present with path = ebgp as path, metric =0 "
+    )
+    # local preference will bgp not applicable for eBGP
+    result = verify_rib_default_route(
+        tgen,
+        topo,
+        dut="r2",
+        routes=DEFAULT_ROUTES,
+        expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R3,
+        metric=0,
+        expected_aspath="4000",
+    )
+    assert result is True, "Testcase {} : Default route from R3 is expected with attributes in R2 RIB .....! NOT FOUND  Error: {}".format(tc_name, result)
+
+    step(
+        "Taking the snapshot2 of the prefix count after configuring the default originate"
+    )
+    snapshot2 = get_prefix_count_route(tgen, topo, dut="r2", peer="r3")
+    step(
+        "Verify out-prefix count is incremented default route on IPv4 and IPv6 neighbor"
+    )
+    isIPv4prefix_incremented = False
+    isIPv6prefix_incremented = False
+    if snapshot1["ipv4_count"] < snapshot2["ipv4_count"]:
+        isIPv4prefix_incremented = True
+    if snapshot1["ipv6_count"] < snapshot2["ipv6_count"]:
+        isIPv6prefix_incremented = True
+
+    assert (
+        isIPv4prefix_incremented is True
+    ), "Testcase {} : Failed Error: IPV4 Prefix is not incremented on receiveing ".format(
+        tc_name
+    )
+
+    assert (
+        isIPv6prefix_incremented is True
+    ), "Testcase {} : Failed Error: IPV6 Prefix is not incremented on receiveing ".format(
+        tc_name
+    )
+    write_test_footer(tc_name)
+
+
+def test_verify_bgp_default_originate_in_IBGP_with_route_map_p0(request):
+    """
+    test_verify_bgp_default_originate_in_IBGP_with_route_map_p0
+    """
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+    step("Configure IPv4 and IPv6 , IBGP neighbor between R1 and R2")
+    step("Configure IPv4 and IPv6 , EBGP neighbor between R1 and R0")
+    r0_local_as = topo["routers"]["r0"]["bgp"]["local_as"]
+    r1_local_as = topo["routers"]["r1"]["bgp"]["local_as"]
+    r2_local_as = topo["routers"]["r2"]["bgp"]["local_as"]
+    r3_local_as = topo["routers"]["r3"]["bgp"]["local_as"]
+    r4_local_as = topo["routers"]["r4"]["bgp"]["local_as"]
+
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": r0_local_as,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": 1000,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": 1000,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": r3_local_as,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": r4_local_as,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "Complete convergence is expected after changing ASN ....! ERROR :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step("Configure 2 IPv4 and 2 IPv6 Static route on R0 with next-hop as Null0")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r0": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = create_static_routes(tgen, static_routes_input)
+        assert result is True, "Testcase {} : Static Configuration is Failed  \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("verify IPv4 and IPv6 static route are configured and up on R0")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r0": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r0", static_routes_input)
+        assert result is True, "Testcase {} : routes {} unable is not found in R0 FIB  \n Error: {}".format(
+            tc_name, static_routes_input,result
+        )
+
+    step(
+        "Configure  redistribute static on IPv4 and IPv6 address family on R0 for R0 to R1 neighbor "
+    )
+    redistribute_static = {
+        "r0": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                    "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                }
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, redistribute_static)
+    assert result is True, "Testcase {} : Failed to configure redistribute static configuration....! \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 static route are configured and up on R1")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r0": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed... Routes {}  expected in r0 FIB after configuring the redistribute config \n Error: {}".format(
+            tc_name,static_routes_input, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed... Routes {}  expected in r0 RIB after configuring the redistribute config \n Error: {}".format(
+            tc_name, static_routes_input,result
+        )
+
+    step(
+        "Configure IPv4 prefix-list Pv4 and and IPv6 prefix-list Pv6 on R1 to match BGP route Sv41, Sv42, IPv6 route Sv61 Sv62 permit "
+    )
+    input_dict_3 = {
+        "r1": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed  to configure the prefix list \n Error: {}".format(tc_name, result)
+
+    step(
+        "Configure IPV4 and IPv6 route-map (RMv4 and RMv6 ) matching prefix-list (Pv4 and Pv6) respectively on R1"
+    )
+    input_dict_3 = {
+        "r1": {
+            "route_maps": {
+                "RMv4": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv4"}},
+                    },
+                ],
+                "RMv6": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv6": {"prefix_lists": "Pv6"}},
+                    },
+                ],
+            }
+        }
+    }
+    result = create_route_maps(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed to configure the route map  \n Error: {}".format(tc_name, result)
+
+    step(
+        "Configure default-originate with route-map (RMv4 and RMv6) on R1, on BGP IPv4 and IPv6 address family "
+    )
+    local_as = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv4"}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv6"}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed to configure the default originate \n Error: {}".format(tc_name, result)
+
+    step("Verify the default route is received in BGP RIB and FIB")
+    step(
+        "After configuring default-originate command , verify default  routes are advertised on R2 "
+    )
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed...! Expected default route from R1 not found in FIB  \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed...!   Expected default route from R1 not found in RIB  \n Error: {}".format(
+            tc_name, result
+        )
+    step("Remove route-map RMv4 and RMv6 from default-originate command in R1")
+    NOTE = """ Configuring the default-originate should remove the  previously applied default originate with condtional route-map"""
+    local_as = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {"unicast": {"default_originate": {"r2": {}}}},
+                    "ipv6": {"unicast": {"default_originate": {"r2": {}}}},
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed  to remove the  default originate conditional route-map \n Error: {}".format(tc_name, result)
+
+    step(
+        "Verify BGP RIB and FIB After removing route-map , default route still present on R2"
+    )
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed Default route from R1 is not found in FIB \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+        )
+        assert result is True, "Testcase {} :  Failed Default route from R1 is not found in RIB  \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Configure default-originate with route-map (RMv4 and RMv6) on R1 ")
+    local_as = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "default_originate": {
+                                "r2": {
+                                    "route_map": "RMv4",
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "default_originate": {
+                                "r2": {
+                                    "route_map": "RMv6",
+                                }
+                            }
+                        }
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed to configure the Default originate route-map \n Error: {}".format(tc_name, result)
+
+    step(
+        "After configuring default-originate command , verify default  routes are advertised on R2 "
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed  Default Route from R1 is not found in FIB  \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed  Default Route from R1 is not found in RIB  \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Delete prefix list using no prefix-list")
+    input_dict_3 = {
+        "r1": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed to delete the prefix list  Error: {}".format(tc_name, result)
+
+    step(
+        "Verify BGP RIB and FIB After deleting prefix-list , verify IPv4 and IPv6 default route got removed from DUT "
+    )
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed\n After deleteing prefix default route is not expected in FIB  \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n After deleteing prefix default route is not expected in RIB \n  Error: {}".format(
+            tc_name, result
+        )
+
+    step("Configure prefix-list and delete route-map using no route-map")
+    input_dict_3 = {
+        "r1": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed to configure the prefix lists Error: {}".format(tc_name, result)
+
+    step(
+        "After configuring the Prefixlist cross checking the BGP Default route is configured again , before deleting the route map"
+    )
+
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+            expected=True,
+        )
+        assert result is True, "Testcase {} : Failed Default route from R1 is expected in FIB but not found \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+            expected=True,
+        )
+        assert result is True, "Testcase {} :  Failed Default route from R1 is expected in RIB but not found \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Deleting the routemap")
+    input_dict = {"r1": {"route_maps": ["RMv4", "RMv6"]}}
+    result = delete_route_maps(tgen, input_dict)
+    assert result is True, "Testcase {} : Failed to delete the Route-map \n Error: {}".format(tc_name, result)
+
+    step(
+        "Verify BGP RIB and FIB ,After deleting route-map , verify IPv4 and IPv6 default route got removed from DUT"
+    )
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n After deleteing  route-map default route is not expected in FIB \nError: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n After deleteing route-map default route is not expected in RIB \n Error: {}".format(
+            tc_name, result
+        )
+
+    write_test_footer(tc_name)
+
+
+def test_verify_bgp_default_originate_in_EBGP_with_route_map_p0(request):
+    """
+    test_verify_bgp_default_originate_in_EBGP_with_route_map_p0
+    """
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+    step("Configure IPv4 and IPv6 , EBGP neighbor between R3 and R2")
+    step("Configure IPv4 and IPv6 IBGP neighbor between R3 and R4")
+    r0_local_as = topo["routers"]["r0"]["bgp"]["local_as"]
+    r1_local_as = topo["routers"]["r1"]["bgp"]["local_as"]
+    r2_local_as = topo["routers"]["r2"]["bgp"]["local_as"]
+    r3_local_as = topo["routers"]["r3"]["bgp"]["local_as"]
+    r4_local_as = topo["routers"]["r4"]["bgp"]["local_as"]
+
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": r0_local_as,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": r1_local_as,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": r2_local_as,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": 4000,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": 4000,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step(
+        "Configure 2 IPv4 and 2 IPv6, Static route on R4 with next-hop as Null0 IPv4 route Sv41, Sv42, IPv6 route Sv61 Sv62"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r4": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = create_static_routes(tgen, static_routes_input)
+        assert result is True, "Testcase {} : Failed  to configure the static routes \n Error: {}".format(
+            tc_name, result
+        )
+    step("verify IPv4 and IPv6 static route are configured and up on R4")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r4": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r4", static_routes_input)
+        assert result is True, "Testcase {} : Failed Static route {}  is not found in R4 FIB  \n Error: {}".format(
+            tc_name, static_routes_input,result
+        )
+
+    step(
+        "Configure  redistribute static on IPv4 and IPv6 address family on R4 for R4 to R3 neighbo"
+    )
+    redistribute_static = {
+        "r4": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                    "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                }
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, redistribute_static)
+    assert result is True, "Testcase {} : Failed to configure the redistribute  static \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 static route are configured and up on R3")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r3": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r3", static_routes_input)
+        assert result is True, "Testcase {} : Failed static routes from R1 and R3 is not found in FIB  \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_bgp_rib(tgen, addr_type, "r3", static_routes_input)
+        assert result is True, "Testcase {} : Failed static routes from R1 and R3 is not found in RIB  \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Configure IPv4 prefix-list Pv4 and and IPv6 prefix-list Pv6 on R3 so new route which is not present on R3"
+    )
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK3_1["ipv4"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK3_1["ipv6"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed to configure the prefix lists \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 Prefix list got configured on R3")
+    input_dict = {"r3": {"prefix_lists": ["Pv4", "Pv6"]}}
+    result = verify_prefix_lists(tgen, input_dict)
+    assert result is True, "Testcase {} : Failed ..! configured  prefix lists {}  are not found  \n Error: {}".format(tc_name,input_dict, result)
+
+    step(
+        "Configure IPv4 and IPv6 route-map ( RMv4 and RMv6 ) matching prefix-list (Pv4 and Pv6 ) respectively on R3"
+    )
+    input_dict_3 = {
+        "r3": {
+            "route_maps": {
+                "RMv4": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv4"}},
+                    },
+                ],
+                "RMv6": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv6": {"prefix_lists": "Pv6"}},
+                    },
+                ],
+            }
+        }
+    }
+    result = create_route_maps(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed to configure the route-map \n Error: {}".format(tc_name, result)
+    step(
+        "Taking the snapshot of the prefix count before configuring the default originate"
+    )
+    snapshot1 = get_prefix_count_route(tgen, topo, dut="r2", peer="r3")
+    step(
+        "Configure default-originate with IPv4 and IPv6  route-map (RMv4 and RMv6) on R3"
+    )
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv4"}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv6"}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed to configure default-originate \n Error: {}".format(tc_name, result)
+
+    step("Verify the default route is NOT received in BGP RIB and FIB on R2 ")
+    step(
+        "After configuring default-originate command , verify default  routes are not Received on R2 "
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n Default route is not expected due to deny in prefix list \nError: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \nDefault route is not expected due to deny in prefix list\n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Add route Sv41, Sv42, IPv6 route Sv61 Sv62 on prefix list Pv4 and Pv6")
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed  to configure the prefix lists Error: {}".format(tc_name, result)
+
+    step("Verify BGP default route for IPv4 and IPv6 is received on R2")
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed Default routes are expected in R2 FIB  from R3 but not found ....!  \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed Default routes are expected in R2 RIB  from R3 but not found ....! \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Remove route  Sv41, Sv42, IPv6 route Sv61 Sv62 on prefix list Pv4 and Pv6")
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                            "delete": True,
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed to remove prefix-lists from R3 Error: {}".format(tc_name, result)
+
+    step(
+        "After Removing route  BGP default route for IPv4 and IPv6 is NOT received on R2"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n After Removing route in prefix list the default route is not expected in FIB \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n After Removing route in prefix list the default route is not expected in RIB\n Error: {}".format(
+            tc_name, result
+        )
+
+    step(" Add route Sv41, Sv42, IPv6 route Sv61 Sv62 on prefix list Pv4 and Pv6")
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+    step("Verify BGP default route for IPv4 and IPv6 is received on R2")
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Change IPv4 and IPv6 prefix-list permit and deny ")
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {"seqid": "1", "network": NETWORK1_1["ipv4"], "action": "deny"},
+                        {"seqid": "2", "network": NETWORK2_1["ipv4"], "action": "deny"},
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {"seqid": "1", "network": NETWORK1_1["ipv6"], "action": "deny"},
+                        {"seqid": "2", "network": NETWORK2_1["ipv6"], "action": "deny"},
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+    step("Verify BGP default route for IPv4 and IPv6 is not received on R2")
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n after denying the prefix list default route is not expected in FIB \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n after denying the prefix list default route is not expected in RIB \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Change IPv4 and IPv6 prefix-list deny to permit ")
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+    step("Verify BGP default route for IPv4 and IPv6 is  received on R2")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Taking the snapshot2 of the prefix count after configuring the default originate"
+    )
+    snapshot2 = get_prefix_count_route(tgen, topo, dut="r2", peer="r3")
+
+    step("verifying the prefix count incrementing or not ")
+    isIPv4prefix_incremented = False
+    isIPv6prefix_incremented = False
+    if snapshot1["ipv4_count"] < snapshot2["ipv4_count"]:
+        isIPv4prefix_incremented = True
+    if snapshot1["ipv6_count"] < snapshot2["ipv6_count"]:
+        isIPv6prefix_incremented = True
+
+    assert (
+        isIPv4prefix_incremented is True
+    ), "Testcase {} : Failed Error: IPV4 Prefix is not incremented on receiveing ".format(
+        tc_name
+    )
+
+    assert (
+        isIPv6prefix_incremented is True
+    ), "Testcase {} : Failed Error: IPV6 Prefix is not incremented on receiveing ".format(
+        tc_name
+    )
+
+    step(
+        "Configure another IPv4 and IPv6 route-map and match same prefix-list (Sv41, Sv42, IPv6 route Sv61 Sv62) with deny statement "
+    )
+    input_dict_3 = {
+        "r3": {
+            "route_maps": {
+                "RMv41": [
+                    {
+                        "action": "deny",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv4"}},
+                    },
+                ],
+                "RMv61": [
+                    {
+                        "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("Attach route-map on IPv4 and IP6 BGP neighbor on fly")
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv41"}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv61"}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "After attaching route-map verify IPv4 and IPv6 default route is withdrawn from the R2"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert result is not True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert result is not True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Change the recently added Routemap from deny to permit")
+    input_dict_3 = {
+        "r3": {
+            "route_maps": {
+                "RMv41": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv4"}},
+                    },
+                ],
+                "RMv61": [
+                    {
+                        "action": "permit",
+                        "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("Verify IPv4 and IPv6 default route is advertised from the R2")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Delete default-originate route-map command while configuring ( neighbor x.x.x default-originate) for IPv4 and IPv6 BGP neighbor "
+    )
+    """ Configuring the Default originate on neighbor  must remove the previously assigned  deault-originate with routemap config  """
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {"unicast": {"default_originate": {"r2": {}}}},
+                    "ipv6": {"unicast": {"default_originate": {"r2": {}}}},
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Verify in running config from BGP that default-originate with route-map command is removed and default-originate command is still present and default route for IPv4 and IPv6 present in RIB and FIB"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Configure default-originate with conditional route-map command on IPv4 and IPv6 address family  "
+    )
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv41"}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RMv61"}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Verify in running config from BGP that default-originate with route-map command is present and default route for IPv4 and IPv6 present"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Delete default originate with 'no bgp default-originate' from IPV4 and IPV6 address family "
+    )
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"delete": True}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"delete": True}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        " Verify in running config from BGP that default-originate complete CLI is removed for IPV4 and IPV6 address family and default originate routes got deleted"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n Default Route is not expected in FIB \nError: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n Default Route is not expected in RIB\nError: {}".format(
+            tc_name, result
+        )
+
+    write_test_footer(tc_name)
+
+
+if __name__ == "__main__":
+    args = ["-s"] + sys.argv[1:]
+    sys.exit(pytest.main(args))
diff --git a/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_2.py b/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_2.py
new file mode 100644 (file)
index 0000000..a9987a8
--- /dev/null
@@ -0,0 +1,2437 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2022 by VMware, Inc. ("VMware")
+# Used Copyright (c) 2018 by Network Device Education Foundation, Inc. ("NetDEF")
+# in this file.
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+# Shreenidhi A R <rshreenidhi@vmware.com>
+# THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+"""
+Following tests are covered.
+5. Verify BGP  default originate route-map with OUT route-map
+6. Verify BGP  default originate route-map with IN route-map
+8. Verify BGP default route after removing default-originate
+9. Verify default-originate route with GR
+"""
+import os
+import sys
+import time
+import pytest
+from time import sleep
+from copy import deepcopy
+from lib.topolog import logger
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+from lib.topogen import Topogen, get_topogen
+from lib.topojson import build_config_from_json
+from lib.topolog import logger
+
+from lib.bgp import (
+    verify_bgp_convergence,
+    verify_graceful_restart,
+    create_router_bgp,
+    verify_router_id,
+    modify_as_number,
+    verify_as_numbers,
+    clear_bgp_and_verify,
+    clear_bgp,
+    verify_bgp_rib,
+    get_prefix_count_route,
+    get_dut_as_number,
+    verify_rib_default_route,
+    verify_fib_default_route,
+    verify_bgp_advertised_routes_from_neighbor,
+    verify_bgp_received_routes_from_neighbor,
+)
+from lib.common_config import (
+    interface_status,
+    verify_prefix_lists,
+    verify_fib_routes,
+    kill_router_daemons,
+    start_router_daemons,
+    shutdown_bringup_interface,
+    step,
+    required_linux_kernel_version,
+    stop_router,
+    start_router,
+    create_route_maps,
+    create_prefix_lists,
+    get_frr_ipv6_linklocal,
+    start_topology,
+    write_test_header,
+    check_address_types,
+    write_test_footer,
+    reset_config_on_routers,
+    create_static_routes,
+    check_router_status,
+    delete_route_maps,
+)
+
+
+# Save the Current Working Directory to find configuration files.
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+sys.path.append(os.path.join(CWD, "../lib/"))
+
+# Required to instantiate the topology builder class.
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+
+# Global variables
+topo = None
+KEEPALIVETIMER = 1
+HOLDDOWNTIMER = 3
+# Global variables
+NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
+NETWORK1_2 = {"ipv4": "1.1.1.2/32", "ipv6": "1::2/128"}
+NETWORK2_1 = {"ipv4": "2.1.1.1/32", "ipv6": "2::1/128"}
+NETWORK2_2 = {"ipv4": "2.1.1.2/32", "ipv6": "2::2/128"}
+NETWORK3_1 = {"ipv4": "3.1.1.1/32", "ipv6": "3::1/128"}
+NETWORK3_2 = {"ipv4": "3.1.1.2/32", "ipv6": "3::2/128"}
+NETWORK4_1 = {"ipv4": "4.1.1.1/32", "ipv6": "4::1/128"}
+NETWORK4_2 = {"ipv4": "4.1.1.2/32", "ipv6": "4::2/128"}
+NETWORK5_1 = {"ipv4": "5.1.1.1/32", "ipv6": "5::1/128"}
+NETWORK5_2 = {"ipv4": "5.1.1.2/32", "ipv6": "5::2/128"}
+DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
+
+IPV4_RM = "RMVIPV4"
+IPV6_RM = "RMVIPV6"
+
+IPV4_RM1 = "RMVIPV41"
+IPV6_RM1 = "RMVIPV61"
+
+IPV4_RM2 = "RMVIPV42"
+IPV6_RM2 = "RMVIPV62"
+
+IPV4_PL_1 = "PV41"
+IPV4_PL_2 = "PV42"
+
+IPV6_PL_1 = "PV61"
+IPV6_PL_2 = "PV62"
+
+
+r1_ipv4_loopback = "1.0.1.0/24"
+r2_ipv4_loopback = "1.0.2.0/24"
+r3_ipv4_loopback = "1.0.3.0/24"
+r4_ipv4_loopback = "1.0.4.0/24"
+r1_ipv6_loopback = "2001:db8:f::1:0/120"
+r2_ipv6_loopback = "2001:db8:f::2:0/120"
+r3_ipv6_loopback = "2001:db8:f::3:0/120"
+r4_ipv6_loopback = "2001:db8:f::4:0/120"
+
+r0_connected_address_ipv4 = "192.168.0.0/24"
+r0_connected_address_ipv6 = "fd00::/64"
+r1_connected_address_ipv4 = "192.168.1.0/24"
+r1_connected_address_ipv6 = "fd00:0:0:1::/64"
+r3_connected_address_ipv4 = "192.168.2.0/24"
+r3_connected_address_ipv6 = "fd00:0:0:2::/64"
+r4_connected_address_ipv4 = "192.168.3.0/24"
+r4_connected_address_ipv6 = "fd00:0:0:3::/64"
+
+
+def setup_module(mod):
+    """
+    Sets up the pytest environment
+
+    * `mod`: module name
+    """
+
+    # Required linux kernel version for this suite to run.
+    result = required_linux_kernel_version("4.15")
+    if result is not True:
+        pytest.skip("Kernel requirements are not met")
+
+    testsuite_run_time = time.asctime(time.localtime(time.time()))
+    logger.info("Testsuite start time: {}".format(testsuite_run_time))
+    logger.info("=" * 40)
+
+    logger.info("Running setup_module to create topology")
+
+    # This function initiates the topology build with Topogen...
+    json_file = "{}/bgp_default_originate_topo1.json".format(CWD)
+    tgen = Topogen(json_file, mod.__name__)
+    global topo
+    topo = tgen.json_topo
+    # ... and here it calls Mininet initialization functions.
+
+    # Starting topology, create tmp files which are loaded to routers
+    #  to start daemons and then start routers
+    start_topology(tgen)
+
+    # Creating configuration from JSON
+    build_config_from_json(tgen, topo)
+
+    global ADDR_TYPES
+    global BGP_CONVERGENCE
+    global DEFAULT_ROUTES
+    global DEFAULT_ROUTE_NXT_HOP_R1, DEFAULT_ROUTE_NXT_HOP_R3
+    global R0_NETWORK_LOOPBACK, R0_NETWORK_LOOPBACK_NXTHOP, R1_NETWORK_LOOPBACK, R1_NETWORK_LOOPBACK_NXTHOP
+    global R0_NETWORK_CONNECTED, R0_NETWORK_CONNECTED_NXTHOP, R1_NETWORK_CONNECTED, R1_NETWORK_CONNECTED_NXTHOP
+    global R4_NETWORK_LOOPBACK, R4_NETWORK_LOOPBACK_NXTHOP, R3_NETWORK_LOOPBACK, R3_NETWORK_LOOPBACK_NXTHOP
+    global R4_NETWORK_CONNECTED, R4_NETWORK_CONNECTED_NXTHOP, R3_NETWORK_CONNECTED, R3_NETWORK_CONNECTED_NXTHOP
+
+    ADDR_TYPES = check_address_types()
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+    # There are the global varibles used through out the file these are acheived only after building the topology.
+
+    r0_loopback_address_ipv4 = topo["routers"]["r0"]["links"]["lo"]["ipv4"]
+    r0_loopback_address_ipv4_nxt_hop = topo["routers"]["r0"]["links"]["r1"][
+        "ipv4"
+    ].split("/")[0]
+    r0_loopback_address_ipv6 = topo["routers"]["r0"]["links"]["lo"]["ipv6"]
+    r0_loopback_address_ipv6_nxt_hop = topo["routers"]["r0"]["links"]["r1"][
+        "ipv6"
+    ].split("/")[0]
+
+    r1_loopback_address_ipv4 = topo["routers"]["r1"]["links"]["lo"]["ipv4"]
+    r1_loopback_address_ipv4_nxt_hop = topo["routers"]["r1"]["links"]["r2"][
+        "ipv4"
+    ].split("/")[0]
+    r1_loopback_address_ipv6 = topo["routers"]["r1"]["links"]["lo"]["ipv6"]
+    r1_loopback_address_ipv6_nxt_hop = topo["routers"]["r1"]["links"]["r2"][
+        "ipv6"
+    ].split("/")[0]
+
+    r4_loopback_address_ipv4 = topo["routers"]["r4"]["links"]["lo"]["ipv4"]
+    r4_loopback_address_ipv4_nxt_hop = topo["routers"]["r4"]["links"]["r3"][
+        "ipv4"
+    ].split("/")[0]
+    r4_loopback_address_ipv6 = topo["routers"]["r4"]["links"]["lo"]["ipv6"]
+    r4_loopback_address_ipv6_nxt_hop = topo["routers"]["r4"]["links"]["r3"][
+        "ipv6"
+    ].split("/")[0]
+
+    r3_loopback_address_ipv4 = topo["routers"]["r3"]["links"]["lo"]["ipv4"]
+    r3_loopback_address_ipv4_nxt_hop = topo["routers"]["r3"]["links"]["r2"][
+        "ipv4"
+    ].split("/")[0]
+    r3_loopback_address_ipv6 = topo["routers"]["r3"]["links"]["lo"]["ipv6"]
+    r3_loopback_address_ipv6_nxt_hop = topo["routers"]["r3"]["links"]["r2"][
+        "ipv6"
+    ].split("/")[0]
+
+    R0_NETWORK_LOOPBACK = {
+        "ipv4": r0_loopback_address_ipv4,
+        "ipv6": r0_loopback_address_ipv6,
+    }
+    R0_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r0_loopback_address_ipv4_nxt_hop,
+        "ipv6": r0_loopback_address_ipv6_nxt_hop,
+    }
+
+    R1_NETWORK_LOOPBACK = {
+        "ipv4": r1_loopback_address_ipv4,
+        "ipv6": r1_loopback_address_ipv6,
+    }
+    R1_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r1_loopback_address_ipv4_nxt_hop,
+        "ipv6": r1_loopback_address_ipv6_nxt_hop,
+    }
+
+    R0_NETWORK_CONNECTED = {
+        "ipv4": r0_connected_address_ipv4,
+        "ipv6": r0_connected_address_ipv6,
+    }
+    R0_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r0_loopback_address_ipv4_nxt_hop,
+        "ipv6": r0_loopback_address_ipv6_nxt_hop,
+    }
+
+    R1_NETWORK_CONNECTED = {
+        "ipv4": r1_connected_address_ipv4,
+        "ipv6": r1_connected_address_ipv6,
+    }
+    R1_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r1_loopback_address_ipv4_nxt_hop,
+        "ipv6": r1_loopback_address_ipv6_nxt_hop,
+    }
+
+    R4_NETWORK_LOOPBACK = {
+        "ipv4": r4_loopback_address_ipv4,
+        "ipv6": r4_loopback_address_ipv6,
+    }
+    R4_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r4_loopback_address_ipv4_nxt_hop,
+        "ipv6": r4_loopback_address_ipv6_nxt_hop,
+    }
+
+    R3_NETWORK_LOOPBACK = {
+        "ipv4": r3_loopback_address_ipv4,
+        "ipv6": r3_loopback_address_ipv6,
+    }
+    R3_NETWORK_LOOPBACK_NXTHOP = {
+        "ipv4": r3_loopback_address_ipv4_nxt_hop,
+        "ipv6": r3_loopback_address_ipv6_nxt_hop,
+    }
+
+    R4_NETWORK_CONNECTED = {
+        "ipv4": r4_connected_address_ipv4,
+        "ipv6": r4_connected_address_ipv6,
+    }
+    R4_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r4_loopback_address_ipv4_nxt_hop,
+        "ipv6": r4_loopback_address_ipv6_nxt_hop,
+    }
+
+    R3_NETWORK_CONNECTED = {
+        "ipv4": r3_connected_address_ipv4,
+        "ipv6": r3_connected_address_ipv6,
+    }
+    R3_NETWORK_CONNECTED_NXTHOP = {
+        "ipv4": r3_loopback_address_ipv4_nxt_hop,
+        "ipv6": r3_loopback_address_ipv6_nxt_hop,
+    }
+
+    # populating the nexthop for default routes
+
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+
+    interface = topo["routers"]["r1"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv4"].split("/")[0]
+    ipv6_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv6"].split("/")[0]
+    DEFAULT_ROUTE_NXT_HOP_R1 = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+
+    interface = topo["routers"]["r3"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r3", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r3"]["links"]["r2"]["ipv4"].split("/")[0]
+    ipv6_nxt_hop = topo["routers"]["r3"]["links"]["r2"]["ipv6"].split("/")[0]
+    DEFAULT_ROUTE_NXT_HOP_R3 = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+
+    logger.info("Running setup_module() done")
+
+
+def teardown_module():
+    """Teardown the pytest environment"""
+
+    logger.info("Running teardown_module to delete topology")
+
+    tgen = get_topogen()
+
+    # Stop toplogy and Remove tmp files
+    tgen.stop_topology()
+
+    logger.info(
+        "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
+    )
+    logger.info("=" * 40)
+
+
+#####################################################
+#
+#                      Local API's
+#
+#####################################################
+
+
+def configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut, peer):
+    """
+    This function groups the repetitive function calls into one function.
+    """
+    result = create_router_bgp(tgen, topo, input_dict)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+    return True
+
+
+#####################################################
+#
+#                      Testcases
+#
+#####################################################
+
+
+def test_verify_bgp_default_originate_route_map_in_OUT_p1(request):
+    """
+    test_verify_bgp_default_originate_route_map_in_OUT_p1
+    """
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+    step("Configure IPv4 and IPv6 , EBGP neighbor between R3 and R2")
+    step("Configure IPv4 and IPv6 IBGP neighbor between R3 and R4")
+    r0_local_as = topo["routers"]["r0"]["bgp"]["local_as"]
+    r1_local_as = topo["routers"]["r1"]["bgp"]["local_as"]
+    r2_local_as = topo["routers"]["r2"]["bgp"]["local_as"]
+    r3_local_as = topo["routers"]["r3"]["bgp"]["local_as"]
+    r4_local_as = topo["routers"]["r4"]["bgp"]["local_as"]
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": r0_local_as,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": r1_local_as,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": r2_local_as,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": 4000,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": 4000,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step(
+        "Configure 2 IPv4 and 2 IPv6, Static route on R4 with next-hop as Null0 IPv4 route Sv41, Sv42, IPv6 route Sv61 Sv62"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r4": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = create_static_routes(tgen, static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("verify IPv4 and IPv6 static route are configured and up on R4")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r4": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r4", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Configure redistribute static knob on R4 , for R4 to R3 neighbor ")
+    redistribute_static = {
+        "r4": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                    "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                }
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, redistribute_static)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    expected_routes = {
+        "ipv4": [
+            {"network": NETWORK1_1["ipv4"], "nexthop": NEXT_HOP_IP["ipv4"]},
+            {"network": NETWORK2_1["ipv4"], "nexthop": NEXT_HOP_IP["ipv4"]},
+        ],
+        "ipv6": [
+            {"network": NETWORK1_1["ipv6"], "nexthop": NEXT_HOP_IP["ipv4"]},
+            {"network": NETWORK2_1["ipv6"], "nexthop": NEXT_HOP_IP["ipv4"]},
+        ],
+    }
+    result = verify_bgp_advertised_routes_from_neighbor(
+        tgen, topo, dut="r4", peer="r3", expected_routes=expected_routes
+    )
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "After redistribute static verify the routes is recevied in router R3 in RIB and FIB"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r3": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r3", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_bgp_rib(tgen, addr_type, "r3", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Configure IPv4 prefix-list Pv4 and and IPv6 prefix-list Pv6 on R3 to match BGP route Sv41, IPv6 route Sv61 with  permit option "
+    )
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 Prefix list got configured on R3")
+    input_dict = {"r3": {"prefix_lists": ["Pv4", "Pv6"]}}
+    result = verify_prefix_lists(tgen, input_dict)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Configure IPv4 and IPv6 route-map RMv4 and RMv6 matching prefix-list Pv4 and Pv6 with permit option "
+    )
+    input_dict_3 = {
+        "r3": {
+            "route_maps": {
+                "RM4": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv4"}},
+                    },
+                ],
+                "RM6": [
+                    {
+                        "action": "permit",
+                        "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(
+        "Configure IPv4 prefix-list Pv42 and and IPv6 prefix-list Pv62 on R3 to match BGP route Sv42, IPv6 route Sv62  with deny option"
+    )
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv42": [
+                        {"seqid": "1", "network": NETWORK2_1["ipv4"], "action": "deny"}
+                    ]
+                },
+                "ipv6": {
+                    "Pv62": [
+                        {"seqid": "1", "network": NETWORK2_1["ipv6"], "action": "deny"}
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 Prefix list got configured on R3")
+    input_dict = {"r3": {"prefix_lists": ["Pv42", "Pv62"]}}
+    result = verify_prefix_lists(tgen, input_dict)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Configure IPv4 and IPv6 route-map (RMv42 and RMv62 )matching prefix-list Pv42 and Pv62 with permit option "
+    )
+    input_dict_3 = {
+        "r3": {
+            "route_maps": {
+                "RMv42": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv42"}},
+                    },
+                ],
+                "RMv62": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv6": {"prefix_lists": "Pv62"}},
+                    },
+                ],
+            }
+        }
+    }
+    result = create_route_maps(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Apply IPv4 and IPv6 route-map RMv4 and RMv6 with default-originate on R3 , for R3 to R2 peers and Apply IPv4 and IPv6 out route-map RMv42 and RMv62 on R3 , for R3 to R2 peers "
+    )
+    local_as = get_dut_as_number(tgen, "r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RM4"}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"route_map": "RM6"}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    updated_topo = topo
+    updated_topo["routers"]["r0"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r0")
+    updated_topo["routers"]["r1"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r1")
+    updated_topo["routers"]["r2"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r2")
+    updated_topo["routers"]["r3"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r3")
+    updated_topo["routers"]["r4"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r4")
+
+    step(
+        "Apply IPv4 and IPv6  route-map RMv42 and RMv62 on R3  (OUT Direction), for R3 to R2 peers "
+    )
+    input_dict_4 = {
+        "r3": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "neighbor": {
+                                "r2": {
+                                    "dest_link": {
+                                        "r3": {
+                                            "route_maps": [
+                                                {"name": "RMv42", "direction": "out"}
+                                            ]
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "neighbor": {
+                                "r2": {
+                                    "dest_link": {
+                                        "r3": {
+                                            "route_maps": [
+                                                {"name": "RMv62", "direction": "out"}
+                                            ]
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        }
+    }
+
+    result = create_router_bgp(tgen, updated_topo, input_dict_4)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    NOTE = """
+    After applying route-map on neighbor verify default BGP route IPv4  IPv6  route populated in R2 BGP and routing table , verify using "show ip bgp json" "show ipv6 bgp json" "show ip route json" "show ip route json"
+    Sv42 and Sv62 route should not be  present on R2
+    """
+    step(NOTE)
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen, addr_type, "r2", static_routes_input, expected=False
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n Static routes are not expected due to conditions \nError: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen, addr_type, "r2", static_routes_input, expected=False
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n Static routes are not expected  due to conditions\n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Change IPv4 prefix-list Pv42 and and IPv6 prefix-list Pv62 deny to permit")
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv42": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+                "ipv6": {
+                    "Pv62": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                        }
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 Prefix list got configured on R3")
+    input_dict = {"r3": {"prefix_lists": ["Pv42", "Pv62"]}}
+    result = verify_prefix_lists(tgen, input_dict)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    NOTE = """Default BGP route and IPv4 ( Sv42)  , IPv6 (Sv62)  route populated in R2 BGP and routing table"""
+    step(NOTE)
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("IPv4 prefix-list Pv4 and and IPv6 prefix-list Pv6 permit to deny ")
+    input_dict_3 = {
+        "r3": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {"seqid": "1", "network": NETWORK1_1["ipv4"], "action": "deny"}
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {"seqid": "1", "network": NETWORK1_1["ipv6"], "action": "deny"}
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    NOTE = """
+    Verify default-originate route (IPv4 and IPv6 ) not present on R2
+    IPv4 ( Sv42)  , IPv6 (Sv62)  route populated in R2 BGP
+    """
+    step(NOTE)
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n default-route in FIB is not expected due to conditions \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R3[addr_type],
+            expected=False,
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n default-route in RIB is not expected due to conditions \n Error: {}".format(
+            tc_name, result
+        )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    write_test_footer(tc_name)
+
+def test_verify_bgp_default_originate_route_map_in_IN_p1(request):
+    """Verify BGP  default originate route-map with IN route-map"""
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+    step("Configure IPv4 and IPv6 , EBGP neighbor between R1 and R2")
+    step("Configure IPv4 and IPv6 , IBGP neighbor between R1 and R0")
+    r0_local_as = topo["routers"]["r0"]["bgp"]["local_as"]
+    r1_local_as = topo["routers"]["r1"]["bgp"]["local_as"]
+    r2_local_as = topo["routers"]["r2"]["bgp"]["local_as"]
+    r3_local_as = topo["routers"]["r3"]["bgp"]["local_as"]
+    r4_local_as = topo["routers"]["r4"]["bgp"]["local_as"]
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": 1000,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": 1000,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": r2_local_as,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": r3_local_as,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": r4_local_as,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step(
+        "Configure 2 IPv4 and 2 IPv6, Static route on R0 with next-hop as Null0 IPv4 route Sv41, Sv42, IPv6 route Sv61 Sv62"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r0": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = create_static_routes(tgen, static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("verifyIPv4 and IPv6 static routes are configure and up on R0 ")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r0": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r0", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Configure redistribute static knob on R0 , for R0 to R1 IPv4 and IPv6 neighbor"
+    )
+    redistribute_static = {
+        "r0": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                    "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
+                }
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, redistribute_static)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("Verify  IPv4 and IPv6 route received on R1  ")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r1": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Configure IPv4 prefix-list Pv4 and and IPv6 prefix-list Pv6 on R1 to match BGP route Sv41, Sv42, IPv6 route Sv61 Sv62"
+    )
+    input_dict_3 = {
+        "r1": {
+            "prefix_lists": {
+                "ipv4": {
+                    "Pv4": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv4"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv4"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+                "ipv6": {
+                    "Pv6": [
+                        {
+                            "seqid": "1",
+                            "network": NETWORK1_1["ipv6"],
+                            "action": "permit",
+                        },
+                        {
+                            "seqid": "2",
+                            "network": NETWORK2_1["ipv6"],
+                            "action": "permit",
+                        },
+                    ]
+                },
+            }
+        }
+    }
+    result = create_prefix_lists(tgen, input_dict_3)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 Prefix list got configured on R1")
+    input_dict = {"r1": {"prefix_lists": ["Pv4", "Pv6"]}}
+    result = verify_prefix_lists(tgen, input_dict)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Configure IPv4 and IPv6 route-map RMv4 and RMv6 matching prefix-list Pv4 and Pv6 with deny option on R1"
+    )
+    input_dict_3 = {
+        "r1": {
+            "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 in R1 (R1 to R0) IPv4 and IPv6 neighbor")
+    updated_topo = topo
+    updated_topo["routers"]["r0"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r0")
+    updated_topo["routers"]["r1"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r1")
+    updated_topo["routers"]["r2"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r2")
+    updated_topo["routers"]["r3"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r3")
+    updated_topo["routers"]["r4"]["bgp"]["local_as"] = get_dut_as_number(tgen, "r4")
+
+    local_as_r1 = get_dut_as_number(tgen, dut="r1")
+    input_dict_4 = {
+        "r1": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "neighbor": {
+                                "r0": {
+                                    "dest_link": {
+                                        "r1": {
+                                            "route_maps": [
+                                                {
+                                                    "name": "RMv4",
+                                                    "direction": "in",
+                                                }
+                                            ]
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "neighbor": {
+                                "r0": {
+                                    "dest_link": {
+                                        "r1": {
+                                            "route_maps": [
+                                                {
+                                                    "name": "RMv6",
+                                                    "direction": "in",
+                                                }
+                                            ]
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        }
+    }
+
+    result = create_router_bgp(tgen, updated_topo, input_dict_4)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    STEP = "After applying route-map verify that IPv4 route Sv41, Sv42, IPv6 route Sv61 Sv62 should not present on R1 BGP and routing table "
+    step(STEP)
+
+    step(
+        "After applying route-map verify that IPv4 route Sv41, Sv42, IPv6 route Sv61 Sv62 should not present on R1 "
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r1": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_fib_routes(
+            tgen, addr_type, "r1", static_routes_input, expected=False
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n default-route in FIB is not expected due to conditions  \nError: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(
+            tgen, addr_type, "r1", static_routes_input, expected=False
+        )
+        assert (
+            result is not True
+        ), "Testcase {} : Failed \n default-route in FIB is not expected due to conditions \nError: {}".format(
+            tc_name, result
+        )
+    # Routes should come to dut but not the shown in RIB thus verifying using  show ip bgp nbr xxx received route
+    step(
+        " Verify the received routes \n using 'show ip bgp nbr xxx received route'  in Router R1"
+    )
+    expected_routes = {
+        "ipv4": [
+            {"network": NETWORK1_1["ipv4"], "nexthop": NEXT_HOP_IP["ipv4"]},
+            {"network": NETWORK2_1["ipv4"], "nexthop": NEXT_HOP_IP["ipv4"]},
+        ],
+        "ipv6": [
+            {"network": NETWORK1_1["ipv6"], "nexthop": NEXT_HOP_IP["ipv6"]},
+            {"network": NETWORK2_1["ipv6"], "nexthop": NEXT_HOP_IP["ipv6"]},
+        ],
+    }
+    result = verify_bgp_received_routes_from_neighbor(
+        tgen, topo, dut="r1", peer="r0", expected_routes=expected_routes
+    )
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("Configure default-originate on R1 for R1 to R2 IPv4 and IPv6 neighbor ")
+    local_as_r1 = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as_r1,
+                "address_family": {
+                    "ipv4": {"unicast": {"default_originate": {"r2": {}}}},
+                    "ipv6": {"unicast": {"default_originate": {"r2": {}}}},
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Verify Default originate knob is configured and default route advertised to R2 , verify on R1 "
+    )
+    expected_routes = {
+        "ipv4": [
+            {"network": "0.0.0.0/0", "nexthop": ""},
+        ],
+        "ipv6": [
+            {"network": "::/0", "nexthop": ""},
+        ],
+    }
+    result = verify_bgp_advertised_routes_from_neighbor(
+        tgen, topo, dut="r1", peer="r2", expected_routes=expected_routes
+    )
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("Verify the Default route Route in FIB in R2")
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r1": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Change route-map RMv4 and RMv6 from deny to permit")
+    input_dict_3 = {
+        "r1": {
+            "route_maps": {
+                "RMv4": [
+                    {
+                        "action": "permit",
+                        "seq_id": "1",
+                        "match": {"ipv4": {"prefix_lists": "Pv4"}},
+                    },
+                ],
+                "RMv6": [
+                    {
+                        "action": "permit",
+                        "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)
+
+    NOTE = """After changing  route-map to permit verify that IPv4 routes Sv41, Sv42, IPv6 routes Sv61 Sv62  present on R1 BGP and routing table , using "show ip route " "show ip bgp nbr xxx received route " "show ipv6 route " "show ipv6 bgp nbr xxx receied route """
+    step(NOTE)
+    expected_routes = {
+        "ipv4": [{"network": NETWORK1_1["ipv4"], "nexthop": NEXT_HOP_IP["ipv4"]}],
+        "ipv6": [{"network": NETWORK1_1["ipv6"], "nexthop": NEXT_HOP_IP["ipv4"]}],
+    }
+    result = verify_bgp_received_routes_from_neighbor(
+        tgen, topo, dut="r1", peer="r0", expected_routes=expected_routes
+    )
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r1": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                ]
+            }
+        }
+        result = verify_bgp_rib(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_fib_routes(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Configure default static route (IPv4 and IPv6) on R2 nexthop as R1 ")
+    NEXT_HOP_IP_R1 = {}
+    r1_r2_ipv4_neighbor = topo["routers"]["r1"]["links"]["r2"]["ipv4"].split("/")[0]
+    r1_r2_ipv6_neighbor = topo["routers"]["r1"]["links"]["r2"]["ipv6"].split("/")[0]
+    NEXT_HOP_IP_R1["ipv4"] = r1_r2_ipv4_neighbor
+    NEXT_HOP_IP_R1["ipv6"] = r1_r2_ipv6_neighbor
+    static_routes_input = {
+        "r2": {
+            "static_routes": [
+                {
+                    "network": "0.0.0.0/0",
+                    "next_hop": NEXT_HOP_IP_R1["ipv4"],
+                },
+                {
+                    "network": "0::0/0",
+                    "next_hop": NEXT_HOP_IP_R1["ipv6"],
+                },
+            ]
+        }
+    }
+    result = create_static_routes(tgen, static_routes_input)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "Verify Static default route is taking preference over BGP default routes , BGP default route is inactive IN RIB and static is up and installed in RIB and FIB "
+    )
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    ipv4_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv4"].split("/")[0]
+    ipv6_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv6"].split("/")[0]
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_nxt_hop}
+
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP[addr_type],
+                        "protocol": "static",
+                    }
+                ]
+            }
+        }
+        result = verify_bgp_rib(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_fib_routes(
+            tgen,
+            addr_type,
+            "r2",
+            static_routes_input,
+            next_hop=DEFAULT_ROUTE_NXT_HOP[addr_type],
+        )
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+    write_test_footer(tc_name)
+
+def test_verify_default_originate_after_removing_default_originate_p1(request):
+    """Verify BGP default route after removing default-originate"""
+
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+    step("Configure EBGP between R0 to R1 and IBGP between R1 to R2")
+    step("Configure EBGP between R2 to R3 and IBGP between R3 to R4")
+    r0_local_as = topo["routers"]["r0"]["bgp"]["local_as"]
+    r1_local_as = topo["routers"]["r1"]["bgp"]["local_as"]
+    r2_local_as = topo["routers"]["r2"]["bgp"]["local_as"]
+    r3_local_as = topo["routers"]["r3"]["bgp"]["local_as"]
+    r4_local_as = topo["routers"]["r4"]["bgp"]["local_as"]
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": r0_local_as,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": 2000,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": 2000,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": 5000,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": 5000,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step("Configure IPv4 and IPv6 static route on R0 and R4")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r0": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            },
+            "r4": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            },
+        }
+        result = create_static_routes(tgen, static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("verify IPv4 and IPv6 static route are configured and up on R0 and R4")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r0": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r0", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r4": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    }
+                ]
+            }
+        }
+        result = verify_fib_routes(tgen, addr_type, "r4", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+    step(
+        "Configure redistribute connected and static on R0 (R0-R1) on R4 ( R4-R3) IPv4 and IPv6 address family "
+    )
+    redistribute_static = {
+        "r0": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                }
+            }
+        },
+        "r4": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                    "ipv6": {
+                        "unicast": {
+                            "redistribute": [
+                                {"redist_type": "static"},
+                                {"redist_type": "connected"},
+                            ]
+                        }
+                    },
+                }
+            }
+        },
+        "r1": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"redistribute": [{"redist_type": "connected"}]}
+                    },
+                    "ipv6": {
+                        "unicast": {"redistribute": [{"redist_type": "connected"}]}
+                    },
+                }
+            }
+        },
+        "r3": {
+            "bgp": {
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"redistribute": [{"redist_type": "connected"}]}
+                    },
+                    "ipv6": {
+                        "unicast": {"redistribute": [{"redist_type": "connected"}]}
+                    },
+                }
+            }
+        },
+    }
+    result = create_router_bgp(tgen, topo, redistribute_static)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("verify IPv4 and IPv6 static route are configured and up on R1 and R3")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r1": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R0_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R0_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R1_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R1_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_bgp_rib(tgen, addr_type, "r1", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("verify IPv4 and IPv6 static route are configured and up on R1 and R3")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r3": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R3_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R3_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R4_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R4_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r3", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r3", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Configure default-originate on R1 for R1 to R2 neighbor  for IPv4 and IPv6 peer "
+    )
+    local_as = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {"unicast": {"default_originate": {"r2": {}}}},
+                    "ipv6": {"unicast": {"default_originate": {"r2": {}}}},
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+    step(
+        "Verify  all the static , connected  and loopback routes from R0,R1,R3 and R4 is receieved on R2 "
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R0_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R0_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R1_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R1_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R3_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R3_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R4_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R4_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step("Verify the Default Originate on R2 nexthop as R1")
+
+    interface = topo["routers"]["r1"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv4"].split("/")[0]
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+
+    result = verify_rib_default_route(
+        tgen,
+        topo,
+        dut="r2",
+        routes=DEFAULT_ROUTES,
+        expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+        expected=True,
+    )
+    assert (
+        result is True
+    ), "Testcase {} : Failed \n Error: After Deactivating the BGP neighbor the default route is   expected but found in RIB -> {}".format(
+        tc_name, result
+    )
+
+    result = verify_fib_default_route(
+        tgen,
+        topo,
+        dut="r2",
+        routes=DEFAULT_ROUTES,
+        expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+        expected=True,
+    )
+    assert (
+        result is True
+    ), "Testcase {} : Failed \n Error:  After Deactivating the BGP neighbor the default route is   expected but found in FIB -> {}".format(
+        tc_name, result
+    )
+
+    step(
+        "Configure default-originate on R3 for R3 to R2 neighbor  for IPv4 and IPv6 peer "
+    )
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {"unicast": {"default_originate": {"r2": {}}}},
+                    "ipv6": {"unicast": {"default_originate": {"r2": {}}}},
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+    STEP = """After configuring the Default Originate From R3 --> R2
+        Both Default routes from R1 and R3 Should present in  R2 BGP RIB
+        The Deafult Route from iBGP is prefferedover EBGP thus
+        Default Route From R1->r2  should only present in R2 FIB  """
+    step(STEP)
+
+    interface = topo["routers"]["r3"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r3", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r3"]["links"]["r2"]["ipv4"].split("/")[0]
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+    result = verify_fib_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: Only IBGP default originate is expected in FIB over EBGP {}".format(
+        tc_name, result
+    )
+
+    result = verify_rib_default_route(
+        tgen,
+        topo,
+        dut="r2",
+        routes=DEFAULT_ROUTES,
+        expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+        expected=True,
+    )
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "No change on static and connected routes which got advertised from R0, R1, R3 and R4"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R0_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R0_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R1_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R1_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R3_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R3_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R4_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R4_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        " Remove default-originate on R1 for R1 to R2 neighbor  for IPv4 and IPv6 peer "
+    )
+    local_as = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"delete": True}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"delete": True}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step("Verify the Default Originate reoute from R1 to r2 is removed in R2 ")
+    interface = topo["routers"]["r1"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r1"]["links"]["r2"]["ipv4"].split("/")[0]
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+    result = verify_fib_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 After removing the default originate the route should not be present in FIB \n Error: {}".format(
+        tc_name, result
+    )
+
+    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 After removing the default originate the route should not be present in RIB \n Error: {}".format(
+        tc_name, result
+    )
+
+    NOTE = """ after removing the Default originate from R1-->R2
+     Verify the BGP Default route received from R3 is present in both BGP RIB and FIB on R2
+     """
+    interface = topo["routers"]["r3"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r3", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r3"]["links"]["r2"]["ipv4"].split("/")[0]
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+    result = verify_fib_default_route(
+        tgen,
+        topo,
+        dut="r2",
+        routes=DEFAULT_ROUTES,
+        expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+        expected=True,
+    )
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    result = verify_rib_default_route(
+        tgen,
+        topo,
+        dut="r2",
+        routes=DEFAULT_ROUTES,
+        expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+        expected=True,
+    )
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "No change on static and connected routes which got advertised from R0, R1, R3 and R4"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R0_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R0_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R1_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R1_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R3_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R3_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R4_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R4_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+    step(
+        "Remove default-originate on R3 for R3 to R2 neighbor  for IPv4 and IPv6 peer "
+    )
+    local_as = get_dut_as_number(tgen, dut="r3")
+    default_originate_config = {
+        "r3": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {"default_originate": {"r2": {"delete": True}}}
+                    },
+                    "ipv6": {
+                        "unicast": {"default_originate": {"r2": {"delete": True}}}
+                    },
+                },
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+    step(
+        "After removing default originate , verify default IPv4 and IPv6 BGP routes removed on R2 from R1 ( next-hop as R3) "
+    )
+    interface = topo["routers"]["r3"]["links"]["r2"]["interface"]
+    ipv6_link_local = get_frr_ipv6_linklocal(tgen, "r3", intf=interface)
+    ipv4_nxt_hop = topo["routers"]["r3"]["links"]["r2"]["ipv4"].split("/")[0]
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local}
+    result = verify_fib_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 After removing the default originate the route should not be present in FIB \n Error: {}".format(
+        tc_name, result
+    )
+
+    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 After removing the default originate the route should not be present in RIB \n Error: {}".format(
+        tc_name, result
+    )
+    step(
+        "No change on static and connected routes which got advertised from R0, R1, R3 and R4"
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [NETWORK1_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [NETWORK2_1[addr_type]],
+                        "next_hop": NEXT_HOP_IP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R0_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R0_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R0_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R1_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R1_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R1_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R3_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R3_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R3_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_LOOPBACK[addr_type]],
+                        "next_hop": R4_NETWORK_LOOPBACK_NXTHOP[addr_type],
+                    },
+                    {
+                        "network": [R4_NETWORK_CONNECTED[addr_type]],
+                        "next_hop": R4_NETWORK_CONNECTED_NXTHOP[addr_type],
+                    },
+                ]
+            }
+        }
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input)
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+    write_test_footer(tc_name)
+
+def test_verify_default_originate_route_with_GR_p1(request):
+    """ "Verify default-originate route with GR "
+    """
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+    global topo
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        check_router_status(tgen)
+    reset_config_on_routers(tgen)
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip("skipped because of BGP Convergence failure")
+
+
+    step("Configure IPV4 and IPV6 IBGP between R1 and R2 ")
+    step("Configure IPV4 and IPV6 EBGP between R2 to R3 ")
+    r0_local_as = topo['routers']['r0']['bgp']['local_as']
+    r1_local_as = topo['routers']['r1']['bgp']['local_as']
+    r2_local_as = topo['routers']['r2']['bgp']['local_as']
+    r3_local_as = topo['routers']['r3']['bgp']['local_as']
+    r4_local_as = topo['routers']['r4']['bgp']['local_as']
+    input_dict = {
+        "r0": {
+            "bgp": {
+                "local_as": r0_local_as,
+            }
+        },
+        "r1": {
+            "bgp": {
+                "local_as": 1000,
+            }
+        },
+        "r2": {
+            "bgp": {
+                "local_as": 1000,
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": r3_local_as,
+            }
+        },
+        "r4": {
+            "bgp": {
+                "local_as": r4_local_as,
+            }
+        },
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+    step("After changing the BGP AS Path Verify the BGP Convergence")
+    BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+    assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+        BGP_CONVERGENCE
+    )
+
+    step(
+        "Configure per peer Graceful restart on R2 ( restarting router) and  R3  helper router "
+    )
+    input_dict = {
+        "r2": {
+            "bgp": {
+                "local_as": get_dut_as_number(tgen, "r2"),
+                "graceful-restart": {
+                    "graceful-restart": True,
+                    "preserve-fw-state": True,
+                },
+            }
+        },
+        "r3": {
+            "bgp": {
+                "local_as": get_dut_as_number(tgen, "r3"),
+                "graceful-restart": {"graceful-restart-helper": True},
+            }
+        },
+    }
+
+    configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r2", peer="r3")
+
+    step("verify Graceful restart at R2")
+    for addr_type in ADDR_TYPES:
+        result = verify_graceful_restart(
+            tgen, topo, addr_type, input_dict, dut="r2", peer="r3"
+        )
+        assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
+
+    step(
+        "Configure default-originate on R1 for R1-R2 neighbor for IPv4 and IPv6 BGP peers "
+    )
+    local_as = get_dut_as_number(tgen, dut="r1")
+    default_originate_config = {
+        "r1": {
+            "bgp": {
+                "local_as": local_as,
+                "address_family": {
+                    "ipv4": {
+                        "unicast": {
+                            "default_originate":{
+                                "r2":{
+
+                                }
+
+                            }
+
+                        }
+                    }, "ipv6": {
+                        "unicast": {
+                            "default_originate":{
+                                "r2":{
+
+                                }
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    result = create_router_bgp(tgen, topo, default_originate_config)
+    assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result)
+
+    step(
+        "R2 received default-originate routes and advertised it to R3 , verify on R2 and R3"
+    )
+    DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+    step(
+        "After configuring default-originate command , verify default  routes are advertised on R2 "
+    )
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input,next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type])
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input,next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type])
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+
+    step(" Kill BGPd session on R2")
+    kill_router_daemons(tgen, "r2", ["bgpd"])
+    start_router_daemons(tgen, "r2", ["bgpd"])
+
+    step("verify default  route is relearned after clear bgp  on R2 on BGP RIB and")
+    for addr_type in ADDR_TYPES:
+        static_routes_input = {
+            "r2": {
+                "static_routes": [
+                    {
+                        "network": [DEFAULT_ROUTES[addr_type]],
+                        "next_hop": DEFAULT_ROUTE_NXT_HOP_R1[addr_type],
+                    }
+                ]
+            }
+        }
+
+        result = verify_fib_routes(tgen, addr_type, "r2", static_routes_input,next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type])
+        assert result is True, "Testcase {} : Failed \n Error: {}".format(
+            tc_name, result
+        )
+
+        result = verify_bgp_rib(tgen, addr_type, "r2", static_routes_input,next_hop=DEFAULT_ROUTE_NXT_HOP_R1[addr_type])
+        assert result is 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))
diff --git a/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..d9192f1
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "neighbors": {
+    "2.2.2.2": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.1.2",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
diff --git a/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..ea78592
--- /dev/null
@@ -0,0 +1,42 @@
+{
+  "neighbors": {
+    "1.1.1.1": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.1.1",
+        "requestCounter": 0
+      }
+    ],
+    "3.3.3.3": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.3",
+        "requestCounter": 0
+      },
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.3.3",
+        "requestCounter": 0
+      }
+    ],
+    "4.4.4.4": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.4",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
diff --git a/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..d3c5024
--- /dev/null
@@ -0,0 +1,32 @@
+{
+  "neighbors": {
+    "2.2.2.2": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.2",
+        "requestCounter": 0
+      },
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.3.2",
+        "requestCounter": 0
+      }
+    ],
+    "4.4.4.4": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.4",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
diff --git a/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json
new file mode 100644 (file)
index 0000000..20751a2
--- /dev/null
@@ -0,0 +1,24 @@
+{
+  "neighbors": {
+    "2.2.2.2": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.2",
+        "requestCounter": 0
+      }
+    ],
+    "3.3.3.3": [
+      {
+        "dbSummaryCounter": 0,
+        "retransmitCounter": 0,
+        "priority": 1,
+        "converged": "Full",
+        "address": "10.0.2.3",
+        "requestCounter": 0
+      }
+    ]
+  }
+}
index 8d69787236eddeb9fcd5f2366123830451a8edf9..cb8adfb55db693b200c6e691d61a4ae4ca8d3663 100644 (file)
@@ -63,9 +63,15 @@ import os
 import re
 import sys
 import pytest
+import json
+from functools import partial
 from time import sleep
 from lib.topolog import logger
 
+# Save the Current Working Directory to find configuration files.
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 from lib import topotest
 from lib.topogen import Topogen, get_topogen
@@ -102,6 +108,29 @@ def build_topo(tgen):
     switch.add_link(tgen.gears["r3"])
 
 
+#####################################################
+##
+##   Helper functions
+##
+#####################################################
+
+
+def router_compare_json_output(rname, command, reference, count=60, wait=1):
+    "Compare router JSON output"
+
+    logger.info('Comparing router "%s" "%s" output', rname, command)
+
+    tgen = get_topogen()
+    filename = "{}/{}/{}".format(CWD, rname, reference)
+    expected = json.loads(open(filename).read())
+
+    # Run test function until we get an result.
+    test_func = partial(topotest.router_json_cmp, tgen.gears[rname], command, expected)
+    _, diff = topotest.run_and_expect(test_func, None, count, wait)
+    assertmsg = '"{}" JSON output mismatches the expected result'.format(rname)
+    assert diff is None, assertmsg
+
+
 #####################################################
 ##
 ##   Tests starting
@@ -218,6 +247,19 @@ def test_mpls_interfaces():
         assert fatal_error == "", fatal_error
 
 
+def test_ospf_convergence():
+    logger.info("Test: check OSPF adjacencies")
+
+    # Skip if previous fatal error condition is raised
+    if fatal_error != "":
+        pytest.skip(fatal_error)
+
+    for rname in ["r1", "r2", "r3", "r4"]:
+        router_compare_json_output(
+            rname, "show ip ospf neighbor json", "show_ip_ospf_neighbor.json"
+        )
+
+
 def test_mpls_ldp_neighbor_establish():
     global fatal_error
     net = get_topogen().net
@@ -510,9 +552,10 @@ def test_mpls_ldp_binding():
             else:
                 print("r%s ok" % i)
 
-            assert (
-                failures == 0
-            ), "MPLS LDP Interface binding output for router r%s:\n%s" % (i, diff)
+            assert failures == 0, "MPLS LDP binding output for router r%s:\n%s" % (
+                i,
+                diff,
+            )
 
     # Make sure that all daemons are running
     for i in range(1, 5):
index 594ec5a58feb2ef2a39dbcdcce87ffcac6b301de..a19e5ccacbca2d4fe1a258bca9b1cd0a1c8d5623 100644 (file)
@@ -14,6 +14,7 @@ mpls ldp
  !
  address-family ipv4
   discovery transport-address 1.1.1.1
+  ttl-security disable
   label local allocate host-routes
   !
   interface r1-eth1
index ffb4f0974a3c905ea30065ea4feae422665e6b40..447b3f140aca95f0f890ed111ea07fcb139f90dd 100644 (file)
@@ -14,6 +14,7 @@ mpls ldp
  !
  address-family ipv4
   discovery transport-address 2.2.2.2
+  ttl-security disable
   label local allocate host-routes
   !
   interface r2-eth1
index c95471ffd8098e857f5e389f9dd1878723137403..ab51471499700ba75cd6f63ae2beafbf7052d869 100644 (file)
@@ -14,6 +14,7 @@ mpls ldp
  !
  address-family ipv4
   discovery transport-address 3.3.3.3
+  ttl-security disable
   label local allocate host-routes
   !
   interface r3-eth1
index 4dd44e3e9e7003f77c3728b978b049a46fe6e7cc..216756f5121e8ff2974f2c8432cc47924c1999e9 100644 (file)
@@ -29,6 +29,7 @@ from lib.common_config import (
     create_common_configurations,
     FRRCFG_FILE,
     InvalidCLIError,
+    apply_raw_config,
     check_address_types,
     find_interface_with_greater_ip,
     generate_ips,
@@ -74,6 +75,12 @@ def create_router_bgp(tgen, topo=None, input_dict=None, build=False, load_config
                 "address_family": {
                     "ipv4": {
                         "unicast": {
+                            "default_originate":{
+                                "neighbor":"R2",
+                                "add_type":"lo"
+                                "route_map":"rm"
+
+                            },
                             "redistribute": [{
                                 "redist_type": "static",
                                     "attribute": {
@@ -498,6 +505,12 @@ def __create_bgp_unicast_neighbor(
                 topo, input_dict, router, addr_type, add_neigh
             )
             config_data.extend(neigh_data)
+        # configure default originate
+        if "default_originate" in addr_data:
+            default_originate_config = __create_bgp_default_originate_neighbor(
+                topo, input_dict, router, addr_type, add_neigh
+            )
+            config_data.extend(default_originate_config)
 
     for addr_type, addr_dict in bgp_data.items():
         if not addr_dict or not check_address_types(addr_type):
@@ -515,6 +528,78 @@ def __create_bgp_unicast_neighbor(
     return config_data
 
 
+def __create_bgp_default_originate_neighbor(
+    topo, input_dict, router, addr_type, add_neigh=True
+):
+    """
+    Helper API to create neighbor default - originate  configuration
+
+    Parameters
+    ----------
+    * `tgen` : Topogen object
+    * `topo` : json file data
+    * `input_dict` : Input dict data, required when configuring from testcase
+    * `router` : router id to be configured
+    """
+    tgen = get_topogen()
+    config_data = []
+    logger.debug("Entering lib API: __create_bgp_default_originate_neighbor()")
+
+    bgp_data = input_dict["address_family"]
+    neigh_data = bgp_data[addr_type]["unicast"]["default_originate"]
+    for name, peer_dict in neigh_data.items():
+        nh_details = topo[name]
+
+        neighbor_ip = None
+        if "dest-link" in neigh_data[name]:
+            dest_link = neigh_data[name]["dest-link"]
+            neighbor_ip = nh_details["links"][dest_link][addr_type].split("/")[0]
+        elif "add_type" in neigh_data[name]:
+            add_type = neigh_data[name]["add_type"]
+            neighbor_ip = nh_details["links"][add_type][addr_type].split("/")[0]
+        else:
+            neighbor_ip = nh_details["links"][router][addr_type].split("/")[0]
+
+        config_data.append("address-family {} unicast".format(addr_type))
+        if "route_map" in peer_dict:
+            route_map = peer_dict["route_map"]
+            if "delete" in peer_dict:
+                if peer_dict["delete"]:
+                    config_data.append(
+                        "no neighbor {} default-originate  route-map {}".format(
+                            neighbor_ip, route_map
+                        )
+                    )
+                else:
+                    config_data.append(
+                        " neighbor {} default-originate  route-map {}".format(
+                            neighbor_ip, route_map
+                        )
+                    )
+            else:
+                config_data.append(
+                    " neighbor {} default-originate  route-map {}".format(
+                        neighbor_ip, route_map
+                    )
+                )
+
+        else:
+            if "delete" in peer_dict:
+                if peer_dict["delete"]:
+                    config_data.append(
+                        "no neighbor {} default-originate".format(neighbor_ip)
+                    )
+                else:
+                    config_data.append(
+                        "neighbor {} default-originate".format(neighbor_ip)
+                    )
+            else:
+                config_data.append("neighbor {} default-originate".format(neighbor_ip))
+
+    logger.debug("Exiting lib API: __create_bgp_default_originate_neighbor()")
+    return config_data
+
+
 def __create_l2vpn_evpn_address_family(
     tgen, topo, input_dict, router, config_data=None
 ):
@@ -4574,3 +4659,876 @@ def verify_tcp_mss(tgen, dut, neighbour, configured_tcp_mss, vrf=None):
             return "TCP-MSS Mismatch"
     logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
     return False
+
+
+def get_dut_as_number(tgen, dut):
+    """
+    API to get the Autonomous Number of the given DUT
+
+    params:
+    =======
+    dut  : Device Under test
+
+    returns :
+    =======
+    Success : DUT Autonomous number
+    Fail : Error message with Boolean False
+    """
+    tgen = get_topogen()
+    for router, rnode in tgen.routers().items():
+        if router == dut:
+            show_bgp_json = run_frr_cmd(rnode, "sh ip bgp summary json ", isjson=True)
+            as_number = show_bgp_json["ipv4Unicast"]["as"]
+            if as_number:
+                logger.info(
+                    "[dut {}] DUT contains Automnomous number :: {} ".format(
+                        dut, as_number
+                    )
+                )
+                return as_number
+            else:
+                logger.error(
+                    "[dut {}] ERROR....!  DUT doesnot contain any  Automnomous number  ".format(
+                        dut
+                    )
+                )
+                return False
+
+
+def get_prefix_count_route(
+    tgen, topo, dut, peer, vrf=None, link=None, sent=None, received=None
+):
+    """
+    API to return  the prefix count  of default originate the given DUT
+    dut  : Device under test
+    peer : neigbor on which you are expecting the route to be received
+
+    returns :
+        prefix_count as dict with ipv4 and ipv6 value
+    """
+    # the neighbor IP address can be accessable by finding the neigborship (vice-versa)
+
+    if link:
+        neighbor_ipv4_address = topo["routers"][peer]["links"][link]["ipv4"]
+        neighbor_ipv6_address = topo["routers"][peer]["links"][link]["ipv6"]
+    else:
+        neighbor_ipv4_address = topo["routers"][peer]["links"][dut]["ipv4"]
+        neighbor_ipv6_address = topo["routers"][peer]["links"][dut]["ipv6"]
+
+    neighbor_ipv4_address = neighbor_ipv4_address.split("/")[0]
+    neighbor_ipv6_address = neighbor_ipv6_address.split("/")[0]
+    prefix_count = {}
+    tgen = get_topogen()
+    for router, rnode in tgen.routers().items():
+        if router == dut:
+
+            if vrf:
+                ipv4_cmd = "sh ip bgp vrf {} summary json".format(vrf)
+                show_bgp_json_ipv4 = run_frr_cmd(rnode, ipv4_cmd, isjson=True)
+                ipv6_cmd = "sh ip bgp vrf {} ipv6 unicast summary json".format(vrf)
+                show_bgp_json_ipv6 = run_frr_cmd(rnode, ipv6_cmd, isjson=True)
+
+                prefix_count["ipv4_count"] = show_bgp_json_ipv4["ipv4Unicast"]["peers"][
+                    neighbor_ipv4_address
+                ]["pfxRcd"]
+                prefix_count["ipv6_count"] = show_bgp_json_ipv6["peers"][
+                    neighbor_ipv6_address
+                ]["pfxRcd"]
+
+                logger.info(
+                    "The Prefix Count of the [DUT:{} : vrf [{}] ] towards neighbor ipv4 : {} and ipv6 : {}  is : {}".format(
+                        dut,
+                        vrf,
+                        neighbor_ipv4_address,
+                        neighbor_ipv6_address,
+                        prefix_count,
+                    )
+                )
+                return prefix_count
+
+            else:
+                show_bgp_json_ipv4 = run_frr_cmd(
+                    rnode, "sh ip bgp summary json ", isjson=True
+                )
+                show_bgp_json_ipv6 = run_frr_cmd(
+                    rnode, "sh ip bgp ipv6 unicast summary json ", isjson=True
+                )
+                if received:
+                    prefix_count["ipv4_count"] = show_bgp_json_ipv4["ipv4Unicast"][
+                        "peers"
+                    ][neighbor_ipv4_address]["pfxRcd"]
+                    prefix_count["ipv6_count"] = show_bgp_json_ipv6["peers"][
+                        neighbor_ipv6_address
+                    ]["pfxRcd"]
+
+                elif sent:
+                    prefix_count["ipv4_count"] = show_bgp_json_ipv4["ipv4Unicast"][
+                        "peers"
+                    ][neighbor_ipv4_address]["pfxSnt"]
+                    prefix_count["ipv6_count"] = show_bgp_json_ipv6["peers"][
+                        neighbor_ipv6_address
+                    ]["pfxSnt"]
+
+                else:
+                    prefix_count["ipv4_count"] = show_bgp_json_ipv4["ipv4Unicast"][
+                        "peers"
+                    ][neighbor_ipv4_address]["pfxRcd"]
+                    prefix_count["ipv6_count"] = show_bgp_json_ipv6["peers"][
+                        neighbor_ipv6_address
+                    ]["pfxRcd"]
+
+                logger.info(
+                    "The Prefix Count of the DUT:{} towards neighbor ipv4 : {} and ipv6 : {}  is : {}".format(
+                        dut, neighbor_ipv4_address, neighbor_ipv6_address, prefix_count
+                    )
+                )
+                return prefix_count
+        else:
+            logger.error("ERROR...! Unknown dut {} in topolgy".format(dut))
+
+
+@retry(retry_timeout=5)
+def verify_rib_default_route(
+    tgen,
+    topo,
+    dut,
+    routes,
+    expected_nexthop,
+    metric=None,
+    origin=None,
+    locPrf=None,
+    expected_aspath=None,
+):
+    """
+    API to verify the the 'Default route" in BGP RIB with the attributes the rout carries (metric , local preference, )
+
+    param
+    =====
+    dut : device under test
+    routes : default route with expected nexthop
+    expected_nexthop : the nexthop that is expected the deafult route
+
+    """
+    result = False
+    logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
+    tgen = get_topogen()
+    connected_routes = {}
+    for router, rnode in tgen.routers().items():
+        if router == dut:
+
+            ipv4_routes = run_frr_cmd(rnode, "sh ip bgp json", isjson=True)
+            ipv6_routes = run_frr_cmd(rnode, "sh ip bgp ipv6 unicast json", isjson=True)
+    is_ipv4_default_attrib_found = False
+    is_ipv6_default_attrib_found = False
+
+    default_ipv4_route = routes["ipv4"]
+    default_ipv6_route = "::/0"
+    ipv4_route_Origin = False
+    ipv4_route_local_pref = False
+    ipv4_route_metric = False
+
+    if default_ipv4_route in ipv4_routes["routes"].keys():
+        nxt_hop_count = len(ipv4_routes["routes"][default_ipv4_route])
+        rib_next_hops = []
+        for index in range(nxt_hop_count):
+            rib_next_hops.append(
+                ipv4_routes["routes"][default_ipv4_route][index]["nexthops"][0]["ip"]
+            )
+
+        for nxt_hop in expected_nexthop.items():
+            if nxt_hop[0] == "ipv4":
+                if nxt_hop[1] in rib_next_hops:
+                    logger.info(
+                        "Default routes [{}] obtained from {} .....PASSED".format(
+                            default_ipv4_route, nxt_hop[1]
+                        )
+                    )
+                else:
+                    logger.error(
+                        "ERROR ...! Default routes [{}] expected  is missing  {}".format(
+                            default_ipv4_route, nxt_hop[1]
+                        )
+                    )
+                    return False
+
+            else:
+                pass
+
+        if "origin" in ipv4_routes["routes"][default_ipv4_route][0].keys():
+            ipv4_route_Origin = ipv4_routes["routes"][default_ipv4_route][0]["origin"]
+        if "locPrf" in ipv4_routes["routes"][default_ipv4_route][0].keys():
+            ipv4_route_local_pref = ipv4_routes["routes"][default_ipv4_route][0][
+                "locPrf"
+            ]
+        if "metric" in ipv4_routes["routes"][default_ipv4_route][0].keys():
+            ipv4_route_metric = ipv4_routes["routes"][default_ipv4_route][0]["metric"]
+    else:
+        logger.error("ERROR [ DUT {}] : The Default Route Not found in RIB".format(dut))
+        return False
+
+    origin_found = False
+    locPrf_found = False
+    metric_found = False
+    as_path_found = False
+
+    if origin:
+        if origin == ipv4_route_Origin:
+            logger.info(
+                "Dafault Route {} expected origin {} Found in RIB....PASSED".format(
+                    default_ipv4_route, origin
+                )
+            )
+            origin_found = True
+        else:
+            logger.error(
+                "ERROR... IPV4::! Expected Origin is {} obtained {}".format(
+                    origin, ipv4_route_Origin
+                )
+            )
+            return False
+    else:
+        origin_found = True
+
+    if locPrf:
+        if locPrf == ipv4_route_local_pref:
+            logger.info(
+                "Dafault Route {} expected local preference {} Found in RIB....PASSED".format(
+                    default_ipv4_route, locPrf
+                )
+            )
+            locPrf_found = True
+        else:
+            logger.error(
+                "ERROR... IPV4::! Expected Local preference is {} obtained {}".format(
+                    locPrf, ipv4_route_local_pref
+                )
+            )
+            return False
+    else:
+        locPrf_found = True
+
+    if metric:
+        if metric == ipv4_route_metric:
+            logger.info(
+                "Dafault Route {} expected metric {} Found in RIB....PASSED".format(
+                    default_ipv4_route, metric
+                )
+            )
+
+            metric_found = True
+        else:
+            logger.error(
+                "ERROR... IPV4::! Expected metric is {} obtained {}".format(
+                    metric, ipv4_route_metric
+                )
+            )
+            return False
+    else:
+        metric_found = True
+
+    if expected_aspath:
+        obtained_aspath = ipv4_routes["routes"]["0.0.0.0/0"][0]["path"]
+        if expected_aspath in obtained_aspath:
+            as_path_found = True
+            logger.info(
+                "Dafault Route {} expected  AS path {} Found in RIB....PASSED".format(
+                    default_ipv4_route, expected_aspath
+                )
+            )
+        else:
+            logger.error(
+                "ERROR.....! Expected AS path {} obtained {}..... FAILED ".format(
+                    expected_aspath, obtained_aspath
+                )
+            )
+            return False
+    else:
+        as_path_found = True
+
+    if origin_found and locPrf_found and metric_found and as_path_found:
+        is_ipv4_default_attrib_found = True
+        logger.info(
+            "IPV4:: Expected origin ['{}'] , Local Preference ['{}'] , Metric ['{}'] and AS path [{}] is found in  RIB".format(
+                origin, locPrf, metric, expected_aspath
+            )
+        )
+    else:
+        is_ipv4_default_attrib_found = False
+        logger.error(
+            "IPV4:: Expected origin ['{}'] Obtained [{}]".format(
+                origin, ipv4_route_Origin
+            )
+        )
+        logger.error(
+            "IPV4:: Expected locPrf ['{}'] Obtained [{}]".format(
+                locPrf, ipv4_route_local_pref
+            )
+        )
+        logger.error(
+            "IPV4:: Expected metric ['{}'] Obtained [{}]".format(
+                metric, ipv4_route_metric
+            )
+        )
+        logger.error(
+            "IPV4:: Expected metric ['{}'] Obtained [{}]".format(
+                expected_aspath, obtained_aspath
+            )
+        )
+
+    route_Origin = False
+    route_local_pref = False
+    route_local_metric = False
+    default_ipv6_route = ""
+    try:
+        ipv6_routes["routes"]["0::0/0"]
+        default_ipv6_route = "0::0/0"
+    except:
+        ipv6_routes["routes"]["::/0"]
+        default_ipv6_route = "::/0"
+    if default_ipv6_route in ipv6_routes["routes"].keys():
+        nxt_hop_count = len(ipv6_routes["routes"][default_ipv6_route])
+        rib_next_hops = []
+        for index in range(nxt_hop_count):
+            rib_next_hops.append(
+                ipv6_routes["routes"][default_ipv6_route][index]["nexthops"][0]["ip"]
+            )
+            try:
+                rib_next_hops.append(
+                    ipv6_routes["routes"][default_ipv6_route][index]["nexthops"][1][
+                        "ip"
+                    ]
+                )
+            except (KeyError, IndexError) as e:
+                logger.error("NO impact ..! Global IPV6 Address not found ")
+
+        for nxt_hop in expected_nexthop.items():
+            if nxt_hop[0] == "ipv6":
+                if nxt_hop[1] in rib_next_hops:
+                    logger.info(
+                        "Default routes [{}] obtained from {} .....PASSED".format(
+                            default_ipv6_route, nxt_hop[1]
+                        )
+                    )
+                else:
+                    logger.error(
+                        "ERROR ...! Default routes [{}] expected from {} obtained {}".format(
+                            default_ipv6_route, nxt_hop[1], rib_next_hops
+                        )
+                    )
+                    return False
+
+            else:
+                pass
+        if "origin" in ipv6_routes["routes"][default_ipv6_route][0].keys():
+            route_Origin = ipv6_routes["routes"][default_ipv6_route][0]["origin"]
+        if "locPrf" in ipv6_routes["routes"][default_ipv6_route][0].keys():
+            route_local_pref = ipv6_routes["routes"][default_ipv6_route][0]["locPrf"]
+        if "metric" in ipv6_routes["routes"][default_ipv6_route][0].keys():
+            route_local_metric = ipv6_routes["routes"][default_ipv6_route][0]["metric"]
+
+    origin_found = False
+    locPrf_found = False
+    metric_found = False
+    as_path_found = False
+
+    if origin:
+        if origin == route_Origin:
+            logger.info(
+                "Dafault Route {} expected origin {} Found in RIB....PASSED".format(
+                    default_ipv6_route, route_Origin
+                )
+            )
+            origin_found = True
+        else:
+            logger.error(
+                "ERROR... IPV6::! Expected Origin is {} obtained {}".format(
+                    origin, route_Origin
+                )
+            )
+            return False
+    else:
+        origin_found = True
+
+    if locPrf:
+        if locPrf == route_local_pref:
+            logger.info(
+                "Dafault Route {} expected Local Preference {} Found in RIB....PASSED".format(
+                    default_ipv6_route, route_local_pref
+                )
+            )
+            locPrf_found = True
+        else:
+            logger.error(
+                "ERROR... IPV6::! Expected Local Preference is {} obtained {}".format(
+                    locPrf, route_local_pref
+                )
+            )
+            return False
+    else:
+        locPrf_found = True
+
+    if metric:
+        if metric == route_local_metric:
+            logger.info(
+                "Dafault Route {} expected metric {} Found in RIB....PASSED".format(
+                    default_ipv4_route, metric
+                )
+            )
+
+            metric_found = True
+        else:
+            logger.error(
+                "ERROR... IPV6::! Expected metric is {} obtained {}".format(
+                    metric, route_local_metric
+                )
+            )
+            return False
+    else:
+        metric_found = True
+
+    if expected_aspath:
+        obtained_aspath = ipv6_routes["routes"]["::/0"][0]["path"]
+        if expected_aspath in obtained_aspath:
+            as_path_found = True
+            logger.info(
+                "Dafault Route {} expected  AS path {} Found in RIB....PASSED".format(
+                    default_ipv4_route, expected_aspath
+                )
+            )
+        else:
+            logger.error(
+                "ERROR.....! Expected AS path {} obtained {}..... FAILED ".format(
+                    expected_aspath, obtained_aspath
+                )
+            )
+            return False
+    else:
+        as_path_found = True
+
+    if origin_found and locPrf_found and metric_found and as_path_found:
+        is_ipv6_default_attrib_found = True
+        logger.info(
+            "IPV6:: Expected origin ['{}'] , Local Preference ['{}'] , Metric ['{}'] and AS path [{}] is found in  RIB".format(
+                origin, locPrf, metric, expected_aspath
+            )
+        )
+    else:
+        is_ipv6_default_attrib_found = False
+        logger.error(
+            "IPV6:: Expected origin ['{}'] Obtained [{}]".format(origin, route_Origin)
+        )
+        logger.error(
+            "IPV6:: Expected locPrf ['{}'] Obtained [{}]".format(
+                locPrf, route_local_pref
+            )
+        )
+        logger.error(
+            "IPV6:: Expected metric ['{}'] Obtained [{}]".format(
+                metric, route_local_metric
+            )
+        )
+        logger.error(
+            "IPV6:: Expected metric ['{}'] Obtained [{}]".format(
+                expected_aspath, obtained_aspath
+            )
+        )
+
+    if is_ipv4_default_attrib_found and is_ipv6_default_attrib_found:
+        logger.info("The attributes are found for default route in RIB ")
+        return True
+    else:
+        return False
+
+
+@retry(retry_timeout=5)
+def verify_fib_default_route(tgen, topo, dut, routes, expected_nexthop):
+    """
+    API to verify the the 'Default route" in FIB
+
+    param
+    =====
+    dut : device under test
+    routes : default route with expected nexthop
+    expected_nexthop : the nexthop that is expected the deafult route
+
+    """
+    result = False
+    logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
+    tgen = get_topogen()
+    connected_routes = {}
+    for router, rnode in tgen.routers().items():
+        if router == dut:
+            ipv4_routes = run_frr_cmd(rnode, "sh ip route json", isjson=True)
+            ipv6_routes = run_frr_cmd(rnode, "sh ipv6 route json", isjson=True)
+
+    is_ipv4_default_route_found = False
+    is_ipv6_default_route_found = False
+    if routes["ipv4"] in ipv4_routes.keys():
+        rib_ipv4_nxt_hops = []
+        ipv4_default_route = routes["ipv4"]
+        nxt_hop_count = len(ipv4_routes[ipv4_default_route][0]["nexthops"])
+        for index in range(nxt_hop_count):
+            rib_ipv4_nxt_hops.append(
+                ipv4_routes[ipv4_default_route][0]["nexthops"][index]["ip"]
+            )
+
+        if expected_nexthop["ipv4"] in rib_ipv4_nxt_hops:
+            is_ipv4_default_route_found = True
+            logger.info(
+                "{} default route with next hop {} is found in FIB ".format(
+                    ipv4_default_route, expected_nexthop
+                )
+            )
+        else:
+            logger.error(
+                "ERROR .. ! {} default route with next hop {} is not found in FIB ".format(
+                    ipv4_default_route, expected_nexthop
+                )
+            )
+            return False
+
+    if routes["ipv6"] in ipv6_routes.keys() or "::/0" in ipv6_routes.keys():
+        rib_ipv6_nxt_hops = []
+        if "::/0" in ipv6_routes.keys():
+            ipv6_default_route = "::/0"
+        elif routes["ipv6"] in ipv6_routes.keys():
+            ipv6_default_route = routes["ipv6"]
+
+        nxt_hop_count = len(ipv6_routes[ipv6_default_route][0]["nexthops"])
+        for index in range(nxt_hop_count):
+            rib_ipv6_nxt_hops.append(
+                ipv6_routes[ipv6_default_route][0]["nexthops"][index]["ip"]
+            )
+
+        if expected_nexthop["ipv6"] in rib_ipv6_nxt_hops:
+            is_ipv6_default_route_found = True
+            logger.info(
+                "{} default route with next hop {} is found in FIB ".format(
+                    ipv6_default_route, expected_nexthop
+                )
+            )
+        else:
+            logger.error(
+                "ERROR .. ! {} default route with next hop {} is not found in FIB ".format(
+                    ipv6_default_route, expected_nexthop
+                )
+            )
+            return False
+
+    if is_ipv4_default_route_found and is_ipv6_default_route_found:
+        return True
+    else:
+        logger.error(
+            "Default Route for ipv4 and ipv6 address family is not found in FIB "
+        )
+        return False
+
+
+@retry(retry_timeout=5)
+def verify_bgp_advertised_routes_from_neighbor(tgen, topo, dut, peer, expected_routes):
+    """
+    APi is verifies the the routes that are advertised from dut to peer
+
+    command used :
+    "sh ip bgp neighbor <x.x.x.x> advertised-routes" and
+    "sh ip bgp ipv6 unicast neighbor<x::x> advertised-routes"
+
+    dut : Device Under Tests
+    Peer : Peer on which  the routs is expected
+    expected_routes : dual stack IPV4-and IPv6 routes  to be verified
+                    expected_routes
+
+    returns: True / False
+
+    """
+    result = False
+    logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
+    tgen = get_topogen()
+
+    peer_ipv4_neighbor_ip = topo["routers"][peer]["links"][dut]["ipv4"].split("/")[0]
+    peer_ipv6_neighbor_ip = topo["routers"][peer]["links"][dut]["ipv6"].split("/")[0]
+
+    for router, rnode in tgen.routers().items():
+        if router == dut:
+            ipv4_receieved_routes = run_frr_cmd(
+                rnode,
+                "sh ip bgp neighbor {} advertised-routes  json".format(
+                    peer_ipv4_neighbor_ip
+                ),
+                isjson=True,
+            )
+            ipv6_receieved_routes = run_frr_cmd(
+                rnode,
+                "sh ip bgp ipv6 unicast neighbor {} advertised-routes  json".format(
+                    peer_ipv6_neighbor_ip
+                ),
+                isjson=True,
+            )
+    ipv4_route_count = 0
+    ipv6_route_count = 0
+    if ipv4_receieved_routes:
+        for index in range(len(expected_routes["ipv4"])):
+            if (
+                expected_routes["ipv4"][index]["network"]
+                in ipv4_receieved_routes["advertisedRoutes"].keys()
+            ):
+                ipv4_route_count += 1
+                logger.info(
+                    "Success  [DUT : {}] The Expected Route {} is  advertised to {} ".format(
+                        dut, expected_routes["ipv4"][index]["network"], peer
+                    )
+                )
+
+            elif (
+                expected_routes["ipv4"][index]["network"]
+                in ipv4_receieved_routes["bgpOriginatingDefaultNetwork"]
+            ):
+                ipv4_route_count += 1
+                logger.info(
+                    "Success  [DUT : {}] The Expected Route {} is  advertised to {} ".format(
+                        dut, expected_routes["ipv4"][index]["network"], peer
+                    )
+                )
+
+            else:
+                logger.error(
+                    "ERROR....![DUT : {}] The Expected Route {} is not advertised to {} ".format(
+                        dut, expected_routes["ipv4"][index]["network"], peer
+                    )
+                )
+    else:
+        logger.error(ipv4_receieved_routes)
+        logger.error(
+            "ERROR...! [DUT : {}] No IPV4 Routes are advertised to  the peer {}".format(
+                dut, peer
+            )
+        )
+        return False
+
+    if ipv6_receieved_routes:
+        for index in range(len(expected_routes["ipv6"])):
+            if (
+                expected_routes["ipv6"][index]["network"]
+                in ipv6_receieved_routes["advertisedRoutes"].keys()
+            ):
+                ipv6_route_count += 1
+                logger.info(
+                    "Success  [DUT : {}] The Expected Route {} is  advertised to {} ".format(
+                        dut, expected_routes["ipv6"][index]["network"], peer
+                    )
+                )
+            elif (
+                expected_routes["ipv6"][index]["network"]
+                in ipv6_receieved_routes["bgpOriginatingDefaultNetwork"]
+            ):
+                ipv6_route_count += 1
+                logger.info(
+                    "Success  [DUT : {}] The Expected Route {} is  advertised to {} ".format(
+                        dut, expected_routes["ipv6"][index]["network"], peer
+                    )
+                )
+            else:
+                logger.error(
+                    "ERROR....![DUT : {}] The Expected Route {} is not advertised to {} ".format(
+                        dut, expected_routes["ipv6"][index]["network"], peer
+                    )
+                )
+    else:
+        logger.error(ipv6_receieved_routes)
+        logger.error(
+            "ERROR...! [DUT : {}] No IPV6 Routes are  advertised to the peer {}".format(
+                dut, peer
+            )
+        )
+        return False
+
+    if ipv4_route_count == len(expected_routes["ipv4"]) and ipv6_route_count == len(
+        expected_routes["ipv6"]
+    ):
+        return True
+    else:
+        logger.error(
+            "ERROR ....! IPV4 : Expected Routes -> {}  obtained ->{} ".format(
+                expected_routes["ipv4"], ipv4_receieved_routes["advertisedRoutes"]
+            )
+        )
+        logger.error(
+            "ERROR ....! IPV6 : Expected Routes -> {}  obtained ->{} ".format(
+                expected_routes["ipv6"], ipv6_receieved_routes["advertisedRoutes"]
+            )
+        )
+        return False
+
+
+@retry(retry_timeout=5)
+def verify_bgp_received_routes_from_neighbor(tgen, topo, dut, peer, expected_routes):
+    """
+    API to verify the bgp received routes
+
+    commad used :
+    =============
+    show ip bgp neighbor <x.x.x.x> received-routes
+    show ip bgp ipv6 unicast neighbor <x::x> received-routes
+
+    params
+    =======
+    dut : Device Under Tests
+    Peer : Peer on which  the routs is expected
+    expected_routes : dual stack IPV4-and IPv6 routes  to be verified
+                    expected_routes
+
+    returns:
+    ========
+    True / False
+    """
+    result = False
+    logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
+    tgen = get_topogen()
+
+    peer_ipv4_neighbor_ip = topo["routers"][peer]["links"][dut]["ipv4"].split("/")[0]
+    peer_ipv6_neighbor_ip = topo["routers"][peer]["links"][dut]["ipv6"].split("/")[0]
+
+    logger.info("Enabling Soft configuration to neighbor INBOUND ")
+    neigbor_dict = {"ipv4": peer_ipv4_neighbor_ip, "ipv6": peer_ipv6_neighbor_ip}
+    result = configure_bgp_soft_configuration(
+        tgen, dut, neigbor_dict, direction="inbound"
+    )
+    assert (
+        result is True
+    ), "  Failed to configure the soft configuration \n Error: {}".format(result)
+
+    """sleep of 10 sec is required to get the routes on peer after soft configuration"""
+    sleep(10)
+    for router, rnode in tgen.routers().items():
+        if router == dut:
+            ipv4_receieved_routes = run_frr_cmd(
+                rnode,
+                "sh ip bgp neighbor {} received-routes json".format(
+                    peer_ipv4_neighbor_ip
+                ),
+                isjson=True,
+            )
+            ipv6_receieved_routes = run_frr_cmd(
+                rnode,
+                "sh ip bgp ipv6 unicast neighbor {} received-routes json".format(
+                    peer_ipv6_neighbor_ip
+                ),
+                isjson=True,
+            )
+    ipv4_route_count = 0
+    ipv6_route_count = 0
+    if ipv4_receieved_routes:
+        for index in range(len(expected_routes["ipv4"])):
+            if (
+                expected_routes["ipv4"][index]["network"]
+                in ipv4_receieved_routes["receivedRoutes"].keys()
+            ):
+                ipv4_route_count += 1
+                logger.info(
+                    "Success  [DUT : {}] The Expected Route {} is  received from {} ".format(
+                        dut, expected_routes["ipv4"][index]["network"], peer
+                    )
+                )
+            else:
+                logger.error(
+                    "ERROR....![DUT : {}] The Expected Route {} is not received from {} ".format(
+                        dut, expected_routes["ipv4"][index]["network"], peer
+                    )
+                )
+    else:
+        logger.error(ipv4_receieved_routes)
+        logger.error(
+            "ERROR...! [DUT : {}] No IPV4 Routes are received from the peer {}".format(
+                dut, peer
+            )
+        )
+        return False
+
+    if ipv6_receieved_routes:
+        for index in range(len(expected_routes["ipv6"])):
+            if (
+                expected_routes["ipv6"][index]["network"]
+                in ipv6_receieved_routes["receivedRoutes"].keys()
+            ):
+                ipv6_route_count += 1
+                logger.info(
+                    "Success  [DUT : {}] The Expected Route {} is  received from {} ".format(
+                        dut, expected_routes["ipv6"][index]["network"], peer
+                    )
+                )
+            else:
+                logger.error(
+                    "ERROR....![DUT : {}] The Expected Route {} is not received from {} ".format(
+                        dut, expected_routes["ipv6"][index]["network"], peer
+                    )
+                )
+    else:
+        logger.error(ipv6_receieved_routes)
+        logger.error(
+            "ERROR...! [DUT : {}] No IPV6 Routes are received from the peer {}".format(
+                dut, peer
+            )
+        )
+        return False
+
+    if ipv4_route_count == len(expected_routes["ipv4"]) and ipv6_route_count == len(
+        expected_routes["ipv6"]
+    ):
+        return True
+    else:
+        logger.error(
+            "ERROR ....! IPV4 : Expected Routes -> {}  obtained ->{} ".format(
+                expected_routes["ipv4"], ipv4_receieved_routes["advertisedRoutes"]
+            )
+        )
+        logger.error(
+            "ERROR ....! IPV6 : Expected Routes -> {}  obtained ->{} ".format(
+                expected_routes["ipv6"], ipv6_receieved_routes["advertisedRoutes"]
+            )
+        )
+        return False
+
+
+def configure_bgp_soft_configuration(tgen, dut, neighbor_dict, direction):
+    """
+    Api to configure the bgp soft configuration to show  the received routes from peer
+    params
+    ======
+    dut : device under test route on which the sonfiguration to be applied
+    neighbor_dict : dict element contains ipv4 and ipv6 neigbor ip
+    direction : Directionon which it should be applied in/out
+
+    returns:
+    ========
+    boolean
+    """
+    logger.info("Enabling Soft configuration to neighbor INBOUND ")
+    local_as = get_dut_as_number(tgen, dut)
+    ipv4_neighbor = neighbor_dict["ipv4"]
+    ipv6_neighbor = neighbor_dict["ipv6"]
+    direction = direction.lower()
+    if ipv4_neighbor and ipv4_neighbor:
+        raw_config = {
+            dut: {
+                "raw_config": [
+                    "router bgp {}".format(local_as),
+                    "address-family ipv4 unicast",
+                    "neighbor {} soft-reconfiguration {} ".format(
+                        ipv4_neighbor, direction
+                    ),
+                    "exit-address-family",
+                    "address-family ipv6 unicast",
+                    "neighbor {}  soft-reconfiguration {} ".format(
+                        ipv6_neighbor, direction
+                    ),
+                    "exit-address-family",
+                ]
+            }
+        }
+        result = apply_raw_config(tgen, raw_config)
+        logger.info(
+            "Success... [DUT : {}] The soft configuration onis applied on neighbors {} ".format(
+                dut, neighbor_dict
+            )
+        )
+        return True
index a7d8b2c9b577b6c9fcbefbfa12ebb08c6ed359bc..0e9e0ba40386db465deb8c7ecc005b77df4e76a2 100644 (file)
@@ -3365,8 +3365,9 @@ def verify_rib(
                     nh_found = False
 
                     for st_rt in ip_list:
-                        st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
-
+                        st_rt = str(
+                            ipaddress.ip_network(frr_unicode(st_rt), strict=False)
+                        )
                         _addr_type = validate_ip_address(st_rt)
                         if _addr_type != addr_type:
                             continue
@@ -3384,6 +3385,9 @@ def verify_rib(
                                     next_hop = [next_hop]
 
                                 for mnh in range(0, len(rib_routes_json[st_rt])):
+                                    if not "selected" in rib_routes_json[st_rt][mnh]:
+                                        continue
+
                                     if (
                                         "fib"
                                         in rib_routes_json[st_rt][mnh]["nexthops"][0]
@@ -3528,8 +3532,8 @@ def verify_rib(
 
                 if nh_found:
                     logger.info(
-                        "[DUT: {}]: Found next_hop {} for all bgp"
-                        " routes in RIB".format(router, next_hop)
+                        "[DUT: {}]: Found next_hop {} for"
+                        " RIB routes: {}".format(router, next_hop, found_routes)
                     )
 
                 if len(missing_routes) > 0:
@@ -3593,7 +3597,7 @@ def verify_rib(
                 nh_found = False
 
                 for st_rt in ip_list:
-                    st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
+                    st_rt = str(ipaddress.ip_network(frr_unicode(st_rt), strict=False))
 
                     _addr_type = validate_ip_address(st_rt)
                     if _addr_type != addr_type:
@@ -3750,8 +3754,9 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
                     nh_found = False
 
                     for st_rt in ip_list:
-                        st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
-
+                        st_rt = str(
+                            ipaddress.ip_network(frr_unicode(st_rt), strict=False)
+                        )
                         _addr_type = validate_ip_address(st_rt)
                         if _addr_type != addr_type:
                             continue
@@ -3855,7 +3860,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
                 nh_found = False
 
                 for st_rt in ip_list:
-                    st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
+                    st_rt = str(ipaddress.ip_network(frr_unicode(st_rt), strict=False))
 
                     _addr_type = validate_ip_address(st_rt)
                     if _addr_type != addr_type:
index 254ce4f4ea6074b9f5c6b6f4fca7cd46bfddc2c3..cd070e08b9a6def3084bbe51ed3230aff59617d5 100644 (file)
@@ -525,6 +525,9 @@ def verify_pim_neighbors(tgen, topo, dut=None, iface=None, nbr_ip=None, expected
             if "pim" not in data:
                 continue
 
+            if "pim" in data and data["pim"] == "disable":
+                continue
+
             if "pim" in data and data["pim"] == "enable":
                 local_interface = data["interface"]
 
index ceac78d88b01db6e74afefa1bca75212c1d376fe..4610c5f15ae235bfeebdfa0327a52c7ec588d766 100644 (file)
@@ -84,6 +84,7 @@ from lib.common_config import (
     run_frr_cmd,
     required_linux_kernel_version,
     topo_daemons,
+    verify_rib,
 )
 
 from lib.pim import (
@@ -106,6 +107,7 @@ from lib.pim import (
     clear_pim_interface_traffic,
     get_pim_interface_traffic,
     McastTesterHelper,
+    verify_pim_neighbors,
 )
 from lib.topolog import logger
 from lib.topojson import build_config_from_json
@@ -180,6 +182,10 @@ def setup_module(mod):
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
 
+    # Verify PIM neighbors
+    result = verify_pim_neighbors(tgen, topo)
+    assert result is True, " Verify PIM neighbor: Failed Error: {}".format(result)
+
     # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
     global app_helper
     app_helper = McastTesterHelper(tgen)
@@ -306,6 +312,14 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr,
         result = create_static_routes(tgen, input_dict)
         assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+        # Verifying static routes are installed
+        for dut, _nexthop in zip([fhr, rp, lhr], [next_hop, next_hop_rp, next_hop_lhr]):
+            input_routes = {dut: input_dict[dut]}
+            result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop)
+            assert result is True, "Testcase {} : Failed \n Error {}".format(
+                tc_name, result
+            )
+
     # RP Mapping
     rp_mapping = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["rp_mapping"]
 
@@ -328,11 +342,24 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr,
         result = create_static_routes(tgen, input_dict)
         assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+        # Verifying static routes are installed
+        result = verify_rib(tgen, "ipv4", fhr, input_dict, next_hop_fhr)
+        assert result is True, "Testcase {} : Failed \n Error {}".format(
+            tc_name, result
+        )
+
         input_dict = {
             lhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_lhr}]},
         }
         result = create_static_routes(tgen, input_dict)
         assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
+
+        # Verifying static routes are installed
+        result = verify_rib(tgen, "ipv4", lhr, input_dict, next_hop_lhr)
+        assert result is True, "Testcase {} : Failed \n Error {}".format(
+            tc_name, result
+        )
+
     return True
 
 
@@ -443,6 +470,23 @@ def test_BSR_higher_prefer_ip_p0(request):
     result = create_static_routes(tgen, input_dict)
     assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+    # Verifying static routes are installed
+    for dut, _nexthop in zip(["i1", "l1"], [next_hop_rp, next_hop_lhr]):
+        input_routes = {dut: input_dict[dut]}
+        result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop)
+        assert result is True, "Testcase {} : Failed \n Error {}".format(
+            tc_name, result
+        )
+
+    for bsr_add, next_hop in zip([BSR1_ADDR, BSR2_ADDR], [NEXT_HOP1, NEXT_HOP2]):
+        input_routes = {
+            "f1": {"static_routes": [{"network": bsr_add, "next_hop": next_hop}]}
+        }
+        result = verify_rib(tgen, "ipv4", "f1", input_routes, next_hop)
+        assert result is True, "Testcase {} : Failed \n Error {}".format(
+            tc_name, result
+        )
+
     # Use scapy to send pre-defined packet from senser to receiver
     step("Send BSR packet from b1 to FHR")
     result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9")
@@ -626,6 +670,24 @@ def test_BSR_CRP_with_blackhole_address_p1(request):
     result = create_static_routes(tgen, input_dict)
     assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+    # Verifying static routes are installed
+    for dut, _nexthop in zip(["i1", "l1"], [next_hop_rp, next_hop_lhr]):
+        input_routes = {dut: input_dict[dut]}
+        result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop)
+        assert result is True, "Testcase {} : Failed \n Error {}".format(
+            tc_name, result
+        )
+
+    input_routes = {
+        "f1": {"static_routes": [{"network": CRP, "next_hop": next_hop_fhr}]}
+    }
+    result = verify_rib(tgen, "ipv4", "f1", input_routes, expected=False)
+    assert (
+        result is not True
+    ), "Testcase {} : Failed \n " "Route is still present \n Error {}".format(
+        tc_name, result
+    )
+
     # Use scapy to send pre-defined packet from senser to receiver
 
     group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
@@ -642,6 +704,10 @@ def test_BSR_CRP_with_blackhole_address_p1(request):
     result = create_static_routes(tgen, input_dict)
     assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+    # Verifying static routes are installed
+    result = verify_rib(tgen, "ipv4", "f1", input_dict)
+    assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)
+
     intf_f1_i1 = topo["routers"]["f1"]["links"]["i1"]["interface"]
     step("Verify bsm transit count is not increamented" "show ip pim interface traffic")
     state_dict = {"f1": {intf_f1_i1: ["bsmTx"]}}
@@ -694,6 +760,28 @@ def test_BSR_CRP_with_blackhole_address_p1(request):
     result = create_static_routes(tgen, input_dict)
     assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+    # Verifying static routes are installed
+    input_dict = {
+        "f1": {"static_routes": [{"network": BSR1_ADDR, "next_hop": NEXT_HOP1}]}
+    }
+    result = verify_rib(tgen, "ipv4", "f1", input_dict, NEXT_HOP1)
+    assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result)
+
+    input_dict = {
+        "f1": {
+            "static_routes": [
+                {"network": [BSR1_ADDR, CRP], "next_hop": "blackhole", "delete": True}
+            ]
+        }
+    }
+    result = verify_rib(tgen, "ipv4", "f1", input_dict, expected=False)
+    assert result is not True, (
+        "Testcase {} : Failed \n "
+        "Routes:[{}, {}] are still present \n Error {}".format(
+            tc_name, BSR1_ADDR, CRP, result
+        )
+    )
+
     step("Sending BSR after removing black-hole address for BSR and candidate RP")
     step("Send BSR packet from b1 to FHR")
     result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9")
@@ -1614,6 +1702,14 @@ def test_iif_join_state_p0(request):
     result = create_static_routes(tgen, input_dict)
     assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+    # Verifying static routes are installed
+    result = verify_rib(tgen, "ipv4", "l1", input_dict, expected=False)
+    assert (
+        result is not True
+    ), "Testcase {} : Failed \n " "Routes:{} are still present \n Error {}".format(
+        tc_name, rp_ip, result
+    )
+
     # Check RP unreachable
     step("Check RP unreachability")
     iif = "Unknown"
@@ -1654,6 +1750,10 @@ def test_iif_join_state_p0(request):
     result = create_static_routes(tgen, input_dict)
     assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+    # Verifying static routes are installed
+    result = verify_rib(tgen, "ipv4", "l1", input_dict, next_hop_lhr)
+    assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result)
+
     # Verify that (*,G) installed in mroute again
     iif = "l1-i1-eth0"
     result = verify_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil)
index 2d6062bf3cef998976883260e0282aac502f1b43..191615cbbe044a48a6e9ee785227a4a2ec28f2ec 100644 (file)
@@ -68,6 +68,7 @@ from lib.common_config import (
     run_frr_cmd,
     required_linux_kernel_version,
     topo_daemons,
+    verify_rib,
 )
 
 from lib.pim import (
@@ -86,6 +87,7 @@ from lib.pim import (
     clear_mroute,
     clear_pim_interface_traffic,
     McastTesterHelper,
+    verify_pim_neighbors,
 )
 from lib.topolog import logger
 from lib.topojson import build_config_from_json
@@ -160,6 +162,10 @@ def setup_module(mod):
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
 
+    # Verify PIM neighbors
+    result = verify_pim_neighbors(tgen, topo)
+    assert result is True, " Verify PIM neighbor: Failed Error: {}".format(result)
+
     # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
     global app_helper
     app_helper = McastTesterHelper(tgen)
@@ -247,6 +253,14 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr,
         result = create_static_routes(tgen, input_dict)
         assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+        # Verifying static routes are installed
+        for dut, _nexthop in zip([fhr, rp, lhr], [next_hop, next_hop_rp, next_hop_lhr]):
+            input_routes = {dut: input_dict[dut]}
+            result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop)
+            assert result is True, "Testcase {} : Failed \n Error {}".format(
+                tc_name, result
+            )
+
     # Add kernel route for source
     group = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["pkt_dst"]
     bsr_interface = topo["routers"][bsr]["links"][fhr]["interface"]
@@ -285,11 +299,24 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr,
         result = create_static_routes(tgen, input_dict)
         assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
 
+        # Verifying static routes are installed
+        result = verify_rib(tgen, "ipv4", fhr, input_dict, next_hop_fhr)
+        assert result is True, "Testcase {} : Failed \n Error {}".format(
+            tc_name, result
+        )
+
         input_dict = {
             lhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_lhr}]},
         }
         result = create_static_routes(tgen, input_dict)
         assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
+
+        # Verifying static routes are installed
+        result = verify_rib(tgen, "ipv4", lhr, input_dict, next_hop_lhr)
+        assert result is True, "Testcase {} : Failed \n Error {}".format(
+            tc_name, result
+        )
+
     return True
 
 
index b1526888ed813f2cac0e354e24df507edd1ac266..860c4980b666b2488978f00d5d7ddd8c8523dd29 100644 (file)
@@ -58,30 +58,61 @@ fabricd_options="-A 127.0.0.1"
 vrrpd_options="  -A 127.0.0.1"
 pathd_options="  -A 127.0.0.1"
 
+
+# If you want to pass a common option to all daemons, you can use the
+# "frr_global_options" variable.
+#
+#frr_global_options=""
+
+
+# The list of daemons to watch is automatically generated by the init script.
+# This variable can be used to pass options to watchfrr that will be passed
+# prior to the daemon list.
+#
+# To make watchfrr create/join the specified netns, add the the "--netns"
+# option here. It will only have an effect in /etc/frr/<somename>/daemons, and
+# you need to start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
+#
+#watchfrr_options=""
+
+
 # configuration profile
 #
 #frr_profile="traditional"
 #frr_profile="datacenter"
 
+
+# This is the maximum number of FD's that will be available.  Upon startup this
+# is read by the control files and ulimit is called.  Uncomment and use a
+# reasonable value for your setup if you are expecting a large number of peers
+# in say BGP.
 #
-# This is the maximum number of FD's that will be available.
-# Upon startup this is read by the control files and ulimit
-# is called.  Uncomment and use a reasonable value for your
-# setup if you are expecting a large number of peers in
-# say BGP.
 #MAX_FDS=1024
 
-# The list of daemons to watch is automatically generated by the init script.
-#watchfrr_options=""
 
-# To make watchfrr create/join the specified netns, use the following option:
-#watchfrr_options="--netns"
-# This only has an effect in /etc/frr/<somename>/daemons, and you need to
-# start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
-
-# for debugging purposes, you can specify a "wrap" command to start instead
-# of starting the daemon directly, e.g. to use valgrind on ospfd:
-#   ospfd_wrap="/usr/bin/valgrind"
-# or you can use "all_wrap" for all daemons, e.g. to use perf record:
-#   all_wrap="/usr/bin/perf record --call-graph -"
-# the normal daemon command is added to this at the end.
+# For any daemon, you can specify a "wrap" command to start instead of starting
+# the daemon directly. This will simply be prepended to the daemon invocation.
+# These variables have the form daemon_wrap, where 'daemon' is the name of the
+# daemon (the same pattern as the daemon_options variables).
+#
+# Note that when daemons are started, they are told to daemonize with the `-d`
+# option. This has several implications. For one, the init script expects that
+# when it invokes a daemon, the invocation returns immediately. If you add a
+# wrap command here, it must comply with this expectation and daemonize as
+# well, or the init script will never return. Furthermore, because daemons are
+# themselves daemonized with -d, you must ensure that your wrapper command is
+# capable of following child processes after a fork() if you need it to do so.
+#
+# If your desired wrapper does not support daemonization, you can wrap it with
+# a utility program that daemonizes programs, such as 'daemonize'. An example
+# of this might look like:
+#
+# bgpd_wrap="/usr/bin/daemonize /usr/bin/mywrapper"
+#
+# This is particularly useful for programs which record processes but lack
+# daemonization options, such as perf and rr.
+#
+# If you wish to wrap all daemons in the same way, you may set the "all_wrap"
+# variable.
+#
+#all_wrap=""
index e5286d14f69258158949d2a939d15dcaffc626e1..c168edc50d6a1c8f89e24d37079ddcfdf01d9f61 100755 (executable)
@@ -52,7 +52,7 @@ is_user_root () {
 debug() {
        [ -n "$watchfrr_debug" ] || return 0
 
-       printf '%s %s(%s):' "`date +%Y-%m-%dT%H:%M:%S.%N`" "$0" $$ >&2
+       printf '%s %s(%s):' "$(date +%Y-%m-%dT%H:%M:%S.%N)" "$0" $$ >&2
        # this is to show how arguments are split regarding whitespace & co.
        # (e.g. for use with `debug "message" "$@"`)
        while [ $# -gt 0 ]; do
@@ -73,12 +73,16 @@ chownfrr() {
 
 vtysh_b () {
        [ "$1" = "watchfrr" ] && return 0
-       [ -r "$C_PATH/frr.conf" ] || return 0
-       if [ -n "$1" ]; then
-               "$VTYSH" `echo $nsopt` -b -d "$1"
-       else
-               "$VTYSH" `echo $nsopt` -b
+       if [ -r "$C_PATH/frr.conf" ]; then
+               log_warning_msg "$C_PATH/frr.conf does not exist; skipping config apply"
+               return 0
        fi
+
+       cmd="$VTYSH $nsopt -b"
+       [ -n "$1" ] && cmd="${cmd} -d $1"
+
+       log_success_msg "Sending config with '$cmd'"
+       eval "$cmd"
 }
 
 daemon_inst() {
@@ -164,7 +168,7 @@ daemon_start() {
 
        daemon_inst "$1"
 
-       ulimit -n $MAX_FDS > /dev/null 2> /dev/null
+       [ "$MAX_FDS" != "" ] && ulimit -n "$MAX_FDS" > /dev/null 2> /dev/null
        daemon_prep "$daemon" "$inst" || return 1
        if test ! -d "$V_PATH"; then
                mkdir -p "$V_PATH"
@@ -176,7 +180,9 @@ daemon_start() {
        instopt="${inst:+-n $inst}"
        eval args="\$${daemon}_options"
 
-       if eval "$all_wrap $wrap $bin $nsopt -d $frr_global_options $instopt $args"; then
+       cmd="$all_wrap $wrap $bin $nsopt -d $frr_global_options $instopt $args"
+       log_success_msg "Starting $daemon with command: '$cmd'"
+       if eval "$cmd"; then
                log_success_msg "Started $dmninst"
                if $all; then
                        debug "Skipping startup of vtysh until all have started"
@@ -202,7 +208,7 @@ daemon_stop() {
 
        [ -r "$pidfile" ] || fail="pid file not found"
        $all && [ -n "$fail" ] && return 0
-       [ -z "$fail" ] && pid="`cat \"$pidfile\"`"
+       [ -z "$fail" ] && pid="$(cat \"$pidfile\")"
        [ -z "$fail" -a -z "$pid" ] && fail="pid file is empty"
        [ -n "$fail" ] || kill -0 "$pid" 2>/dev/null || fail="pid $pid not running"
 
@@ -236,7 +242,7 @@ daemon_status() {
        pidfile="$V_PATH/$daemon${inst:+-$inst}.pid"
 
        [ -r "$pidfile" ] || return 3
-       pid="`cat \"$pidfile\"`"
+       pid="$(cat \"$pidfile\")"
        [ -z "$pid" ] && return 1
        kill -0 "$pid" 2>/dev/null || return 1
        return 0
@@ -360,7 +366,7 @@ frrcommon_main() {
        cmd="$1"
        shift
 
-       if [ "$1" = "all" -o -z "$1" ]; then
+       if [ "$1" = "all" ] || [ -z "$1" ]; then
                case "$cmd" in
                start)  all_start;;
                stop)   all_stop;;
index 828d2d73b0fec2a589a416e394c9d0ddb39eaf2b..a52bd7b116b36ca79c2e93825d7106dc3ad7a77f 100644 (file)
@@ -1672,7 +1672,7 @@ DEFUNSH(VTYSH_ZEBRA, srv6_locator, srv6_locator_cmd,
 
 #ifdef HAVE_BGPD
 DEFUNSH(VTYSH_BGPD, router_bgp, router_bgp_cmd,
-       "router bgp [(1-4294967295) [<view|vrf> WORD]]",
+       "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
        ROUTER_STR BGP_STR AS_STR
        "BGP view\nBGP VRF\n"
        "View/VRF name\n")
index 7eb98faeb11d0a896e0a04051f2ee29955b56e60..96e378444d22da26d61c694d83270f8e3fed7239 100644 (file)
@@ -1119,7 +1119,9 @@ void if_down(struct interface *ifp)
 
 void if_refresh(struct interface *ifp)
 {
+#ifndef GNU_LINUX
        if_get_flags(ifp);
+#endif
 }
 
 void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex,
index 239763754b442d9f7bf3147007470da27634243b..6311400251e99d6b3a7d78017786922f93a332a5 100644 (file)
@@ -160,7 +160,8 @@ void if_get_mtu(struct interface *ifp)
 
 #if defined(SIOCGIFMTU)
        if (vrf_if_ioctl(SIOCGIFMTU, (caddr_t)&ifreq, ifp->vrf->vrf_id) < 0) {
-               zlog_info("Can't lookup mtu by ioctl(SIOCGIFMTU)");
+               zlog_info("Can't lookup mtu by ioctl(SIOCGIFMTU) for %s(%u)",
+                         ifp->name, ifp->vrf->vrf_id);
                ifp->mtu6 = ifp->mtu = -1;
                return;
        }
@@ -171,7 +172,8 @@ void if_get_mtu(struct interface *ifp)
        zebra_interface_up_update(ifp);
 
 #else
-       zlog_info("Can't lookup mtu on this system");
+       zlog_info("Can't lookup mtu on this system for %s(%u)", ifp->name,
+                 ifp->vrf->vrf_id);
        ifp->mtu6 = ifp->mtu = -1;
 #endif
 }
@@ -512,7 +514,8 @@ int if_set_flags(struct interface *ifp, uint64_t flags)
        ret = vrf_if_ioctl(SIOCSIFFLAGS, (caddr_t)&ifreq, ifp->vrf->vrf_id);
 
        if (ret < 0) {
-               zlog_info("can't set interface flags");
+               zlog_info("can't set interface %s(%u) flags %" PRIu64,
+                         ifp->name, ifp->vrf->vrf_id, flags);
                return ret;
        }
        return 0;
@@ -533,7 +536,8 @@ int if_unset_flags(struct interface *ifp, uint64_t flags)
        ret = vrf_if_ioctl(SIOCSIFFLAGS, (caddr_t)&ifreq, ifp->vrf->vrf_id);
 
        if (ret < 0) {
-               zlog_info("can't unset interface flags");
+               zlog_warn("can't unset interface %s(%u) flags %" PRIu64,
+                         ifp->name, ifp->vrf->vrf_id, flags);
                return ret;
        }
        return 0;
index 3bdd70e2075e6e1620aeb44b2d8a0fb183c81d00..38a36cc7aef0b291a995c4322cb1343cf97edec3 100644 (file)
@@ -324,7 +324,7 @@ void zebra_evpn_deref_ip2mac(struct zebra_evpn *zevpn, struct zebra_mac *mac)
 }
 
 static void zebra_evpn_mac_get_access_info(struct zebra_mac *mac,
-                                          struct interface **ifpP,
+                                          struct interface **p_ifp,
                                           vlanid_t *vid)
 {
        /* if the mac is associated with an ES we must get the access
@@ -334,7 +334,7 @@ static void zebra_evpn_mac_get_access_info(struct zebra_mac *mac,
                struct zebra_if *zif;
 
                /* get the access port from the es */
-               *ifpP = mac->es->zif ? mac->es->zif->ifp : NULL;
+               *p_ifp = mac->es->zif ? mac->es->zif->ifp : NULL;
                /* get the vlan from the EVPN */
                if (mac->zevpn->vxlan_if) {
                        zif = mac->zevpn->vxlan_if->info;
@@ -347,8 +347,8 @@ static void zebra_evpn_mac_get_access_info(struct zebra_mac *mac,
 
                *vid = mac->fwd_info.local.vid;
                zns = zebra_ns_lookup(mac->fwd_info.local.ns_id);
-               *ifpP = if_lookup_by_index_per_ns(zns,
-                                                 mac->fwd_info.local.ifindex);
+               *p_ifp = if_lookup_by_index_per_ns(zns,
+                                                  mac->fwd_info.local.ifindex);
        }
 }
 
index 87356408d09eab3e3cfb41a01bc2e896885f2204..dfb55b0d6d8ecda198bed5c353009c731160ebd8 100644 (file)
@@ -1163,22 +1163,20 @@ int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args)
                 * if zebra vrf already mapped to different vni id.
                 */
                pn_dnode = yang_dnode_get_parent(args->dnode, "vrf");
-               if (pn_dnode) {
-                       vrfname = yang_dnode_get_string(pn_dnode, "./name");
-                       zvrf = zebra_vrf_lookup_by_name(vrfname);
-                       if (!zvrf) {
-                               snprintf(args->errmsg, args->errmsg_len,
-                                        "zebra vrf info not found for vrf:%s.",
-                                        vrfname);
-                               return NB_ERR_VALIDATION;
-                       }
-                       if (zvrf->l3vni && zvrf->l3vni != vni) {
-                               snprintf(
-                                       args->errmsg, args->errmsg_len,
-                                       "vni %u cannot be configured as vni %u is already configured under the vrf",
-                                       vni, zvrf->l3vni);
-                               return NB_ERR_VALIDATION;
-                       }
+               vrfname = yang_dnode_get_string(pn_dnode, "./name");
+               zvrf = zebra_vrf_lookup_by_name(vrfname);
+               if (!zvrf) {
+                       snprintf(args->errmsg, args->errmsg_len,
+                                "zebra vrf info not found for vrf:%s.",
+                                vrfname);
+                       return NB_ERR_VALIDATION;
+               }
+               if (zvrf->l3vni && zvrf->l3vni != vni) {
+                       snprintf(
+                               args->errmsg, args->errmsg_len,
+                               "vni %u cannot be configured as vni %u is already configured under the vrf",
+                               vni, zvrf->l3vni);
+                       return NB_ERR_VALIDATION;
                }
 
                /* Check if this VNI is already present in the system */
index 739ba330364e161a2713c7073041478e049a2aad..73d585c1a33118ce0323f01d36d014043ff278c0 100644 (file)
@@ -255,66 +255,59 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
                }
        }
 
-       if (ret <= 0) {
-               if (errno != EEXIST && ret != 0) {
-                       flog_err(
-                               EC_LIB_SOCKET,
-                               "netlink( %u) recvfrom() error 2 when reading: %s",
-                               fd, safe_strerror(errno));
-                       close(sock);
-                       if (netnspath)
-                               close(fd);
-                       if (errno == ENOTSUP) {
-                               zlog_debug("NEWNSID locally generated");
-                               return zebra_ns_id_get_fallback(netnspath);
-                       }
-                       return NS_UNKNOWN;
-               }
-               /* message to send to netlink : GETNSID */
-               memset(buf, 0, NETLINK_SOCKET_BUFFER_SIZE);
-               nlh = initiate_nlh(buf, &seq, RTM_GETNSID);
-               rt = (struct rtgenmsg *)(buf + nlh->nlmsg_len);
-               nlh->nlmsg_len += NETLINK_ALIGN(sizeof(struct rtgenmsg));
-               rt->rtgen_family = AF_UNSPEC;
-
-               nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_FD, fd);
-               nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_NSID,
-                             ns_id);
-
-               ret = send_receive(sock, nlh, seq, buf);
-               if (ret < 0) {
-                       close(sock);
-                       if (netnspath)
-                               close(fd);
-                       return NS_UNKNOWN;
+       if (errno != EEXIST && ret != 0) {
+               flog_err(EC_LIB_SOCKET,
+                        "netlink( %u) recvfrom() error 2 when reading: %s", fd,
+                        safe_strerror(errno));
+               close(sock);
+               if (netnspath)
+                       close(fd);
+               if (errno == ENOTSUP) {
+                       zlog_debug("NEWNSID locally generated");
+                       return zebra_ns_id_get_fallback(netnspath);
                }
-               nlh = (struct nlmsghdr *)buf;
-               len = ret;
-               ret = 0;
-               do {
-                       if (nlh->nlmsg_type >= NLMSG_MIN_TYPE) {
-                               return_nsid = extract_nsid(nlh, buf);
-                               if (return_nsid != NS_UNKNOWN)
-                                       break;
-                       } else if (nlh->nlmsg_type == NLMSG_ERROR) {
-                               struct nlmsgerr *err =
-                                       (struct nlmsgerr
-                                                *)((char *)nlh
-                                                   + NETLINK_ALIGN(sizeof(
-                                                             struct
-                                                             nlmsghdr)));
-                               if (err->error < 0)
-                                       errno = -err->error;
-                               else
-                                       errno = err->error;
-                               break;
-                       }
-                       len = len - NETLINK_ALIGN(nlh->nlmsg_len);
-                       nlh = (struct nlmsghdr *)((char *)nlh
-                                                 + NETLINK_ALIGN(
-                                                           nlh->nlmsg_len));
-               } while (len != 0 && ret == 0);
+               return NS_UNKNOWN;
        }
+       /* message to send to netlink : GETNSID */
+       memset(buf, 0, NETLINK_SOCKET_BUFFER_SIZE);
+       nlh = initiate_nlh(buf, &seq, RTM_GETNSID);
+       rt = (struct rtgenmsg *)(buf + nlh->nlmsg_len);
+       nlh->nlmsg_len += NETLINK_ALIGN(sizeof(struct rtgenmsg));
+       rt->rtgen_family = AF_UNSPEC;
+
+       nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_FD, fd);
+       nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_NSID, ns_id);
+
+       ret = send_receive(sock, nlh, seq, buf);
+       if (ret < 0) {
+               close(sock);
+               if (netnspath)
+                       close(fd);
+               return NS_UNKNOWN;
+       }
+       nlh = (struct nlmsghdr *)buf;
+       len = ret;
+       ret = 0;
+       do {
+               if (nlh->nlmsg_type >= NLMSG_MIN_TYPE) {
+                       return_nsid = extract_nsid(nlh, buf);
+                       if (return_nsid != NS_UNKNOWN)
+                               break;
+               } else if (nlh->nlmsg_type == NLMSG_ERROR) {
+                       struct nlmsgerr *err =
+                               (struct nlmsgerr *)((char *)nlh +
+                                                   NETLINK_ALIGN(sizeof(
+                                                           struct nlmsghdr)));
+                       if (err->error < 0)
+                               errno = -err->error;
+                       else
+                               errno = err->error;
+                       break;
+               }
+               len = len - NETLINK_ALIGN(nlh->nlmsg_len);
+               nlh = (struct nlmsghdr *)((char *)nlh +
+                                         NETLINK_ALIGN(nlh->nlmsg_len));
+       } while (len != 0 && ret == 0);
 
        if (netnspath)
                close(fd);
index cf09902d5253cd1ecb3740e5b9642be98d0956b3..500f4b0f1bbf0011190bfb169512cdb98338c981 100644 (file)
@@ -324,8 +324,8 @@ static int zebra_nhg_insert_id(struct nhg_hash_entry *nhe)
        if (hash_lookup(zrouter.nhgs_id, nhe)) {
                flog_err(
                        EC_ZEBRA_NHG_TABLE_INSERT_FAILED,
-                       "Failed inserting NHG id=%u into the ID hash table, entry already exists",
-                       nhe->id);
+                       "Failed inserting NHG %pNG into the ID hash table, entry already exists",
+                       nhe);
                return -1;
        }
 
@@ -358,10 +358,9 @@ zebra_nhg_connect_depends(struct nhg_hash_entry *nhe,
        if (!zebra_nhg_depends_is_empty(nhe)) {
                frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
                        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-                               zlog_debug("%s: nhe %p (%u), dep %p (%u)",
-                                          __func__, nhe, nhe->id,
-                                          rb_node_dep->nhe,
-                                          rb_node_dep->nhe->id);
+                               zlog_debug("%s: nhe %p (%pNG), dep %p (%pNG)",
+                                          __func__, nhe, nhe, rb_node_dep->nhe,
+                                          rb_node_dep->nhe);
 
                        zebra_nhg_dependents_add(rb_node_dep->nhe, nhe);
                }
@@ -470,9 +469,9 @@ static void *zebra_nhg_hash_alloc(void *arg)
                else {
                        if (IS_ZEBRA_DEBUG_NHG)
                                zlog_debug(
-                                       "Failed to lookup an interface with ifindex=%d in vrf=%u for NHE id=%u",
+                                       "Failed to lookup an interface with ifindex=%d in vrf=%u for NHE %pNG",
                                        nhe->nhg.nexthop->ifindex,
-                                       nhe->nhg.nexthop->vrf_id, nhe->id);
+                                       nhe->nhg.nexthop->vrf_id, nhe);
                }
        }
 
@@ -706,9 +705,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
                (*nhe) = hash_lookup(zrouter.nhgs, lookup);
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: lookup => %p (%u)",
-                          __func__, (*nhe),
-                          (*nhe) ? (*nhe)->id : 0);
+               zlog_debug("%s: lookup => %p (%pNG)", __func__, *nhe, *nhe);
 
        /* If we found an existing object, we're done */
        if (*nhe)
@@ -745,8 +742,8 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
        *nhe = newnhe;
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: => created %p (%u)", __func__, newnhe,
-                          newnhe->id);
+               zlog_debug("%s: => created %p (%pNG)", __func__, newnhe,
+                          newnhe);
 
        /* Only hash/lookup the depends if the first lookup
         * fails to find something. This should hopefully save a
@@ -928,8 +925,7 @@ static struct nhg_hash_entry *zebra_nhg_find_nexthop(uint32_t id,
        zebra_nhg_find(&nhe, id, &nhg, NULL, vrf_id, afi, type, from_dplane);
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: nh %pNHv => %p (%u)",
-                          __func__, nh, nhe, nhe ? nhe->id : 0);
+               zlog_debug("%s: nh %pNHv => %p (%pNG)", __func__, nh, nhe, nhe);
 
        return nhe;
 }
@@ -1096,7 +1092,7 @@ static void zebra_nhg_release_all_deps(struct nhg_hash_entry *nhe)
 static void zebra_nhg_release(struct nhg_hash_entry *nhe)
 {
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: nhe %p (%u)", __func__, nhe, nhe->id);
+               zlog_debug("%s: nhe %p (%pNG)", __func__, nhe, nhe);
 
        zebra_nhg_release_all_deps(nhe);
 
@@ -1135,8 +1131,8 @@ static void zebra_nhg_handle_kernel_state_change(struct nhg_hash_entry *nhe,
        if (nhe->refcnt) {
                flog_err(
                        EC_ZEBRA_NHG_SYNC,
-                       "Kernel %s a nexthop group with ID (%u) that we are still using for a route, sending it back down",
-                       (is_delete ? "deleted" : "updated"), nhe->id);
+                       "Kernel %s a nexthop group with ID (%pNG) that we are still using for a route, sending it back down",
+                       (is_delete ? "deleted" : "updated"), nhe);
 
                UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
                zebra_nhg_install_kernel(nhe);
@@ -1199,7 +1195,7 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx)
        }
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: nhe %p (%u) is new", __func__, nhe, nhe->id);
+               zlog_debug("%s: nhe %p (%pNG) is new", __func__, nhe, nhe);
 
        /*
         * If daemon nhg from the kernel, add a refcnt here to indicate the
@@ -1389,8 +1385,7 @@ static struct nhg_hash_entry *depends_find_singleton(const struct nexthop *nh,
        nexthop_del_srv6_seg6(&lookup);
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: nh %pNHv => %p (%u)",
-                          __func__, nh, nhe, nhe ? nhe->id : 0);
+               zlog_debug("%s: nh %pNHv => %p (%pNG)", __func__, nh, nhe, nhe);
 
        return nhe;
 }
@@ -1413,10 +1408,10 @@ static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi,
 
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL) {
-               zlog_debug("%s: nh %pNHv %s => %p (%u)", __func__, nh,
+               zlog_debug("%s: nh %pNHv %s => %p (%pNG)", __func__, nh,
                           CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE) ? "(R)"
                                                                         : "",
-                          nhe, nhe ? nhe->id : 0);
+                          nhe, nhe);
        }
 
 done:
@@ -1495,8 +1490,7 @@ struct nhg_hash_entry *zebra_nhg_rib_find(uint32_t id,
        zebra_nhg_find(&nhe, id, nhg, NULL, vrf_id, rt_afi, type, false);
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: => nhe %p (%u)",
-                          __func__, nhe, nhe ? nhe->id : 0);
+               zlog_debug("%s: => nhe %p (%pNG)", __func__, nhe, nhe);
 
        return nhe;
 }
@@ -1514,13 +1508,12 @@ zebra_nhg_rib_find_nhe(struct nhg_hash_entry *rt_nhe, afi_t rt_afi)
        }
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: rt_nhe %p (%u)", __func__, rt_nhe, rt_nhe->id);
+               zlog_debug("%s: rt_nhe %p (%pNG)", __func__, rt_nhe, rt_nhe);
 
        zebra_nhe_find(&nhe, rt_nhe, NULL, rt_afi, false);
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: => nhe %p (%u)",
-                          __func__, nhe, nhe ? nhe->id : 0);
+               zlog_debug("%s: => nhe %p (%pNG)", __func__, nhe, nhe);
 
        return nhe;
 }
@@ -1604,16 +1597,16 @@ void zebra_nhg_free(struct nhg_hash_entry *nhe)
        if (IS_ZEBRA_DEBUG_NHG_DETAIL) {
                /* Group or singleton? */
                if (nhe->nhg.nexthop && nhe->nhg.nexthop->next)
-                       zlog_debug("%s: nhe %p (%u), refcnt %d",
-                                  __func__, nhe, nhe->id, nhe->refcnt);
+                       zlog_debug("%s: nhe %p (%pNG), refcnt %d", __func__,
+                                  nhe, nhe, nhe->refcnt);
                else
-                       zlog_debug("%s: nhe %p (%u), refcnt %d, NH %pNHv",
-                                  __func__, nhe, nhe->id, nhe->refcnt,
+                       zlog_debug("%s: nhe %p (%pNG), refcnt %d, NH %pNHv",
+                                  __func__, nhe, nhe, nhe->refcnt,
                                   nhe->nhg.nexthop);
        }
 
        if (nhe->refcnt)
-               zlog_debug("nhe_id=%u hash refcnt=%d", nhe->id, nhe->refcnt);
+               zlog_debug("nhe_id=%pNG hash refcnt=%d", nhe, nhe->refcnt);
 
        zebra_nhg_free_members(nhe);
 
@@ -1629,9 +1622,8 @@ void zebra_nhg_hash_free(void *p)
 void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe)
 {
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: nhe %p (%u) %d => %d",
-                          __func__, nhe, nhe->id, nhe->refcnt,
-                          nhe->refcnt - 1);
+               zlog_debug("%s: nhe %p (%pNG) %d => %d", __func__, nhe, nhe,
+                          nhe->refcnt, nhe->refcnt - 1);
 
        nhe->refcnt--;
 
@@ -1645,9 +1637,8 @@ void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe)
 void zebra_nhg_increment_ref(struct nhg_hash_entry *nhe)
 {
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: nhe %p (%u) %d => %d",
-                          __func__, nhe, nhe->id, nhe->refcnt,
-                          nhe->refcnt + 1);
+               zlog_debug("%s: nhe %p (%pNG) %d => %d", __func__, nhe, nhe,
+                          nhe->refcnt, nhe->refcnt + 1);
 
        nhe->refcnt++;
 
@@ -2287,9 +2278,9 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,
                        }
 
                        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-                               zlog_debug("%s: CONNECT match %p (%u), newhop %pNHv",
-                                          __func__, match,
-                                          match->nhe->id, newhop);
+                               zlog_debug(
+                                       "%s: CONNECT match %p (%pNG), newhop %pNHv",
+                                       __func__, match, match->nhe, newhop);
 
                        return 1;
                } else if (CHECK_FLAG(flags, ZEBRA_FLAG_ALLOW_RECURSION)) {
@@ -2302,9 +2293,9 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,
                        /* Only useful if installed */
                        if (!CHECK_FLAG(match->status, ROUTE_ENTRY_INSTALLED)) {
                                if (IS_ZEBRA_DEBUG_RIB_DETAILED)
-                                       zlog_debug("%s: match %p (%u) not installed",
-                                                  __func__, match,
-                                                  match->nhe->id);
+                                       zlog_debug(
+                                               "%s: match %p (%pNG) not installed",
+                                               __func__, match, match->nhe);
 
                                goto done_with_match;
                        }
@@ -2319,9 +2310,10 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,
                                        continue;
 
                                if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-                                       zlog_debug("%s: RECURSIVE match %p (%u), newhop %pNHv",
-                                                  __func__, match,
-                                                  match->nhe->id, newhop);
+                                       zlog_debug(
+                                               "%s: RECURSIVE match %p (%pNG), newhop %pNHv",
+                                               __func__, match, match->nhe,
+                                               newhop);
 
                                SET_FLAG(nexthop->flags,
                                         NEXTHOP_FLAG_RECURSIVE);
@@ -2355,9 +2347,10 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,
                                        continue;
 
                                if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-                                       zlog_debug("%s: RECURSIVE match backup %p (%u), newhop %pNHv",
-                                                  __func__, match,
-                                                  match->nhe->id, newhop);
+                                       zlog_debug(
+                                               "%s: RECURSIVE match backup %p (%pNG), newhop %pNHv",
+                                               __func__, match, match->nhe,
+                                               newhop);
 
                                SET_FLAG(nexthop->flags,
                                         NEXTHOP_FLAG_RECURSIVE);
@@ -2702,9 +2695,8 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re)
        curr_nhe = zebra_nhe_copy(re->nhe, re->nhe->id);
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: re %p nhe %p (%u), curr_nhe %p",
-                          __func__, re, re->nhe, re->nhe->id,
-                          curr_nhe);
+               zlog_debug("%s: re %p nhe %p (%pNG), curr_nhe %p", __func__, re,
+                          re->nhe, re->nhe, curr_nhe);
 
        /* Clear the existing id, if any: this will avoid any confusion
         * if the id exists, and will also force the creation
@@ -2742,9 +2734,10 @@ backups_done:
                new_nhe = zebra_nhg_rib_find_nhe(curr_nhe, rt_afi);
 
                if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-                       zlog_debug("%s: re %p CHANGED: nhe %p (%u) => new_nhe %p (%u)",
-                                  __func__, re, re->nhe,
-                                  re->nhe->id, new_nhe, new_nhe->id);
+                       zlog_debug(
+                               "%s: re %p CHANGED: nhe %p (%pNG) => new_nhe %p (%pNG)",
+                               __func__, re, re->nhe, re->nhe, new_nhe,
+                               new_nhe);
 
                route_entry_update_nhe(re, new_nhe);
        }
@@ -2803,8 +2796,8 @@ static uint8_t zebra_nhg_nhe2grp_internal(struct nh_grp *grp,
                        if (!depend) {
                                flog_err(
                                        EC_ZEBRA_NHG_FIB_UPDATE,
-                                       "Failed to recursively resolve Nexthop Hash Entry in the group id=%u",
-                                       nhe->id);
+                                       "Failed to recursively resolve Nexthop Hash Entry in the group id=%pNG",
+                                       nhe);
                                continue;
                        }
                }
@@ -2909,8 +2902,8 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe)
                case ZEBRA_DPLANE_REQUEST_FAILURE:
                        flog_err(
                                EC_ZEBRA_DP_INSTALL_FAIL,
-                               "Failed to install Nexthop ID (%u) into the kernel",
-                               nhe->id);
+                               "Failed to install Nexthop ID (%pNG) into the kernel",
+                               nhe);
                        break;
                case ZEBRA_DPLANE_REQUEST_SUCCESS:
                        SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
@@ -2932,8 +2925,8 @@ void zebra_nhg_uninstall_kernel(struct nhg_hash_entry *nhe)
                case ZEBRA_DPLANE_REQUEST_FAILURE:
                        flog_err(
                                EC_ZEBRA_DP_DELETE_FAIL,
-                               "Failed to uninstall Nexthop ID (%u) from the kernel",
-                               nhe->id);
+                               "Failed to uninstall Nexthop ID (%pNG) from the kernel",
+                               nhe);
                        break;
                case ZEBRA_DPLANE_REQUEST_SUCCESS:
                        UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
@@ -3006,8 +2999,8 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
                              !PROTO_OWNED(nhe)))
                                flog_err(
                                        EC_ZEBRA_DP_INSTALL_FAIL,
-                                       "Failed to install Nexthop ID (%u) into the kernel",
-                                       nhe->id);
+                                       "Failed to install Nexthop (%pNG) into the kernel",
+                                       nhe);
                }
                break;
 
@@ -3358,14 +3351,14 @@ struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id, int type)
        if (nhe->refcnt > 1) {
                if (IS_ZEBRA_DEBUG_NHG)
                        zlog_debug(
-                               "%s: id %u, still being used by routes refcnt %u",
-                               __func__, nhe->id, nhe->refcnt);
+                               "%s: %pNG, still being used by routes refcnt %u",
+                               __func__, nhe, nhe->refcnt);
                return nhe;
        }
 
        if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: deleted nhe %p (%u), vrf %d, type %s", __func__,
-                          nhe, nhe->id, nhe->vrf_id,
+               zlog_debug("%s: deleted nhe %p (%pNG), vrf %d, type %s",
+                          __func__, nhe, nhe, nhe->vrf_id,
                           zebra_route_string(nhe->type));
 
        return nhe;
@@ -3388,8 +3381,8 @@ static void zebra_nhg_score_proto_entry(struct hash_bucket *bucket, void *arg)
        if (nhe->type == iter->type && PROTO_OWNED(nhe)) {
                if (IS_ZEBRA_DEBUG_NHG_DETAIL)
                        zlog_debug(
-                               "%s: found nhe %p (%u), vrf %d, type %s after client disconnect",
-                               __func__, nhe, nhe->id, nhe->vrf_id,
+                               "%s: found nhe %p (%pNG), vrf %d, type %s after client disconnect",
+                               __func__, nhe, nhe, nhe->vrf_id,
                                zebra_route_string(nhe->type));
 
                /* Add to removal list */
@@ -3425,3 +3418,32 @@ unsigned long zebra_nhg_score_proto(int type)
 
        return count;
 }
+
+printfrr_ext_autoreg_p("NG", printfrr_nhghe);
+static ssize_t printfrr_nhghe(struct fbuf *buf, struct printfrr_eargs *ea,
+                             const void *ptr)
+{
+       const struct nhg_hash_entry *nhe = ptr;
+       const struct nhg_connected *dep;
+       ssize_t ret = 0;
+
+       if (!nhe)
+               return bputs(buf, "[NULL]");
+
+       ret += bprintfrr(buf, "%u[", nhe->id);
+       if (nhe->ifp)
+               ret += printfrr_nhs(buf, nhe->nhg.nexthop);
+       else {
+               int count = zebra_nhg_depends_count(nhe);
+
+               frr_each (nhg_connected_tree_const, &nhe->nhg_depends, dep) {
+                       ret += bprintfrr(buf, "%u", dep->nhe->id);
+                       if (count > 1)
+                               ret += bputs(buf, "/");
+                       count--;
+               }
+       }
+
+       ret += bputs(buf, "]");
+       return ret;
+}
index 3fbf778be2eb4004017b639bb5f8263b73c51533..0863d90a7ead6fe78b2ce33b42db026bc93ff515 100644 (file)
@@ -364,6 +364,10 @@ extern void zebra_nhg_mark_keep(void);
 struct route_entry; /* Forward ref to avoid circular includes */
 extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
 
+#ifdef _FRR_ATTRIBUTE_PRINTFRR
+#pragma FRR printfrr_ext "%pNG" (const struct nhg_hash_entry *)
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index fda5ef02cf1fb244e0afa653ad00ce8c6e879df1..3127d2d3042619a3358aa034adf3a96768fa8d2d 100644 (file)
@@ -1294,10 +1294,6 @@ static void zebra_ptm_send_bfdd(struct stream *msg)
 
        /* Create copy for replication. */
        msgc = stream_dup(msg);
-       if (msgc == NULL) {
-               zlog_debug("%s: not enough memory", __func__);
-               return;
-       }
 
        /* Send message to all running BFDd daemons. */
        for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
@@ -1308,10 +1304,6 @@ static void zebra_ptm_send_bfdd(struct stream *msg)
 
                /* Allocate more messages. */
                msg = stream_dup(msgc);
-               if (msg == NULL) {
-                       zlog_debug("%s: not enough memory", __func__);
-                       return;
-               }
        }
 
        stream_free(msgc);
@@ -1326,10 +1318,6 @@ static void zebra_ptm_send_clients(struct stream *msg)
 
        /* Create copy for replication. */
        msgc = stream_dup(msg);
-       if (msgc == NULL) {
-               zlog_debug("%s: not enough memory", __func__);
-               return;
-       }
 
        /* Send message to all running client daemons. */
        for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
@@ -1340,10 +1328,6 @@ static void zebra_ptm_send_clients(struct stream *msg)
 
                /* Allocate more messages. */
                msg = stream_dup(msgc);
-               if (msg == NULL) {
-                       zlog_debug("%s: not enough memory", __func__);
-                       return;
-               }
        }
 
        stream_free(msgc);