From 131153ea22aa3de94e36b2caf06d45068b0393de Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 27 May 2023 08:50:01 -0400 Subject: [PATCH 1/3] tests: Allow ping to run multiple times before failing the bgp_default_originate test brings up the topology and then immediately pings. Which sometimes fails. This is of course possible since the first ping might actually fail due to arp going on. So let's give it a second chance or two. Especially since the test, at this point, is just installing a default route. Signed-off-by: Donald Sharp --- .../test_bgp_default_originate_2links.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py b/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py index 8058823baf..75e66566b7 100644 --- a/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py +++ b/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py @@ -26,6 +26,7 @@ from time import sleep from lib.topogen import Topogen, get_topogen from lib.topojson import build_config_from_json from lib.topolog import logger +from lib import topotest from lib.bgp import ( verify_bgp_convergence, @@ -1559,8 +1560,14 @@ def test_verify_default_originate_with_2way_ecmp_p2(request): step("Ping R1 configure IPv4 and IPv6 loopback address from R2") pingaddr = topo["routers"]["r1"]["links"]["lo"]["ipv4"].split("/")[0] router = tgen.gears["r2"] - output = router.run("ping -c 4 -w 4 {}".format(pingaddr)) - assert " 0% packet loss" in output, "Ping R1->R2 FAILED" + + def ping_router(): + output = router.run("ping -c 4 -w 4 {}".format(pingaddr)) + logger.info(output) + if " 0% packet loss" not in output: + return False + + _, res = topotest.run_and_expect(ping_router, None, count=10, wait=1) logger.info("Ping from R1 to R2 ... success") step("Shuting up the active route") From 06504bea79e9b054dffb56374cc42054180e24c1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 28 May 2023 07:18:36 -0400 Subject: [PATCH 2/3] pimd: When doing json output do not output non-json strings When entering some show commands that use json in pimd when the interface cannot be found do not output non-json format in that case. Signed-off-by: Donald Sharp --- pimd/pim_cmd_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 75df09ec35..5b905a9536 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -2747,7 +2747,7 @@ void pim_show_interfaces_single(struct pim_instance *pim, struct vty *vty, } } - if (!found_ifname) + if (!found_ifname && !json) vty_out(vty, "%% No such interface\n"); } @@ -3200,7 +3200,7 @@ void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty, } } - if (!found_neighbor) + if (!found_neighbor && !json) vty_out(vty, "%% No such interface or neighbor\n"); } From 46d725f76b4ae045f0930fe310dbbcf8d8280bb4 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 28 May 2023 10:13:16 -0400 Subject: [PATCH 3/3] lib, zebra: Ensure that the ifp->node exists On removal, ensure that the ifp->node is set to a null pointer so that FRR does not use data after freed. In addition ensure that the ifp->node exists before attempting to free it. Signed-off-by: Donald Sharp --- lib/if.c | 1 + zebra/interface.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/if.c b/lib/if.c index 08d8918742..6f567861d1 100644 --- a/lib/if.c +++ b/lib/if.c @@ -1028,6 +1028,7 @@ void if_terminate(struct vrf *vrf) if (ifp->node) { ifp->node->info = NULL; route_unlock_node(ifp->node); + ifp->node = NULL; } if_delete(&ifp); } diff --git a/zebra/interface.c b/zebra/interface.c index 231ddc51db..ccf1a0a204 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -267,6 +267,9 @@ struct interface *if_link_per_ns(struct zebra_ns *ns, struct interface *ifp) /* Delete a VRF. This is called in vrf_terminate(). */ void if_unlink_per_ns(struct interface *ifp) { + if (!ifp->node) + return; + ifp->node->info = NULL; route_unlock_node(ifp->node); ifp->node = NULL;