Commit Graph

867 Commits

Author SHA1 Message Date
Phil Sutter
c339b4cc53 ipneigh: add missing proxy keyword to help text
And while we're at it, add whitespace around braces and pipe symbol.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-02 11:23:51 -08:00
Phil Sutter
5c2ea5b8c0 iplink: fix help text syntax
Get rid of extraneous closing brackets and while here, merge the double
netns parameter.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-02 11:23:51 -08:00
Phil Sutter
27ff1a564b ipaddrlabel: Improve help text precision
Neither 'list' nor 'flush' actions accept parameters, and with given
prefix the action keyword is not optional anymore.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-02 11:23:51 -08:00
Phil Sutter
7a53aa592f ip: align help text with manpage
Although the ip command accepts both "neighbor" and "neighbour" as
subcommand, I assume it's sufficient to list it in help text as just
"neigh" like ip.8 does.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-02 11:23:51 -08:00
Stephen Hemminger
da60d03136 Merge branch 'master' into net-next 2016-03-02 09:41:28 -08:00
Phil Sutter
e897776690 ipl2tp: Print help even on systems without l2tp support
Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-02 09:33:20 -08:00
Stephen Hemminger
240b3573f7 Merge branch 'master' into net-next 2016-03-02 09:27:09 -08:00
Phil Sutter
67eedcd9a1 iprule: Align help text with man page synopsis
The help text was misleading: One could think it is possible to list
rules by selector, which would be nice but isn't. This change also
clarifies that 'ip rule' defaults to 'list' if no further arguments are
given.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-02 09:26:32 -08:00
Hiroshi Shimamoto
b6d77d9ee3 iplink: Support VF Trust
Add IFLA_VF_TRUST message to trust the VF.
PF can accept some privileged operation from the trusted VF.
For example, ixgbe PF doesn't allow to enable VF promiscuous mode until
the VF is trusted because it may hurt performance.

To trust VF.
 # ip link set dev eth0 vf 1 trust on

To untrust VF.
 # ip link set dev eth0 vf 1 trust off

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
2016-03-02 09:26:24 -08:00
Stephen Hemminger
9ecf3da984 Merge branch 'master' into net-next 2016-02-21 12:02:10 -08:00
Nikolay Aleksandrov
8a4cd3943f iplink: bridge: remove unnecessary returns
invarg exits so no need to return, remove this c&p error from my recent
patches

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-21 12:00:47 -08:00
Stephen Hemminger
1a6b1aa602 Merge branch 'master' into net-next 2016-02-17 17:53:28 -08:00
Nikolay Aleksandrov
478a8e5920 iplink: bridge_slave: add support for IFLA_BRPORT_FAST_LEAVE
Add support to be able to view and change IFLA_BRPORT_FAST_LEAVE
port attribute.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-17 17:47:01 -08:00
Nikolay Aleksandrov
10759a90ab iplink: bridge_slave: add support for IFLA_BRPORT_MULTICAST_ROUTER
Add support to be able to view and change IFLA_BRPORT_MULTICAST_ROUTER port
attribute.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-17 17:47:01 -08:00
Nikolay Aleksandrov
38b31a78da iplink: bridge_slave: add support for IFLA_BRPORT_PROXYARP_WIFI
Add support to be able to view and change IFLA_BRPORT_PROXYARP_WIFI port
attribute.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-17 17:47:01 -08:00
Nikolay Aleksandrov
f6e615dec9 iplink: bridge_slave: add support for IFLA_BRPORT_PROXYARP
Add support to be able to view and change IFLA_BRPORT_PROXYARP port
attribute.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-17 17:47:00 -08:00
Nikolay Aleksandrov
3069539fb8 iplink: bridge_slave: export read-only values
Export all the read-only values that get returned about a bridge port
such as the timers, the ids, designated_port and cost,
topology_change_ack and config_pending. For the bridge ids the
br_dump_bridge_id function is exported from iplink_bridge.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-17 17:47:00 -08:00
David Ahern
33e41670d7 vrf: Add support for slave_info
Print VRF slave_info attributes if present.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2016-02-17 17:45:04 -08:00
Stephen Hemminger
0aefb9fa41 Merge branch 'master' into net-next 2016-02-17 17:36:17 -08:00
Nicolas Cavallari
a1b4a274d4 netns: Fix an off-by-one strcpy() in netns_map_add().
netns_map_add() does a malloc of (sizeof (struct nsid_cache) +
strlen(name)) and then proceed with strcpy() of name into the
zero-length member at the end of the nsid_cache structure.  The
nul-terminator is written outside of the allocated memory and may
overwrite the allocator's internal structure.

This can trigger a segmentation fault on i386 uclibc with names of size 8:
after the corruption occurs, the call to closedir() on netns_map_init()
crashes while freeing the DIR structure.

Here is the relevant valgrind output:

==1251== Memcheck, a memory error detector
==1251== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==1251== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright
info
==1251== Command: ./ip netns
==1251==
==1251== Invalid write of size 1
==1251==    at 0x4011975: strcpy (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==1251==    by 0x8058B00: netns_map_add (ipnetns.c:181)
==1251==    by 0x8058E2A: netns_map_init (ipnetns.c:226)
==1251==    by 0x8058E79: do_netns (ipnetns.c:776)
==1251==    by 0x804D9FF: do_cmd (ip.c:110)
==1251==    by 0x804D814: main (ip.c:300)
2016-02-17 17:35:31 -08:00
Stephen Hemminger
07ec183418 iplink: display rx nohandler stats
Support for the new rx_nohandler statistic.
This code is designed to handle the case where the kernel reported statistic
structure is smaller than the larger structure in later releases (and vice versa).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-02-09 11:16:57 -08:00
Roopa Prabhu
ecc509f9a3 ip route: add mpls multipath support
This patch adds support to add mpls multipath
routes.

example:
ip -f mpls route add 100 \
	nexthop as 200 via inet 10.1.1.2 dev swp1 \
	nexthop as 700 via inet 10.1.1.6 dev swp2

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
2016-02-09 10:43:16 -08:00
Nikolay Aleksandrov
e6c38e2c59 iplink: bond_slave: fix ad_actor/partner_oper_port_state output
It seems that I've made a mistake when I exported these, instead of a
space in the end I've put a newline character which is wrong and breaks
the single line output.

Fixes: 7d6bc3b87a ("bonding: export 3ad actor and partner port state")
Reported-by: Sam Tannous <stannous@cumulusnetworks.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:43:06 -08:00
Nikolay Aleksandrov
861c5dae5c iplink: bridge: add support for netfilter call attributes
This patch implements support for the IFLA_BR_NF_CALL_(IP|IP6|ARP)TABLES
attributes in iproute2 so it can change their values.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
178b18066a iplink: bridge: add support for IFLA_BR_MCAST_STARTUP_QUERY_INTVL
This patch implements support for the IFLA_BR_MCAST_STARTUP_QUERY_INTVL
attribute in iproute2 so it can change the startup query interval.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
483df11cf1 iplink: bridge: add support for IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
This patch implements support for the IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
attribute in iproute2 so it can change the query response interval.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
5a32388f5c iplink: bridge: add support for IFLA_BR_MCAST_QUERY_INTVL
This patch implements support for the IFLA_BR_MCAST_QUERY_INTVL attribute
in iproute2 so it can change the query interval.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
1f2244b851 iplink: bridge: add support for IFLA_BR_MCAST_QUERIER_INTVL
This patch implements support for the IFLA_BR_MCAST_QUERIER_INTVL
attribute in iproute2 so it can change the querier interval.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
7f3d559226 iplink: bridge: add support for IFLA_BR_MCAST_MEMBERSHIP_INTVL
This patch implements support for the IFLA_BR_MCAST_MEMBERSHIP_INTVL
attribute in iproute2 so it can change the membership interval.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
10082a253f iplink: bridge: add support for IFLA_BR_MCAST_LAST_MEMBER_INTVL
This patch implements support for the IFLA_BR_MCAST_LAST_MEMBER_INTVL
attribute in iproute2 so it can change the last member interval.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
ceb6486655 iplink: bridge: add support for IFLA_BR_MCAST_STARTUP_QUERY_CNT
This patch implements support for the IFLA_BR_MCAST_STARTUP_QUERY_CNT
attribute in iproute2 so it can change the startup query count.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
fb44cadb92 iplink: bridge: add support for IFLA_BR_MCAST_LAST_MEMBER_CNT
This patch implements support for the IFLA_BR_MCAST_LAST_MEMBER_CNT
attribute in iproute2 so it can change the last member count value.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
8b9eb7cd25 iplink: bridge: add support for IFLA_BR_MCAST_HASH_MAX
This patch implements support for the IFLA_BR_MCAST_HASH_MAX attribute
in iproute2 so it can change the maximum hashed entries.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
92c0ef7071 iplink: bridge: add support for IFLA_BR_MCAST_HASH_ELASTICITY
This patch implements support for the IFLA_BR_MCAST_HASH_ELASTICTITY
attribute in iproute2 so it can change the hash elasticity value.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
0778b74122 iplink: bridge: add support for IFLA_BR_MCAST_QUERIER
This patch implements support for the IFLA_BR_MCAST_QUERIER attribute
in iproute2 so it can toggle the mcast querier value.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
449843d1d6 iplink: bridge: add support for IFLA_BR_MCAST_QUERY_USE_IFADDR
This patch implements support for the IFLA_BR_MCAST_QUERY_USE_IFADDR
attribute in iproute2 so it can toggle the multicast_query_use_ifaddr val.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
7ddd2d946c iplink: bridge: add support for IFLA_BR_MCAST_SNOOPING
This patch implements support for the IFLA_BR_MCAST_SNOOPING attribute
in iproute2 so it can change the multicast snooping value.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
963d137cf9 iplink: bridge: add support for IFLA_BR_MCAST_ROUTER
This patch implements support for the IFLA_BR_MCAST_ROUTER attribute
in iproute2 so it can change the multicast router value.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
719832af6c iplink: bridge: add support for IFLA_BR_VLAN_DEFAULT_PVID
This patch implements support for the IFLA_BR_VLAN_DEFAULT_PVID
attribute in iproute2 so it can change the default pvid.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
0a61aa3963 iplink: bridge: add support for IFLA_BR_GROUP_ADDR
This patch implements support for the IFLA_BR_GROUP_ADDR attribute
in iproute2 so it can change the group address.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
8caaf33bdb iplink: bridge: add support for IFLA_BR_GROUP_FWD_MASK
This patch implements support for the IFLA_BR_GROUP_FWD_MASK attribute
in iproute2 so it can change the group forwarding mask.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
8c0f7a1630 iplink: bridge: export read-only timers
Netlink already provides hello_timer, tcn_timer, topology_change_timer
and gc_timer, so let's make them visible.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
4e3bbc6658 iplink: bridge: export root_(port|path_cost), topology_change and change_detected
Netlink already export these values, we just need to make them visible.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Nikolay Aleksandrov
70dfb0b883 iplink: bridge: export bridge_id and designated_root
Netlink returns the bridge_id and designated_root, we just need to
make them visible.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Paolo Abeni
9450c5ec63 geneve: add support for lwt tunnel creation and dst port selection
This change add the ability to create lwt/flow based/externally
controlled geneve device and to select the udp destination port used
by a full geneve tunnel.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2016-02-05 11:55:06 +11:00
Roopa Prabhu
a9390c921a ipmonitor: match user option 'all' before 'all-nsid'
'ip monitor all' is broken on older kernels.
This patch fixes 'ip monitor all' to match
'all' and not 'all-nsid'.

It moves parsing arg 'all-nsid' to after parsing
'all'.

Before:
$ip monitor all
NETLINK_LISTEN_ALL_NSID: Protocol not available

After:
$ip monitor all
[NEIGH]Deleted 10.0.0.1 dev eth1 lladdr c4:54:44:4f:b2:dd STALE

Fixes: 449b824ad1 ("ipmonitor: allows to monitor in several netns")
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2016-02-05 11:45:02 +11:00
Zhang Shengju
eb85526923 ip-link: remove warning message
the warning was:
iproute.c:301:12: warning: 'val' may be used uninitialized in this
function [-Wmaybe-uninitialized]
   features &= ~RTAX_FEATURE_ECN;
            ^
iproute.c:575:10: note: 'val' was declared here
   __u32 val;
	  ^

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2016-02-02 15:57:43 +11:00
Thomas Faivre
5cd64c979f vxlan: fix help and man text
Options 'group' and 'remote' cannot take 'any' as value but 'local' can.

Signed-off-by: Thomas Faivre <thomas.faivre@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2016-01-18 11:44:22 -08:00
Stephen Hemminger
2505780c20 Merge branch 'net-next' 2016-01-18 09:37:45 -08:00
Roopa Prabhu
f921f567d1 iplink: replace exit with return
This patch replaces exits with returns in iplink
command. Helps to continue on errors when
invoked with ip -force -batch.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
2016-01-11 08:23:27 -08:00
Bjørn Mork
8e12bc0a9d iplink: support show and set of "addrgenmode random"
"random" is a new IPv6 addrgenmode, enabling "stable_secret" type
addresses with an auto-generated secret.

$ ip link set eth0 addrgenmode random

$ ip -d link show dev eth0
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:21:86:a3:25:7d brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode random

Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
2016-01-06 09:20:59 -08:00
Bjørn Mork
8e098dd81a iplink: support setting addrgenmode stable_secret
It is possible to switch to another addrgenmode after setting a
valid secret.  Allow switching back without reconfiguring the
secret for completeness.

Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
2016-01-06 09:20:59 -08:00
Stephen Hemminger
e49b51d663 monitor: fix file handle leak
In some cases passing file to monitor left file open.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2015-12-30 17:26:38 -08:00
Hangbin Liu
68eede2505 route: allow routes to be configured with expire values
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2015-12-21 21:38:29 -08:00
Phil Sutter
f8fc1d101e iptunnel: Fix compile error in ip/tunnel.c
I repeatedly failed to get this right, so now I have to clean up my mess
afterwards.

Fixes: 7d6aadcd0a ("ip{,6}tunnel: have a shared stats parser/printer")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-12-21 21:33:51 -08:00
Phil Sutter
7d6aadcd0a ip{,6}tunnel: have a shared stats parser/printer
This has a slight side-effect of not aborting when /proc/net/dev is
malformed, but OTOH stats are not parsed for uninteresting interfaces.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-12-18 11:46:21 -08:00
Paolo Abeni
d95cdcf52b lwtunnel: implement support for ip6 encap
Currently ip6 encap support for lwtunnel is missing.
This patch implement it, mostly duplicating the ipv4 parts.

Also be sure to insert a space after the encap type, when
showing lwtunnel, to avoid the tunnel type and the following
argument being merged into a single word.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2015-12-18 11:40:32 -08:00
Paolo Abeni
926b39e1fe gre: add support for collect metadata flag
This patch add support for IFLA_GRE_COLLECT_METADATA via the
'external' keyword to the gre link.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2015-12-18 11:40:32 -08:00
Paolo Abeni
e79c327edd vxlan: add support for collect metadata flag
This patch add support for IFLA_VXLAN_COLLECT_METADATA via the
'external' keyword to the vxlan link.

Also enforce mutual exclusion between 'vni' and 'external'.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2015-12-18 11:40:32 -08:00
Hannes Frederic Sowa
5c5176ce4b iproute: print addrgenmode stable_secret and fallback otherwise
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
2015-12-17 17:25:04 -08:00
Paolo Abeni
f0df40810f lwtunnel: fix argument parsing
Currently parse_encap_ip() does not update correctly argv/argc;
if multiple lwtunnel arguments are provided, the parsing fails after
the first one, i.e.

 ip route add 172.16.101.0/24 dev vxlan1 encap ip id 42 dst 192.168.255.1

fails with:

 Error: either "to" is duplicate, or "dst" is a garbage.

This commit addresses the issue, stepping to next argument at each iteration
of the parsing loop.

Fixes: 1e5293056a ("lwtunnel: Add encapsulation support to ip route")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2015-12-17 17:16:02 -08:00
Phil Sutter
ed6b8652f7 route: Fix printing of locked entries
Commit 0f7543322c ("route: ignore RTAX_HOPLIMIT of value -1")
accidentally reordered fprintf statements. This patch restores the
original ordering.

Fixes: 0f7543322c ("route: ignore RTAX_HOPLIMIT of value -1")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-12-17 17:07:07 -08:00
Konstantin Khlebnikov
e834eb8eba ip neigh: device is optional for proxy entries
Though dumping such entries crashes present kernels.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
2015-12-17 17:07:07 -08:00
Tom Herbert
5866bddd9a ila: Add support for ILA lwtunnels
This patch:
 - Adds a utility function for parsing a 64 bit address
 - Adds a utility function for converting a 64 bit address to ASCII
 - Adds and ILA encap type in lwt tunnels

Signed-off-by: Tom Herbert <tom@herbertland.com>
2015-12-17 17:07:07 -08:00
Stephen Hemminger
654ae881de ip: fix format string when reading statistics
The tunnel code was doing sscanf(buf, "%ld", &x) where x was unsigned
long.
2015-12-10 08:52:10 -08:00
David Ahern
8a23f82045 vrf: Add support for table names
Currently, the table id for VRF devices requires an integer. Convert
it to use rtnl_rttable_a2n which handles table names from the iproute2
directory.

This also fixes a bug in the original commit where table name are not
properly handled.

Fixes: 15faa0a30b ("add support for VRF device")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2015-12-10 08:45:30 -08:00
Phil Sutter
0f7543322c route: ignore RTAX_HOPLIMIT of value -1
Older kernels use -1 internally as indicator to use the sysctl default,
but they still export the setting. Newer kernels use 0 to indicate that
(which is why the conversion from -1 to 0 was done here), but they also
stopped exporting the value. Since the meaning of -1 is clear, treat it
equally like default on newer kernels (which is to not print anything).

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-12-10 08:45:11 -08:00
Stephen Hemminger
a96a5d94c6 iptunnel: cleanup code
Make iptunnel pass checkpatch (mostly).
2015-11-29 12:05:39 -08:00
Konstantin Shemyak
cc9c1dfaee ip_tunnel: determine tunnel address family from the tunnel type
On 24.11.2015 02:26, Stephen Hemminger wrote:
> On Thu, 12 Nov 2015 21:10:08 +0000
> Konstantin Shemyak <konstantin@shemyak.com> wrote:
>
>> When creating an IP tunnel over IPv6, the address family must be passed in
>> the option, e.g.
>>
>> ip -6 tunnel add mode ip6gre local 1::1 remote 2::2
>>
>> This makes it impossible to create both IPv4 and IPv6 tunnels in one batch.
>>
>> In fact the address family option is redundant here, as each tunnel mode is
>> relevant for only one address family.
>> The patch determines whether the applicable address family is AF_INET6
>> instead of the default AF_INET and makes the "-6" option unnecessary for
>> "ip tunnel add".
>>
>> Signed-off-by: Konstantin Shemyak <konstantin@shemyak.com>
>> ---
>>   ip/iptunnel.c                          | 26 ++++++++++++++++++++++++++
>>   testsuite/tests/ip/tunnel/add_tunnel.t | 14 ++++++++++++++
>>   2 files changed, 40 insertions(+)
>>   create mode 100755 testsuite/tests/ip/tunnel/add_tunnel.t
>>
>> diff --git a/ip/iptunnel.c b/ip/iptunnel.c
>> index 78fa988..7826a37 100644
>> --- a/ip/iptunnel.c
>> +++ b/ip/iptunnel.c
>> @@ -629,8 +629,34 @@ static int do_6rd(int argc, char **argv)
>>          return tnl_6rd_ioctl(cmd, medium, &ip6rd);
>>   }
>>
>> +static int tunnel_mode_is_ipv6(char *tunnel_mode) {
>> +       char *ipv6_modes[] = {
>> +               "ipv6/ipv6", "ip6ip6",
>> +               "vti6",
>> +               "ip/ipv6", "ipv4/ipv6", "ipip6", "ip4ip6",
>> +               "ip6gre", "gre/ipv6",
>> +               "any/ipv6", "any"
>> +       };
>> +       int i;
>> +
>> +       for (i = 0; i < sizeof(ipv6_modes) / sizeof(char *); i++) {
>> +               if (strcmp(ipv6_modes[i], tunnel_mode) == 0)
>> +                       return 1;
>> +       }
>> +       return 0;
>> +}
>> +
>
> The ipv6_modes table should be static const.

Thank you for the note! attached the corrected patch.

> Also is it possible to use strstr for ipv6 and ip6 or even strchr(tunnel_mode, '6')
> to simplify this?

There is IPv6 tunnel mode 'any', and IPv4 tunnel mode 'ipv6/ip' (aka
'sit'). It looks to me that attempts to find some substring match
would not make the code much shorter, but definitely less readable.

Konstantin Shemyak.

>From 42d27db0055c3a114fe6eb86d680bef9ec098ad4 Mon Sep 17 00:00:00 2001
From: Konstantin Shemyak <konstantin@shemyak.com>
Date: Thu, 12 Nov 2015 20:52:02 +0200
Subject: [PATCH] Tunnel address family is determined from the tunnel mode

When the tunnel mode already tells the IP address family, "ip tunnel"
command determines it and does not require option "-4"/"-6" to be passed.

This makes possible creating both IPv4 and IPv6 tunnels in one batch.

Signed-off-by: Konstantin Shemyak <konstantin@shemyak.com>
2015-11-29 11:57:21 -08:00
Tom Herbert
35f59d862f vxlan: Add support for remote checksum offload
This patch adds support to remote checksum checksum offload
to VXLAN. This patch adds remcsumtx and remcsumrx to ip vxlan
configuration to enable remote checksum offload for transmit
and receive on the VXLAN tunnel.

