mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
atf_python: support setting interface mtu
Teach the vnet support code to set interface MTU. Some tests make use of
this, so have the framework handle it.
Adapt a few pf tests to use this.
Reviewed by: melifaro
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D54333
This commit is contained in:
parent
3a4275a5f1
commit
4f35a84b32
4 changed files with 9 additions and 15 deletions
|
|
@ -109,6 +109,9 @@ class VnetInterface(object):
|
|||
ret.append(if2);
|
||||
return ret
|
||||
|
||||
def set_mtu(self, mtu):
|
||||
run_cmd("/sbin/ifconfig {} mtu {}".format(self.name, mtu))
|
||||
|
||||
def setup_addr(self, _addr: str):
|
||||
addr = ipaddress.ip_interface(_addr)
|
||||
if addr.version == 6:
|
||||
|
|
@ -370,6 +373,7 @@ class VnetTestTemplate(BaseTest):
|
|||
idx = iface_map.vnet_aliases.index(vnet.alias)
|
||||
prefixes6 = topo[iface.alias].get("prefixes6", [])
|
||||
prefixes4 = topo[iface.alias].get("prefixes4", [])
|
||||
mtu = topo[iface.alias].get("mtu", 0)
|
||||
if prefixes6 or prefixes4:
|
||||
ipv6_ifaces.append(iface)
|
||||
iface.turn_up()
|
||||
|
|
@ -378,6 +382,8 @@ class VnetTestTemplate(BaseTest):
|
|||
for prefix in prefixes6 + prefixes4:
|
||||
if prefix[idx]:
|
||||
iface.setup_addr(prefix[idx])
|
||||
if mtu != 0:
|
||||
iface.set_mtu(mtu)
|
||||
for iface in ipv6_ifaces:
|
||||
while iface.has_tentative():
|
||||
time.sleep(0.1)
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ class TestFrag6_RouteTo(VnetTestTemplate):
|
|||
"vnet2": {"ifaces": ["if1", "if2"]},
|
||||
"vnet3": {"ifaces": ["if2"]},
|
||||
"if1": {"prefixes6": [("2001:db8::1/64", "2001:db8::2/64")]},
|
||||
"if2": {"prefixes6": [("2001:db8:1::1/64", "2001:db8:1::2/64")]},
|
||||
"if2": {"prefixes6": [("2001:db8:1::1/64", "2001:db8:1::2/64")], "mtu": 1300},
|
||||
}
|
||||
|
||||
def vnet2_handler(self, vnet):
|
||||
|
|
@ -238,7 +238,6 @@ class TestFrag6_RouteTo(VnetTestTemplate):
|
|||
"pass in route-to (%s 2001:db8:1::2) from 2001:db8::1 to 2001:db8:666::1" % if2name,
|
||||
])
|
||||
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s mtu 1300" % if2name)
|
||||
ToolsHelper.print_output("/sbin/sysctl net.inet6.ip6.forwarding=1")
|
||||
|
||||
def vnet3_handler(self, vnet):
|
||||
|
|
|
|||
|
|
@ -43,13 +43,10 @@ class TestICMP(VnetTestTemplate):
|
|||
"vnet2": {"ifaces": ["if1", "if2"]},
|
||||
"vnet3": {"ifaces": ["if2"]},
|
||||
"if1": {"prefixes4": [("192.0.2.2/24", "192.0.2.1/24")]},
|
||||
"if2": {"prefixes4": [("198.51.100.1/24", "198.51.100.2/24")]},
|
||||
"if2": {"prefixes4": [("198.51.100.1/24", "198.51.100.2/24")], "mtu": 1492},
|
||||
}
|
||||
|
||||
def vnet2_handler(self, vnet):
|
||||
ifname = vnet.iface_alias_map["if1"].name
|
||||
if2name = vnet.iface_alias_map["if2"].name
|
||||
|
||||
ToolsHelper.print_output("/sbin/pfctl -e")
|
||||
ToolsHelper.pf_rules([
|
||||
"set reassemble yes",
|
||||
|
|
@ -61,8 +58,6 @@ class TestICMP(VnetTestTemplate):
|
|||
ToolsHelper.print_output("/sbin/sysctl net.inet.ip.forwarding=1")
|
||||
ToolsHelper.print_output("/sbin/pfctl -x loud")
|
||||
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s mtu 1492" % if2name)
|
||||
|
||||
def vnet3_handler(self, vnet):
|
||||
# Import in the correct vnet, so at to not confuse Scapy
|
||||
import scapy.all as sp
|
||||
|
|
@ -70,7 +65,6 @@ class TestICMP(VnetTestTemplate):
|
|||
ifname = vnet.iface_alias_map["if2"].name
|
||||
ToolsHelper.print_output("/sbin/route add default 198.51.100.1")
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s inet alias 198.51.100.3/24" % ifname)
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s mtu 1492" % ifname)
|
||||
|
||||
def checkfn(packet):
|
||||
icmp = packet.getlayer(sp.ICMP)
|
||||
|
|
|
|||
|
|
@ -39,13 +39,11 @@ class TestNAT66(VnetTestTemplate):
|
|||
"vnet1": {"ifaces": ["if1"]},
|
||||
"vnet2": {"ifaces": ["if1", "if2"]},
|
||||
"vnet3": {"ifaces": ["if2"]},
|
||||
"if1": {"prefixes6": [("2001:db8::2/64", "2001:db8::1/64")]},
|
||||
"if1": {"prefixes6": [("2001:db8::2/64", "2001:db8::1/64")], "mtu": 9000},
|
||||
"if2": {"prefixes6": [("2001:db8:1::1/64", "2001:db8:1::2/64")]},
|
||||
}
|
||||
|
||||
def vnet2_handler(self, vnet):
|
||||
ifname = vnet.iface_alias_map["if1"].name
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s mtu 9000" % ifname)
|
||||
outifname = vnet.iface_alias_map["if2"].name
|
||||
|
||||
ToolsHelper.print_output("/sbin/pfctl -e")
|
||||
|
|
@ -130,8 +128,6 @@ class TestNAT66(VnetTestTemplate):
|
|||
@pytest.mark.require_progs(["scapy"])
|
||||
def test_npt_icmp(self):
|
||||
cl_vnet = self.vnet_map["vnet1"]
|
||||
ifname = cl_vnet.iface_alias_map["if1"].name
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s mtu 9000" % ifname)
|
||||
|
||||
ToolsHelper.print_output("/sbin/route add -6 2001:db8:1::/64 2001:db8::1")
|
||||
|
||||
|
|
@ -160,7 +156,6 @@ class TestNAT66(VnetTestTemplate):
|
|||
def test_npt_route_to_icmp(self):
|
||||
cl_vnet = self.vnet_map["vnet1"]
|
||||
ifname = cl_vnet.iface_alias_map["if1"].name
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s mtu 9000" % ifname)
|
||||
ToolsHelper.print_output("/sbin/ifconfig %s inet6 alias 2001:db8::3/64" % ifname)
|
||||
|
||||
ToolsHelper.print_output("/sbin/route add -6 2001:db8:1::/64 2001:db8::1")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue