提交 604dfd6e 编写于 作者: C Cong Wang 提交者: David S. Miller

pktgen: correctly handle failures when adding a device

The return value of pktgen_add_device() is not checked, so
even if we fail to add some device, for example, non-exist one,
we still see "OK:...". This patch fixes it.

After this patch, I got:

	# echo "add_device non-exist" > /proc/net/pktgen/kpktgend_0
	-bash: echo: write error: No such device
	# cat /proc/net/pktgen/kpktgend_0
	Running:
	Stopped:
	Result: ERROR: can not add device non-exist
	# echo "add_device eth0" > /proc/net/pktgen/kpktgend_0
	# cat /proc/net/pktgen/kpktgend_0
	Running:
	Stopped: eth0
	Result: OK: add_device=eth0

(Candidate for -stable)

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: NCong Wang <amwang@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a13d3104
...@@ -1781,10 +1781,13 @@ static ssize_t pktgen_thread_write(struct file *file, ...@@ -1781,10 +1781,13 @@ static ssize_t pktgen_thread_write(struct file *file,
return -EFAULT; return -EFAULT;
i += len; i += len;
mutex_lock(&pktgen_thread_lock); mutex_lock(&pktgen_thread_lock);
pktgen_add_device(t, f); ret = pktgen_add_device(t, f);
mutex_unlock(&pktgen_thread_lock); mutex_unlock(&pktgen_thread_lock);
if (!ret) {
ret = count; ret = count;
sprintf(pg_result, "OK: add_device=%s", f); sprintf(pg_result, "OK: add_device=%s", f);
} else
sprintf(pg_result, "ERROR: can not add device %s", f);
goto out; goto out;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册