https://tools.ietf.org/html/draft-herbert-vxlan-rco-00

Example:

ip link add name vxlan0 type vxlan id 42 group 239.1.1.1 dev eth0 \
    udpcsum remcsumtx remcsumrx

Testing:

Ran single netperf over mlnx4 to illustrate the effest:

- Without RCO (UDP csum set to zero)
  4335.99 Mbps
- With RCO enabled
  7661.81 Mbps

Signed-off-by: Tom Herbert <tom@herbertland.com>
2015-11-29 11:53:02 -08:00
Phil Sutter
ea6cbab792 iproute: restrict hoplimit values to be in range [0; 255]
Technically, the range of possible hoplimit values are defined by IPv4
and IPv6 header formats. Both define the field to be eight bits in size,
which leads to a value range of [0;255]. Setting a packet's hoplimit
field to 0 though makes not much sense, as the next hop would
immediately drop the packet. Therefore Linux uses 0 as a special value
indicating to use the system's default hoplimit (configurable via
sysctl). In iproute, setting the hoplimit of a route to 0 is equivalent
to omitting the hoplimit parameter alltogether, so it is actually not
necessary to allow that value to be specified, but keep it anyway for
backwards compatibility.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-29 11:47:29 -08:00
Phil Sutter
d81f54d599 iptoken: simplify iptoken_list a bit
Since it uses only a single filter, rtnl_dump_filter() can be used.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-29 11:47:29 -08:00
Phil Sutter
906dfe4887 ipaddress: drop unnecessary check in ipaddr_list_flush_or_save()
Right after ipaddr_reset_filter(), filter.family is always AF_UNSPEC.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-29 11:47:29 -08:00
Phil Sutter
d25ec03e1d ipaddress: fix ipaddr_flush for Linux >= 3.1
Linux version 3.1 introduced a consistency check for netlink dumps in
commit 670dc28 ("netlink: advertise incomplete dumps"). This bites
iproute2 when flushing more addresses than can fit into a single
RTM_GETADDR response. To silence the spurious error message "Dump was
interrupted and may be inconsistent.", advise rtnl_dump_filter_l() to
not care about NLM_F_DUMP_INTR.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-29 11:47:29 -08:00
Phil Sutter
c6995c4802 ipaddress: simplify ipaddr_flush()
Since it's no longer relevant whether an IP address is primary or
secondary when flushing, ipaddr_flush() can be simplified a bit.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-29 11:47:29 -08:00
John W. Linville
906ac5437a geneve: add support for IPv6 link partners
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2015-11-23 16:23:11 -08:00
Neil Horman
e149d4e843 iproute2: Ignore EADDRNOTAVAIL errors during address flush operation
I found recently that, if I disabled address promotion in the kernel, that
ip addr flush dev <dev>

would fail with an EADDRNOTAVAIL errno (though the flush operation would in fact
flush all addresses from an interface properly)

Whats happening is that, if I add a primary and multiple secondary addresses to
an interface, the flush operation first ennumerates them all with a GETADDR |
DUMP operation, then sends a delete request for each address.  But the kernel,
having promotion disabled, deletes all secondary addresses when the primary is
removed.  That means, that several delete requests may still be pending in the
netlink request for addresses that have been removed on our behalf, resulting in
EADDRNOTAVAIL return codes.

