netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ip tap: Simplify add 'tap' device w/o mode
@ 2015-02-28  9:59 Vadim Kochan
  2015-03-01 22:07 ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Vadim Kochan @ 2015-02-28  9:59 UTC (permalink / raw)
  To: stephen; +Cc: netdev, Vadim Kochan

From: Vadim Kochan <vadim4j@gmail.com>

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

    # ip tap add tap0

instead of return error message.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
 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

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

end of thread, other threads:[~2015-03-03 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-28  9:59 [PATCH iproute2] ip tap: Simplify add 'tap' device w/o mode Vadim Kochan
2015-03-01 22:07 ` Stephen Hemminger
2015-03-01 22:13   ` Jonathon Reinhart
2015-03-01 22:03     ` Vadim Kochan
2015-03-03 18:53   ` Vadim Kochan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).