netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Kochan <vadim4j@gmail.com>
To: stephen@networkplumber.org
Cc: netdev@vger.kernel.org, Vadim Kochan <vadim4j@gmail.com>
Subject: [PATCH iproute2] ip tap: Simplify add 'tap' device w/o mode
Date: Sat, 28 Feb 2015 11:59:46 +0200	[thread overview]
Message-ID: <1425117586-21461-1-git-send-email-vadim4j@gmail.com> (raw)

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

             reply	other threads:[~2015-02-28 10:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-28  9:59 Vadim Kochan [this message]
2015-03-01 22:07 ` [PATCH iproute2] ip tap: Simplify add 'tap' device w/o mode Stephen Hemminger
2015-03-01 22:13   ` Jonathon Reinhart
2015-03-01 22:03     ` Vadim Kochan
2015-03-03 18:53   ` Vadim Kochan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425117586-21461-1-git-send-email-vadim4j@gmail.com \
    --to=vadim4j@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).