]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: conditional advertisement - topotests-2
authorMadhuri Kuruganti <k.madhuri@samsung.com>
Fri, 23 Oct 2020 16:09:12 +0000 (21:39 +0530)
committerMadhuri Kuruganti <k.madhuri@samsung.com>
Tue, 27 Oct 2020 10:45:36 +0000 (16:15 +0530)
Signed-off-by: Madhuri Kuruganti <k.madhuri@samsung.com>
bgpd/bgp_conditional_adv.c
bgpd/bgp_route.c
bgpd/bgp_route.h
bgpd/bgp_updgrp_adv.c
bgpd/bgpd.c
bgpd/bgpd.h
tests/topotests/bgp_conditional_advertisement/r2/bgpd.conf
tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py

index 521c8056f57e01e3b024e7ae0548023ed77f40c2..ff1eb2be20af1fa8c7def584b367ece840ee4a49 100644 (file)
@@ -50,17 +50,28 @@ bgp_check_rmap_prefixes_in_bgp_table(struct bgp_table *table,
                        ret = route_map_apply(rmap, dest_p, RMAP_BGP, &path);
                        if (ret != RMAP_PERMITMATCH)
                                bgp_attr_flush(&dummy_attr);
-                       else
+                       else {
+                               if (BGP_DEBUG(update, UPDATE_OUT))
+                                       zlog_debug(
+                                               "%s: Condition map routes present in BGP table",
+                                               __func__);
+
                                return ret;
+                       }
                }
        }
+
+       if (BGP_DEBUG(update, UPDATE_OUT))
+               zlog_debug("%s: Condition map routes not present in BGP table",
+                          __func__);
+
        return ret;
 }
 
 static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
                                       safi_t safi, struct bgp_table *table,
                                       struct route_map *rmap,
-                                      enum update_type advertise)
+                                      enum update_type update_type)
 {
        int addpath_capable;
        struct bgp_dest *dest;
@@ -81,6 +92,11 @@ static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
        if (!subgrp)
                return;
 
+       if (BGP_DEBUG(update, UPDATE_OUT))
+               zlog_debug("%s: %s routes to/from %s for %s", __func__,
+                          update_type == ADVERTISE ? "Advertise" : "Withdraw",
+                          peer->host, get_afi_safi_str(afi, safi, false));
+
        addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
 
        for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
@@ -115,7 +131,7 @@ static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
                                 * on same peer, routes in advertise-map may not
                                 * be advertised as expected.
                                 */
-                               if ((advertise == ADVERTISE)
+                               if ((update_type == ADVERTISE)
                                    && subgroup_announce_check(dest, pi, subgrp,
                                                               dest_p, &attr,
                                                               true))
@@ -165,7 +181,6 @@ static int bgp_conditional_adv_timer(struct thread *t)
        bgp = THREAD_ARG(t);
        assert(bgp);
 
-       bgp->t_condition_check = NULL;
        thread_add_timer(bm->master, bgp_conditional_adv_timer, bgp,
                         CONDITIONAL_ROUTES_POLL_TIME, &bgp->t_condition_check);
 
@@ -211,6 +226,19 @@ static int bgp_conditional_adv_timer(struct thread *t)
                            && !peer->advmap_table_change)
                                continue;
 
+                       if (BGP_DEBUG(update, UPDATE_OUT)) {
+                               if (peer->advmap_table_change)
+                                       zlog_debug(
+                                               "%s: %s - routes changed in BGP table.",
+                                               __func__, peer->host);
+                               if (peer->advmap_config_change[afi][safi])
+                                       zlog_debug(
+                                               "%s: %s for %s - advertise/condition map configuration is changed.",
+                                               __func__, peer->host,
+                                               get_afi_safi_str(afi, safi,
+                                                                false));
+                       }
+
                        /* cmap (route-map attached to exist-map or
                         * non-exist-map) map validation
                         */
@@ -235,6 +263,14 @@ static int bgp_conditional_adv_timer(struct thread *t)
                         * or route-map filter configuration on the same peer.
                         */
                        if (peer->advmap_config_change[afi][safi]) {
+
+                               if (BGP_DEBUG(update, UPDATE_OUT))
+                                       zlog_debug(
+                                               "%s: Configuration is changed on peer %s for %s, send the normal update first.",
+                                               __func__, peer->host,
+                                               get_afi_safi_str(afi, safi,
+                                                                false));
+
                                paf = peer_af_find(peer, afi, safi);
                                if (paf) {
                                        update_subgroup_split_peer(paf, NULL);
@@ -271,8 +307,13 @@ void bgp_conditional_adv_enable(struct peer *peer, afi_t afi, safi_t safi)
        /* advertise-map is already configured on atleast one of its
         * neighbors (AFI/SAFI). So just increment the counter.
         */
-       if (++bgp->condition_filter_count > 1)
+       if (++bgp->condition_filter_count > 1) {
+               if (BGP_DEBUG(update, UPDATE_OUT))
+                       zlog_debug("%s: condition_filter_count %d", __func__,
+                                  bgp->condition_filter_count);
+
                return;
+       }
 
        /* Register for conditional routes polling timer */
        thread_add_timer(bm->master, bgp_conditional_adv_timer, bgp,
@@ -289,8 +330,13 @@ void bgp_conditional_adv_disable(struct peer *peer, afi_t afi, safi_t safi)
         * it is configured on more than one neighbor(AFI/SAFI).
         * So there's nothing to do except decrementing the counter.
         */
-       if (--bgp->condition_filter_count != 0)
+       if (--bgp->condition_filter_count != 0) {
+               if (BGP_DEBUG(update, UPDATE_OUT))
+                       zlog_debug("%s: condition_filter_count %d", __func__,
+                                  bgp->condition_filter_count);
+
                return;
+       }
 
        /* Last filter removed. So cancel conditional routes polling thread. */
        THREAD_OFF(bgp->t_condition_check);
index 3074531476bf9bbe23155cdfd9a1e834f7f94db3..366d96b3a79a7630d858938290c2f6d3932321fd 100644 (file)
@@ -1657,6 +1657,33 @@ void bgp_attr_add_gshut_community(struct attr *attr)
 }
 
 
+/* Notify BGP Conditional advertisement scanner process. */
+void bgp_notify_conditional_adv_scanner(struct update_subgroup *subgrp)
+{
+       struct peer *temp_peer;
+       struct peer *peer = SUBGRP_PEER(subgrp);
+       struct listnode *temp_node, *temp_nnode = NULL;
+       afi_t afi = SUBGRP_AFI(subgrp);
+       safi_t safi = SUBGRP_SAFI(subgrp);
+       struct bgp *bgp = SUBGRP_INST(subgrp);
+       struct bgp_filter *filter = &peer->filter[afi][safi];
+
+       if (!ADVERTISE_MAP_NAME(filter))
+               return;
+
+       for (ALL_LIST_ELEMENTS(bgp->peer, temp_node, temp_nnode, temp_peer)) {
+               if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
+                       continue;
+
+               if (peer != temp_peer)
+                       continue;
+
+               temp_peer->advmap_table_change = true;
+               break;
+       }
+}
+
+
 static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr)
 {
        if (family == AF_INET) {
@@ -1988,8 +2015,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
 
        /* Route map & unsuppress-map apply. */
        if (!skip_rmap_check
-           && (ROUTE_MAP_OUT_NAME(filter)
-               || (pi->extra && pi->extra->suppress))) {
+           && (ROUTE_MAP_OUT_NAME(filter) || bgp_path_suppressed(pi))) {
                struct bgp_path_info rmap_path = {0};
                struct bgp_path_info_extra dummy_rmap_path_extra = {0};
                struct attr dummy_attr = {0};
@@ -2030,28 +2056,6 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
                                        peer->host, p);
 
                        bgp_attr_flush(attr);
-
-                       /* TBD : Not sure if this is the correct way to fetch
-                        * peer from group.
-                        * Notify BGP Conditional advertisement scanner process.
-                        */
-                       if (ADVERTISE_MAP_NAME(filter)
-                           || CONDITION_MAP_NAME(filter)) {
-                               struct peer *temp_peer;
-                               struct listnode *temp_node, *temp_nnode = NULL;
-
-                               for (ALL_LIST_ELEMENTS(bgp->peer, temp_node,
-                                                      temp_nnode, temp_peer)) {
-                                       if (!CHECK_FLAG(peer->flags,
-                                                       PEER_FLAG_CONFIG_NODE))
-                                               continue;
-                                       if (strcmp(peer->host, temp_peer->host)
-                                           != 0)
-                                               continue;
-                                       temp_peer->advmap_table_change = true;
-                                       break;
-                               }
-                       }
                        return false;
                }
        }
index f770f9cb8dd92a2e1bb1c4aa3185a803199c5027..206cc82b7b09365a50f94e378a970cb41cce57f3 100644 (file)
@@ -671,6 +671,8 @@ extern void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
                                  struct bgp_path_info *path, int display,
                                  json_object *json);
 
+extern void bgp_notify_conditional_adv_scanner(struct update_subgroup *subgrp);
+
 extern void subgroup_process_announce_selected(struct update_subgroup *subgrp,
                                               struct bgp_path_info *selected,
                                               struct bgp_dest *dest,
index ae1359ae467adefc315ba4d9de51d3fa1c1390d5..ac77ccd8a4bddda8dad808de7990d08497c1ccb9 100644 (file)
@@ -215,6 +215,9 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
                                }
                        }
                }
+
+               /* Notify BGP Conditional advertisement */
+               bgp_notify_conditional_adv_scanner(subgrp);
        }
 
        return UPDWALK_CONTINUE;
index db72eb1775aba909298adad6d01cc781a13690f1..cf16378de199f8ceaf1557a20e582a6fe8c4c7be 100644 (file)
@@ -6717,6 +6717,11 @@ int peer_advertise_map_unset(struct peer *peer, afi_t afi, safi_t safi,
        /* Check if handling a regular peer and skip peer-group mechanics. */
        if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
                /* Process peer route updates. */
+               if (BGP_DEBUG(update, UPDATE_OUT))
+                       zlog_debug("%s: Send normal update to %s for %s",
+                                  __func__, peer->host,
+                                  get_afi_safi_str(afi, safi, false));
+
                peer_on_policy_change(peer, afi, safi, 1);
                return 0;
        }
@@ -6736,6 +6741,11 @@ int peer_advertise_map_unset(struct peer *peer, afi_t afi, safi_t safi,
                        condition_name, condition_map, condition, false);
 
                /* Process peer route updates. */
+               if (BGP_DEBUG(update, UPDATE_OUT))
+                       zlog_debug("%s: Send normal update to %s for %s ",
+                                  __func__, member->host,
+                                  get_afi_safi_str(afi, safi, false));
+
                peer_on_policy_change(member, afi, safi, 1);
        }
 
