[PATCH net-next v3 09/10] net: pktgen: fix mpls reset parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix mpls list reset parsing to work as describe in
Documentation/networking/pktgen.rst:

  pgset "mpls 0"    turn off mpls (or any invalid argument works too!)

- before the patch

	$ echo "mpls 00000001,00000002" > /proc/net/pktgen/lo\@0
	$ grep mpls /proc/net/pktgen/lo\@0
	     mpls: 00000001, 00000002
	Result: OK: mpls=00000001,00000002

	$ echo "mpls 00000001,00000002" > /proc/net/pktgen/lo\@0
	$ echo "mpls 0" > /proc/net/pktgen/lo\@0
	$ grep mpls /proc/net/pktgen/lo\@0
	     mpls: 00000000
	Result: OK: mpls=00000000

	$ echo "mpls 00000001,00000002" > /proc/net/pktgen/lo\@0
	$ echo "mpls invalid" > /proc/net/pktgen/lo\@0
	$ grep mpls /proc/net/pktgen/lo\@0
	Result: OK: mpls=

- after the patch

	$ echo "mpls 00000001,00000002" > /proc/net/pktgen/lo\@0
	$ grep mpls /proc/net/pktgen/lo\@0
	     mpls: 00000001, 00000002
	Result: OK: mpls=00000001,00000002

	$ echo "mpls 00000001,00000002" > /proc/net/pktgen/lo\@0
	$ echo "mpls 0" > /proc/net/pktgen/lo\@0
	$ grep mpls /proc/net/pktgen/lo\@0
	Result: OK: mpls=

	$ echo "mpls 00000001,00000002" > /proc/net/pktgen/lo\@0
	$ echo "mpls invalid" > /proc/net/pktgen/lo\@0
	$ grep mpls /proc/net/pktgen/lo\@0
	Result: OK: mpls=

Signed-off-by: Peter Seiderer <ps.report@xxxxxxx>
---
Changes v2 -> v3:
  - new patch
---
 net/core/pktgen.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 6675375c052c..7328681bafb2 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -924,8 +924,13 @@ static ssize_t get_labels(const char __user *buffer, int maxlen, struct pktgen_d
 
 		max = min(8, maxlen - i);
 		len = hex32_arg(&buffer[i], max, &tmp);
-		if (len <= 0)
+		if (len < 0)
 			return len;
+
+		// return empty list in case of invalid input and/or zero value
+		if (len == 0 || tmp == 0)
+			return maxlen;
+
 		pkt_dev->labels[n] = htonl(tmp);
 		if (pkt_dev->labels[n] & MPLS_STACK_BOTTOM)
 			pkt_dev->flags |= F_MPLS_RND;
-- 
2.48.1


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux