Commit Graph

42 Commits

Author SHA1 Message Date
Stephen Hemminger
4ccfb44dfb Make link mode case independent
The link mode is printed in upper case, and following the general
rule that ip command output should work on input, allow either case.
2012-04-05 15:10:19 -07:00
Stephen Hemminger
4f2fdd44b6 Add ability to set link state with ip
Exposes existing netlink operations to modify link state of devices.
2012-04-05 15:08:57 -07:00
Stephen Hemminger
82499282b2 ip: allow set and display of link mode parameter
The kernel supports a link mode attribute (which can be dormant or default).
This attribute is used to control how the link watch engine
handles operstate transistion.

This adds a new parameter to ip link command to allow setting and
displaying the value.
---
2012-03-19 17:24:43 -07:00
Stephen Hemminger
09fa327941 iproute: allow changing gretap parameters
Change the order of evaluation of ip link type arguements to allow
changing parameters of gre tunnels.

The following wouldn't work:
 # ip li add mytunnel type gretap remote 1.1.1.1 key 3
 # ip li set mytunnel type gretap key 9
2012-03-14 10:28:33 -07:00
Stephen Hemminger
cd70f3f522 libnetlink: remove unused junk callback
Both rtnl_talk and rtnl_dump had a callback for handling portions
of netlink message that do not match the correct pid or seq.
But this callback was never used by any part of iproute2 so remove
it.
2011-12-28 10:37:12 -08:00
Stephen Hemminger
6cf8398f5f libnetlink: change rtnl_send() to take void *
Avoid having to cast buffer being sent.
2011-12-23 10:41:50 -08:00
Greg Rose
7b8179c780 iproute2: Add new command to ip link to enable/disable VF spoof check
Add ip link command parsing for VF spoof checking enable/disable

V2 - Fixed problem with parsing of dump info on kernels that don't
     support the spoof checking option and also wrapped the ifla_vf_info
     structure in #ifdef __KERNEL__ to prevent user space from directly
     accessing the structure
V3 - Improved parsing of vfinfo
V4 - Put Makefile back to proper list of subdirs
V5 - Remove struct ifla_vf_info, it is only used by the kernel
V6 - Make sure spoof check is reported by the driver - rtnl will set
     it to -1 to indicate driver didn't report a value.

Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2011-11-23 14:53:12 -08:00
Sridhar Samudrala
a22e92951d iproute2: Fix usage and man page for 'ip link'
Add bridge as a supported type with 'ip link' in usage and all the missing
types in 'ip' man page. Also fixed some typos.

Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
2011-10-07 11:04:46 -07:00
Eric W. Biederman
0dc34c7713 iproute2: Add processless network namespace support
The goal of this code change is to implement a mechanism such that it is
simple to work with a kernel that is using multiple network namespaces
at once.

This comes in handy for interacting with vpns where there may be rfc1918
address overlaps, and different policies default routes, name servers
and the like.

Configuration specific to a network namespace that would ordinarily be
stored under /etc/ is stored under /etc/netns/<name>.  For example if
the dns server configuration is different for your vpn you would create
a file /etc/netns/myvpn/resolv.conf.

File descriptors that can be used to manipulate a network namespace can
be created by opening /var/run/netns/<NAME>.

This adds the following commands to iproute.
ip netns add NAME
ip netns delete NAME
ip netns monitor
ip netns list
ip netns exec NAME cmd ....
ip link set DEV netns NAME

ip netns exec exists to cater the vast majority of programs that only
know how to operate in a single network namespace.  ip netns exec
changes the default network namespace, creates a new mount namespace,
remounts /sys and bind mounts netns specific configuration files to
their standard locations.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
2011-07-13 09:48:26 -07:00
Stephen Hemminger
d5b7420a26 Remove #ifdef's
The iproute package keeps its own headers so there is no need
of polluting code with #ifdef's
2011-02-25 20:00:54 -08:00
Jiri Pirko
a1e191b90c iplink: implement setting of master devic 2011-02-25 19:55:19 -08:00
Vlad Dogaru
db02608b6f iproute2: support device group semantics
Add the group keyword to ip link set, which has the following meaning:
If both a group and a device name are pressent, we change the device's
group to the specified one. If only a group is present, then the
operation specified by the rest of the command should apply on an entire
group, not a single device.

So, to set eth0 to the default group, one would use
	ip link set dev eth0 group default

Conversely, to set all the devices in the default group down, use
	ip link set group default down

Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org>
2011-02-25 12:43:14 -08:00
Vlad Dogaru
f960c92aac iproute2: support listing devices by group
User can specify device group to list by using the group keyword:

	ip link show group test

If no group is specified, 0 (default) is implied.

Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org>
2011-02-25 12:38:50 -08:00
Stephen Hemminger
1598b9ef7b Revert "iproute2: add VF_PORT support"
This reverts commit 632110aa0d.

There seem to be some recent changes in the 802.1Qbh/bg specs which may
result in changes to this patch in the near future. It seems like its best
to ignore this patch for now.
I will re-spin at a later time when the changes in the specs converge.

BTW, Please let me know if I should CC netdev list and others on the
original email. I can resend this email.

Thanks,
Roopa
2011-01-13 14:53:02 -08:00
Roopa Prabhu
632110aa0d iproute2: add VF_PORT support
Resubmitting Scott Feldmans original patch with below changes

- Fix port profile strlen which was off by 1
- Added function to convert IFLA_PORT_RESPONSE codes to string

Add support for IFLA_VF_PORTS.  VF port netlink msg layout is

        [IFLA_NUM_VF]
        [IFLA_VF_PORTS]
                [IFLA_VF_PORT]
                        [IFLA_PORT_*], ...
                [IFLA_VF_PORT]
                        [IFLA_PORT_*], ...
                ...
        [IFLA_PORT_SELF]
                [IFLA_PORT_*], ...

The iproute2 cmd line for link set is now:

Usage: ip link add link DEV [ name ] NAME
                   [ txqueuelen PACKETS ]
                   [ address LLADDR ]
                   [ broadcast LLADDR ]
                   [ mtu MTU ]
                   type TYPE [ ARGS ]
       ip link delete DEV type TYPE [ ARGS ]

       ip link set DEVICE [ { up | down } ]
                          [ arp { on | off } ]
                          [ dynamic { on | off } ]
                          [ multicast { on | off } ]
                          [ allmulticast { on | off } ]
                          [ promisc { on | off } ]
                          [ trailers { on | off } ]
                          [ txqueuelen PACKETS ]
                          [ name NEWNAME ]
                          [ address LLADDR ]
                          [ broadcast LLADDR ]
                          [ mtu MTU ]
                          [ netns PID ]
                          [ alias NAME ]
                          [ port MODE { PROFILE | VSI } ]
                          [ vf NUM [ mac LLADDR ]
                                   [ vlan VLANID [ qos VLAN-QOS ] ]
                                   [ rate TXRATE ]
                                   [ port MODE { PROFILE | VSI } ] ]
       ip link show [ DEVICE ]

TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can }
MODE := { assoc | preassoc | preassocrr | disassoc }
PROFILE := profile PROFILE
           [ instance UUID ]
           [ host UUID ]
VSI := vsi mgr MGRID type VTID ver VER
       [ instance UUID ]

Signed-off-by: Scott Feldman <scofeldm@cisco.com>
Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
2011-01-13 14:50:46 -08:00
Chris Wright
3fd8663087 iproute2: rework SR-IOV VF support
The kernel interface changed just before 2.6.34 was released.  This brings
iproute2 in line with the current changes.  The VF portion of setlink is
comprised of a set of nested attributes.

  IFLA_VFINFO_LIST (NESTED)
    IFLA_VF_INFO (NESTED)
      IFLA_VF_MAC
      IFLA_VF_VLAN
      IFLA_VF_TX_RATE

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
2010-05-18 08:12:31 -07:00
Williams, Mitch A
ae7229d5f9 ip: Add support for setting and showing SR-IOV virtual funtion link params
Add support to 'ip' for setting and showing SR-IOV virtual function
link parameters.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2010-03-03 16:33:26 -08:00
Wolfgang Grandegger
5a2044782b iproute2: Support for the CAN netlink
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
2009-05-26 15:22:44 -07:00
Andreas Henriksson
cb2eb9997a Bug#526329: iproute: Segfault on garbage lladdr
On tor, 2009-04-30 at 14:32 +0100, Timothy Baldwin wrote:
> Package: iproute
> Version: 20090324-1
> Severity: minor
>
>
> $ ip link set eth0 address help
> "help" is invalid lladdr.
> Segmentation fault
>
> Desipte the invalid command line arguments it shouldn't crash.
>