It seems the simplest thing to do is to understand that EADDRUNAVAIL isn't a
fatal outcome on a flush operation, as it just indicates that an address which
you want to remove is already removed, so it can safely be ignored.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Stephen Hemminger <stephen@networkplumber.org>
CC: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
2015-11-23 15:59:08 -08:00
Phil Sutter
f7b49a3fc7 ip_common.h header cleanup
- Drop 'extern' keyword from all function prototypes.
- Make line breaking of print_* functions consistent.
- Make print_ntable() and ipntable_reset_filter() static and remove
  their declaration.
- Drop declaration of non-existent ipaddr_list() and iproute_monitor().

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:44:03 -08:00
Phil Sutter
04ce8d3eda ip{,6}tunnel: put spaces around non-unary operators
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
f53ecee818 iptunnel: sanitize copying tunnel name
Since p->name is only IFNAMSIZ bytes, do not copy more than IFNAMSIZ - 1
bytes into it so there remains at least a single null byte in the end.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
c957821b18 iptunnel: share common code when determining the default interface name
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
0dd4d2b37f iptunnel: simplify parsing TTL, allow 'hlim' as identifier
Instead of parsing an unsigned integer and checking boundaries, simply
parse u8. This and the added ttl alias 'hlim' provide consistency with
ip6tunnel.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
2520598a1a iptunnel: share common code when setting tunnel mode
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
7894ce7722 ip6tunnel: fix coding style: no newline between brace and else
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
9af72f819e ip6tunnel: print local/remote addresses like iptunnel does
This makes output consistent with iptunnel, also supporting reverse DNS
lookup for remote address if requested.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
c4527d7ba3 ip{,6}tunnel: align do_tunnels_list() a bit
In iptunnel, declare loop variables inside the loop as done in
ip6tunnel.

Fix and simplify goto logic in ip6tunnel:
- Failure to read over header lines would have left fp opened.
- By returning directly upon fopen() failure, fp can be closed
  unconditionally in the end.

Use the same goto logic in iptunnel, as well.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
4b3cb96281 iptunnel: use ll_name_to_index() for physical interface lookup
Although the cache is only initialized in do_show(), this way it is at
least consistent with ip6tunnel.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
6ddb1e8c90 ip{, 6}tunnel: unify behaviour if physical device is not found
Make ip6tunnel print an error message as well. While there, get rid of
unnecessary line breaking.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
a7ed1520ee ip/tunnel: introduce tnl_parse_key()
Instead of duplicating the same code six times (key, ikey and okey in
iptunnel and ip6tunnel), have a common parsing routine. This has the
added benefit of having the same verbose error message in ip6tunnel as
well as iptunnel.

I'm not sure if parsing an IPv4 address as key makes sense for
ip6tunnel, but the code was there before so this patch at least doesn't
make it worse.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Phil Sutter
8de592d05c ip{, 6}tunnel: get rid of extraneous whitespace when printing
Put whitespace in the beginning of optional parts, not as suffix
anywhere. Also drop double whitespaces in between words.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-23 15:26:37 -08:00
Stephen Hemminger
86c392f958 Merge branch 'master' into net-next 2015-10-23 15:46:08 -07:00
Stephen Hemminger
f7520a1998 ip: remove extra newlines at end-of-file
Shouldn't have extra blank lines.
2015-10-23 15:41:58 -07:00
Stephen Hemminger
651dccbee7 Merge branch 'master' into net-next 2015-10-22 23:42:37 -07:00
Daniel Borkmann
d583e88ebc ip, realms: also allow to pass in raw realms value
If get_rt_realms() fails, try to get a possible raw u32 realms
value for the u32 RTA_FLOW/FRA_FLOW attribute, as it might be
useful to directly configure the hex value itself. And only if
that fails, then bail out.

The source realm is provided in the upper u16 (mask: 0xffff0000)
and the destination realm through the lower u16 part (mask:
0x0000ffff). This can be useful for tc's bpf realm matcher, but
also a full hex/mask param can be provided already for matching
through iptables' --realm cmdline option, for example.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2015-10-22 23:40:51 -07:00
Kirill Tkhai
2f4e171f7d Add ip rule save/restore
This patch adds save and restore commands to "ip rule"
similar the same is made in commit f4ff11e3e2 for "ip route".

The feature is useful in checkpoint/restore for container
migration, also it may be helpful in some normal situations.

Signed-off-by: Kirill Tkhai <ktkhai@odin.com>
2015-10-22 23:35:57 -07:00
Stephen Hemminger
b89c359c15 Merge branch 'master' into net-next 2015-10-18 21:58:29 -07:00
Roopa Prabhu
8b21cef129 ip route get: change exit to return to support batch commands
replace exit with return -2 on rtnl_talk failure

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
2015-10-18 21:57:46 -07:00
Phil Sutter
ccaf6eb5cc ip-rule: neither prohibit nor reject or unreachable flags exist
This has been inconsistent since the beginning of Git and seems to be
merely a documentation leftover, therefore just remove it from help
output and man page.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-10-18 21:57:01 -07:00
Roopa Prabhu
1e5293056a lwtunnel: Add encapsulation support to ip route
This patch adds support to parse and print lwtunnel
encapsulation attributes attached to routes for MPLS
and IP tunnels.

example:
Add ipv4 route with mpls encap attributes:

Examples:

  MPLS:
  $ ip route add 40.1.2.0/30 encap mpls 200 via inet 40.1.1.1 dev eth3
  $ ip route show
  40.1.2.0/30  encap mpls 200 via 40.1.1.1 dev eth3

  Add ipv4 multipath route with mpls encap attributes:
  $ ip route add 10.1.1.0/30 nexthop encap mpls 200 via 10.1.1.1 dev eth0 \
		    nexthop encap mpls 700 via  40.1.1.2 dev eth3
  $ ip route show
  10.1.1.0/30
    nexthop encap mpls 200  via 10.1.1.1  dev eth0 weight 1
    nexthop encap mpls 700  via 40.1.1.2  dev eth3 weight 1

  IP:
  $ ip route add 10.1.1.1/24 encap ip id 200 dst 20.1.1.1 dev vxlan0

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Jiri Benc <jbenc@redhat.com>
2015-10-16 16:13:22 -07:00
Stephen Hemminger
c6646c1ea5 Merge branch 'master' into net-next 2015-10-16 16:03:32 -07:00
Phil Sutter
6f07f3dc41 ip-address: fix oneline mode for interfaces with VF
Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-10-16 16:02:38 -07:00
Roopa Prabhu
39ca4879a0 ip monitor neigh: Change 'delete' to 'Deleted' to be consistent with ip route
It helps to grep for one string "Deleted" when monitoring all events.

