Commit d6332b1bee for frr
commit d6332b1bee9fd773d00727ece22ea3bd1da8c114
Author: Donald Sharp <sharpd@nvidia.com>
Date: Wed Dec 2 20:52:45 2026 -0500
tests: Convert usage of ping to generate_neighbor
Fix the topotests that are directly calling ping to
use generate_neighbor for when they are attempting
to create a neighbor entry instead of the results
of a ping.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
diff --git a/tests/topotests/bgp_evpn_mac_move_back/common_bgp_evpn_mac_move_back.py b/tests/topotests/bgp_evpn_mac_move_back/common_bgp_evpn_mac_move_back.py
index dd564fd12d..9f3385022a 100644
--- a/tests/topotests/bgp_evpn_mac_move_back/common_bgp_evpn_mac_move_back.py
+++ b/tests/topotests/bgp_evpn_mac_move_back/common_bgp_evpn_mac_move_back.py
@@ -35,6 +35,7 @@ import functools
import os
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.common_config import kill_router_daemons, start_router_daemons
from lib.topogen import Topogen, get_topogen
from lib.topolog import logger
@@ -171,7 +172,7 @@ def teardown(mod):
def talk(host):
"""Make the host send a frame (an ARP request) so its PE learns the MAC."""
- get_topogen().net[host].cmd(f"ping -c 2 -i 0.2 -W 1 {PING_TARGET[host]}")
+ generate_neighbor(host, PING_TARGET[host], count=2)
def _zebra_mac(pe, vni):
diff --git a/tests/topotests/bgp_evpn_mh_v4_v6_num/test_evpn_mh_v4_v6_num.py b/tests/topotests/bgp_evpn_mh_v4_v6_num/test_evpn_mh_v4_v6_num.py
index 27d4cdd91d..dede46d457 100644
--- a/tests/topotests/bgp_evpn_mh_v4_v6_num/test_evpn_mh_v4_v6_num.py
+++ b/tests/topotests/bgp_evpn_mh_v4_v6_num/test_evpn_mh_v4_v6_num.py
@@ -20,7 +20,6 @@ This is an IPv6 VTEP variant with EBGP numbered peering and unified FRR config
import os
import sys
-import subprocess
from functools import partial
from ipaddress import ip_network
@@ -44,6 +43,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.common_config import kill_router_daemons, start_router_daemons
from lib.evpn import (
evpn_verify_bgp_es_vtep,
@@ -1323,21 +1323,9 @@ def test_evpn_mh_peer_withdraw_during_bgpd_restart(tgen_and_ip_version):
def ping_anycast_gw(tgen):
# ping the anycast gw from the local and remote hosts to populate
# the mac address on the PEs
- intf = "torbond"
- ipaddr = "2001:db8:45::1"
- cmd_tmpl = "ping6 -I {} -c 1 {}"
- if active_ip_version == "ipv4":
- ipaddr = "45.0.0.1"
- cmd_tmpl = "ping -I {} -c 1 {}"
+ ipaddr = "45.0.0.1" if active_ip_version == "ipv4" else "2001:db8:45::1"
for name in ("hostd11", "hostd21", "hostd12", "hostd22"):
- host = tgen.net.hosts[name]
- ping_cmd = cmd_tmpl.format(intf, ipaddr)
- _, stdout, _ = host.cmd_status(ping_cmd, warn=False, stderr=subprocess.STDOUT)
- stdout = stdout.strip()
- if stdout:
- host.logger.debug(
- "%s: ping6 on %s for %s returned: %s", name, intf, ipaddr, stdout
- )
+ generate_neighbor(name, ipaddr, source_addr="torbond")
def check_mac(dut, vni, mac, m_type, esi, intf, ping_gw=False, tgen=None):
diff --git a/tests/topotests/bgp_evpn_overlay_index_gateway_irb/test_bgp_evpn_overlay_index_gateway_irb.py b/tests/topotests/bgp_evpn_overlay_index_gateway_irb/test_bgp_evpn_overlay_index_gateway_irb.py
index e01b2d9907..a973addb47 100644
--- a/tests/topotests/bgp_evpn_overlay_index_gateway_irb/test_bgp_evpn_overlay_index_gateway_irb.py
+++ b/tests/topotests/bgp_evpn_overlay_index_gateway_irb/test_bgp_evpn_overlay_index_gateway_irb.py
@@ -66,6 +66,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.topogen import Topogen, get_topogen
from lib.topolog import logger
@@ -256,10 +257,8 @@ def _learn_host(tgen):
Have h2 talk to r2 so that r2 learns h2's MAC and IPs as local
neighbors and advertises them in type-2 routes.
"""
- h2 = tgen.net["h2"]
- for afi, _, _, r2_svi in ROUTES:
- ping = "ping" if afi == "ip" else "ping -6"
- h2.cmd("{} -c 3 -i 0.2 -W 1 {}".format(ping, r2_svi))
+ for _, _, _, r2_svi in ROUTES:
+ generate_neighbor("h2", r2_svi, count=3)
def _check_host_macip(router, ip, local, vni=100):
diff --git a/tests/topotests/bgp_evpn_vxlan_local_address/test_bgp_evpn_vxlan_implicit_local.py b/tests/topotests/bgp_evpn_vxlan_local_address/test_bgp_evpn_vxlan_implicit_local.py
index a6c5e0f9ac..9d3ac7b9eb 100644
--- a/tests/topotests/bgp_evpn_vxlan_local_address/test_bgp_evpn_vxlan_implicit_local.py
+++ b/tests/topotests/bgp_evpn_vxlan_local_address/test_bgp_evpn_vxlan_implicit_local.py
@@ -25,6 +25,7 @@ CWD = os.path.dirname(os.path.realpath(__file__))
# pylint: disable=C0413
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.topolog import logger
from lib.topogen import Topogen, get_topogen
@@ -342,9 +343,8 @@ def test_bgp_evpn_rt2_nexthop():
pytest.skip(tgen.errors)
for hname in ("h1", "h2"):
- host = tgen.gears[hname]
- host.cmd("ping -c 1 192.168.0.254")
- host.cmd("ping -c 1 2001:db8::ff")
+ generate_neighbor(hname, "192.168.0.254")
+ generate_neighbor(hname, "2001:db8::ff")
for rname in ("vtep1", "vtep2"):
router = tgen.gears[rname]
diff --git a/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo.py b/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo.py
index a1ea1eaeb5..66b5423235 100755
--- a/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo.py
+++ b/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo.py
@@ -32,6 +32,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.evpn import (
evpn_check_vni_macs_present,
evpn_ip_learn_test,
@@ -215,10 +216,8 @@ def test_pe1_converge_evpn():
# each other. Otherwise under certain startup conditions
# they may not actually do any l2 arp'ing and as such
# the bridges won't know about the hosts on their networks
- host1 = tgen.gears["host1"]
- host1.run("ping -c 1 10.10.1.56")
- host2 = tgen.gears["host2"]
- host2.run("ping -c 1 10.10.1.55")
+ generate_neighbor("host1", "10.10.1.56")
+ generate_neighbor("host2", "10.10.1.55")
test_func = partial(
evpn_check_vni_macs_present,
@@ -330,7 +329,7 @@ def test_ip_pe1_learn():
# pe2.vtysh_cmd("debug zebra vxlan")
# pe2.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host1.run("ping -c1 10.10.1.1")
+ generate_neighbor("host1", "10.10.1.1")
evpn_ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55")
# tgen.mininet_cli()
@@ -349,7 +348,7 @@ def test_ip_pe2_learn():
# pe1.vtysh_cmd("debug zebra vxlan")
# pe1.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host2.run("ping -c1 10.10.1.3")
+ generate_neighbor("host2", "10.10.1.3")
evpn_ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56")
# tgen.mininet_cli()
@@ -570,8 +569,8 @@ def test_macvrf_soo():
host2_neigh_rt_str, _, _ = get_evpn_rt_json_str(*host2_neigh_parms)
## trigger mac/arp learn
- host1.run("ping -c1 10.10.1.1")
- host2.run("ping -c1 10.10.1.3")
+ generate_neighbor("host1", "10.10.1.1")
+ generate_neighbor("host2", "10.10.1.3")
step("Test pe2/host2 routes are installed on pe1 (global/l2vni)")
diff --git a/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo_v6_vtep.py b/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo_v6_vtep.py
index 833af6e6b6..a4de460faf 100755
--- a/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo_v6_vtep.py
+++ b/tests/topotests/bgp_evpn_vxlan_macvrf_soo_topo1/test_bgp_evpn_vxlan_macvrf_soo_v6_vtep.py
@@ -32,6 +32,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.evpn import (
evpn_check_vni_macs_present,
evpn_ip_learn_test,
@@ -216,10 +217,8 @@ def test_pe1_converge_evpn():
# each other. Otherwise under certain startup conditions
# they may not actually do any l2 arp'ing and as such
# the bridges won't know about the hosts on their networks
- host1 = tgen.gears["host1"]
- host1.run("ping -c 1 10.10.1.56")
- host2 = tgen.gears["host2"]
- host2.run("ping -c 1 10.10.1.55")
+ generate_neighbor("host1", "10.10.1.56")
+ generate_neighbor("host2", "10.10.1.55")
test_func = partial(
evpn_check_vni_macs_present,
@@ -331,7 +330,7 @@ def test_ip_pe1_learn():
# pe2.vtysh_cmd("debug zebra vxlan")
# pe2.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host1.run("ping -c1 10.10.1.1")
+ generate_neighbor("host1", "10.10.1.1")
evpn_ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55")
# tgen.mininet_cli()
@@ -350,7 +349,7 @@ def test_ip_pe2_learn():
# pe1.vtysh_cmd("debug zebra vxlan")
# pe1.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host2.run("ping -c1 10.10.1.3")
+ generate_neighbor("host2", "10.10.1.3")
evpn_ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56")
# tgen.mininet_cli()
@@ -525,8 +524,8 @@ def test_macvrf_soo():
host2_neigh_rt_str, _, _ = get_evpn_rt_json_str(*host2_neigh_parms)
## trigger mac/arp learn
- host1.run("ping -c1 10.10.1.1")
- host2.run("ping -c1 10.10.1.3")
+ generate_neighbor("host1", "10.10.1.1")
+ generate_neighbor("host2", "10.10.1.3")
step("Test pe2/host2 routes are installed on pe1 (global/l2vni)")
diff --git a/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py b/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py
index fba1ac376d..61e3baef53 100755
--- a/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py
+++ b/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py
@@ -40,6 +40,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.evpn import (
evpn_check_vni_macs_present,
evpn_ip_learn_test,
@@ -271,10 +272,8 @@ def test_pe1_converge_evpn():
# each other. Otherwise under certain startup conditions
# they may not actually do any l2 arp'ing and as such
# the bridges won't know about the hosts on their networks
- host1 = tgen.gears["host1"]
- host1.run("ping -c 1 10.10.1.56")
- host2 = tgen.gears["host2"]
- host2.run("ping -c 1 10.10.1.55")
+ generate_neighbor("host1", "10.10.1.56")
+ generate_neighbor("host2", "10.10.1.55")
test_func = partial(
evpn_check_vni_macs_present,
@@ -455,7 +454,7 @@ def test_ip_pe1_learn():
# pe2.vtysh_cmd("debug zebra vxlan")
# pe2.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host1.run("ping -c1 10.10.1.1")
+ generate_neighbor("host1", "10.10.1.1")
evpn_ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55")
# tgen.mininet_cli()
@@ -474,7 +473,7 @@ def test_ip_pe2_learn():
# pe1.vtysh_cmd("debug zebra vxlan")
# pe1.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host2.run("ping -c1 10.10.1.3")
+ generate_neighbor("host2", "10.10.1.3")
evpn_ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56")
# tgen.mininet_cli()
diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py
index e6cac248b4..8b0de2e063 100755
--- a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py
+++ b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py
@@ -25,6 +25,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.evpn import (
evpn_check_vni_macs_present,
evpn_mac_learn_test,
@@ -204,10 +205,8 @@ def test_pe1_converge_evpn():
# each other. Otherwise under certain startup conditions
# they may not actually do any l2 arp'ing and as such
# the bridges won't know about the hosts on their networks
- host1 = tgen.gears["host1"]
- host1.run("ping -c 1 10.10.1.56")
- host2 = tgen.gears["host2"]
- host2.run("ping -c 1 10.10.1.55")
+ generate_neighbor("host1", "10.10.1.56")
+ generate_neighbor("host2", "10.10.1.55")
test_func = partial(
evpn_check_vni_macs_present,
@@ -416,7 +415,7 @@ def test_ip_pe1_learn():
# pe2.vtysh_cmd("debug zebra vxlan")
# pe2.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host1.run("ping -c1 10.10.1.1")
+ generate_neighbor("host1", "10.10.1.1")
ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55")
# tgen.mininet_cli()
@@ -435,7 +434,7 @@ def test_ip_pe2_learn():
# pe1.vtysh_cmd("debug zebra vxlan")
# pe1.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host2.run("ping -c1 10.10.1.3")
+ generate_neighbor("host2", "10.10.1.3")
ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56")
# tgen.mininet_cli()
@@ -976,11 +975,10 @@ def test_remote_neigh_uninstall_on_vxlan_down():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- host1 = tgen.gears["host1"]
pe1 = tgen.gears["PE1"]
# Trigger ARP/neighbor learning for the remote host
- host1.run("ping -c1 10.10.1.56")
+ generate_neighbor("host1", "10.10.1.56")
test_func = partial(_ip_neigh_has_entry, pe1, "br101", "10.10.1.56", True)
_, result = topotest.run_and_expect(test_func, True, count=20, wait=3)
diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan_v6_vtep.py b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan_v6_vtep.py
index 866f8f2b88..4fa7dcd33d 100755
--- a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan_v6_vtep.py
+++ b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan_v6_vtep.py
@@ -28,6 +28,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.evpn import (
evpn_check_vni_macs_present,
evpn_ip_learn_test,
@@ -171,10 +172,8 @@ def test_pe1_converge_evpn():
# each other. Otherwise under certain startup conditions
# they may not actually do any l2 arp'ing and as such
# the bridges won't know about the hosts on their networks
- host1 = tgen.gears["host1"]
- host1.run("ping -c 1 10.10.1.56")
- host2 = tgen.gears["host2"]
- host2.run("ping -c 1 10.10.1.55")
+ generate_neighbor("host1", "10.10.1.56")
+ generate_neighbor("host2", "10.10.1.55")
test_func = partial(
evpn_check_vni_macs_present,
@@ -288,7 +287,7 @@ def test_ip_pe1_learn():
# pe2.vtysh_cmd("debug zebra vxlan")
# pe2.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host1.run("ping -c1 10.10.1.1")
+ generate_neighbor("host1", "10.10.1.1")
evpn_ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55")
# tgen.mininet_cli()
@@ -307,7 +306,7 @@ def test_ip_pe2_learn():
# pe1.vtysh_cmd("debug zebra vxlan")
# pe1.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
- host2.run("ping -c1 10.10.1.3")
+ generate_neighbor("host2", "10.10.1.3")
evpn_ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56")
# tgen.mininet_cli()
diff --git a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
index 6bf0aa9ca7..159bfa7724 100644
--- a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
+++ b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
@@ -18,6 +18,7 @@ import time
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
+from lib.checkping import generate_neighbor
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from lib.common_config import (
@@ -349,7 +350,7 @@ def test_local_map_neighbor():
nhc1.cmd("ip route add 172.16.1.99/32 dev nhc1-gre0")
def _local_neighbor_probed():
- nhc1.cmd("ping -c 1 -W 1 172.16.1.99")
+ generate_neighbor("nhc1", "172.16.1.99")
output = nhc1.cmd("ip -s neigh show 172.16.1.99 dev nhc1-gre0")
return re.search(r"probes [1-9]", output) is not None