Commit Graph

14 Commits

Author SHA1 Message Date
Phil Sutter
625df645b7 Check user supplied interface name lengths
The original problem was that something like:

| strncpy(ifr.ifr_name, *argv, IFNAMSIZ);

might leave ifr.ifr_name unterminated if length of *argv exceeds
IFNAMSIZ. In order to fix this, I thought about replacing all those
cases with (equivalent) calls to snprintf() or even introducing
strlcpy(). But as Ulrich Drepper correctly pointed out when rejecting
the latter from being added to glibc, truncating a string without
notifying the user is not to be considered good practice. So let's
excercise what he suggested and reject empty, overlong or otherwise
invalid interface names right from the start - this way calls to
strncpy() like shown above become safe and the user has a chance to
reconsider what he was trying to do.

Note that this doesn't add calls to check_ifname() to all places where
user supplied interface name is parsed. In many cases, the interface
must exist already and is therefore looked up using ll_name_to_index(),
so if_nametoindex() will perform the necessary checks already.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2017-10-02 08:01:21 -07:00
Thomas Graf
113fab78e4 tuntap: Add name attribute to usage text
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-09-08 14:31:33 -07:00
Stephen Hemminger
cc28aad1e6 ip: iptuntap cleanup
Minor whitespace changes
2016-09-01 09:03:40 -07:00
Stephen Hemminger
ae810982cc remove useless return statement
Get rid of:
void foo() {
...
	return;
}
2016-09-01 08:44:20 -07:00
Hannes Frederic Sowa
567e696072 iptuntap: show processes using tuntap interface
Show which processes are using which tun/tap devices, e.g.:

$ ip -d tuntap
tun0: tun
	Attached to processes: vpnc(9531)
vnet0: tap vnet_hdr
	Attached to processes: qemu-system-x86(10442)
virbr0-nic: tap UNKNOWN_FLAGS:800
	Attached to processes:

Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
2016-09-01 08:41:37 -07:00
Stephen Hemminger
56f5daac98 ip: code cleanup
Run all the ip code through checkpatch and have it fix the obvious stuff.
2016-03-21 11:52:19 -07:00
vadimk
08ce8ae95d ip tuntap: Added missing commands in usage
show, list, lst and help commands were not printed in usage.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-09-28 16:19:31 -07:00
vadimk
f1a505aca8 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: Vadim Kochan <vadim4j@gmail.com>
2014-09-28 16:19:31 -07:00
Sriram Narasimhan
c41e038f48 iptuntap: allow creation of multi-queue tun/tap device
This patch adds multi_queue option to ip tuntap.
This allows IFF_MULTI_QUEUE flag to be specified during
tun/tap device creation enabling multi-queue support in tun/tap
device.

Example: ip tuntap add dev tap0 mode tap multi_queue

Signed-off-by: Sriram Narasimhan <sriram.narasimhan@hp.com>
2013-05-24 08:12:52 -07:00
Kees van Reeuwijk
14645ec231 iproute2: improved error messages
This patch improves many error messages as follows:
- For incorrect parameters, show the value of the offending parameter, rather than just say that it is incorrect
- Rephrased messages for clarity
- Rephrased to more `mainstream' english

Signed-off-by: Kees van Reeuwijk <reeuwijk@few.vu.nl>
2013-02-11 09:22:22 -08:00
Andreas Henriksson
6e30461e73 iproute2: man page and /bin/ip disagree on del vs delete
Reported by Robert Henney:
> the 'ip' man page does not mention the command "del" at all but does
> claim, "As a rule, it is possible to add, delete and show (or list ) objects".
> however, 'ip' does not always recognize "delete" as a commend.
>
> robh@debian:~$ ip tunnel delete
> Command "delete" is unknown, try "ip tunnel help".

Lets use "delete" in all calls to matches() for consistency. This will
make both "del" and "delete" work everywhere.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2012-05-21 15:17:28 -07:00
Thomas Jarosch
e9a927dc08 Add missing closedir() call in do_show()
Detected by cppcheck.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
2011-10-07 11:17:41 -07:00
Dan McGee
1313ceb4d6 iptuntap: avoid double open
would leak a file handle
2011-08-31 12:14:51 -07:00
David Woodhouse
580fbd88f7 Add 'ip tuntap' support.
This patch provides support for 'ip tuntap', allowing creation and
deletion of persistent tun/tap devices.
2009-09-19 12:49:41 -07:00