summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_conditional_adv.c58
-rw-r--r--bgpd/bgp_route.c52
-rw-r--r--bgpd/bgp_route.h2
-rw-r--r--bgpd/bgp_updgrp_adv.c3
-rw-r--r--bgpd/bgpd.c10
-rw-r--r--bgpd/bgpd.h2
-rw-r--r--tests/topotests/bgp_conditional_advertisement/r2/bgpd.conf15
-rw-r--r--tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py414
8 files changed, 504 insertions, 52 deletions
diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c
index 521c8056f..ff1eb2be2 100644
--- a/bgpd/bgp_conditional_adv.c
+++ b/bgpd/bgp_conditional_adv.c
@@ -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);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 307453147..366d96b3a 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -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;
}
}
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index f770f9cb8..206cc82b7 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -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,
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index ae1359ae4..ac77ccd8a 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -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;
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index db72eb177..cf16378de 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -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);
}
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 4eb5bdd01..74828e91d 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -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;
diff --git a/tests/topotests/bgp_conditional_advertisement/r2/bgpd.conf b/tests/topotests/bgp_conditional_advertisement/r2/bgpd.conf
index c8f4357f9..c6147fe65 100644
--- a/tests/topotests/bgp_conditional_advertisement/r2/bgpd.conf
+++ b/tests/topotests/bgp_conditional_advertisement/r2/bgpd.conf
@@ -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
diff --git a/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py b/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py
index e50988244..99cf08b4f 100644
--- a/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py
+++ b/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py
@@ -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."