ip tap: Simplify add 'tap' device w/o mode
Subsystems (2)
PATCH 1/1 ip tap: Simplify add 'tap' device w/o mode
From: Vadim Kochan <[email protected]>
It allows add 'tap' device w/o specify mode:
# ip tap add tap0
instead of return error message.
--- ip/iptuntap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
ip/iptuntap.c +7 -2
@@ -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 ;
Signature · 1 line
2.2.2
Quoted 9 lines · On Sat, 28 Feb 2015 11:59:46 +0200 Vadim Kochan <[email protected]> wrote:
From: Vadim Kochan <[email protected]>
It allows add 'tap' device w/o specify mode:
# ip tap add tap0instead of return error message.
Signed-off-by Vadim Kochan <[email protected]>
No. mode should not depend on device name.
Also, I noticed that reading kernel code it is possible to create a broken tun device if type is not set.
Quoted 1 line · Stephen Hemminger
No. mode should not depend on device name.
Isn't this looking at the "tap" part of "ip tap", not the device name?
Quoted 5 lines · Jonathon Reinhart
Quoted 1 line · Stephen Hemminger
No. mode should not depend on device name.
Isn't this looking at the "tap" part of "ip tap", not the device name?
Right it checks 'ip tap' not the device name.
Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Sat, 28 Feb 2015 11:59:46 +0200 Vadim Kochan <[email protected]> wrote:
From: Vadim Kochan <[email protected]>
It allows add 'tap' device w/o specify mode:
# ip tap add tap0
Quoted 9 lines
Quoted 3 lines
instead of return error message.
Signed-off-by Vadim Kochan <[email protected]>No. mode should not depend on device name.
Also, I noticed that reading kernel code it is possible to create a broken tun device if type is not set.
Is it still bad if it checks for 'tap' in 'ip tap' ?