Commit f1a505ac authored by vadimk's avatar vadimk Committed by Stephen Hemminger

ip tuntap: Add checking if tun/tap mode was set by default

This checking was performed only when adding interface but
it is needed also when deleting, otherwise the error will be:

    ioctl(TUNSETIFF): Invalid argument
Signed-off-by: default avatarVadim Kochan <vadim4j@gmail.com>
parent 6ad5399c
...@@ -186,6 +186,11 @@ static int parse_args(int argc, char **argv, struct ifreq *ifr, uid_t *uid, gid_ ...@@ -186,6 +186,11 @@ static int parse_args(int argc, char **argv, struct ifreq *ifr, uid_t *uid, gid_
argc--; argv++; argc--; argv++;
} }
if (!(ifr->ifr_flags & TUN_TYPE_MASK)) {
fprintf(stderr, "You failed to specify a tunnel mode\n");
return -1;
}
return 0; return 0;
} }
...@@ -199,10 +204,6 @@ static int do_add(int argc, char **argv) ...@@ -199,10 +204,6 @@ static int do_add(int argc, char **argv)
if (parse_args(argc, argv, &ifr, &uid, &gid) < 0) if (parse_args(argc, argv, &ifr, &uid, &gid) < 0)
return -1; return -1;
if (!(ifr.ifr_flags & TUN_TYPE_MASK)) {
fprintf(stderr, "You failed to specify a tunnel mode\n");
return -1;
}
return tap_add_ioctl(&ifr, uid, gid); return tap_add_ioctl(&ifr, uid, gid);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment