return 1;
/*
- * If path is learnt from an interface based peer,
+ * If it's a V6 nexthop, path is learnt from a v6 LL peer,
+ * and if the NH prefix matches peer's LL address then
* set the ifindex to peer's interface index so that
* correct nexthop can be found in nexthop tree.
+ *
+ * NH could be set to different v6 LL address (compared to
+ * peer's LL) using route-map. In such a scenario, do not set
+ * the ifindex.
*/
- if (pi->peer->conf_if)
+ if (afi == AFI_IP6 &&
+ IN6_IS_ADDR_LINKLOCAL(&pi->peer->su.sin6.sin6_addr) &&
+ IPV6_ADDR_SAME(&pi->peer->su.sin6.sin6_addr, &p.u.prefix6))
ifindex = pi->peer->su.sin6.sin6_scope_id;
if (!is_bgp_static_route && orig_prefix
no bgp ebgp-requires-policy
neighbor r4-eth0 interface remote-as internal
!
+address-family ipv4 unicast
+ neighbor r4-eth0 route-map FOO in
+exit-address-family
+!
+route-map FOO permit 10
+ set ipv6 next-hop local fe80::202:ff:fe00:99
+exit
return topotest.json_cmp(output, expected)
+ def _bgp_verify_nexthop_validity():
+ output = json.loads(tgen.gears["r4"].vtysh_cmd("show bgp nexthop json"))
+
+ expected = {
+ "ipv6": {
+ "fe80::202:ff:fe00:99": {
+ "valid": True,
+ "complete": True,
+ "igpMetric": 0,
+ "pathCount": 2,
+ "nexthops": [{"interfaceName": "r4-eth0"}],
+ },
+ }
+ }
+
+ return topotest.json_cmp(output, expected)
+
test_func = functools.partial(_bgp_converge)
success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
)
step("Check if 172.16.255.254/32 is advertised to iBGP peers")
-
test_func = functools.partial(_bgp_no_advertise_ibgp)
success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
tgen.gears["r2"]
)
+ step("Verify if the nexthop set via route-map on r4 is marked valid")
+ test_func = functools.partial(_bgp_verify_nexthop_validity)
+ success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert result is None, 'Nexthops are not valid "{}"'.format(tgen.gears["r4"])
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
}
return topotest.json_cmp(output, expected)
+ def _bgp_verify_v4_nexthop_validity():
+ output = json.loads(tgen.gears["cpe1"].vtysh_cmd("show bgp nexthop json"))
+ expected = {
+ "ipv4": {
+ "192.168.1.2": {
+ "valid": True,
+ "complete": True,
+ "igpMetric": 0,
+ "pathCount": 0,
+ "nexthops": [{"interfaceName": "cpe1-eth0"}],
+ },
+ }
+ }
+ return topotest.json_cmp(output, expected)
+
+ def _bgp_verify_v6_global_nexthop_validity():
+ output = json.loads(tgen.gears["pe2"].vtysh_cmd("show bgp nexthop json"))
+ expected = {
+ "ipv6": {
+ "2001:db8::1": {
+ "valid": True,
+ "complete": True,
+ "igpMetric": 0,
+ "pathCount": 2,
+ "nexthops": [{"interfaceName": "pe2-eth0"}],
+ },
+ "2001:db8:1::1": {
+ "valid": True,
+ "complete": True,
+ "igpMetric": 20,
+ "pathCount": 2,
+ "peer": "2001:db8:1::1",
+ "nexthops": [{"interfaceName": "pe2-eth0"}],
+ },
+ }
+ }
+ return topotest.json_cmp(output, expected)
+
test_func = functools.partial(_bgp_vpn_nexthop_changed)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result is None, "Failed overriding IPv6 next-hop for VPN underlay"
+ test_func = functools.partial(_bgp_verify_v4_nexthop_validity)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert result is None, "IPv4 nexthop is invalid"
+
+ test_func = functools.partial(_bgp_verify_v6_global_nexthop_validity)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert result is None, "IPv6 nexthop is invalid"
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]