Skip to content

Commit

Permalink
ntttcp: Add BSD support for sysctl settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sharsonia committed Jul 21, 2023
1 parent a53db91 commit d34481a
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions lisa/tools/ntttcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
TransportProtocol,
create_perf_message,
)
from lisa.operating_system import CBLMariner
from lisa.operating_system import CBLMariner, FreeBSD
from lisa.tools import Firewall, Gcc, Git, Make, Sed
from lisa.util import constants
from lisa.util.process import ExecutableResult, Process
Expand Down Expand Up @@ -119,12 +119,23 @@ class Ntttcp(Tool):
{"vm.max_map_count": "655300"},
{"net.ipv4.ip_local_port_range": "1024 65535"},
]
freebsd_sys_list_tcp = [
{"kern.pid_max": "99999"},
{"vm.max_map_count": "2147483647"},
{"net.inet.ip.portrange.first": "10000"},
{"net.inet.ip.portrange.last": "65535"},
]
sys_list_udp = [
{"net.core.rmem_max": "67108864"},
{"net.core.rmem_default": "67108864"},
{"net.core.wmem_default": "67108864"},
{"net.core.wmem_max": "67108864"},
]
freebsd_sys_list_udp = [
{"kern.ipc.maxsockbuf": "67108864"},
{"net.inet.udp.recvspace": "67108864"},
{"net.inet.udp.sendspace": "67108864"},
]

@property
def dependencies(self) -> List[Type[Tool]]:
Expand All @@ -140,9 +151,17 @@ def can_install(self) -> bool:

def setup_system(self, udp_mode: bool = False, set_task_max: bool = True) -> None:
sysctl = self.node.tools[Sysctl]
sys_list = self.sys_list_tcp
sys_list: List[Dict[str, str]] = []
if isinstance(self.node.os, FreeBSD):
sys_list = self.freebsd_sys_list_tcp
else:
sys_list = self.sys_list_tcp
if udp_mode:
sys_list = self.sys_list_udp
if isinstance(self.node.os, FreeBSD):
sys_list = self.freebsd_sys_list_udp
else:
sys_list = self.sys_list_udp

for sys in sys_list:
for variable, value in sys.items():
sysctl.write(variable, value)
Expand Down Expand Up @@ -421,10 +440,19 @@ def _initialize(self, *args: Any, **kwargs: Any) -> None:
self._original_settings_tcp: List[Dict[str, str]] = []
self._original_settings_udp: List[Dict[str, str]] = []
sysctl = self.node.tools[Sysctl]
for tcp_sys in self.sys_list_tcp:
sys_list_tcp: List[Dict[str, str]] = []
sys_list_udp: List[Dict[str, str]] = []
if isinstance(self.node.os, FreeBSD):
sys_list_tcp = self.freebsd_sys_list_tcp
sys_list_udp = self.freebsd_sys_list_udp
else:
sys_list_tcp = self.sys_list_tcp
sys_list_udp = self.sys_list_udp

for tcp_sys in sys_list_tcp:
for variable, _ in tcp_sys.items():
self._original_settings_tcp.append({variable: sysctl.get(variable)})
for udp_sys in self.sys_list_udp:
for udp_sys in sys_list_udp:
for variable, _ in udp_sys.items():
self._original_settings_udp.append({variable: sysctl.get(variable)})

Expand Down

0 comments on commit d34481a

Please sign in to comment.