From patchwork Thu Feb 27 13:55:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Seiderer X-Patchwork-Id: 869132 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39F03231A2D; Thu, 27 Feb 2025 13:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664586; cv=none; b=gjugJrddMT4of6CkhX+71H1SRcemexo0mq60Olp7D7OODhMRkqR2YOSia5kvebQKF4t3Vwb8o85uPOui5vYHAb2w+aRU8bMHy5plwU5bWui4UXM9AuFB9PodnAchgeOmnX2kamxP4Cj49RCE1mZtalj3Ua1DMbqHAIVpkveT09Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664586; c=relaxed/simple; bh=JgGQVVAhjrzOOCs+tFIJPn5/RIQ8L4OMx++skv9az9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hhLFuS/MIdIsJ8eOQz8pHCOvxkwcaqnGC8I+4QrX+lQI7VsC1qMV4B8Ikml82vXY2uhxtpEqL0bF+Yyj4Jl6q63BmJpQPqm6FAO3PRM8FpPdem3Ff3Go/g8LQRxHKKsFLqT5d3CfuTx9Be/76cnGkzLPzg+4dCyHxQbtuS7MQqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net; spf=pass smtp.mailfrom=gmx.net; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b=GhtadAWS; arc=none smtp.client-ip=212.227.17.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b="GhtadAWS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1740664574; x=1741269374; i=ps.report@gmx.net; bh=JgGQVVAhjrzOOCs+tFIJPn5/RIQ8L4OMx++skv9az9E=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=GhtadAWSYXO9ggz/SCi8mD8APvIGdJhbi2m7MJQJl/m2VLwEFdbW85c0VmoZhAcO pAr6JB6j4PdBG44xscw7y91jz6rbzz2m7+dZPBt8gzPdGAxgt8/iInzE+a82TOFAh kFriNiUQnbaqyUDYqvGbmTVzPkl75nfMZFDaQs0pOrPZN+PCXKfHsBZ8QKP2gizRB LxGAGt0uJXTdS7UPtVcHEVDe5D/My/1d47vv+uhCIuuG2wG9lTWGSiZFa0e9eITK2 7Oxl2jMF3eqThwpsZl73815O3p2wzbYxg9yZvNrL3e6JgcU/H8yk3mTxTfoIvYvBw GUg/dEEHC485rZB/Ag== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.fritz.box ([82.135.81.151]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M72oB-1twB4z0zXj-00D6Yw; Thu, 27 Feb 2025 14:56:14 +0100 From: Peter Seiderer To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , Peter Seiderer , Fedor Pchelkin , Arnd Bergmann , Nam Cao Subject: [PATCH net-next v8 2/8] net: pktgen: remove extra tmp variable (re-use len instead) Date: Thu, 27 Feb 2025 14:55:58 +0100 Message-ID: <20250227135604.40024-3-ps.report@gmx.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250227135604.40024-1-ps.report@gmx.net> References: <20250227135604.40024-1-ps.report@gmx.net> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:X36GMHKlFQYWbPGzh0isIFHJJaFo6jhBUDudzhYm3OOXtpqURVk svPTMi+Z2UB6WZ4LkITVRp+P8PtJSxMknZXurPvcHD6FJCEiNBH2v/Z1v+bT+L0S3js+F82 CHTOyi/ZuRA97fIF9MXRUeLnb3MUau+msB8x3vOBT+iQW0xpt2zlGqTfZ5avqx3Pu9qRGWT 33b2PG2eBSACgX9erVOJg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:QB+H4xaP0Kc=;orwU92IZ52FMWIGSfgV2i8UK5aQ ScyhfYVlPsBc52p7OUeNvlPLJkJiFpOCnnLDm8wlWSnzKyFoCbgjfpq9xXCA3LRigvXZMNGzD POrOL8jKNTiuJnvtamvZs5Hsqqlt/kmnnRyof9hYQK1wR/1qn07QbYwDkWZcRWjZd434jhQQU JcQqQC7irNxHNCq+teM3SKkxjv63YmpFHXj7TaKaOyXECFYxhhR4ILovtGRuSYKpupiBOCtN1 3/zyQ3J0JzniH7Lh/+fs9JeJMjV6VLTUyCX+CgxcovMXEuukN02k8Do7xHETbIV3Ghuc+T/E9 cBnWcuVElKp9L6AqYRIEO+uc52OOmLExQjqPfBgNq6VVvs6QtUMAl+2qW/I1yQ8V601sF0mRI +ImtbEffwkgJ9sTxvAMbUpXVNplQdXnLOempOkIHw0/haRTEIwObn0rK5PHXJX9gXSbfB8Uz2 r9g78myxn7dmZbHTDae57GTZbmLVN4jxSFxcJYpEn9sSTLcHQcDZyhChmbeNMMlJebRzswR89 U5ES67Z3G7bcWegtzrBtZw/RtF/AgCZOXv8LA/UYy2cFxnCEcLQkuFVPXcWTSzPXehGuUTFMq 6aK1V399KrxzwGgpRaMpuMk1YVAfZ6+b4tHZcLSeL4U6HdBJ0PVdyfel66lVDk9V6DO54a4wl WHJDfbGwnioGGxEJnt9TX2D/LkZe/gwTJ2gdEs6V6GSd4SZB/+qcQCLyU9twcPYn3VcgtD+pQ BgRVQsvaQUH6M16OqqkYN/z3VBUQxfKDjtYZeesFMSCSJs/oyueMkRE693uG2UziKATUfg7fT m3rOZSSgUN5MUw6HG7D5AKH+jWlUiOLsUiK/WLDSb48PYfwHfIo8d/cK9ksn7Dwgs4+pS+CwP pXClMTHA/+hxXaG+bdZplrjJnDORVsDAhFMDx0MnFVykEkM3NbgcpzHhZGihfsPg3ETvU0HwO pRm58TiiDiqQFLJT0PT97LRn+JaumAYUAEWjN5nv+G+5b7V0qJ/QNrbn0UFi6E27021D7sHwW WpYQW0gTOUgpQIyq1qHRGc8POTKo5RjBWt9Nui5hTXjYVg/eZ2tFWJDHGyCEHKvFbi1f5EkhH OcJLVztzIoSN/gCW+GfmRcTVqsZ/sIgrxLgwEM25VyRrfPNFkC0nN1kYMafy/ODA3fbpbn2NH YwgiDvA+Sy9CYqVNsGC/y3jSSag9e7c7iR+uhaSG2EmWNccgWHeXpTk8Tmgkuk4ziTVA1sqEw zUTzPwFyta3Lt1clTwJQOZ/kLc3a2kqbEzWsj1v7LzUvrXBHxe1so3EU+GnS+1Xz1yknxh358 VsJjkoPxe/4PeikkTeJd+NoaQ9IZJgRNZYL/DGHlh2t1eBsO4kGJCwbzk4a7YJhhI9sKKeEts zZ05x5me4hj+1MZcEwP2K+jpvxf2h3m5guED8c99PT4dpUZBWFT+qTB6UYE4We2bj9ExQ467m doq8cog== Remove extra tmp variable in pktgen_if_write (re-use len instead). Signed-off-by: Peter Seiderer Reviewed-by: Simon Horman --- Changes v7 -> v8 - rebased on actual net-next/main - no changes Changes v6 -> v7 - rebased on actual net-next/main - no changes Changes v5 -> v6 - no changes Changes v4 -> v5 - split up patchset into part i/ii (suggested by Simon Horman) - add rev-by Simon Horman Changes v3 -> v4 - new patch (factored out of patch 'net: pktgen: fix access outside of user given buffer in pktgen_if_write()') --- net/core/pktgen.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 4775cdd2ae1c..9a5fc1298bd3 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -959,7 +959,6 @@ static ssize_t pktgen_if_write(struct file *file, char name[16], valstr[32]; unsigned long value = 0; char *pg_result = NULL; - int tmp = 0; char buf[128]; pg_result = &(pkt_dev->result[0]); @@ -970,12 +969,12 @@ static ssize_t pktgen_if_write(struct file *file, } max = count; - tmp = count_trail_chars(user_buffer, max); - if (tmp < 0) { + len = count_trail_chars(user_buffer, max); + if (len < 0) { pr_warn("illegal format\n"); - return tmp; + return len; } - i = tmp; + i = len; /* Read variable name */ From patchwork Thu Feb 27 13:55:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Seiderer X-Patchwork-Id: 869133 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C15C342C0B; Thu, 27 Feb 2025 13:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664580; cv=none; b=l+XRr9zDeqDfLE1im4ZBWTj3Prm+D+zuOxvleheiPODFXlbCJTW7EY+anJjb/UgxqQnoASBonoN+gX9Rbi8Iwuz4gUzCY2YJ/GB0BF1uOZJsmyfLEzENgvm9Skp0vHh8+/CR86OvEHEZyjbc3avo9B4oIOGaqNrTI/5WjXv+/eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664580; c=relaxed/simple; bh=6YhuMD+fZp15NlYpzOupLk0ws9PYq1Voacu06J0Qh2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJ7XB+kbbUJgS/1hKR3nT31ppXc9gJe72U40Obio5zGWusCLbqU58c0CW+u8V1yoZm7prb1cYhPZ/gKpVQB3FBFbq//UxgqH5U1ya2o6MV3UKqM7RygCAUI9qUrQK7Kpf+e8l0Lg8O1s1CokX53Rzy7GuEKix1+06WdaKdxFZso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net; spf=pass smtp.mailfrom=gmx.net; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b=lvjC/kcM; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b="lvjC/kcM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1740664574; x=1741269374; i=ps.report@gmx.net; bh=6YhuMD+fZp15NlYpzOupLk0ws9PYq1Voacu06J0Qh2E=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=lvjC/kcMwpbAjEwFKs6zxoDbniNDyzxr2fMTAjgACe4M2sLwLpeIZqz+Vh1i0Kd3 QZDkSN2v02WgKemDU+fzjokJsAq/gqaNk1TN9fVJ1gwuost+JH1miiLvdLyj0bzJg 4+FGYYHGWvl8Loxhj5zOkNHIEdHus3F2oxsPFvQHJJlKBcxdIfqzyx24rYeSdR31H i1O6VRBjr4T0yEmkaPrT4CO1RcuCy3X06kMqVzoEyGE94405DzhscKOiACiDf5g0V P+VA5YXdg45852VJH2R8iEl6ff8ftj316uYQmycqTpbMuby47KqNh6VQmNM8O9iGW hv11P2bqUEMMRZ2kuQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.fritz.box ([82.135.81.151]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M4b1y-1tpIGO2kkw-00F2NT; Thu, 27 Feb 2025 14:56:14 +0100 From: Peter Seiderer To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , Peter Seiderer , Fedor Pchelkin , Arnd Bergmann , Nam Cao Subject: [PATCH net-next v8 3/8] net: pktgen: remove some superfluous variable initializing Date: Thu, 27 Feb 2025 14:55:59 +0100 Message-ID: <20250227135604.40024-4-ps.report@gmx.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250227135604.40024-1-ps.report@gmx.net> References: <20250227135604.40024-1-ps.report@gmx.net> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:EUIXcxlKZnX2/p/4jMa01w1aUMFkC6XFDOrlNn91juwz9cofZ1D gdl+8BnZhZSL7RY7CLN+Nd0YMid9W2/nCUqQVplpJLb5OrGd+8dtXL5epnohYroihgkaKg1 t3rTbfGAsFQ9lhcpoXdAg0kEmTN2UuF6jzigv8r4XElyHQPDVuUnB0a0cafoQ8WuY3c6uAA LrZG087Ui2F3evhbo51cg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:BkUoI9KaCRo=;zxEJzEjODqPk70w6cvO33JrWQcy +uwZeqZcivYV+bv/UsbgHHAA8uoiQ591PDaNJDMoNCwgTJcKaHsBPfte+5qjeosZVtmLVOqiG B1nc53mQiT+K3nOOnbhrv0pBpHBVnadmshZCUdzI/xVafImlc2KnqmDqHSGN6OvcZiO8Fsnvd 5RnQRxJh8Nnx2KV1rKymbd53tzxvmjvZCiDGHf9FLtAeL1tf3GeG2OlJJy4bZQjL69jqPe6KX cvhxdm52OJvmVRStSLVaZ1rcXQvVfmtaXoOD3O2ETLw2pqFgF+tf21mwmcMOW9z0HJUqogY29 Uw0Oi8cC7IpybW5c727OgeJOnqH/Euh7RZnr9Mqyefyj2QGJl8oisfohUpHm7A9n/ctmHT8D8 DkV19xvdFP/BSASFBm9Ai9P551C7F3uZH/PLS1P2APjLNB5O11ITAOrRoJcGM8WwHD064rCeh F64l9PuNa/ZlrETMtoN6qhn3aDKokefL3PI1VbcCHtWBQ1X3S4YQmSmGxHYv9YOj3hFeERv4+ 5cbEaPi5VSF/CqOXZWT4/k6MxDNbssr7kTW/YiLq+g2Zlb5kFBj0h4m8ZM4lC2/Y94PC+cMiG dLC9YcsylsGj8yhtjsfOQQ26jsxV4qGBXyYqU9z/PBlkZRxh3tOrBUyB4+f3Epxq3FnHIbCAx YmtGIs4BlHKncKmf8OsQARFC0oyvQH9y6gmhM49jGbExWq9TGlvaRvVkACi6XqHqIFg8w260r MOEsGoA0dIBkKt7zYDdrWcETP6BdkkIUrtoivvlegBkku0/JVGIE7aR/Hs2D3oPIA60FBj2hV broGDqpORyIq5WI9LKQyxD3qxuhVma77nKEMm8bLo+LIGCKdtCat7r6JGwNRVlI/Dzh89Fc9o 6/aWvBfmbP2M5YjxEkaFVZtHIUK9STMNHySjwDKSpS4BnpY88SkcHUFOIcLMVEmfbmgAeVUKC q3Iq8DGMmlMSI3sAaT0HrqL9jo2RIQ4Hnk28AWgg0RqvX6+Ypr6QPw+rL1prw7owqLFfW01kR zoPs+oJJm7SeQPeBdMbSlwrZ5MFAh/lCcJg2cbpaIC4NeXFx0im6wS8ySd8agZPLzlorNyC6Y pk6xsZ6yVhBBOrVamQYz64c8NqOukajFYUhpulbulpq1TTeSXDiA9J9BIJSk6QRor5Wc2eymA sGVuZJ5WqbS+2j/ys5u2ViKTcfbESrnHf7KT8i051UjsJEdBXSN8s8U3i61ocBTaUvJibjRjs R23p/UAmjdGtWVdsrzNkVHJNNVBxchgLS21Mg5/KLchdf8RCFOlw0zVFYyiz5SpvcTMIjs6A/ Ikkkn0yfjhDUbaRVV5nV3faMwzx7fXFiR7jFWUPe2TShJFxRmoFUHMsdT5Ch8L83NR6dsvObg JhDP7Xc015Ag5F7OIRohnwtf4dYMXw/aVBDStBNkzNi3jjDdGFkj090ChZ Remove some superfluous variable initializing before hex32_arg call (as the same init is done here already). Signed-off-by: Peter Seiderer Reviewed-by: Simon Horman --- Changes v7 -> v8 - rebased on actual net-next/main - no changes Changes v6 -> v7 - rebased on actual net-next/main - no changes Changes v5 -> v6 - adjust to dropped patch 'net: pktgen: use defines for the various dec/hex number parsing digits lengths' Changes v4 -> v5 - split up patchset into part i/ii (suggested by Simon Horman) - add rev-by Simon Horman Changes v3 -> v4 - new patch (factored out of patch 'net: pktgen: fix access outside of user given buffer in pktgen_if_write()') --- net/core/pktgen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 9a5fc1298bd3..b678b28dedae 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -1785,7 +1785,7 @@ static ssize_t pktgen_if_write(struct file *file, } if (!strcmp(name, "tos")) { - __u32 tmp_value = 0; + __u32 tmp_value; len = hex32_arg(&user_buffer[i], 2, &tmp_value); if (len < 0) return len; @@ -1801,7 +1801,7 @@ static ssize_t pktgen_if_write(struct file *file, } if (!strcmp(name, "traffic_class")) { - __u32 tmp_value = 0; + __u32 tmp_value; len = hex32_arg(&user_buffer[i], 2, &tmp_value); if (len < 0) return len; From patchwork Thu Feb 27 13:56:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Seiderer X-Patchwork-Id: 869129 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 789B8232364; Thu, 27 Feb 2025 13:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664606; cv=none; b=CWewBK9/1gOdMbkUHuHblxBoqsyMqGUmfubvGE+ztovb4fu934K4mtBB4cb+VdG1rW+a9N8qEvTxov5QarMLkBflqqM8TUZixSBBmg+YvPBvvvmwpms8dPOgNPt7JQ84WVBImCAEud8tVpi/ktBHIQ1FaFMxD+9bwHRQ0KrcmZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664606; c=relaxed/simple; bh=U55Wfaml+iLmuDzRSmhF6XHXxgqauTNIupr+1KWPRZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cJtqATs50LjAn9XGY7YBr9EzI1Sa208yI2FryKB6laFqXit5yq2wYJFVD7EoGZJesuuzkcpJ/NSjtyfgwBDfJBinoCINSNZiOZG3bCPaataL47BGwFx5Ypa29gQLfv2tcO2vxMBoU0vD4YsYW5tJre/rpCXdVksO0ANPyAfe6vk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net; spf=pass smtp.mailfrom=gmx.net; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b=sbP/y1Hc; arc=none smtp.client-ip=212.227.17.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b="sbP/y1Hc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1740664576; x=1741269376; i=ps.report@gmx.net; bh=U55Wfaml+iLmuDzRSmhF6XHXxgqauTNIupr+1KWPRZk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=sbP/y1HctdaY8Nyn4Uj1Kx3Hpt1Ful3MvpliXfrPzCnncEqeMmBGchyUtAhfRsnb I2z0VnLKXfPzPM2YX5f71UTMm/EHMlsozLped3ZSRRNBJiozSy6r88s5yxsfTrEoH 2trK96horOzs4+B5AQfxmGS091MrxysLIlq26zAjb0MzcVFileL+brqIK5H+w9OE1 XnDyJX5kR1Fwlt+jaJbNA6MABwn21EQneQmMGg7WMTodHrFaOiVB2oc3j0ZoVvfRN C24gwFlzSzm89ZDZ5oJkIHKauMn/PyvLYP/EbyqVd8+bbbLmZYrCzpzPpLeVYuoSa wOMX1sO9jWpiLgYkwA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.fritz.box ([82.135.81.151]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MOiDX-1teVfc47Dz-00UlyI; Thu, 27 Feb 2025 14:56:16 +0100 From: Peter Seiderer To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , Peter Seiderer , Fedor Pchelkin , Arnd Bergmann , Nam Cao Subject: [PATCH net-next v8 6/8] net: pktgen: fix mpls reset parsing Date: Thu, 27 Feb 2025 14:56:02 +0100 Message-ID: <20250227135604.40024-7-ps.report@gmx.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250227135604.40024-1-ps.report@gmx.net> References: <20250227135604.40024-1-ps.report@gmx.net> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:qXH4O+ui+hIs/MVWTwQuygtjseriezg+brhpV1ZDBDiz3fuL7Wl wYa5VCSKSkYbDBCwgBCjz6XYP8ui5EnBFVXhQVcB8jNdAuqroAP6BwSwmIfFF7zZiDSlFG6 Yp75Vp7EoLYljsBAeWbj/ZBtVyT8HBqQx/WuIDWfI6OD0fLIC0m5HmIYxuwrl2l+AVq1APn M6xYHprMtAoH8MRbUr/HQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ONC9ffTbhzc=;KaLBZ5Z2xVz2txuGiXrKGFlbIZK SIl7YKx4TqQ//onW/OXIJlvA8SvDInNHsBK/fAniAJHFt2RePoLNvAHt9J9jiCmSxv7w4Enu2 XwDXj0a19gBsw0ECL+Ay1rXgY+SSEmZ7O+EsoUekm4Kz7ZhlN9u/geuylwKLKymg2s4c2Tq+8 njAyd0fwyXPkk3EM/jSYdD9vlLr8Fr0JP8FB/VCaattrYSFTt/DQQYb5bHUnglh4quQtNF6WU mVHR4lq1Bd/UuvO/FRUleFvcrfEkGaGfIUyammSTR1JWfAnnVtuzvMcr/Kz7WAoV51dDiqFsD xzgjfArV7Y5Dgk4GF//JyLh/y9mFllBXxDF1NjBOaDJQWGI+fKjMkuBU2q8a4Cl87mXJg7qtB bVCFZcpnCDHHWVyOJIaji2m78tujD6mxX/+jx4L01X07b0g+QLB9rRwUaZJfoYDDdeJ55jD/V 6x1+iahhWjlCya0zSDx3aX9GFiYXgBLxZ3bt/Bv1pgu3blNIquLLAxgWjxDcJfL8GinNg/F4j cB5UkgtDWibQL6f09xD+AHhywJi4eugNgMni9DF78cpz3LPCTTntn1bxBXu1WhRtgm6UteHiY v7Kv7VDucDpZlxE3bvF99HqCb9uD47I0tGdf0dgL9bJct86CIqHmWIG0jmV2v2rpgkUP5XWt6 my1o8Obxm8qfTIP78ikVUAOKtHI7zNnuqG8iUilioXOe5vnFMQhR48QJduQezDqaKh6NhgjPW uXBCpBNmTtkggrtx6lTI7QTJ7QddywGt8Tdz+d0JNV4hyDoPooEMe0zK7zvbMPBGIZBw10Gbj HqAJEBf9VyDZHhtCCMC0CHzQjuS1NuR9nkZHtLxHuK7jht2V00pSjX+yc8q/5KYrjJTHyH+X3 xfT31ElIRHBdZ1HHOWzYvG762aLv2YtOQaneh7UczKTcEYeGyNtsCDVJxi+k39W9b8mCq2vm0 mH2CXrEK/jWc70SvnwsBMoTKNU0ovBI0iqFh+opGPtdQMa7/AdCZsslYvDYiMvPz/LYO7PNkG QYUJePss2rL6yATr0we8gzgj8rJcivGshVC1HMIxvPu1yvCBt+8hnCuoBJffsSsBf/+gtMJGM 5GWoOkXLaMOyrxZI1FcgD+fQvukKo+81LyYDP2gLEJUrO5i6mW/mVo8YAZoKdwvT66VyvjQyI drEuOFNlO1zLQn3Ge5mIwzWipSI/fCm4gyhXNofZP0BVdkZEvNezGv1vZ3qKiuAeiT1f9iYCN Bhh1Qor0qssSGKd+0MNklhLkNnV0C5VLjIoPDbKvvjlYya5pOWCZPExA4e0mFCyn6A0nYwj3w W0JAGQsaedXaFFKwIqRvTXwtT4sWjDobIboss57qNSCgt0/HlU2iSbHnQT+QPubvhr8yexTg6 3FRZtt7VWNu+1PbYBO4i0XDSPNIYNr6NS/QFc06CHi9kyt5BxE0Z+jeMn2 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 Reviewed-by: Simon Horman --- Changes v7 -> v8 - rebased on actual net-next/main - fix c99 comment (suggested by Paolo Abeni) Changes v6 -> v7 - rebased on actual net-next/main - no changes Changes v5 -> v6 - no changes Changes v4 -> v5 - split up patchset into part i/ii (suggested by Simon Horman) Changes v3 -> v4 - add rev-by Simon Horman 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 f4f9c9d83694..c604a68f2840 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -913,8 +913,13 @@ static ssize_t get_labels(const char __user *buffer, 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 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; From patchwork Thu Feb 27 13:56:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Seiderer X-Patchwork-Id: 869130 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48A86234989; Thu, 27 Feb 2025 13:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664594; cv=none; b=GaaS/7hdwyLu4bWiolsvhHXH+JW8lOpsC2+YdKODg0vxqO68fAT+qDCVarxywRCgjpzDUGlAZz2lWOJbZe59cS86miEfzuQdBHLcdf2cWiZrUen3077H46tQykyIPmsOgP4ppxvdhRUqre2lJIN+/cSDU8QQ2w3qwp0TXQoGSs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740664594; c=relaxed/simple; bh=R66KWURTQxfxE9QPO8h9nl2i3JtDs8+Tof5JV0SnMWc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g+yWr3OGsrx3qqfvTkFYPAZDVQR6PBtAy9GnzOF+VzjwUbwnU18+Jk3JDMQH5X4+nycrvDMuSV4YGExUqDvPzFqaDtFViD7GUr41DdfanZKjTR1ujsexZlLk6OIXApQ9IVlnsIBkfNss8uMCGJxSJmZs77ZfX80VAV12fqGC39I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net; spf=pass smtp.mailfrom=gmx.net; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b=GaoM3fmm; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=ps.report@gmx.net header.b="GaoM3fmm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1740664577; x=1741269377; i=ps.report@gmx.net; bh=R66KWURTQxfxE9QPO8h9nl2i3JtDs8+Tof5JV0SnMWc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=GaoM3fmmeSS3M/wtc/vvu8NbGNCH15ESJUsGu0r9/24PkKTxiCYYCT02f1to6owA t5NTGNp4eyehQ2ho00WnI6kkM/mQ9+aULEcrnU6kys7cJzqNetwJ2gGNT4WOQOVfH 8H3a6+P7R813bnGNDf/8fBvACoR4DaNfrI96+H1pSK7bxqqESftT1VyQr7S+MAz6d LUZyyQrXNtS3G/VMSmdNFH3v3OuknOSxhkSgb3B8mnsMAyvJzEWrnD0if+7ymwm02 sl+ZAIDRqmcBm2r850s9QTos5XiK9JbAwOkNAIbSn7BRMpKdYtoTpyuP6cfsIVcEG M2QSc9zuqKLOQRLWSA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.fritz.box ([82.135.81.151]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N8ofO-1tBkU23YV4-00sVzz; Thu, 27 Feb 2025 14:56:16 +0100 From: Peter Seiderer To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , Peter Seiderer , Fedor Pchelkin , Arnd Bergmann , Nam Cao Subject: [PATCH net-next v8 8/8] selftest: net: add proc_net_pktgen Date: Thu, 27 Feb 2025 14:56:04 +0100 Message-ID: <20250227135604.40024-9-ps.report@gmx.net> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250227135604.40024-1-ps.report@gmx.net> References: <20250227135604.40024-1-ps.report@gmx.net> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:JRkG2y119lj6hU47pPDGwn2J9NwBBplikiaogmzgs6NE9ZSnQH4 p705kCBD6CAtb2GF4LcbqPoHmmCx7YmrF3lYca7NLsIrSoJ+gsH8PAJ0qSWoGqQG+DDW/0V cU904CT1BxjkItPNlFKWkLDGDYir6eUnELzfE+Y7Jci8J/LF+XSg+aiQNa90c/es8qiNagL DY469+/etqC+GZ+3j8ONg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:hAGCCLaPtu4=;B2Ev2orQzpPqnHiQHux/xQz2RkI KcfcXdoAVtuNOrbn9wAKJaqJ09ftayFSgA7VPl4T1TdLTVl+YAajBXMZvjkcn38TvnhKQ1H7L s2mQndz4MAkrT5By26UnYhtvW0612ucnZJiw64QQF9gQOItogz9B2+kWIbYIzETEXtXRzhfuO 0BAz38Wu4fV87O2TxgqhaN/bj7mMou2aOQDjMp8P3vqMdB1y0c8KIz4N1J57y4omSkhNwvRhQ H7wkv1776efZsUmrqPWMcBrOHWmkwvg4vey5GcZur0mNOQLT/VSFp72wGTrv2gBVxT6mQfSKt axkI65E2ROgcDTi2QqMhQtlHWeQGhRmGGGyQVWCPe1Tmzijop/AV1kunpiRJT+GA8Oc0ZJhvs g+oHHh4L31Son+G09UYsqbU2nGmjLmmIgaw174pO9QLo7/6sJZgo2quThPCcqXzlePF83rf8W f4x1NywiMX76n3e37AIpr1E8XyepfcFJMFjLVJZj9QKrvGk1CzMYJuFaxzIHbLqlqA3Cm8ART xJkHz7dfbKxhAcSdmvVk6IfyJLexovVZVC79JelUDqEhARrUGdv16KwVDar+fvM9yZTlzLnJ2 vbHuQegWHY95TKUbkUgLr2auLhDRRCvZmmtvJSsDubLhrLN7YRkY6qOq1bqq0DFUQ34zHRuGB KC+UvkhfGNrfcf2o3jhCJFTSs2uAj3QFz+nu8Nc6Ve7eR2bZEQ8fFbEDOyC34BCV27XUmTTw1 73mz+Q/d5uiygSFJuz496Dmta//wrtTbGa+jE/u5tz1j7+t8C35XcliKNubOUBvAt0JMCkuyO P3mV0oq9l+X3H+U7LxzZfyTKMm0TrdC1NyafJiMgaN8NTP6Dt8INCTg2W5mIOaB3RytQWjgfP y8/tMhDNJzOMXyJLy/byPJy0MZD7s/JVle60bxBONw+44za/mOpzag/gTpoBJdI4+hAzSSZBI i3yfoQaN8XQCIy+S8HpUZt3oHohQftiE1f33ZCNARa+LMgNoj4qFP24ctiC8/Kq3+soU6kAuk zgBxVxbSHr4IjtbI2R6eMhYy3gjBbzCnLHwiF9XbixnOXtN51X3fmnzJz8+um5fvfAXbaRwdt 5Mfv+raxVFwfejGJBBiZPPA7vdftytcfk0Sf33U+mBYQ/boE3Gw7THnlCTjxvvni21jXVJEAP Yb87UIkVikFAJ8OKe60/Dpdlhcn7h8F5qODJhwGYiFVJzBgegmmj08q145Pf9Ial5CHoKeDRX XTDXeWB1xByYN46ljSR1f05juXdK0rtRQU+YEpbCUS7wuM9cEsFRFzHJsFFGRW0PRZXrhFIj9 f/MTHO1qWedd3SoUjm1caNhYtrv4CQKVIVyztA/+h4d6/36ZtMEDfvn7ykgrgmA6hcaSr5do1 QDDb7zFumIiLZROdwW+rhIGTfhSzHuDQSogRyOL4dJZB55cD9FHQQ6creT Add some test for /proc/net/pktgen/... interface. - enable 'CONFIG_NET_PKTGEN=m' in tools/testing/selftests/net/config Signed-off-by: Peter Seiderer Reviewed-by: Simon Horman --- Changes v7 -> v8 - rebased on actual net-next/main - fix c99 comments (suggested by Paolo Abeni) - add rev-by Simon Horman (given to v6 version) Changes v6 -> v7 - rebased on actual net-next/main - fixed conflict in tools/testing/selftests/net/config Changes v5 -> v6 - no changes Changes v4 -> v5 - split up patchset into part i/ii (suggested by Simon Horman) - addapt to dropped patch 'net: pktgen: hex32_arg/num_arg error out in case no characters are available', empty hex/num arg is now implicit assumed as zero value (instead of failure) Changes v3 -> v4: - no changes Changes v2 -> v3: - fix typo in change description ('v1 -> v1' and tyop) - rename some vars to better match usage add_loopback_0 -> thr_cmd_add_loopback_0 rm_loopback_0 -> thr_cmd_rm_loopback_0 wrong_ctrl_cmd -> wrong_thr_cmd legacy_ctrl_cmd -> legacy_thr_cmd ctrl_fd -> thr_fd - add ctrl interface tests Changes v1 -> v2: - fix tyop not vs. nod (suggested by Jakub Kicinski) - fix misaligned line (suggested by Jakub Kicinski) - enable fomerly commented out CONFIG_XFRM dependent test (command spi), as CONFIG_XFRM is enabled via tools/testing/selftests/net/config CONFIG_XFRM_INTERFACE/CONFIG_XFRM_USER (suggestex by Jakub Kicinski) - add CONFIG_NET_PKTGEN=m to tools/testing/selftests/net/config (suggested by Jakub Kicinski) - add modprobe pktgen to FIXTURE_SETUP() (suggested by Jakub Kicinski) - fix some checkpatch warnings (Missing a blank line after declarations) - shrink line length by re-naming some variables (command -> cmd, device -> dev) - add 'rate 0' testcase - add 'ratep 0' testcase --- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/proc_net_pktgen.c | 646 ++++++++++++++++++ 3 files changed, 648 insertions(+) create mode 100644 tools/testing/selftests/net/proc_net_pktgen.c diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 2e16ce6d28e4..d5aa16185f42 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -104,6 +104,7 @@ TEST_PROGS += vlan_bridge_binding.sh TEST_PROGS += bpf_offload.py TEST_PROGS += ipv6_route_update_soft_lockup.sh TEST_PROGS += busy_poll_test.sh +TEST_GEN_PROGS += proc_net_pktgen # YNL files, must be before "include ..lib.mk" YNL_GEN_FILES := busy_poller netlink-dumps diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config index ab55270669ec..a86f3e752ce2 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -112,3 +112,4 @@ CONFIG_CAN=m CONFIG_CAN_DEV=m CONFIG_CAN_VXCAN=m CONFIG_NETKIT=y +CONFIG_NET_PKTGEN=m diff --git a/tools/testing/selftests/net/proc_net_pktgen.c b/tools/testing/selftests/net/proc_net_pktgen.c new file mode 100644 index 000000000000..462805ac1614 --- /dev/null +++ b/tools/testing/selftests/net/proc_net_pktgen.c @@ -0,0 +1,646 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * proc_net_pktgen: kselftest for /proc/net/pktgen interface + * + * Copyright (c) 2025 Peter Seiderer + * + */ +#include +#include +#include +#include + +#include "../kselftest_harness.h" + +static const char ctrl_cmd_stop[] = "stop"; +static const char ctrl_cmd_start[] = "start"; +static const char ctrl_cmd_reset[] = "reset"; + +static const char wrong_ctrl_cmd[] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; + +static const char thr_cmd_add_loopback_0[] = "add_device lo@0"; +static const char thr_cmd_rm_loopback_0[] = "rem_device_all"; + +static const char wrong_thr_cmd[] = "forsureawrongcommand"; +static const char legacy_thr_cmd[] = "max_before_softirq"; + +static const char wrong_dev_cmd[] = "forsurewrongcommand"; +static const char dev_cmd_min_pkt_size_0[] = "min_pkt_size"; +static const char dev_cmd_min_pkt_size_1[] = "min_pkt_size "; +static const char dev_cmd_min_pkt_size_2[] = "min_pkt_size 0"; +static const char dev_cmd_min_pkt_size_3[] = "min_pkt_size 1"; +static const char dev_cmd_min_pkt_size_4[] = "min_pkt_size 100"; +static const char dev_cmd_min_pkt_size_5[] = "min_pkt_size=1001"; +static const char dev_cmd_min_pkt_size_6[] = "min_pkt_size =2002"; +static const char dev_cmd_min_pkt_size_7[] = "min_pkt_size= 3003"; +static const char dev_cmd_min_pkt_size_8[] = "min_pkt_size = 4004"; +static const char dev_cmd_max_pkt_size_0[] = "max_pkt_size 200"; +static const char dev_cmd_pkt_size_0[] = "pkt_size 300"; +static const char dev_cmd_imix_weights_0[] = "imix_weights 0,7 576,4 1500,1"; +static const char dev_cmd_imix_weights_1[] = "imix_weights 101,1 102,2 103,3 104,4 105,5 106,6 107,7 108,8 109,9 110,10 111,11 112,12 113,13 114,14 115,15 116,16 117,17 118,18 119,19 120,20"; +static const char dev_cmd_imix_weights_2[] = "imix_weights 100,1 102,2 103,3 104,4 105,5 106,6 107,7 108,8 109,9 110,10 111,11 112,12 113,13 114,14 115,15 116,16 117,17 118,18 119,19 120,20 121,21"; +static const char dev_cmd_debug_0[] = "debug 1"; +static const char dev_cmd_debug_1[] = "debug 0"; +static const char dev_cmd_frags_0[] = "frags 100"; +static const char dev_cmd_delay_0[] = "delay 100"; +static const char dev_cmd_delay_1[] = "delay 2147483647"; +static const char dev_cmd_rate_0[] = "rate 0"; +static const char dev_cmd_rate_1[] = "rate 100"; +static const char dev_cmd_ratep_0[] = "ratep 0"; +static const char dev_cmd_ratep_1[] = "ratep 200"; +static const char dev_cmd_udp_src_min_0[] = "udp_src_min 1"; +static const char dev_cmd_udp_dst_min_0[] = "udp_dst_min 2"; +static const char dev_cmd_udp_src_max_0[] = "udp_src_max 3"; +static const char dev_cmd_udp_dst_max_0[] = "udp_dst_max 4"; +static const char dev_cmd_clone_skb_0[] = "clone_skb 1"; +static const char dev_cmd_clone_skb_1[] = "clone_skb 0"; +static const char dev_cmd_count_0[] = "count 100"; +static const char dev_cmd_src_mac_count_0[] = "src_mac_count 100"; +static const char dev_cmd_dst_mac_count_0[] = "dst_mac_count 100"; +static const char dev_cmd_burst_0[] = "burst 0"; +static const char dev_cmd_node_0[] = "node 100"; +static const char dev_cmd_xmit_mode_0[] = "xmit_mode start_xmit"; +static const char dev_cmd_xmit_mode_1[] = "xmit_mode netif_receive"; +static const char dev_cmd_xmit_mode_2[] = "xmit_mode queue_xmit"; +static const char dev_cmd_xmit_mode_3[] = "xmit_mode nonsense"; +static const char dev_cmd_flag_0[] = "flag UDPCSUM"; +static const char dev_cmd_flag_1[] = "flag !UDPCSUM"; +static const char dev_cmd_flag_2[] = "flag nonsense"; +static const char dev_cmd_dst_min_0[] = "dst_min 101.102.103.104"; +static const char dev_cmd_dst_0[] = "dst 101.102.103.104"; +static const char dev_cmd_dst_max_0[] = "dst_max 201.202.203.204"; +static const char dev_cmd_dst6_0[] = "dst6 2001:db38:1234:0000:0000:0000:0000:0000"; +static const char dev_cmd_dst6_min_0[] = "dst6_min 2001:db8:1234:0000:0000:0000:0000:0000"; +static const char dev_cmd_dst6_max_0[] = "dst6_max 2001:db8:1234:0000:0000:0000:0000:0000"; +static const char dev_cmd_src6_0[] = "src6 2001:db38:1234:0000:0000:0000:0000:0000"; +static const char dev_cmd_src_min_0[] = "src_min 101.102.103.104"; +static const char dev_cmd_src_max_0[] = "src_max 201.202.203.204"; +static const char dev_cmd_dst_mac_0[] = "dst_mac 01:02:03:04:05:06"; +static const char dev_cmd_src_mac_0[] = "src_mac 11:12:13:14:15:16"; +static const char dev_cmd_clear_counters_0[] = "clear_counters"; +static const char dev_cmd_flows_0[] = "flows 100"; +static const char dev_cmd_spi_0[] = "spi 100"; +static const char dev_cmd_flowlen_0[] = "flowlen 100"; +static const char dev_cmd_queue_map_min_0[] = "queue_map_min 1"; +static const char dev_cmd_queue_map_max_0[] = "queue_map_max 2"; +static const char dev_cmd_mpls_0[] = "mpls 00000001"; +static const char dev_cmd_mpls_1[] = "mpls 00000001,000000f2"; +static const char dev_cmd_mpls_2[] = "mpls 00000f00,00000f01,00000f02,00000f03,00000f04,00000f05,00000f06,00000f07,00000f08,00000f09,00000f0a,00000f0b,00000f0c,00000f0d,00000f0e,00000f0f"; +static const char dev_cmd_mpls_3[] = "mpls 00000f00,00000f01,00000f02,00000f03,00000f04,00000f05,00000f06,00000f07,00000f08,00000f09,00000f0a,00000f0b,00000f0c,00000f0d,00000f0e,00000f0f,00000f10"; +static const char dev_cmd_vlan_id_0[] = "vlan_id 1"; +static const char dev_cmd_vlan_p_0[] = "vlan_p 1"; +static const char dev_cmd_vlan_cfi_0[] = "vlan_cfi 1"; +static const char dev_cmd_vlan_id_1[] = "vlan_id 4096"; +static const char dev_cmd_svlan_id_0[] = "svlan_id 1"; +static const char dev_cmd_svlan_p_0[] = "svlan_p 1"; +static const char dev_cmd_svlan_cfi_0[] = "svlan_cfi 1"; +static const char dev_cmd_svlan_id_1[] = "svlan_id 4096"; +static const char dev_cmd_tos_0[] = "tos 0"; +static const char dev_cmd_tos_1[] = "tos 0f"; +static const char dev_cmd_tos_2[] = "tos 0ff"; +static const char dev_cmd_traffic_class_0[] = "traffic_class f0"; +static const char dev_cmd_skb_priority_0[] = "skb_priority 999"; + +FIXTURE(proc_net_pktgen) { + int ctrl_fd; + int thr_fd; + int dev_fd; +}; + +FIXTURE_SETUP(proc_net_pktgen) { + int r; + ssize_t len; + + r = system("modprobe pktgen"); + ASSERT_EQ(r, 0) TH_LOG("CONFIG_NET_PKTGEN not enabled, module pktgen not loaded?"); + + self->ctrl_fd = open("/proc/net/pktgen/pgctrl", O_RDWR); + ASSERT_GE(self->ctrl_fd, 0) TH_LOG("CONFIG_NET_PKTGEN not enabled, module pktgen not loaded?"); + + self->thr_fd = open("/proc/net/pktgen/kpktgend_0", O_RDWR); + ASSERT_GE(self->thr_fd, 0) TH_LOG("CONFIG_NET_PKTGEN not enabled, module pktgen not loaded?"); + + len = write(self->thr_fd, thr_cmd_add_loopback_0, sizeof(thr_cmd_add_loopback_0)); + ASSERT_EQ(len, sizeof(thr_cmd_add_loopback_0)) TH_LOG("device lo@0 already registered?"); + + self->dev_fd = open("/proc/net/pktgen/lo@0", O_RDWR); + ASSERT_GE(self->dev_fd, 0) TH_LOG("device entry for lo@0 missing?"); +} + +FIXTURE_TEARDOWN(proc_net_pktgen) { + int ret; + ssize_t len; + + ret = close(self->dev_fd); + EXPECT_EQ(ret, 0); + + len = write(self->thr_fd, thr_cmd_rm_loopback_0, sizeof(thr_cmd_rm_loopback_0)); + EXPECT_EQ(len, sizeof(thr_cmd_rm_loopback_0)); + + ret = close(self->thr_fd); + EXPECT_EQ(ret, 0); + + ret = close(self->ctrl_fd); + EXPECT_EQ(ret, 0); +} + +TEST_F(proc_net_pktgen, wrong_ctrl_cmd) { + for (int i = 0; i <= sizeof(wrong_ctrl_cmd); i++) { + ssize_t len; + + len = write(self->ctrl_fd, wrong_ctrl_cmd, i); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, EINVAL); + } +} + +TEST_F(proc_net_pktgen, ctrl_cmd) { + ssize_t len; + + len = write(self->ctrl_fd, ctrl_cmd_stop, sizeof(ctrl_cmd_stop)); + EXPECT_EQ(len, sizeof(ctrl_cmd_stop)); + + len = write(self->ctrl_fd, ctrl_cmd_stop, sizeof(ctrl_cmd_stop) - 1); + EXPECT_EQ(len, sizeof(ctrl_cmd_stop) - 1); + + len = write(self->ctrl_fd, ctrl_cmd_start, sizeof(ctrl_cmd_start)); + EXPECT_EQ(len, sizeof(ctrl_cmd_start)); + + len = write(self->ctrl_fd, ctrl_cmd_start, sizeof(ctrl_cmd_start) - 1); + EXPECT_EQ(len, sizeof(ctrl_cmd_start) - 1); + + len = write(self->ctrl_fd, ctrl_cmd_reset, sizeof(ctrl_cmd_reset)); + EXPECT_EQ(len, sizeof(ctrl_cmd_reset)); + + len = write(self->ctrl_fd, ctrl_cmd_reset, sizeof(ctrl_cmd_reset) - 1); + EXPECT_EQ(len, sizeof(ctrl_cmd_reset) - 1); +} + +TEST_F(proc_net_pktgen, wrong_thr_cmd) { + for (int i = 0; i <= sizeof(wrong_thr_cmd); i++) { + ssize_t len; + + len = write(self->thr_fd, wrong_thr_cmd, i); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, EINVAL); + } +} + +TEST_F(proc_net_pktgen, legacy_thr_cmd) { + for (int i = 0; i <= sizeof(legacy_thr_cmd); i++) { + ssize_t len; + + len = write(self->thr_fd, legacy_thr_cmd, i); + if (i < (sizeof(legacy_thr_cmd) - 1)) { + /* incomplete command string */ + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, EINVAL); + } else { + /* complete command string without/with trailing '\0' */ + EXPECT_EQ(len, i); + } + } +} + +TEST_F(proc_net_pktgen, wrong_dev_cmd) { + for (int i = 0; i <= sizeof(wrong_dev_cmd); i++) { + ssize_t len; + + len = write(self->dev_fd, wrong_dev_cmd, i); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, EINVAL); + } +} + +TEST_F(proc_net_pktgen, dev_cmd_min_pkt_size) { + ssize_t len; + + /* with trailing '\0' */ + len = write(self->dev_fd, dev_cmd_min_pkt_size_0, sizeof(dev_cmd_min_pkt_size_0)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_0)); + + /* without trailing '\0' */ + len = write(self->dev_fd, dev_cmd_min_pkt_size_0, sizeof(dev_cmd_min_pkt_size_0) - 1); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_0) - 1); + + /* with trailing '\0' */ + len = write(self->dev_fd, dev_cmd_min_pkt_size_1, sizeof(dev_cmd_min_pkt_size_1)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_1)); + + /* without trailing '\0' */ + len = write(self->dev_fd, dev_cmd_min_pkt_size_1, sizeof(dev_cmd_min_pkt_size_1) - 1); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_1) - 1); + + /* with trailing '\0' */ + len = write(self->dev_fd, dev_cmd_min_pkt_size_2, sizeof(dev_cmd_min_pkt_size_2)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_2)); + + /* without trailing '\0' */ + len = write(self->dev_fd, dev_cmd_min_pkt_size_2, sizeof(dev_cmd_min_pkt_size_2) - 1); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_2) - 1); + + len = write(self->dev_fd, dev_cmd_min_pkt_size_3, sizeof(dev_cmd_min_pkt_size_3)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_3)); + + len = write(self->dev_fd, dev_cmd_min_pkt_size_4, sizeof(dev_cmd_min_pkt_size_4)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_4)); + + len = write(self->dev_fd, dev_cmd_min_pkt_size_5, sizeof(dev_cmd_min_pkt_size_5)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_5)); + + len = write(self->dev_fd, dev_cmd_min_pkt_size_6, sizeof(dev_cmd_min_pkt_size_6)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_6)); + + len = write(self->dev_fd, dev_cmd_min_pkt_size_7, sizeof(dev_cmd_min_pkt_size_7)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_7)); + + len = write(self->dev_fd, dev_cmd_min_pkt_size_8, sizeof(dev_cmd_min_pkt_size_8)); + EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_8)); +} + +TEST_F(proc_net_pktgen, dev_cmd_max_pkt_size) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_max_pkt_size_0, sizeof(dev_cmd_max_pkt_size_0)); + EXPECT_EQ(len, sizeof(dev_cmd_max_pkt_size_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_pkt_size) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_pkt_size_0, sizeof(dev_cmd_pkt_size_0)); + EXPECT_EQ(len, sizeof(dev_cmd_pkt_size_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_imix_weights) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_imix_weights_0, sizeof(dev_cmd_imix_weights_0)); + EXPECT_EQ(len, sizeof(dev_cmd_imix_weights_0)); + + len = write(self->dev_fd, dev_cmd_imix_weights_1, sizeof(dev_cmd_imix_weights_1)); + EXPECT_EQ(len, sizeof(dev_cmd_imix_weights_1)); + + len = write(self->dev_fd, dev_cmd_imix_weights_2, sizeof(dev_cmd_imix_weights_2)); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, E2BIG); +} + +TEST_F(proc_net_pktgen, dev_cmd_debug) { + ssize_t len; + + /* debug on */ + len = write(self->dev_fd, dev_cmd_debug_0, sizeof(dev_cmd_debug_0)); + EXPECT_EQ(len, sizeof(dev_cmd_debug_0)); + + /* debug off */ + len = write(self->dev_fd, dev_cmd_debug_1, sizeof(dev_cmd_debug_1)); + EXPECT_EQ(len, sizeof(dev_cmd_debug_1)); +} + +TEST_F(proc_net_pktgen, dev_cmd_frags) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_frags_0, sizeof(dev_cmd_frags_0)); + EXPECT_EQ(len, sizeof(dev_cmd_frags_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_delay) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_delay_0, sizeof(dev_cmd_delay_0)); + EXPECT_EQ(len, sizeof(dev_cmd_delay_0)); + + len = write(self->dev_fd, dev_cmd_delay_1, sizeof(dev_cmd_delay_1)); + EXPECT_EQ(len, sizeof(dev_cmd_delay_1)); +} + +TEST_F(proc_net_pktgen, dev_cmd_rate) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_rate_0, sizeof(dev_cmd_rate_0)); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, EINVAL); + + len = write(self->dev_fd, dev_cmd_rate_1, sizeof(dev_cmd_rate_1)); + EXPECT_EQ(len, sizeof(dev_cmd_rate_1)); +} + +TEST_F(proc_net_pktgen, dev_cmd_ratep) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_ratep_0, sizeof(dev_cmd_ratep_0)); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, EINVAL); + + len = write(self->dev_fd, dev_cmd_ratep_1, sizeof(dev_cmd_ratep_1)); + EXPECT_EQ(len, sizeof(dev_cmd_ratep_1)); +} + +TEST_F(proc_net_pktgen, dev_cmd_udp_src_min) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_udp_src_min_0, sizeof(dev_cmd_udp_src_min_0)); + EXPECT_EQ(len, sizeof(dev_cmd_udp_src_min_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_udp_dst_min) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_udp_dst_min_0, sizeof(dev_cmd_udp_dst_min_0)); + EXPECT_EQ(len, sizeof(dev_cmd_udp_dst_min_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_udp_src_max) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_udp_src_max_0, sizeof(dev_cmd_udp_src_max_0)); + EXPECT_EQ(len, sizeof(dev_cmd_udp_src_max_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_udp_dst_max) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_udp_dst_max_0, sizeof(dev_cmd_udp_dst_max_0)); + EXPECT_EQ(len, sizeof(dev_cmd_udp_dst_max_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_clone_skb) { + ssize_t len; + + /* clone_skb on (gives EOPNOTSUPP on lo device) */ + len = write(self->dev_fd, dev_cmd_clone_skb_0, sizeof(dev_cmd_clone_skb_0)); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, EOPNOTSUPP); + + /* clone_skb off */ + len = write(self->dev_fd, dev_cmd_clone_skb_1, sizeof(dev_cmd_clone_skb_1)); + EXPECT_EQ(len, sizeof(dev_cmd_clone_skb_1)); +} + +TEST_F(proc_net_pktgen, dev_cmd_count) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_count_0, sizeof(dev_cmd_count_0)); + EXPECT_EQ(len, sizeof(dev_cmd_count_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_src_mac_count) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_src_mac_count_0, sizeof(dev_cmd_src_mac_count_0)); + EXPECT_EQ(len, sizeof(dev_cmd_src_mac_count_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst_mac_count) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst_mac_count_0, sizeof(dev_cmd_dst_mac_count_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst_mac_count_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_burst) { + ssize_t len; + + /* burst off */ + len = write(self->dev_fd, dev_cmd_burst_0, sizeof(dev_cmd_burst_0)); + EXPECT_EQ(len, sizeof(dev_cmd_burst_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_node) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_node_0, sizeof(dev_cmd_node_0)); + EXPECT_EQ(len, sizeof(dev_cmd_node_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_xmit_mode) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_xmit_mode_0, sizeof(dev_cmd_xmit_mode_0)); + EXPECT_EQ(len, sizeof(dev_cmd_xmit_mode_0)); + + len = write(self->dev_fd, dev_cmd_xmit_mode_1, sizeof(dev_cmd_xmit_mode_1)); + EXPECT_EQ(len, sizeof(dev_cmd_xmit_mode_1)); + + len = write(self->dev_fd, dev_cmd_xmit_mode_2, sizeof(dev_cmd_xmit_mode_2)); + EXPECT_EQ(len, sizeof(dev_cmd_xmit_mode_2)); + + len = write(self->dev_fd, dev_cmd_xmit_mode_3, sizeof(dev_cmd_xmit_mode_3)); + EXPECT_EQ(len, sizeof(dev_cmd_xmit_mode_3)); +} + +TEST_F(proc_net_pktgen, dev_cmd_flag) { + ssize_t len; + + /* flag UDPCSUM on */ + len = write(self->dev_fd, dev_cmd_flag_0, sizeof(dev_cmd_flag_0)); + EXPECT_EQ(len, sizeof(dev_cmd_flag_0)); + + /* flag UDPCSUM off */ + len = write(self->dev_fd, dev_cmd_flag_1, sizeof(dev_cmd_flag_1)); + EXPECT_EQ(len, sizeof(dev_cmd_flag_1)); + + /* flag invalid */ + len = write(self->dev_fd, dev_cmd_flag_2, sizeof(dev_cmd_flag_2)); + EXPECT_EQ(len, sizeof(dev_cmd_flag_2)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst_min) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst_min_0, sizeof(dev_cmd_dst_min_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst_min_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst_0, sizeof(dev_cmd_dst_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst_max) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst_max_0, sizeof(dev_cmd_dst_max_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst_max_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst6) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst6_0, sizeof(dev_cmd_dst6_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst6_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst6_min) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst6_min_0, sizeof(dev_cmd_dst6_min_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst6_min_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst6_max) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst6_max_0, sizeof(dev_cmd_dst6_max_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst6_max_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_src6) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_src6_0, sizeof(dev_cmd_src6_0)); + EXPECT_EQ(len, sizeof(dev_cmd_src6_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_src_min) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_src_min_0, sizeof(dev_cmd_src_min_0)); + EXPECT_EQ(len, sizeof(dev_cmd_src_min_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_src_max) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_src_max_0, sizeof(dev_cmd_src_max_0)); + EXPECT_EQ(len, sizeof(dev_cmd_src_max_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_dst_mac) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_dst_mac_0, sizeof(dev_cmd_dst_mac_0)); + EXPECT_EQ(len, sizeof(dev_cmd_dst_mac_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_src_mac) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_src_mac_0, sizeof(dev_cmd_src_mac_0)); + EXPECT_EQ(len, sizeof(dev_cmd_src_mac_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_clear_counters) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_clear_counters_0, sizeof(dev_cmd_clear_counters_0)); + EXPECT_EQ(len, sizeof(dev_cmd_clear_counters_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_flows) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_flows_0, sizeof(dev_cmd_flows_0)); + EXPECT_EQ(len, sizeof(dev_cmd_flows_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_spi) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_spi_0, sizeof(dev_cmd_spi_0)); + EXPECT_EQ(len, sizeof(dev_cmd_spi_0)) TH_LOG("CONFIG_XFRM not enabled?"); +} + +TEST_F(proc_net_pktgen, dev_cmd_flowlen) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_flowlen_0, sizeof(dev_cmd_flowlen_0)); + EXPECT_EQ(len, sizeof(dev_cmd_flowlen_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_queue_map_min) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_queue_map_min_0, sizeof(dev_cmd_queue_map_min_0)); + EXPECT_EQ(len, sizeof(dev_cmd_queue_map_min_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_queue_map_max) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_queue_map_max_0, sizeof(dev_cmd_queue_map_max_0)); + EXPECT_EQ(len, sizeof(dev_cmd_queue_map_max_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_mpls) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_mpls_0, sizeof(dev_cmd_mpls_0)); + EXPECT_EQ(len, sizeof(dev_cmd_mpls_0)); + + len = write(self->dev_fd, dev_cmd_mpls_1, sizeof(dev_cmd_mpls_1)); + EXPECT_EQ(len, sizeof(dev_cmd_mpls_1)); + + len = write(self->dev_fd, dev_cmd_mpls_2, sizeof(dev_cmd_mpls_2)); + EXPECT_EQ(len, sizeof(dev_cmd_mpls_2)); + + len = write(self->dev_fd, dev_cmd_mpls_3, sizeof(dev_cmd_mpls_3)); + EXPECT_EQ(len, -1); + EXPECT_EQ(errno, E2BIG); +} + +TEST_F(proc_net_pktgen, dev_cmd_vlan_id) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_vlan_id_0, sizeof(dev_cmd_vlan_id_0)); + EXPECT_EQ(len, sizeof(dev_cmd_vlan_id_0)); + + len = write(self->dev_fd, dev_cmd_vlan_p_0, sizeof(dev_cmd_vlan_p_0)); + EXPECT_EQ(len, sizeof(dev_cmd_vlan_p_0)); + + len = write(self->dev_fd, dev_cmd_vlan_cfi_0, sizeof(dev_cmd_vlan_cfi_0)); + EXPECT_EQ(len, sizeof(dev_cmd_vlan_cfi_0)); + + len = write(self->dev_fd, dev_cmd_vlan_id_1, sizeof(dev_cmd_vlan_id_1)); + EXPECT_EQ(len, sizeof(dev_cmd_vlan_id_1)); +} + +TEST_F(proc_net_pktgen, dev_cmd_svlan_id) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_svlan_id_0, sizeof(dev_cmd_svlan_id_0)); + EXPECT_EQ(len, sizeof(dev_cmd_svlan_id_0)); + + len = write(self->dev_fd, dev_cmd_svlan_p_0, sizeof(dev_cmd_svlan_p_0)); + EXPECT_EQ(len, sizeof(dev_cmd_svlan_p_0)); + + len = write(self->dev_fd, dev_cmd_svlan_cfi_0, sizeof(dev_cmd_svlan_cfi_0)); + EXPECT_EQ(len, sizeof(dev_cmd_svlan_cfi_0)); + + len = write(self->dev_fd, dev_cmd_svlan_id_1, sizeof(dev_cmd_svlan_id_1)); + EXPECT_EQ(len, sizeof(dev_cmd_svlan_id_1)); +} + + +TEST_F(proc_net_pktgen, dev_cmd_tos) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_tos_0, sizeof(dev_cmd_tos_0)); + EXPECT_EQ(len, sizeof(dev_cmd_tos_0)); + + len = write(self->dev_fd, dev_cmd_tos_1, sizeof(dev_cmd_tos_1)); + EXPECT_EQ(len, sizeof(dev_cmd_tos_1)); + + len = write(self->dev_fd, dev_cmd_tos_2, sizeof(dev_cmd_tos_2)); + EXPECT_EQ(len, sizeof(dev_cmd_tos_2)); +} + + +TEST_F(proc_net_pktgen, dev_cmd_traffic_class) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_traffic_class_0, sizeof(dev_cmd_traffic_class_0)); + EXPECT_EQ(len, sizeof(dev_cmd_traffic_class_0)); +} + +TEST_F(proc_net_pktgen, dev_cmd_skb_priority) { + ssize_t len; + + len = write(self->dev_fd, dev_cmd_skb_priority_0, sizeof(dev_cmd_skb_priority_0)); + EXPECT_EQ(len, sizeof(dev_cmd_skb_priority_0)); +} + +TEST_HARNESS_MAIN