index 4eb5bdd01803be19004c66095ec8e404998eddcf..74828e91df217411f128becc5625179f910e65e0 100644 (file)
@@ -681,7 +681,7 @@ struct bgp {
 
        /* Process Queue for handling routes */
        struct work_queue *process_queue;
-       
+
        /* BGP Conditional advertisement */
        uint32_t condition_filter_count;
        struct thread *t_condition_check;
index c8f4357f99ad20c447edbf5fc487a03f39dd05bb..c6147fe658c417ae4d8fc924f7e436086e1e7c72 100644 (file)
@@ -4,22 +4,32 @@ ip prefix-list DEFAULT seq 10 permit 192.0.2.1/32
 ip prefix-list EXIST seq 5 permit 10.10.10.10/32
 ip prefix-list DEFAULT-ROUTE seq 5 permit 0.0.0.0/0
 ip prefix-list IP1 seq 5 permit 10.139.224.0/20
+ip prefix-list IP2 seq 5 permit 203.0.113.1/32
 !
 bgp community-list standard DC-ROUTES seq 5 permit 64952:3008
 bgp community-list standard DC-ROUTES seq 10 permit 64671:501
 bgp community-list standard DC-ROUTES seq 15 permit 64950:3009
 bgp community-list standard DEFAULT-ROUTE seq 5 permit 65013:200
 !
-route-map ADV-MAP permit 10
+route-map ADV-MAP-1 permit 10
  match ip address prefix-list IP1
 !
-route-map ADV-MAP permit 20
+route-map ADV-MAP-1 permit 20
  match community DC-ROUTES
 !
+route-map ADV-MAP-2 permit 10
+ match ip address prefix-list IP2
+!
 route-map EXIST-MAP permit 10
  match community DEFAULT-ROUTE
  match ip address prefix-list DEFAULT-ROUTE
 !
+route-map RMAP-1 deny 10
+ match ip address prefix-list IP1
+!
+route-map RMAP-2 deny 10
+ match ip address prefix-list IP2
+!
 router bgp 2
  bgp log-neighbor-changes
  no bgp ebgp-requires-policy
@@ -27,6 +37,7 @@ router bgp 2
  neighbor 10.10.20.3 remote-as 3
  !
  address-family ipv4 unicast
+  network 203.0.113.1/32
   neighbor 10.10.10.1 soft-reconfiguration inbound
   neighbor 10.10.20.3 soft-reconfiguration inbound
  exit-address-family
index e5098824487897518c44d999714b9050c5204d6f..99cf08b4f7a0c9537d36f578648c73ff5c28ae93 100644 (file)
@@ -38,6 +38,7 @@ Conditional advertisement
 -------------------------
 TC11: R3 BGP convergence, without advertise-map configuration.
       All routes are advertised to R3.
+
 TC21: exist-map routes present in R2's BGP table.
       advertise-map routes present in R2's BGP table are advertised to R3.
 TC22: exist-map routes not present in R2's BGP table
@@ -46,13 +47,14 @@ TC31: non-exist-map routes not present in R2's BGP table
       advertise-map routes present in R2's BGP table are advertised to R3.
 TC32: non-exist-map routes present in R2's BGP table
       advertise-map routes present in R2's BGP table are withdrawn from R3.
+
 TC41: non-exist-map route-map configuration removed in R2.
       advertise-map routes present in R2's BGP table are advertised to R3.
 TC42: exist-map route-map configuration removed in R2
       advertise-map routes present in R2's BGP table are withdrawn from R3.
 
-Conditional advertisement along with Route-map Filter
------------------------------------------------------
+Conditional advertisement(received routes) along with Route-map Filter
+----------------------------------------------------------------------
 TC51: exist-map routes present in R2's BGP table, with route-map filter.
       All routes are withdrawn from R3 except advertise-map routes.
 TC52: exist-map routes present in R2's BGP table, without route-map filter.
@@ -61,6 +63,7 @@ TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
       All routes are withdrawn from R3 including advertise-map routes.
 TC54: non-exist-map routes present in R2's BGP table, without route-map filter.
       All routes are advertised to R3 except advertise-map routes.
+
 TC61: exist-map routes not present in R2's BGP table, with route-map filter.
       All routes are withdrawn from R3 including advertise-map routes.
 TC62: exist-map routes not present in R2's BGP table, without route-map filter.
@@ -70,6 +73,34 @@ TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
 TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
       All routes are advertised to R3 including advertise-map routes.
 
+Conditional advertisement(attached routes) along with Route-map Filter
+-----------------------------------------------------------------
+TC71: exist-map routes present in R2's BGP table, with route-map filter.
+      All routes are withdrawn from R3 except advertise-map routes.
+TC72: exist-map routes present in R2's BGP table, without route-map filter.
+      All routes are advertised to R3 including advertise-map routes.
+TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
+      All routes are withdrawn from R3 including advertise-map routes.
+TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
+      All routes are advertised to R3 except advertise-map routes.
+
+TC81: exist-map routes not present in R2's BGP table, with route-map filter.
+      All routes are withdrawn from R3 including advertise-map routes.
+TC82: exist-map routes not present in R2's BGP table, without route-map filter.
+      All routes are advertised to R3 except advertise-map routes.
+TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
+      All routes are withdrawn from R3 except advertise-map routes.
+TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
+      All routes are advertised to R3 including advertise-map routes.
+
+TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
+      All routes are advertised to R3 including advertise-map routes.
+TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
+      All routes are advertised to R3 except advertise-map routes.
+TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
+      All routes are advertised to R3 including advertise-map routes.
+TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
+      All routes are advertised to R3 except advertise-map routes.
 
 i.e.
 +----------------+-------------------------+------------------------+
@@ -191,6 +222,7 @@ def test_bgp_conditional_advertisement():
             "192.0.2.1/32": [{"protocol": "bgp"}],
             "192.0.2.5/32": [{"protocol": "bgp"}],
             "10.139.224.0/20": [{"protocol": "bgp"}],
+            "203.0.113.1/32": [{"protocol": "bgp"}],
         }
         return topotest.json_cmp(output, expected)
 
