Commit Graph

60 Commits

Author SHA1 Message Date
Stephen Hemminger
4b726cb176 Whitespace and indentation cleanup
Need to go over whole source and scrub..
2014-05-09 12:36:46 -07:00
Jiri Pirko
fbea611564 introduce support for slave info data
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2014-02-17 10:53:33 -08:00
Pavel Emelyanov
5e25cf77b9 iproute: Make it possible to specify index on link creation
The RTM_NEWLINK message accepts ifi_index non-zero value and lets
creation of links with given index (if it's free, or course). This
functionality is available since linux-v3.5.

This patch makes this API available via ip tool.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-28 11:24:11 -08:00
Stephen Hemminger
d2468da0a3 check return value of rtnl_send and related functions
Use warn_unused_result to enforce checking return value of rtnl_send,
and fix where the errors are.

Suggested by initial patch from Petr Písař <ppisar@redhat.com>
2013-12-20 08:24:44 -08:00
Jiri Pirko
cc26a8909f iplink: add support for bonding netlink
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-10-30 16:45:04 -07:00
Nicolas Dichtel
1253a10a63 iplink: update available type list
macvtap and vti were missing.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2013-10-09 15:29:09 -07:00
xeb@mail.ru
af89576d7a iproute2: GRE over IPv6 tunnel support.
GRE over IPv6 tunnel support.

Signed-off-by: Dmitry Kozlov <xeb@mail.ru>
2013-09-30 21:33:55 -07:00
Rony Efraim
07fa9c1529 Add VF link state control
Add link state per VF command

Signed-off-by: Rony Efraim <ronye@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
2013-06-19 18:14:39 -07:00
Stephen Hemminger
f0124b0f0a ip: remove unnecessary ll_init_map
Don't call ll_init_map on modify operations
Saves significant overhead with 1000's of devices.
2013-03-28 15:17:47 -07:00
Petr Šabata
4405123433 iproute2: Mention the 'up' argument in documentation
Both ip-link and ip-address support the 'up' argument, however this
isn't documented in neither their help outputs or ip-address' manpage.
This patch fixes that.

Signed-off-by: Petr Šabata <contyk@redhat.com>
Reported-by: Jiří Popelka <jpopelka@redhat.com>
2013-03-14 13:26:33 -07:00
Stephen Hemminger
d1f28cf181 ip: make local functions static 2013-02-12 11:38:35 -08: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
Zhi Yong Wu
602e9d36ba ip: add the type 'vxlan' in the output of "ip link help"
The new type 'vxlan' is added in the output of "ip link help"

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
2012-12-17 08:15:57 -08:00
Nicolas Dichtel
1ce2de9738 ip: add support of 'ip link type [ipip|sit]'
This patch allows to manage ip tunnels via the interface ip link.
The syntax for parameters is the same that 'ip tunnel'.

It also allows to display tunnels parameters with 'ip -details link' or
'ip -details monitor link'.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2012-12-12 09:10:22 -08:00
Nicolas Dichtel
9d0efc1048 ip: add support of 'ip link type ip6tnl'
This patch allows to manage ip6 tunnels via the interface ip link.
The syntax for parameters is the same that 'ip -6 tunnel'.

It also allows to display tunnels parameters with 'ip -details link' or
'ip -details monitor link'.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2012-12-12 09:09:23 -08:00
Or Gerlitz
de0389935f iplink: Added support for the kernel IPoIB RTNL ops
Added support to ipoib rtnl ops through which one can create, configure,
query and delete IPoIB devices, for example

 $ ip link add link ib0.8001 name ib0.8001 type ipoib pkey 0x8001
 $ ip link add link ib0.1 name ib0.1 type ipoib mode connected
 $ ip --details link show dev ib0.1

Cc: Patrick McHardy <kaber@trash.net>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
2012-10-25 08:53:12 -07:00
Jiri Pirko
d992f3e611 iplink: add support for num[tr]xqueues 2012-08-01 16:19:55 -07:00
Christoph J. Thompson
5c434a9e5a iproute2 - Fix up and simplify variables pointing to install directories
Define where is the are located the iproute2 config files.
Get rid of trailing slashes for paths in several file.

Signed-off-by: Christoph J. Thompson <cjsthompson@gmail.com>
2012-04-12 09:49:10 -07:00
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