Thread (5 messages) 5 messages, 3 authors, 2015-03-03

[PATCH iproute2] ip tap: Simplify add 'tap' device w/o mode

flat view
STALE4261d

From: Vadim Kochan <hidden>
Date: 2015-02-28 10:11:10
Subsystem: the rest · Maintainer: Linus Torvalds

From: Vadim Kochan <redacted>

It allows add 'tap' device w/o specify mode:

    # ip tap add tap0

instead of return error message.

Signed-off-by: Vadim Kochan <redacted>
---
 ip/iptuntap.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ip/iptuntap.c b/ip/iptuntap.c
index b9b28a1..61b6c19 100644
--- a/ip/iptuntap.c
+++ b/ip/iptuntap.c
@@ -107,6 +107,7 @@ static int tap_del_ioctl(struct ifreq *ifr)
 static int parse_args(int argc, char **argv, struct ifreq *ifr, uid_t *uid, gid_t *gid)
 {
 	int count = 0;
+	char *cmd = *(argv - 2);
 
 	memset(ifr, 0, sizeof(*ifr));
 
@@ -187,8 +188,12 @@ static int parse_args(int argc, char **argv, struct ifreq *ifr, uid_t *uid, gid_
 	}
 
 	if (!(ifr->ifr_flags & TUN_TYPE_MASK)) {
-		fprintf(stderr, "You failed to specify a tunnel mode\n");
-		return -1;
+		if(strncmp("tap", cmd, 3) == 0) {
+			ifr->ifr_flags |= IFF_TAP;
+		} else {
+			fprintf(stderr, "You failed to specify a tunnel mode\n");
+			return -1;
+		}
 	}
 
 	return 0;
-- 
2.2.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help