All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 1/2] ioctl: add two receive mode checking for TUN/TAP driver
@ 2017-12-20 13:10 Li Wang
  2017-12-20 13:11 ` [LTP] [PATCH v3 2/2] ioctl: convert ioctl03 to new API Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2017-12-20 13:10 UTC (permalink / raw)
  To: ltp

IFF_NAPI(1) and IFF_NAPI_FRAGS(2) are two new flags for TUN/TAP
driver, but currently ioctl03 does not hanlde them so it always
failed on latest kernel-4.15.0-rc2 like:

ioctl03     0  TINFO  :  Available features are: 0x7133
ioctl03     0  TINFO  :  TUN 0x1
ioctl03     0  TINFO  :  TAP 0x2
ioctl03     0  TINFO  :  NO_PI 0x1000
ioctl03     0  TINFO  :  ONE_QUEUE 0x2000
ioctl03     0  TINFO  :  VNET_HDR 0x4000
ioctl03     0  TINFO  :  MULTI_QUEUE 0x100
ioctl03     1  TFAIL  :  ioctl03.c:114: (UNKNOWN 0x30)

See kernel commit:
(1) commit 943170998b2 (tun: enable NAPI for TUN/TAP driver)
(2) commit 90e33d45940 (tun: enable napi_gro_frags() for TUN/TAP driver)

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/ioctl/ioctl03.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl03.c b/testcases/kernel/syscalls/ioctl/ioctl03.c
index 83433b8..8c3d446 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl03.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl03.c
@@ -60,6 +60,14 @@
 #define IFF_MULTI_QUEUE	0x0100
 #endif
 
+#ifndef IFF_NAPI
+#define IFF_NAPI       0x0010
+#endif
+
+#ifndef IFF_NAPI_FRAGS
+#define IFF_NAPI_FRAGS 0x0020
+#endif
+
 char *TCID = "ioctl03";
 int TST_TOTAL = 1;
 
@@ -84,7 +92,9 @@ static struct {
 	IFF_NO_PI, "NO_PI"}, {
 	IFF_ONE_QUEUE, "ONE_QUEUE"}, {
 	IFF_VNET_HDR, "VNET_HDR"}, {
-	IFF_MULTI_QUEUE, "MULTI_QUEUE"}
+	IFF_MULTI_QUEUE, "MULTI_QUEUE"}, {
+	IFF_NAPI, "IFF_NAPI"}, {
+	IFF_NAPI_FRAGS, "IFF_NAPI_FRAGS"}
 };
 
 int main(void)
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH v3 2/2] ioctl: convert ioctl03 to new API
  2017-12-20 13:10 [LTP] [PATCH v3 1/2] ioctl: add two receive mode checking for TUN/TAP driver Li Wang
@ 2017-12-20 13:11 ` Li Wang
  2017-12-20 15:10   ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2017-12-20 13:11 UTC (permalink / raw)
  To: ltp

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/ioctl/ioctl03.c | 101 ++++++++++++------------------
 1 file changed, 41 insertions(+), 60 deletions(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl03.c b/testcases/kernel/syscalls/ioctl/ioctl03.c
index 8c3d446..d4931b9 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl03.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl03.c
@@ -1,41 +1,35 @@
 /*
- *
- * Copyright (c) Rusty Russell <rusty@rustcorp.com.au>
  * Copyright (c) International Business Machines  Corp., 2008
+ * Copyright (c) Linux Test Project, 2017
  *
- * This program is free software;  you can redistribute it and/or modify
+ * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 2 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
- *
- *
  * File:        ioctl03.c
  *
  * Description: This program tests whether all the valid IFF flags are
  *              returned properly by implementation of TUNGETFEATURES ioctl
  *              on kernel 2.6.27
  *
- * Total Tests: 1
- *
  * Test Name:   ioctl03
  *
  * Author:      Rusty Russell <rusty@rustcorp.com.au>
  *
- * History:     Created - Nov 28 2008 - Rusty Russell <rusty@rustcorp.com.au>
- *              Ported to LTP
- *                      - Nov 28 2008 - Subrata <subrata@linux.vnet.ibm.com>
+ * history:     created - nov 28 2008 - rusty russell <rusty@rustcorp.com.au>
+ *              ported to ltp
+ *                      - nov 28 2008 - subrata <subrata@linux.vnet.ibm.com>
  */
 
 #include <sys/types.h>
@@ -43,10 +37,8 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <stdio.h>
 #include <linux/if_tun.h>
-
-#include "test.h"
+#include "tst_test.h"
 
 #ifndef TUNGETFEATURES
 #define TUNGETFEATURES _IOR('T', 207, unsigned int)
@@ -61,67 +53,56 @@
 #endif
 
 #ifndef IFF_NAPI
-#define IFF_NAPI       0x0010
+#define IFF_NAPI	0x0010
 #endif
 
 #ifndef IFF_NAPI_FRAGS
-#define IFF_NAPI_FRAGS 0x0020
+#define IFF_NAPI_FRAGS	0x0020
 #endif
 
-char *TCID = "ioctl03";
-int TST_TOTAL = 1;
-
-static void cleanup(void)
-{
-	tst_rmdir();
-}
-
-static void setup(void)
-{
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
 static struct {
 	unsigned int flag;
 	const char *name;
 } known_flags[] = {
-	{
-	IFF_TUN, "TUN"}, {
-	IFF_TAP, "TAP"}, {
-	IFF_NO_PI, "NO_PI"}, {
-	IFF_ONE_QUEUE, "ONE_QUEUE"}, {
-	IFF_VNET_HDR, "VNET_HDR"}, {
-	IFF_MULTI_QUEUE, "MULTI_QUEUE"}, {
-	IFF_NAPI, "IFF_NAPI"}, {
-	IFF_NAPI_FRAGS, "IFF_NAPI_FRAGS"}
+	{IFF_TUN, "TUN"},
+	{IFF_TAP, "TAP"},
+	{IFF_NO_PI, "NO_PI"},
+	{IFF_ONE_QUEUE, "ONE_QUEUE"},
+	{IFF_VNET_HDR, "VNET_HDR"},
+	{IFF_MULTI_QUEUE, "MULTI_QUEUE"},
+	{IFF_NAPI, "IFF_NAPI"},
+	{IFF_NAPI_FRAGS, "IFF_NAPI_FRAGS"}
 };
 
-int main(void)
+static void verify_features(void)
 {
 	unsigned int features, i;
 
-	setup();
-	tst_require_root();
-
 	int netfd = open("/dev/net/tun", O_RDWR);
-	if (netfd < 0)
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "opening /dev/net/tun failed");
+	if (netfd == -1) {
+		if (errno == ENODEV)
+			tst_brk(TCONF, "Kernel does not load TUN module");
+
+		tst_brk(TBROK | TERRNO, "opening /dev/net/tun failed");
+	}
 
-	if (ioctl(netfd, TUNGETFEATURES, &features) != 0)
-		tst_brkm(TCONF, cleanup,
-			 "Kernel does not support TUNGETFEATURES");
-	tst_resm(TINFO, "Available features are: %#x", features);
-	for (i = 0; i < sizeof(known_flags) / sizeof(known_flags[0]); i++) {
+	SAFE_IOCTL(netfd, TUNGETFEATURES, &features);
+
+	tst_res(TINFO, "Available features are: %#x", features);
+	for (i = 0; i < ARRAY_SIZE(known_flags); i++) {
 		if (features & known_flags[i].flag) {
 			features &= ~known_flags[i].flag;
-			tst_resm(TINFO, "%s %#x", known_flags[i].name,
+			tst_res(TPASS, "%s %#x", known_flags[i].name,
 				 known_flags[i].flag);
 		}
 	}
 	if (features)
-		tst_resm(TFAIL, "(UNKNOWN %#x)", features);
-	cleanup();
-	tst_exit();
+		tst_res(TFAIL, "(UNKNOWN %#x)", features);
+
+	SAFE_CLOSE(netfd);
 }
+
+static struct tst_test test = {
+	.test_all = verify_features,
+	.needs_root = 1,
+};
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH v3 2/2] ioctl: convert ioctl03 to new API
  2017-12-20 13:11 ` [LTP] [PATCH v3 2/2] ioctl: convert ioctl03 to new API Li Wang
@ 2017-12-20 15:10   ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2017-12-20 15:10 UTC (permalink / raw)
  To: ltp

Hi!
Both pushed, thanks.

(I've changed the TCONF message a bit)

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-20 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-20 13:10 [LTP] [PATCH v3 1/2] ioctl: add two receive mode checking for TUN/TAP driver Li Wang
2017-12-20 13:11 ` [LTP] [PATCH v3 2/2] ioctl: convert ioctl03 to new API Li Wang
2017-12-20 15:10   ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.