Callers need to check return value from ll_addr_a2n(). Patch below.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2009-05-26 15:18:05 -07:00
Oliver Hartkopp
685f3a9ffb iproute2: add vcan to ip link help text
Hello Stephen,

thanks für the commit of my last CAN patch.

Today i got a hint, that the help text of 'ip link' can be improved also.

Many thanks!

Oliver

Signed-Off-By: Oliver Hartkopp <oliver@hartkopp.net>
2009-04-13 13:38:05 -07:00
Stephen Hemminger
ace9c96121 Add support for IFALIAS
New 2.6.28 support for text description
2009-03-23 10:46:47 -07:00
Stephen Hemminger
750a405a5a Fix help text for ip link
This is a variant of Patrick McHardy patch for help text.
Add help for ip link add and ip link delete.
The help conditional on what the kernel supports.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
2008-10-13 07:17:08 -07:00
Patrick McHardy
3ef0c85942 Refuse "ip link add/replace" without device type parameter
Fix confusing error message noticed by Martin Josefsson:
Fix typo noticed by Phil Oester: information vs. informatin

# ip link add
RTNETLINK answers: Operation not supported

The reason is missing device type information, refuse this and print a message.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-10-13 07:03:41 -07:00
Patrick McHardy
0532555202 Support "ip link add help" for rtnl_link API
For some reason "ip link add help" is currently not supported when using
the new rtnl_link API. Fix that.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-10-13 07:02:44 -07:00
Andreas Henriksson
5e3bb534ae iproute: DESTDIR vs LIBDIR.
Hello Rafael Almeida.

I noticed your patch adding DESTDIR support in the latest iproute2 release.
Much appreciated! Soon the debian packages might be able to move to actually
using "make install" rather then it's own installation procedure when
building packages. I've noticed something that will break though....

Debian packages usually sets DESTDIR=debian/tmp/ and packages the contents
of that directory as if it where the root file system. This will break
the /usr/lib/{tc,ip}/ module loading, because they DESTDIR (/usr) will be
/whatever-the-build-path-was/debian/tmp/lib/{tc,ip}/.
I beleive others usually call this the LIBDIR to make the separation between
DISTDIR being the (possibly temporary) place things are put when build is
done, and LIBDIR (and others) are used for actual runtime paths.

I'm attaching a patch that I think fixes this, but would be really happy if
you could have a look at to verify I'm not screwing something up.

--
Regards,
Andreas Henriksson

Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
2008-09-17 22:04:02 -07:00
Rafael Almeida
b514b3587e Fixed installation when changing DESTDIR
After changing the DESTDIR the installated binaries have some issues
due to hard coded paths. For example, using distributions on NetEm
would segfault.

I've changed iplink.c and tc_util.c so they are now aware of DESTDIR.
Along with that change I needed to change the main Makefile so it
defines the DESTDIR macro when calling gcc.

I also changed the paths so that during the installation sbin, etc,
share and lib directories are created directly inside of the DESTDIR,
instead of creating a usr directory inside that. That's the behaviour
of most packages out there, so I think most users will be expecting
that to happen.
2008-07-25 13:40:19 -07:00
Benjamin Thery
e2613dc860 iproute2: add support for IFLA_NET_NS_PID in ip link
Hi Stephen,

