lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aA-2pwRo4pBjg7rm@LQ3V64L9R2>
Date: Mon, 28 Apr 2025 10:11:03 -0700
From: Joe Damato <jdamato@...tly.com>
To: David Wei <dw@...idwei.uk>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next v1 1/2] io_uring/zcrx: selftests: use rand_port()

On Sat, Apr 26, 2025 at 12:55:24PM -0700, David Wei wrote:
> Use rand_port() and stop hard coding port 9999.
> 
> Signed-off-by: David Wei <dw@...idwei.uk>
> ---
>  .../selftests/drivers/net/hw/iou-zcrx.py      | 48 ++++++++++++-------
>  1 file changed, 31 insertions(+), 17 deletions(-)
> 
> diff --git a/tools/testing/selftests/drivers/net/hw/iou-zcrx.py b/tools/testing/selftests/drivers/net/hw/iou-zcrx.py
> index c2977871ddaf..3962bf002ab6 100755
> --- a/tools/testing/selftests/drivers/net/hw/iou-zcrx.py
> +++ b/tools/testing/selftests/drivers/net/hw/iou-zcrx.py
> @@ -5,7 +5,7 @@ import re
>  from os import path
>  from lib.py import ksft_run, ksft_exit
>  from lib.py import NetDrvEpEnv
> -from lib.py import bkg, cmd, defer, ethtool, wait_port_listen
> +from lib.py import bkg, cmd, defer, ethtool, rand_port, wait_port_listen
>  
>  
>  def _get_current_settings(cfg):
> @@ -28,14 +28,14 @@ def _create_rss_ctx(cfg, chans):
>      return (ctx_id, defer(ethtool, f"-X {cfg.ifname} delete context {ctx_id}", host=cfg.remote))
>  
>  
> -def _set_flow_rule(cfg, chan):
> -    output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port 9999 action {chan}", host=cfg.remote).stdout
> +def _set_flow_rule(cfg, port, chan):
> +    output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} action {chan}", host=cfg.remote).stdout
>      values = re.search(r'ID (\d+)', output).group(1)
>      return int(values)
>  
>  
> -def _set_flow_rule_rss(cfg, chan):
> -    output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port 9999 action {chan}", host=cfg.remote).stdout
> +def _set_flow_rule_rss(cfg, port, chan):
> +    output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} action {chan}", host=cfg.remote).stdout
>      values = re.search(r'ID (\d+)', output).group(1)
>      return int(values)
>  
> @@ -47,22 +47,27 @@ def test_zcrx(cfg) -> None:
>      if combined_chans < 2:
>          raise KsftSkipEx('at least 2 combined channels required')
>      (rx_ring, hds_thresh) = _get_current_settings(cfg)
> +    port = rand_port()
>  
>      ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote)
> +
>      ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote)
> +
>      ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote)
> +
>      ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote)
>      defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote)
> -    flow_rule_id = _set_flow_rule(cfg, combined_chans - 1)
> +
> +    flow_rule_id = _set_flow_rule(cfg, port, combined_chans - 1)
>      defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote)
>  
> -    rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1}"
> -    tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 12840"
> +    rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}"
> +    tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 12840"
>      with bkg(rx_cmd, host=cfg.remote, exit_wait=True):
> -        wait_port_listen(9999, proto="tcp", host=cfg.remote)
> +        wait_port_listen(port, proto="tcp", host=cfg.remote)
>          cmd(tx_cmd)
>  
>  
> @@ -73,22 +78,27 @@ def test_zcrx_oneshot(cfg) -> None:
>      if combined_chans < 2:
>          raise KsftSkipEx('at least 2 combined channels required')
>      (rx_ring, hds_thresh) = _get_current_settings(cfg)
> +    port = rand_port()
>  
>      ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote)
> +
>      ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote)
> +
>      ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote)
> +
>      ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote)
>      defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote)
> -    flow_rule_id = _set_flow_rule(cfg, combined_chans - 1)
> +
> +    flow_rule_id = _set_flow_rule(cfg, port, combined_chans - 1)
>      defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote)
>  
> -    rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1} -o 4"
> -    tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 4096 -z 16384"
> +    rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1} -o 4"
> +    tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 4096 -z 16384"
>      with bkg(rx_cmd, host=cfg.remote, exit_wait=True):
> -        wait_port_listen(9999, proto="tcp", host=cfg.remote)
> +        wait_port_listen(port, proto="tcp", host=cfg.remote)
>          cmd(tx_cmd)
>  
>  
> @@ -99,24 +109,28 @@ def test_zcrx_rss(cfg) -> None:
>      if combined_chans < 2:
>          raise KsftSkipEx('at least 2 combined channels required')
>      (rx_ring, hds_thresh) = _get_current_settings(cfg)
> +    port = rand_port()
>  
>      ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote)
> +
>      ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote)
> +
>      ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote)
>      defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote)
> +
>      ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote)
>      defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote)
>  
>      (ctx_id, delete_ctx) = _create_rss_ctx(cfg, combined_chans)
> -    flow_rule_id = _set_flow_rule_rss(cfg, ctx_id)
> +    flow_rule_id = _set_flow_rule_rss(cfg, port, ctx_id)
>      defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote)
>  
> -    rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1}"
> -    tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 12840"
> +    rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}"
> +    tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 12840"
>      with bkg(rx_cmd, host=cfg.remote, exit_wait=True):
> -        wait_port_listen(9999, proto="tcp", host=cfg.remote)
> +        wait_port_listen(port, proto="tcp", host=cfg.remote)
>          cmd(tx_cmd)
>  
>  

I think this is fine; my only nit might be that in main, the rand
port could be allocated and passed in via args when ksft_run is
called.

But, I think it probably doesn't matter and it's not worth holding
this up.

Reviewed-by: Joe Damato <jdamato@...tly.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