Fixes: 6ea3ebafe0 ("iproute2: inform user when a neighbor is removed")
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-10-16 16:01:34 -07:00
Stephen Hemminger
d2ccb70a91 Merge branch 'master' into net-next 2015-10-12 09:50:46 -07:00
Phil Sutter
3cf8ba5960 ip: macvlan: support MACVLAN_FLAG_NOPROMISC flag
This flag is allowed for devices in passthru mode to prevent forcing the
underlying interface into promiscuous mode.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-10-12 09:46:55 -07:00
Phil Sutter
541f1b3e1d ip: link: consolidate macvlan and macvtap
After eliminating the minor differences in both files which existed
solely because features/fixes were applied to only one of them and not
the other, the remaining differences were in function naming and error
messages. The latter is addressed by using the 'id' field of struct
link_util.

Fold both files into one in order to share common code and eliminate the
chance of having fixes/enhancements applied to only one of them.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-10-12 09:46:55 -07:00
David Ahern
b8c753245b ip neigh: Add ifindex to request when filtering dumps by device
Add ifindex to dump request when filtering by device. If the kernel
supports it adding the index to the request limits the amount of data
the kernel pushes to userpsace.

The feature exists in userspace already, so no need to warn the user
if kernel side support does not exist. Using the kernel side filter
makes the request more efficient.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2015-10-12 09:43:28 -07:00
David Ahern
0d238ca2b8 ip neigh: Add support for filtering dumps by master device
Add support for filtering neighbor dumps by master device. Kernel side
support provided by commit 21fdd092acc7. Since the feature is not
available in older kernels the user is given a warning message if the
kernel does not support the request.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2015-10-12 09:39:37 -07:00
Stephen Hemminger
cf5b002f20 Merge branch 'master' into net-next 2015-10-12 09:32:14 -07:00
Christoph Schulz
8aacb9bbbd ip: allow using a device "help" (or a prefix thereof)
Device names that match "help" or a prefix thereof should be allowed anywhere
a device name can be used. Note that a suitable keyword ("dev" or "name", the
latter for "ip tunnel") has to be used in these cases to resolve ambiguities.

Signed-off-by: Christoph Schulz <develop@kristov.de>
Reported-by: Leonhard Preis <leonhard@pre.is>
Reported-by: Wilhelm Wijkander <lists@0x5e.se>
2015-10-07 10:35:17 +01:00
David Ahern
84d30afd8a ip: Add type and master filters to brief output
The brief format does not honer the master and type filters:

$ ip link show master vrf-mgmt
7: dummy0: <BROADCAST,NOARP,SLAVE> mtu 1500 qdisc noop master vrf-mgmt state DOWN mode DEFAULT group default qlen 1000
    link/ether 66:39:cc:2b:e9:bd brd ff:ff:ff:ff:ff:ff

$ ip -br link show master vrf-mgmt
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0             UP             08:00:27🇩🇪14:c8 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth1             UP             08:00:27:87:02:f1 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth2             UP             08:00:27:61:1e:fd <BROADCAST,MULTICAST,UP,LOWER_UP>
vrf-blue         UNKNOWN        a6:3f:09:34:7e:74 <NOARP,MASTER,UP,LOWER_UP>
vrf-red          DOWN           fe:a2:2d:e1:bc:ac <NOARP,MASTER>
dummy0           DOWN           66:39:cc:2b:e9:bd <BROADCAST,NOARP,SLAVE>
dummy1           DOWN           4a:4f:13:91:64:b1 <BROADCAST,NOARP,SLAVE>
dummy2           DOWN           b2:4f:b6💿bd:a6 <BROADCAST,NOARP>
dummy3           DOWN           1e:06:3d:40:b8:c2 <BROADCAST,NOARP,SLAVE>
vrf-mgmt         DOWN           ce:b2:74:41:21:df <NOARP,MASTER>

With this patch the expected output is shown:

$ ip -br link show master vrf-mgmt
dummy0           DOWN           66:39:cc:2b:e9:bd <BROADCAST,NOARP,SLAVE>

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2015-09-23 16:27:52 -07:00
David Ahern
bc234301af ip route: Add RTM_F_LOOKUP_TABLE flag and show table id
Currently 'ip route get' does not show the table the lookup result comes
from and prior to kernel commit c36ba6603a11 the response from the kernel
was hardcoded to the main table. From the discussion this appears to be
a leftover from the route cache where the cached entry lost the table id
and so the result was hardcoded to main table.

c36ba6603a11 added the RTM_F_LOOKUP_TABLE flag to maintain that behavior
but to allow new tools to ask for the actual table id for the lookup.
This patch adds that flag to ip route get request and if the result is
not the main table shows the table id.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2015-09-23 16:18:56 -07:00
Andrew Vagin
5b9ac19029 route: filter routes by family if it's specified
Currently when we specify AF_INET6 when it is disabled, we will get
all routes.

For example, we can boot kernel with ipv6.disable=1 and try to get ipv6
routes:
$ ip -6 route show
default via 192.168.122.1 dev eth0  proto static  metric 100
192.168.122.0/24 dev eth0  proto kernel  scope link  src 192.168.122.141  metric 100

Here are ipv4 routes and this is unexpected behaviour.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
2015-09-23 16:16:19 -07:00
Phil Sutter
940a96e6ca ip-link: do not support 'ip link add dev help'
Commit 0532555 ('Support "ip link add help" for rtnl_link API') added a
check for specified help parameter. Though due to the place where it has
been added to, it is not possible anymore to force a given parameter to
be interpreted as interface name by prefixing it with 'dev '. Fix this
by forcing whatever follows 'dev' to be presumed as interface name.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-09-23 16:00:48 -07:00
Arthur Gautier
a197883432 ip link: missing options in bond usage
Signed-off-by: Arthur Gautier <baloo@gandi.net>
2015-09-21 14:36:02 -07:00
Stephen Hemminger
3649d01895 l2tp: add missing newline on show output
After cookie there was no newline.
2015-09-11 15:26:58 -07:00
Denis Kirjanov
9827fa57da iproute: print more verbose error on route cache flush
Before:
kda@vfirst ~/devel/iproute2 $ ./ip/ip route flush cache
Cannot open "/proc/sys/net/ipv4/route/flush"

After:
kda@vfirst ~/devel/iproute2/ip $ ./ip route flush cache
Cannot open "/proc/sys/net/ipv4/route/flush": Permission denied

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
2015-09-07 11:10:22 -07:00
Toshiaki Makita
1eea5c46ec iplink: Add support for IFLA_BR_VLAN_PROTOCOL attribute
This patch adds support for bridge vlan_protocol.

Example:
$ ip link set br0 type bridge vlan_protocol 802.1ad
$ ip -d link show br0
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UP mode DEFAULT group default qlen 1000
    link/ether 44:37:e6🆎cd:ef brd ff:ff:ff:ff:ff:ff promiscuity 0
    bridge forward_delay 0 hello_time 200 max_age 2000 ageing_time 30000
stp_state 0 priority 32768 vlan_filtering 0 vlan_protocol 802.1ad
addrgenmode eui64

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
2015-08-31 16:35:25 -07:00
Stephen Hemminger
f1e225beef Merge branch 'master' into net-next 2015-08-31 16:32:10 -07:00
Andy Gospodarek
5d295bb8e1 add support for brief output for link and addresses
This adds support for slightly less output than is normally provided by
'ip link show' and 'ip addr show'.  This is a bit better when you have a
host with lots of interfaces.  Sample output:

$ ip -br link show
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
p2p1             UP             08:00:27:ee:0b:3b <BROADCAST,MULTICAST,UP,LOWER_UP>
p7p1             UP             08:00:27:9d:62:9f <BROADCAST,MULTICAST,UP,LOWER_UP>
p8p1             DOWN           08:00:27:dc:d8:ca <NO-CARRIER,BROADCAST,MULTICAST,UP>
p9p1             UP             08:00:27:76:d9:75 <BROADCAST,MULTICAST,UP,LOWER_UP>
p7p1.100@p7p1    UP             08:00:27:9d:62:9f <BROADCAST,MULTICAST,UP,LOWER_UP>

$ ip -br -4 addr show
lo               UNKNOWN        127.0.0.1/8
p2p1             UP             192.168.56.2/24
p7p1             UP             70.0.0.1/24
p8p1             DOWN           80.0.0.1/24
p9p1             UP             10.0.5.15/24
p7p1.100@p7p1    UP             200.0.0.1/24

$ ip -br -6 addr show
lo               UNKNOWN        ::1/128
p2p1             UP             fe80::a00:27ff:feee:b3b/64
p7p1             UP             7000::1/8 fe80::a00:27ff:fe9d:629f/64
p8p1             DOWN           8000::1/8
p9p1             UP             fe80::a00:27ff:fe76:d975/64
p7p1.100@p7p1    UP             fe80::a00:27ff:fe9d:629f/64

$ ip -br addr show p7p1
p7p1             UP             70.0.0.1/24 7000::1/8 fe80::a00:27ff:fe9d:629f/64

v2: Now with color support!
v3: Better field width estimation (except netdev names to keep output at a
decent width) and whitespace fixup.

Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
2015-08-31 16:24:10 -07:00
Stephen Hemminger
6c5ffb9a2c iplink: cleanup whitespace and checkpatch issues
Mostly just use of {} and whitespace.
2015-08-25 15:57:04 -07:00
David Ahern
15faa0a30b add support for VRF device
Allow user to create a vrf device and specify its table binding.
Based on the iplink_vlan implementation.

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2015-08-23 10:14:16 -07:00
Stephen Hemminger
dfc3d015f6 Merge branch 'master' into net-next 2015-08-23 10:09:46 -07:00
Zhang Shengju
6843d36e3d ip-link: cut one level indentation
Cut one level indentation to make things easier to read.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-19 16:09:09 -07:00
Stephen Hemminger
9a6422c243 Merge branch 'master' into net-next 2015-08-13 19:42:41 -07:00
Stephen Hemminger
e0f229fb75 bond: fix return after invarg 2015-08-13 14:20:54 -07:00
Zhang Shengju
6a9ce30e78 ip-link: remove unnecessary return
Remove unnecessary retrun, because invarg() exit.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-13 14:12:33 -07:00
Pavel Šimerda
4e972d5ef4 ip-address: fix and extend documentation
* Improve manual page synopsis and built-it help
 * Use full subcommand names (e.g. 'address' and 'maddress')
 * Specify when IPv4, IPv6 or both are affected
 * Add lifetimes, home and nodad
 * Remove any remaining excess spaces

Commit 43d29f7 substantially improves generated ip-address.8 instead of
ip-address.8.in and commit e419f2d removes the generated one losing the
improvements entirely. This commit recovers the lost changes, adapts
them to the current manual page and adds more man page and help
improvements.

Original commit by: Kenyon Ralph <kenyon@kenyonralph.com>
2015-08-13 14:11:09 -07:00
Pavel Šimerda
142434dc51 ip: fix and extend documentation
* Use unabbreviated `address` and `maddress`
 * Keep only `-n` and `-netns` for network namespace
2015-08-13 14:11:09 -07:00
Zhang Shengju
ff1e35edf5 ip-link: enhance prompt message
Enhance promtp message for 'spoofchk' and 'query_rss' flag, and fix a
typo.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-13 14:10:22 -07:00
Nikolay Aleksandrov
e4d456f0bb iplink: add support for IFLA_BR_VLAN_FILTERING attribute
This patch implements support for the IFLA_BR_VLAN_FILTERING attribute
in iproute2 so it can enable/disable vlan_filtering.

