aboutsummaryrefslogtreecommitdiff
path: root/tests/atf_python
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2022-08-06 10:36:12 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-01-13 21:24:11 +0000
commit7d15b0f2e42ea623bd42c987ee70335b6d005af8 (patch)
tree283e3e745271066493cf250fc740286b0bb562f8 /tests/atf_python
parent23dcc3104b993cb84fdf2a17407a5f2fc8c76103 (diff)
Diffstat (limited to 'tests/atf_python')
-rw-r--r--tests/atf_python/sys/net/tools.py15
-rw-r--r--tests/atf_python/sys/net/vnet.py8
2 files changed, 20 insertions, 3 deletions
diff --git a/tests/atf_python/sys/net/tools.py b/tests/atf_python/sys/net/tools.py
index c67941b414fc..23bb5f4b4128 100644
--- a/tests/atf_python/sys/net/tools.py
+++ b/tests/atf_python/sys/net/tools.py
@@ -41,7 +41,7 @@ class ToolsHelper(object):
def get_routes(cls, family: str, fibnum: int = 0):
family_key = {"inet": "-4", "inet6": "-6"}.get(family)
out = cls.get_output(
- "{} {} -rn -F {} --libxo json".format(cls.NETSTAT_PATH, family_key, fibnum)
+ "{} {} -rnW -F {} --libxo json".format(cls.NETSTAT_PATH, family_key, fibnum)
)
js = json.loads(out)
js = js["statistics"]["route-information"]["route-table"]["rt-family"]
@@ -51,6 +51,19 @@ class ToolsHelper(object):
return []
@classmethod
+ def get_nhops(cls, family: str, fibnum: int = 0):
+ family_key = {"inet": "-4", "inet6": "-6"}.get(family)
+ out = cls.get_output(
+ "{} {} -onW -F {} --libxo json".format(cls.NETSTAT_PATH, family_key, fibnum)
+ )
+ js = json.loads(out)
+ js = js["statistics"]["route-nhop-information"]["nhop-table"]["rt-family"]
+ if js:
+ return js[0]["nh-entry"]
+ else:
+ return []
+
+ @classmethod
def get_linklocals(cls):
ret = {}
ifname = None
diff --git a/tests/atf_python/sys/net/vnet.py b/tests/atf_python/sys/net/vnet.py
index 663f7695a0cc..0d9f969b28d9 100644
--- a/tests/atf_python/sys/net/vnet.py
+++ b/tests/atf_python/sys/net/vnet.py
@@ -101,11 +101,15 @@ class VnetInterface(object):
addr = ipaddress.ip_interface(_addr)
if addr.version == 6:
family = "inet6"
+ cmd = "/sbin/ifconfig {} {} {}".format(self.name, family, addr)
else:
family = "inet"
- cmd = "/sbin/ifconfig {} {} {}".format(self.name, family, addr)
+ if self.addr_map[family]:
+ cmd = "/sbin/ifconfig {} alias {}".format(self.name, addr)
+ else:
+ cmd = "/sbin/ifconfig {} {} {}".format(self.name, family, addr)
self.run_cmd(cmd)
- self.addr_map[family][str(addr)] = addr
+ self.addr_map[family][str(addr.ip)] = addr
def delete_addr(self, _addr: str):
addr = ipaddress.ip_address(_addr)