@@ -201,9 +233,12 @@ def test_bgp_conditional_advertisement():
             "192.0.2.1/32": None,
             "192.0.2.5/32": None,
             "10.139.224.0/20": None,
+            "203.0.113.1/32": None,
         }
         return topotest.json_cmp(output, expected)
 
+    # BGP conditional advertisement with route-maps
+    # EXIST-MAP, ADV-MAP-1 and RMAP-1
     def _exist_map_routes_present(router):
         return _all_routes_advertised(router)
 
@@ -214,6 +249,7 @@ def test_bgp_conditional_advertisement():
             "192.0.2.1/32": None,
             "192.0.2.5/32": [{"protocol": "bgp"}],
             "10.139.224.0/20": None,
+            "203.0.113.1/32": [{"protocol": "bgp"}],
         }
         return topotest.json_cmp(output, expected)
 
@@ -224,6 +260,7 @@ def test_bgp_conditional_advertisement():
             "192.0.2.1/32": None,
             "192.0.2.5/32": [{"protocol": "bgp"}],
             "10.139.224.0/20": None,
+            "203.0.113.1/32": [{"protocol": "bgp"}],
         }
         return topotest.json_cmp(output, expected)
 
@@ -234,6 +271,7 @@ def test_bgp_conditional_advertisement():
             "192.0.2.1/32": [{"protocol": "bgp"}],
             "192.0.2.5/32": [{"protocol": "bgp"}],
             "10.139.224.0/20": [{"protocol": "bgp"}],
+            "203.0.113.1/32": [{"protocol": "bgp"}],
         }
         return topotest.json_cmp(output, expected)
 
@@ -250,6 +288,7 @@ def test_bgp_conditional_advertisement():
             "192.0.2.1/32": [{"protocol": "bgp"}],
             "192.0.2.5/32": None,
             "10.139.224.0/20": [{"protocol": "bgp"}],
+            "203.0.113.1/32": None,
         }
         return topotest.json_cmp(output, expected)
 
@@ -274,6 +313,68 @@ def test_bgp_conditional_advertisement():
     def _non_exist_map_routes_not_present_no_rmap_filter(router):
         return _non_exist_map_routes_not_present(router)
 
