Commit 9c1c96b37e for frr
commit 9c1c96b37e4e69c4f8e15d86edb8e961a13f4783
Author: Donald Sharp <sharpd@nvidia.com>
Date: Fri Oct 2 13:18:35 2026 -0400
tests: Add freebsd side of shutdown_bringup_interface_in_kernel
Add a freebsd side to the shutdown_bringup_interface_in_kernel
so that we can use this everywhere.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index b6b3b20cce..8fd7f02bee 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -1814,18 +1814,25 @@ def delete_address_on_interface_freebsd(
def shutdown_bringup_interface_in_kernel(tgen, dut, intf_name, ifaceaction=False):
"""
- Cretae interfaces in kernel for ipv4/ipv6
- Config is done in Linux Kernel:
+ Shut down or bring up a kernel interface.
Parameters
----------
* `tgen` : Topogen object
- * `dut` : Device for which interfaces to be added
+ * `dut` : Device whose interface changes state
* `intf_name` : interface name
- * `ifaceaction` : False to shutdown and True to bringup the
- ineterface
+ * `ifaceaction` : False to shut the interface down, True to bring it up
"""
+ if sys.platform.startswith("freebsd"):
+ shutdown_bringup_interface_in_kernel_freebsd(tgen, dut, intf_name, ifaceaction)
+ else:
+ shutdown_bringup_interface_in_kernel_linux(tgen, dut, intf_name, ifaceaction)
+
+
+def shutdown_bringup_interface_in_kernel_linux(tgen, dut, intf_name, ifaceaction=False):
+ """Set a Linux interface administratively up or down."""
+
rnode = tgen.gears[dut]
cmd = "ip link set dev"
@@ -1840,6 +1847,16 @@ def shutdown_bringup_interface_in_kernel(tgen, dut, intf_name, ifaceaction=False
rnode.run(cmd)
+def shutdown_bringup_interface_in_kernel_freebsd(
+ tgen, dut, intf_name, ifaceaction=False
+):
+ """Set a FreeBSD interface administratively up or down."""
+
+ rnode = tgen.gears[dut]
+ action = "up" if ifaceaction else "down"
+ _freebsd_run(rnode, dut, ["/sbin/ifconfig", intf_name, action])
+
+
def validate_ip_address(ip_address):
"""
Validates the type of ip address