Commit Graph

18 Commits

Author SHA1 Message Date
Serhey Popovych
c58213f69c iplink: Perform most of request buffer setups and checks in iplink_parse()
To benefit other users (e.g. link_veth.c) of iplink_parse() from
additional attribute checks and setups made in iplink_modify(). This
catches most of weired cobination of parameters to peer device
configuration.

Drop @name, @dev, @link, @group and @index from iplink_parse() parameters
list: they are not needed outside.

While there change return -1 to exit(-1) for group parsing errors: we
want to stop further command processing unless -force option is given
to get error line easily.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
2018-03-11 17:59:03 -07:00
Serhey Popovych
c14f9d92ee treewide: Use addattr_nest()/addattr_nest_end() to handle nested attributes
We have helper routines to support nested attribute addition into
netlink buffer: use them instead of open coding.

Use addattr_nest_compat()/addattr_nest_compat_end() where appropriate.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-02 15:01:09 -08:00
Serhey Popovych
28254695d1 ip: Minor cleanups
1) Rename @hdr parameter to @n to be coherent with rest of the parsing
     code.

  2) Use NLMSG_DATA() to get pointer to the data after nlmsghdr instead
     of calculating it directly in ip/tunnel code.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-02 14:58:26 -08:00
Serhey Popovych
8c0b19d178 vxcan,veth: Forbid "type" for peer device
It is already given for original device we configure this
peer for.

Results from following command before/after change applied
are shown below:

  $ ip link add dev veth1a type veth peer name veth1b \
                           type veth peer name veth1c

Before:
-------

<no output, no netdevs created>

After:
------

Error: duplicate "type": "veth" is the second value.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-12-28 09:35:27 -08:00
Serhey Popovych
dac9ff35ea iplink: Kill redundant network device name checks
Since commit 625df645b7 (Check user supplied interface name lengths)
iplink_parse() validates network device name using check_ifname()
helpers.

Remove redundant "name" length checks from iplink_parse() callers.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-12-19 08:12:41 -08: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
561e650eff ip link: Shortify printing the usage of link type
Allow to print particular link type usage by:

    ip link help [TYPE]

Currently to print usage for some link type it is needed
to use the following way:

    ip link { add | del | set } type TYPE help

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-10-09 08:29:47 -07:00
Kusanagi Kouichi
1891754487 veth: Handle flags correctry
Flags for a peer override flags for the other and not used for the
peer.

before:
# ip link add up type veth peer down multicast off
# ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: veth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 2e:5c:cd:f5:63:d2 brd ff:ff:ff:ff:ff:ff
3: veth1: <BROADCAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 72:b0:fa:1e:76:7a brd ff:ff:ff:ff:ff:ff

after:
# ip link add up type veth peer down multicast off
# ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: veth0: <BROADCAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 6e:db:03:b3:bd:ff brd ff:ff:ff:ff:ff:ff
3: veth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether a6:62:d9:84:f0:73 brd ff:ff:ff:ff:ff:ff

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
2014-04-11 17:44:48 -07: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
Sergey Popovich
e0d47aa303 Handle netdev group for veth peer too
Currently ip-link(8) parses, but ignores "group" argument to
peer interface on veth creation.

Insert IFLA_GROUP attribute for peer interface when present.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ru>
2013-12-20 08:27:51 -08:00
Stephen Hemminger
be2c3142f9 veth: fix uninitialized arguments
Based on patch by Sergey Popovich <popovich_sergei@mail.ru>
This fixes crash when ip-link(8) invoced with command:

  ip link add dev veth1a type veth peer
2013-12-20 08:25:13 -08:00
Stephen Hemminger
ac3ff72032 cleanup help message
Split it naturally
2013-08-04 15:00:42 -07: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
Stephen Hemminger
118c923cc0 veth.h move to linux/
Move veth.h to linux/ since it is an API.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-12-25 12:38:08 -08:00
Stephen Hemminger
c595fda55b veth: use kernel header file
Use santized kernel header for veth.h and put in correct place
to prevent possible future problems with API.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-12-21 09:37:30 -08:00
Vitaliy Gusev
f9329ccaf9 veth device link management
Signed-off-by: Vitaliy Gusev <vgusev@openvz.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-12-21 09:24:12 -08:00
Stephen Hemminger
e32d4db0a5 don't make veth a shared library
Making veth a shared library for ip caused build problems (not PIC)
and is unneeded.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-11 13:01:42 -07:00
Pavel Emelianov
2da55b1bbe Module for ip utility to support veth device (v.2.1)
The usage is
# ip link add [name] type veth [peer <name>] [mac <mac>] [peer_mac <mac>]

This version doesn't include the fix for ip/iplink.c as Patrick
said that he had included it into his patches already.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-09-05 12:04:16 +01:00