Example:
$ ip link set br0 type bridge vlan_filtering 1
$ ip -d link show br0
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
UP mode DEFAULT group default
    link/ether 08:00:27:ea:07:38 brd ff:ff:ff:ff:ff:ff promiscuity 0
    bridge forward_delay 1500 hello_time 200 max_age 2000 vlan_filtering 1
    addrgenmode eui64

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2015-08-12 09:19:06 -07:00
Stephen Hemminger
941c509906 Merge branch 'master' into net-next 2015-08-12 09:14:48 -07:00
Nikolay Aleksandrov
fdba05155c iplink: add ageing_time, stp_state and priority for bridge
When showing bridge attributes, show also ageing_time, stp_state and
priority if available.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2015-08-12 09:11:30 -07:00
Stephen Hemminger
4b942cb1df Merge branch 'master' into net-next 2015-08-12 09:09:43 -07:00
Zhang Shengju
e543a6a8a0 ip-link: fix a typo in help message
fix a typo: "noarp" -> "arp"

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-12 09:05:57 -07:00
Zhang Shengju
a560d850d9 iplink: shortify printing the usage of link type
Allow to print link type usage by: ip link help bridge_slave

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-12 09:05:57 -07:00
Zhang Shengju
43367ef7eb iplink: use the short format to print help info
Allow to print link type usage by: ip link help bridge

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-12 09:05:57 -07:00
Zhang Shengju
d8cf93de04 iplink: add missing link type
Add missing link type "bridge_slave".

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-12 09:05:57 -07:00
Stephen Hemminger
2f29d6bb50 ipnetns: make net namespace cache variable size
Save some space by using variable size for nsid cache elements.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2015-08-12 08:53:31 -07:00
Nikolay Aleksandrov
d02e46627f iplink: bonding: add support for IFLA_BOND_TLB_DYNAMIC_LB
Add support to be able to set and show the value of tlb_dynamic_lb
(IFLA_BOND_TLB_DYNAMIC_LB).
Example:
$ ip -d link show dev bond0 type bond
7: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
mode DEFAULT group default
    link/ether ce:2f:e1:6e:d7:e0 brd ff:ff:ff:ff:ff:ff promiscuity 0
    bond mode balance-tlb miimon 100 updelay 0 downdelay 0 use_carrier 1
arp_interval 0 arp_validate none arp_all_targets any primary_reselect
always fail_over_mac none xmit_hash_policy layer2 resend_igmp 1
num_grat_arp 1 all_slaves_active 0 min_links 0 lp_interval 1
packets_per_slave 1 lacp_rate slow ad_select stable tlb_dynamic_lb 1
addrgenmode eui64

$ ip -d l set dev bond0 type bond tlb_dynamic_lb 0
$ ip -d link show dev bond0 type bond
7: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
mode DEFAULT group default
    link/ether ce:2f:e1:6e:d7:e0 brd ff:ff:ff:ff:ff:ff promiscuity 0
    bond mode balance-tlb miimon 100 updelay 0 downdelay 0 use_carrier 1
arp_interval 0 arp_validate none arp_all_targets any primary_reselect
always fail_over_mac none xmit_hash_policy layer2 resend_igmp 1
num_grat_arp 1 all_slaves_active 0 min_links 0 lp_interval 1
packets_per_slave 1 lacp_rate slow ad_select stable tlb_dynamic_lb 0
addrgenmode eui64

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2015-08-10 11:22:09 -07:00
Stephen Hemminger
68831d6b45 Merge branch 'master' into net-next 2015-07-31 18:12:57 -07:00
Antti Paila
531d5da413 ip: Preserve original portocol family in batch mode
Reset the 'preferred_family' global variable
to its initially set value before each batch
file command is processed.

Signed-off-by: Antti Paila <antti.paila@gmail.com>
2015-07-31 18:10:14 -07:00
Anuradha Karuppiah
188648270a ip link: proto_down config and display.
This patch adds support to set and display protodown on a switch port. The
switch driver can handle this error state by doing a phys down on the port.

One example user space application setting this flag is a multi-chassis
LAG application to handle split-brain situation on peer-link failure.

Example:
root@net-next:~# ip link set eth1 protodown on
root@net-next:~/iproute2# ip link show eth1
4: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:12:35:01 brd ff:ff:ff:ff:ff:ff protodown on
root@net-next:~/iproute2# ip link set eth1 protodown off
root@net-next:~/iproute2# ip link show eth1
4: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:12:35:01 brd ff:ff:ff:ff:ff:ff
root@net-next:~/iproute2#

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
2015-07-28 16:43:20 -07:00
Felix Janda
ea343669fa Replace BSD MAXPATHLEN by POSIX PATH_MAX
Prefer using the POSIX constant PATH_MAX instead of the legacy BSD
derived MAXPATHLEN. The necessary includes for MAXPATHLEN and PATH_MAX
are <sys/param.h> and <limits.h>, respectively.

Signed-off-by: Felix Janda <felix.janda@posteo.de>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
2015-07-28 16:39:29 -07:00
Zhang Shengju
cb89c7c70a ip/ip6tunnel: fix missing return value check
Make sure that return value of each socket() call is properly checked
and do not continue processing if the call failed.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-07-27 14:37:47 -07:00
Zhang Shengju
0dc2e22978 xfrm: remove duplicated include
Remove dupldated include for <linux/xfrm.h>, since it's already
included by 'xfrm.h'.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-07-27 14:36:53 -07:00
Stephen Hemminger
ec7aff5c4f ip: fix all the checkpatch warnings
Zhang Shengju some places where tabs were not being used.
Go ahead and fix all the trival checkpatch warnings in ip/ip.c
Also fix bridge.c
2015-07-26 21:50:22 -07:00
Jiri Pirko
122f2fc573 iproute2: ipa: show switch id
We forgot to include this patch somehow. So do it now.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Andy Gospodarek <gospo@cumulusnetworks.com>
2015-07-20 14:59:50 -07:00
Roopa Prabhu
56d8ff0ac8 support batching of ip route get commands
This patch replaces exits with returns in
ip route get command handling. This allows batching
of ip route get commands.

$cat route_get_batch.txt
route get 10.0.14.2
route get 12.0.14.2
route get 10.0.14.4

$ip -batch route_get_batch.txt
local 10.0.14.2 dev lo  src 10.0.14.2
    cache <local>
12.0.14.2 via 192.168.0.2 dev eth0  src 192.168.0.15
    cache
10.0.14.4 dev dummy0  src 10.0.14.2
    cache

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
2015-07-20 14:55:19 -07:00
Andy Gospodarek
528c2551cd iproute2: add support to print 'linkdown' nexthop flag
Signed-off-by: Andy Gospodaerk <gospo@cumulusnetworks.com>
Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
Acked-by: Scott Feldman <sfeldma@gmail.com>
2015-06-26 00:13:47 -04:00
Nikolay Aleksandrov
b0197a047e iplink_bridge: add support for priority
This patch adds support to set bridge stp priority via IFLA_BR_PRIORITY.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
2015-06-26 00:06:45 -04:00