+    # BGP conditional advertisement with route-maps
+    # EXIST-MAP, ADV-MAP-2 and RMAP-2
+    def _exist_map_routes_not_present_rmap2_filter(router):
+        return _all_routes_withdrawn(router)
+
+    def _exist_map_routes_not_present_no_rmap2_filter(router):
+        output = json.loads(router.vtysh_cmd("show ip route json"))
+        expected = {
+            "0.0.0.0/0": None,
+            "192.0.2.1/32": [{"protocol": "bgp"}],
+            "192.0.2.5/32": [{"protocol": "bgp"}],
+            "10.139.224.0/20": [{"protocol": "bgp"}],
+            "203.0.113.1/32": None,
+        }
+        return topotest.json_cmp(output, expected)
+
+    def _non_exist_map_routes_not_present_rmap2_filter(router):
+        output = json.loads(router.vtysh_cmd("show ip route json"))
+        expected = {
+            "0.0.0.0/0": None,
+            "192.0.2.1/32": None,
+            "192.0.2.5/32": None,
+            "10.139.224.0/20": None,
+            "203.0.113.1/32": [{"protocol": "bgp"}],
+        }
+        return topotest.json_cmp(output, expected)
+
+    def _non_exist_map_routes_not_present_no_rmap2_filter(router):
+        return _non_exist_map_routes_not_present(router)
+
+    def _exist_map_routes_present_rmap2_filter(router):
+        return _non_exist_map_routes_not_present_rmap2_filter(router)
+
+    def _exist_map_routes_present_no_rmap2_filter(router):
+        return _all_routes_advertised(router)
+
+    def _non_exist_map_routes_present_rmap2_filter(router):
+        return _all_routes_withdrawn(router)
+
+    def _non_exist_map_routes_present_no_rmap2_filter(router):
+        output = json.loads(router.vtysh_cmd("show ip route json"))
+        expected = {
+            "0.0.0.0/0": [{"protocol": "bgp"}],
+            "192.0.2.1/32": [{"protocol": "bgp"}],
+            "192.0.2.5/32": [{"protocol": "bgp"}],
+            "10.139.224.0/20": [{"protocol": "bgp"}],
+            "203.0.113.1/32": None,
+        }
+        return topotest.json_cmp(output, expected)
+
+    def _exist_map_routes_present_rmap2_network(router):
+        return _non_exist_map_routes_not_present_rmap2_filter(router)
+
+    def _exist_map_routes_present_rmap2_no_network(router):
+        return _all_routes_withdrawn(router)
+
+    def _non_exist_map_routes_not_present_rmap2_network(router):
+        return _non_exist_map_routes_not_present_rmap2_filter(router)
+
+    def _non_exist_map_routes_not_present_rmap2_no_network(router):
+        return _all_routes_withdrawn(router)
+
     # TC11: R3 BGP convergence, without advertise-map configuration.
     # All routes are advertised to R3.
     test_func = functools.partial(_all_routes_advertised, router3)
@@ -291,7 +392,7 @@ def test_bgp_conditional_advertisement():
           configure terminal
             router bgp 2
               address-family ipv4 unicast
-               neighbor 10.10.20.3 advertise-map ADV-MAP exist-map EXIST-MAP
+               neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
         """
     )
 
@@ -329,7 +430,7 @@ def test_bgp_conditional_advertisement():
           configure terminal
             router bgp 2
               address-family ipv4 unicast
-               neighbor 10.10.20.3 advertise-map ADV-MAP non-exist-map EXIST-MAP
+               neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
         """
     )
 
@@ -384,7 +485,7 @@ def test_bgp_conditional_advertisement():
           configure terminal
             router bgp 2
               address-family ipv4 unicast