I resend you this patch once more. This time I updated the documentation
too (may be that was the reason why you didn't take it before?).

Please tell me if there are other things missing in this patch
It applies on iproute2 git tree.

Regards,
Benjamin

Description:
------------

This patch adds support for the IFLA_NET_NS_PID type. It is used to
move network devices between network namespaces.

The syntax is:
ip link set DEVICE netns PID

PID is the pid of a process in the target network namespace.

(Daniel Lezcano is the original author).

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
2008-06-23 09:10:47 -07:00
Pavel Emelyanov
909dfe2c7e iplink_parse() routine
This routine parses CLI attributes, describing generic link
parameters such as name, address, etc.

This is mostly copy-pasted from iplink_modify().

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-12-21 09:23:40 -08:00
Patrick McHardy
66e529f579 iproute 2.6.23 incompatibility
Arkadiusz Miskiewicz wrote:
> People are reporting that
>> ip link set multicast on dev eth0 (Invalid argument)
>> no longer works when using iproute 2.6.23 on kernel 2.6.21.
>>
>> On my testing machine it also fails:
>> # ./ip link set eth0 multicast on
>> RTNETLINK answers: Invalid argument

It seems it fails to properly detect that your kernel is missing
RTM_NEWLINK support. Apparently the reason is that the kernels
I tested with return a different error in this situation.


Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-25 19:09:08 -07:00
Patrick McHardy
ca78b0e7d4 Prevent renaming interfaces to empty string.
Andreas Henriksson wrote:
> From: Alexander Wirt <formorer@debian.org>
>
>
> Signed-off-by: Andreas Henriksson <andreas@fatal.se>
> ---
>  ip/iplink.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/ip/iplink.c b/ip/iplink.c
> index 4060845..da1f64e 100644
> --- a/ip/iplink.c
> +++ b/ip/iplink.c
> @@ -670,6 +670,10 @@ static int do_set(int argc, char **argv)
>  	}
>
>  	if (newname && strcmp(dev, newname)) {
> +		if (strlen(newname) == 0) {
> +		    printf("\"\" is not valid device identifier\n");
> +		    return -1;
> +		}

Indentation fixed, same change for the non-ioctl case, use invarg.
While I'm at it I also fixed the error message for "name too long",
*argv is NULL at this point.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2007-10-12 15:45:12 -07:00
Stephen Hemminger
5058332f3c Revert "don't allow "" for device name"
Use Patrick's instead

This reverts commit ba371d9890.
2007-10-12 15:44:44 -07:00
Stephen Hemminger
59cc4f73f2 Revert "Remove bogus reference to tc-filters(8) from tc(8) manpage."
This reverts commit 1bacc7ce75.
2007-10-12 15:44:07 -07:00
Andreas Barth
1bacc7ce75 Remove bogus reference to tc-filters(8) from tc(8) manpage.
Spotted by Aleš Kozumplík <al_es@seznam.cz>
(http://bugs.debian.org/289225)

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-12 14:55:42 -07:00
Stephen Hemminger
ba371d9890 don't allow "" for device name
If a zero-length string is given, it is not rejected by
netlink in kernel so catch it at command line.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-12 14:43:03 -07:00
Patrick McHardy
1d93483985 iplink: use netlink for link configuration
Add support for using netlink for link configuration. Kernel-support is
probed, when not available it falls back to using ioctls.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2007-08-22 10:49:01 -07:00
Stephen Hemminger
ae665a522b Remove trailing whitespace
Go through source files and remove all trailing whitespace

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:10:22 -08:00
shemminger
7b5657545d The ip(8) command has a bug when dealing with IPoIB link layer
addresses. Specifically it does not correctly handle the addition of
new entries in the neighbor/arp table. For example, this command will
fail:

ip neigh add 192.168.0.138 lladdr
00:00:04:04:fe:80:00:00:00:00:00:00:00:01:73:00:00:00:8a:91 nud
permanent dev ib0

An IPoIB link layer address is 20-bytes (see
http://www.ietf.org/internet-drafts/draft-ietf-ipoib-ip-over-infiniband-09.txt,
section 9.1.1).

The command line parsing code expects link layer addresses to be a
maximum of 16-bytes. Addresses over 16-bytes are truncated.
2006-03-21 23:57:50 +00:00
shemminger
f332d16924 Cleanup GCC4 warnings about signedness. 2005-07-05 22:37:15 +00:00
osdl.net!shemminger
71058eb8ef Fix ip command to not crash when interface name is too long.
always use strncpy(.., IFNAMSIZ)

(Logical change 1.79)
2004-09-01 17:15:45 +00:00
net[shemminger]!shemminger
d27b1b5b41 Import patch iplink.c.more_ifcfg_opts.diff
(Logical change 1.42)
2004-07-01 22:15:50 +00:00
osdl.org!shemminger
aba5acdfdb (Logical change 1.3) 2004-04-15 20:56:59 +00:00
osdl.org!shemminger
86fdf0e47b Initial revision 2004-04-15 20:56:59 +00:00