Commit 3ba38c25 authored by Peter Seiderer's avatar Peter Seiderer Committed by Jakub Kicinski
Browse files

net: pktgen: fix 'rate 0' error handling (return -EINVAL)



Given an invalid 'rate' command e.g. 'rate 0' the return value is '1',
leading to the following misleading output:

- the good case

	$ echo "rate 100" > /proc/net/pktgen/lo\@0
	$ grep "Result:" /proc/net/pktgen/lo\@0
	Result: OK: rate=100

- the bad case (before the patch)

	$ echo "rate 0" > /proc/net/pktgen/lo\@0"
	-bash: echo: write error: Invalid argument
	$ grep "Result:" /proc/net/pktgen/lo\@0
	Result: No such parameter "ate"

- with patch applied

	$ echo "rate 0" > /proc/net/pktgen/lo\@0
	-bash: echo: write error: Invalid argument
	$ grep "Result:" /proc/net/pktgen/lo\@0
	Result: Idle

Signed-off-by: default avatarPeter Seiderer <ps.report@gmx.net>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250219084527.20488-5-ps.report@gmx.net


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b3850434
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1115,7 +1115,7 @@ static ssize_t pktgen_if_write(struct file *file,

		i += len;
		if (!value)
			return len;
			return -EINVAL;
		pkt_dev->delay = pkt_dev->min_pkt_size*8*NSEC_PER_USEC/value;
		if (debug)
			pr_info("Delay set at: %llu ns\n", pkt_dev->delay);