-               neighbor 10.10.20.3 advertise-map ADV-MAP exist-map EXIST-MAP
+               neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
         """
     )
 
@@ -405,12 +506,9 @@ def test_bgp_conditional_advertisement():
             match community DEFAULT-ROUTE
             match ip address prefix-list DEFAULT-ROUTE
            !
-           route-map RMAP deny 10
-            match ip address prefix-list IP1
-           !
            router bgp 2
             address-family ipv4 unicast
-             neighbor 10.10.20.3 route-map RMAP out
+             neighbor 10.10.20.3 route-map RMAP-1 out
         """
     )
 
@@ -429,7 +527,7 @@ def test_bgp_conditional_advertisement():
           configure terminal
            router bgp 2
             address-family ipv4 unicast
-             no neighbor 10.10.20.3 route-map RMAP out
+             no neighbor 10.10.20.3 route-map RMAP-1 out
         """
     )
 
@@ -448,8 +546,8 @@ def test_bgp_conditional_advertisement():
           configure terminal
             router bgp 2
               address-family ipv4 unicast
-               neighbor 10.10.20.3 route-map RMAP out
-               neighbor 10.10.20.3 advertise-map ADV-MAP non-exist-map EXIST-MAP
+               neighbor 10.10.20.3 route-map RMAP-1 out
+               neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
         """
     )
 
@@ -468,7 +566,7 @@ def test_bgp_conditional_advertisement():
           configure terminal
             router bgp 2
               address-family ipv4 unicast
-               no neighbor 10.10.20.3 route-map RMAP out
+               no neighbor 10.10.20.3 route-map RMAP-1 out
         """
     )
 
@@ -495,8 +593,8 @@ def test_bgp_conditional_advertisement():
           configure terminal
            router bgp 2
             address-family ipv4 unicast
-             neighbor 10.10.20.3 route-map RMAP out
-             neighbor 10.10.20.3 advertise-map ADV-MAP exist-map EXIST-MAP
+             neighbor 10.10.20.3 route-map RMAP-1 out
+             neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
         """
     )
 
@@ -515,7 +613,7 @@ def test_bgp_conditional_advertisement():
           configure terminal
            router bgp 2
             address-family ipv4 unicast
-             no neighbor 10.10.20.3 route-map RMAP out
+             no neighbor 10.10.20.3 route-map RMAP-1 out
         """
     )
 
@@ -534,8 +632,8 @@ def test_bgp_conditional_advertisement():
           configure terminal
            router bgp 2
             address-family ipv4 unicast
-             neighbor 10.10.20.3 route-map RMAP out
-             neighbor 10.10.20.3 advertise-map ADV-MAP non-exist-map EXIST-MAP
+             neighbor 10.10.20.3 route-map RMAP-1 out
+             neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
         """
     )
 
@@ -556,7 +654,7 @@ def test_bgp_conditional_advertisement():
           configure terminal
            router bgp 2
             address-family ipv4 unicast
-             no neighbor 10.10.20.3 route-map RMAP out
+             no neighbor 10.10.20.3 route-map RMAP-1 out
         """
     )
 
@@ -570,6 +668,284 @@ def test_bgp_conditional_advertisement():
 
     logger.info(msg + passed)
 
+    # TC71: exist-map routes present in R2's BGP table, with route-map filter.
+    # All routes are withdrawn from R3 except advertise-map routes.
+    router1.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 1
+            address-family ipv4 unicast
+             network 0.0.0.0/0 route-map DEF
+        """
+    )
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             neighbor 10.10.20.3 route-map RMAP-2 out
+             neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
+        """
+    )
+
+    test_func = functools.partial(_exist_map_routes_present_rmap2_filter, router3)
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC71: exist-map routes present, route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC72: exist-map routes present in R2's BGP table, without route-map filter.
+    # All routes are advertised to R3 including advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             no neighbor 10.10.20.3 route-map RMAP-2 out
+        """
+    )
+
+    test_func = functools.partial(_exist_map_routes_present_no_rmap2_filter, router3)
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC72: exist-map routes present, no route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
+    # All routes are advertised to R3 including advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             neighbor 10.10.20.3 route-map RMAP-2 out
+             neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
+        """
+    )
+
+    test_func = functools.partial(_non_exist_map_routes_present_rmap2_filter, router3)
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC73: non-exist-map routes present, route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
+    # All routes are advertised to R3 including advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             no neighbor 10.10.20.3 route-map RMAP-2 out
+        """
+    )
+
+    test_func = functools.partial(
+        _non_exist_map_routes_present_no_rmap2_filter, router3
+    )
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC74: non-exist-map routes present, no route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC81: exist-map routes not present in R2's BGP table, with route-map filter.
+    # All routes are withdrawn from R3 including advertise-map routes.
+    router1.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 1
+            address-family ipv4 unicast
+             no network 0.0.0.0/0 route-map DEF
+        """
+    )
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             neighbor 10.10.20.3 route-map RMAP-2 out
+             neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
+        """
+    )
+
+    test_func = functools.partial(_exist_map_routes_not_present_rmap2_filter, router3)
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC81: exist-map routes not present, route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC82: exist-map routes not present in R2's BGP table, without route-map filter.
+    # All routes are advertised to R3 except advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             no neighbor 10.10.20.3 route-map RMAP-2 out
+        """
+    )
+
+    test_func = functools.partial(
+        _exist_map_routes_not_present_no_rmap2_filter, router3
+    )
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC82: exist-map routes not present, no route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
+    # All routes are advertised to R3 including advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             neighbor 10.10.20.3 route-map RMAP-2 out
+             neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
+        """
+    )
+
+    test_func = functools.partial(
+        _non_exist_map_routes_not_present_rmap2_filter, router3
+    )
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC83: non-exist-map routes not present, route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
+    # All routes are advertised to R3 including advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             no neighbor 10.10.20.3 route-map RMAP-2 out
+        """
+    )
+
+    test_func = functools.partial(
+        _non_exist_map_routes_not_present_no_rmap2_filter, router3
+    )
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC84: non-exist-map routes not present, no route-map filter - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
+    # All routes are advertised to R3 including advertise-map routes.
+    router1.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 1
+            address-family ipv4 unicast
+             network 0.0.0.0/0 route-map DEF
+        """
+    )
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             neighbor 10.10.20.3 route-map RMAP-2 out
+             neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
+        """
+    )
+
+    test_func = functools.partial(_exist_map_routes_present_rmap2_network, router3)
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC91: exist-map routes present, route-map filter and network - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
+    # All routes are advertised to R3 except advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             no network 203.0.113.1/32
+        """
+    )
+
+    test_func = functools.partial(_exist_map_routes_present_rmap2_no_network, router3)
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC92: exist-map routes present, route-map filter and no network - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
+    # All routes are advertised to R3 including advertise-map routes.
+    router1.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 1
+            address-family ipv4 unicast
+             no network 0.0.0.0/0 route-map DEF
+        """
+    )
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             network 203.0.113.1/32
+             neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
+        """
+    )
+
+    test_func = functools.partial(
+        _non_exist_map_routes_not_present_rmap2_network, router3
+    )
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC93: non-exist-map routes not present, route-map filter and network - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
+    # TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
+    # All routes are advertised to R3 except advertise-map routes.
+    router2.vtysh_cmd(
+        """
+          configure terminal
+           router bgp 2
+            address-family ipv4 unicast
+             no network 203.0.113.1/32
+        """
+    )
+
+    test_func = functools.partial(
+        _non_exist_map_routes_not_present_rmap2_no_network, router3
+    )
+    success, result = topotest.run_and_expect(test_func, None, count=90, wait=1)
+
+    msg = "TC94: non-exist-map routes not present, route-map filter and no network - "
+    assert result is None, msg + failed
+
+    logger.info(msg + passed)
+
 
 def test_memory_leak():
     "Run the memory leak test and report results."