Commit Graph

206 Commits

Author SHA1 Message Date
Phil Sutter
070ebbdf75 iproute: TYPE keyword is not optional, fix help text accordingly
This is a bit pedantic, but brackets ([]) show optional values and since
TYPE must not become empty, they're not suited to surround the type
keyword choices. Use curly braces instead.

Also add some missing whitespace to the parameter list above.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-02 11:23:51 -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
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
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
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
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
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
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
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
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
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
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
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
Roopa Prabhu
f638e9f7c8 mpls: always set type RTN_UNICAST and scope RT_SCOPE_UNIVERSE for
This patch fixes incorrect -EINVAL errors due to invalid
scope and type during mpls route deletes.

$ip -f mpls route add 100 as 200 via inet 10.1.1.2 dev swp1

$ip -f mpls route show
100 as to 200 via inet 10.1.1.2 dev swp1

$ip -f mpls route del 100 as 200 via inet 10.1.1.2 dev swp1
RTNETLINK answers: Invalid argument

$ip -f mpls route del 100
RTNETLINK answers: Invalid argument

After patch:

$ip -f mpls route show
100 as to 200 via inet 10.1.1.2 dev swp1

$ip -f mpls route del 100 as 200 via inet 10.1.1.2 dev swp1

$ip -f mpls route show

Always set type to RTN_UNICAST for mpls route add/deletes.
Also to keep things consistent with kernel set scope to
RT_SCOPE_UNIVERSE for both mpls and ipv6 routes. Both mpls and ipv6 route
deletes ignore scope.

Suggested-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-06-25 23:54:27 -04:00
Stephen Hemminger
03371c7d98 Merge branch 'master' into net-next
Conflicts:
	include/linux/tcp.h
	lib/libnetlink.c
2015-05-28 09:18:01 -07:00
Stephen Hemminger
c52827e907 change of rtnetlink to use RTN_F_OFFLOAD
The definition of offload flag changed during 4.1 rc process.
2015-05-27 18:29:02 -07:00
Stephen Hemminger
c079e121a7 libnetlink: add size argument to rtnl_talk
There have been several instances where response from kernel
has overrun the stack buffer from the caller. Avoid future problems
by passing a size argument.

Also drop the unused peer and group arguments to rtnl_talk.
2015-05-27 13:00:21 -07:00
Nicolas Dichtel
0628cddd9d libnetlink: introduce rtnl_listen_filter_t
There is no functional change with this commit. It only prepares the next one.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-05-21 15:28:56 -07:00
Thomas Graf
38a7f26828 route: Add missing newline in helptext
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2015-05-11 09:14:44 -07:00
Stephen Hemminger
d58ba4ba2a ip: return correct exit code on route failure
If kernel complains about ip route request, exit status should be
2 not 1.

This fixes regression introduced by:
commit 42ecedd4ba
Author: Roopa Prabhu <roopa@cumulusnetworks.com>
Date:   Tue Mar 17 19:26:32 2015 -0700

    fix ip -force -batch to continue on errors
2015-05-07 08:11:30 -07:00
Andy Gospodarek
aa05b988f5 iproute2: unify naming for entries offloaded to hardware
The kernel now has the capability to offload FDB and FIB entries to hardware.
It is important to let users know if table entries are also offloaded to
hardware.  Currently offloaded FDB entries are indicated by the existence of
the flag 'external' on the entry as of the following commit:

commit 28467b7f3f
Author: Scott Feldman <sfeldma@gmail.com>
Date:   Thu Dec 4 09:57:15 2014 +0100

    bridge/fdb: add flag/indication for FDB entry synced from offload device

When the patch to add support for indicating that FIB entries were also
offloaded as posted to netdev by Scott Feldman it became clear that 'external'
would not be an ideal name for routes.  There could definitely be confusion
about what this might mean since many routes are to external networks -- a
collision/confusion that did not happen with FDB.

Scott Feldman asked me to check with others and build concensus around a name.
After speaking with several people about this I am proposing we refer to both
FDB and FIB entries that are currently backed by hardware (based on the work
done in rocker) with the flag 'offload' appended to the end ofthe entry.

Some people liked the string 'external,' others liked 'hardware,' but the point
is to communicate that these routes are available to something that will will
offload the forwarding normally done by the kernel.  Since the term 'offload'
is used so frequently it seems appropriate to use the same language in
ip/bridge output.

The term 'offload' also seems to resonate with many of the people who have
responded on Scott's original thread or to those who I reached out to directly
and did respond to my query, so it seems we have reached consensus that it
should be the term used going forward.

v2: rebased against net-next branch

Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
CC: Jamal Hadi Salim <jhs@mojatatu.com>
CC: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
CC: Jiri Pirko <jiri@resnulli.us>
CC: John W. Linville <linville@tuxdriver.com>
CC: Roopa Prabhu <roopa@cumulusnetworks.com>
CC: Scott Feldman <sfeldma@gmail.com>
CC: Stephen Hemminger <stephen@networkplumber.org>
2015-04-13 09:40:46 -07:00
Lubomir Rintel
194e9b855d ip: support RFC4191 router preference
This allows querying and setting the route preference. It's usually set from
the IPv6 Neighbor Discovery Router Advertisement messages.

Introduced in "ipv6: expose RFC4191 route preference via rtnetlink", enqueued
for Linux 4.1.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2015-03-24 15:45:23 -07:00
Eric W. Biederman
dacc5d4197 add basic mpls support to iproute
- Pull in the uapi mpls.h
- Update rtnetlink.h to include the mpls rtnetlink notification multicast group.
- Define AF_MPLS in utils.h if it is not defined from elsewhere
  as is done with AF_DECnet

The address syntax for multiple mpls labels is a complete invention.
When I looked there seemed to be no wide spread convention for talking
about an mpls label stack in text for.  Sometimes people did:
"{ Label1, Label2, Label3 }", sometimes people would do:
"[ label3, label2, label1 ]", and most of the time label
stacks were not explicitly shown at all.

The syntax I wound up using, so it would not have spaces and so it
would visually distinct from other kinds of addresses is.

label1/label2/label3 Where label1 is the label at the top of the label
stack and label3 is the label at the bottom on the label stack.

When there is a single label this matches what seems to be convention
with other tools.  Just print out the numeric value of the mpls label.

The netlink protocol for labels uses the on the wire format for a
label stack. The ttl and traffic class are expected to be 0.  Using
the on the wire format is common and what happens with other address
types. BGP when passing label stacks also uses this technique with the
exception that the ttl byte is not included making each label in a BGP
label stack 3 bytes instead of 4.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-03-24 15:45:23 -07:00
Eric W. Biederman
6f7a9f4dc5 add support for the RTA_NEWDST attribute.
This attribute is like RTA_DST except it specifies the destination
address to place on a packet when it leaves the host.  For ip based
protocols this is destination NAT and not a common part of forwarding.
For protocols like MPLS label swapping is something that typically
happens on every hop.

There is likely to be a RTA_NEWSRC at some point so RTA_NEWDST
is printed as "as to"  and can be specified either as "as to"
or just "as"

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-03-24 15:45:23 -07:00
Eric W. Biederman
93ae283594 add support for the RTA_VIA attribute
Add support for the RTA_VIA attribute that specifies an address family
as well as an address for the next hop gateway.

To make it easy to pass this reorder inet_prefix so that it's tail
is a proper RTA_VIA attribute.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-03-24 15:45:23 -07:00
Eric W. Biederman
26dcdf3a91 add a source addres length parameter to rt_addr_n2a
For some address families (like AF_PACKET) it is helpful to have the
length when prenting the address.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-03-24 15:45:23 -07:00
Scott Feldman
655444bdad route: label externally offloaded routes
On ip route print dump, label externally offloaded routes with "external".
Offloaded routes are flagged with RTNH_F_EXTERNAL, a recent additon to
net-next.  For example:

$ ip route
default via 192.168.0.2 dev eth0
11.0.0.0/30 dev swp1  proto kernel  scope link  src 11.0.0.2 external
11.0.0.4/30 via 11.0.0.1 dev swp1  proto zebra  metric 20 external
11.0.0.8/30 dev swp2  proto kernel  scope link  src 11.0.0.10 external
11.0.0.12/30 via 11.0.0.9 dev swp2  proto zebra  metric 20 external
12.0.0.2  proto zebra  metric 30 external
        nexthop via 11.0.0.1  dev swp1 weight 1
        nexthop via 11.0.0.9  dev swp2 weight 1
12.0.0.3 via 11.0.0.1 dev swp1  proto zebra  metric 20 external
12.0.0.4 via 11.0.0.9 dev swp2  proto zebra  metric 20 external
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.15

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Reviewed-by: Jiri Pirko <jiri@resnulli.us>
2015-03-24 15:45:23 -07:00
Roopa Prabhu
42ecedd4ba fix ip -force -batch to continue on errors
This patch replaces exits with returns in several
iproute2 commands. This fixes `ip -batch -force`
to not exit but continue on errors.

$cat c.txt
route del 1.2.3.0/24 dev eth0
route del 1.2.4.0/24 dev eth0
route del 1.2.5.0/24 dev eth0
route add 1.2.3.0/24 dev eth0

$ip -force -batch c.txt
RTNETLINK answers: No such process
Command failed c.txt:2
RTNETLINK answers: No such process
Command failed c.txt:3

Reported-by: Sven-Haegar Koch <haegar@sdinet.de>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
2015-03-24 14:59:40 -07:00
Vadim Kochan
f3a2ddc124 lib utils: Use helpers to get AF bit/byte len
Added funcs to get AF_XXX len in bit/bytes and replace
places where switch(AF_XXX) is used for this.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-03-15 12:15:19 -07:00
Daniel Borkmann
6ef87f9cce ip: route: add congestion control metric
This patch adds configuration and dumping of congestion control metric
for ip route, for example:

  ip route add <dst> dev foo congctl [lock] dctcp

Reference: http://thread.gmane.org/gmane.linux.network/344733
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2015-01-13 17:40:49 -08:00
Florian Westphal
29d1f730b8 ip route: enable per-route ecn settings via 'features' option
This permits to selectively enable explicit congestion notification via
the routing table.

If this ecn feature is not set, the kernel will use the tcp_ecn sysctl
to decide wheter to use ECN when establising a TCP connection.

At the time of this writing, the kernel supports ecn and allfrags, but
allfrags is of dubious value and not implemented here.

Example:

ip route change 192.168.2.0/24 dev eth0 features ecn

Signed-off-by: Florian Westphal <fw@strlen.de>
2014-12-09 16:26:39 -08:00
Pavel Simerda
922b482204 ip route: don't assume default route
Just print the help when "ip route del" is called without any other
arguments.

Resolves:

 * https://bugzilla.redhat.com/show_bug.cgi?id=997965

Signed-off-by: Pavel Šimerda <psimerda@redhat.com>
2014-12-03 09:16:07 -08:00
vadimk
093b76466e ip monitor: Allow to filter events by dev
Added 'dev' option to allow filtering events by device.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-11-29 11:15:40 -08:00
Stephen Hemminger
656111b2f9 cleanup warnings
ll_index can return -1 but was declared unsigned.
rt_addr_n2a had unused length parameter
2014-08-04 10:30:35 -07:00
Masatake YAMATO
577e5a53fc iproute: Show default type, table, proto and scope of route
In "ip route show" output unicast type, main table, boot protocol and
universe scope are hidden as default labels.

Sometimes it is helpful to show the hidden label for people not enough
familiar with routing subsystem to map the output of "ip route show" and
kernel source code.

With this patch "ip route show" with -d option shows the default labels.

Example of difference of output with -d option:

    $ ./ip/ip -4   route show table all dev virbr1
    ...
    192.168.121.0/28  proto kernel  scope link  src 192.168.121.1
    ...
    $ ./ip/ip -4 -d  route show table all dev virbr1
    ...
    unicast 192.168.121.0/28  table main  proto kernel  scope link  src 192.168.121.1
    ...

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2014-03-21 14:21:26 -07:00
Stephen Hemminger
4806867a6c kill spaces before tabs 2014-02-17 10:56:31 -08:00
Stephen Hemminger
0612519e01 Remove trailing whitespace 2014-02-17 10:55:31 -08:00
Richard Godbee
8f48063721 iproute2: iproute.c: fix usage() spacing problems
Fix two spacing problems around square brackets in usage text.

Signed-off-by: Richard Godbee <richard@godbee.net>
2013-08-31 10:30:01 -07:00
Stephen Hemminger
cc71ad3ddd Merge branch 'net-next-3.10' 2013-07-16 10:20:31 -07:00
Adam Borowski
5d8a75293c ip: fix build failure if time_t is not long int
This includes x32, and, per Linus' decree, any future arch with longs
shorter than 64 bits.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
2013-06-25 13:36:56 -07:00
Cong Wang
b37f2c895d add quickack option to ip route
This patch adds quickack option to enable/disable TCP quick ack
mode for per-route.

Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <amwang@redhat.com>
2013-06-20 08:35:21 -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
Stephen Hemminger
caae16b3b8 ip: handle flush with table > 2^31
Fixes Debian bug #700434
Need to table id in filter to be unsigned to avoid conversion to -1

The documentation for "ip" suggests that, when using multiple routing tables, the table ID can be an arbitrary 32 bit number. I've been writing a script that calculates a table Id based on an IP addresses and sets up tables accordingly based on it. This seems to work for everything I've tried except "ip route flush". If you specify a table to flush with an ID over 2^31, it flushes all IPv4 routing tables. For example:

Will delete all routing tables, including the default one. Needless to say, this is quite annoying. I think this is an upstream bug, but your opinions will be greatly appreciated.
2013-02-12 11:42:57 -08: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
Vincent Bernat
4d6c3796a5 ip: fix "ip -6 route add ... nexthop"
IPv6 multipath routes were not accepted by "ip route" because an IPv4
address was expected for each gateway. Use `get_addr()` instead of
`get_addr32()`.

Signed-off-by: Vincent Bernat <bernat@luffy.cx>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2012-10-25 09:07:01 -07:00
Pavel Emelyanov
93b7986345 iproute: Add route showdump command (v2)
Some time ago the save+restore commands were added to ip route (git
id f4ff11e3, Add ip route save/restore). These two save the raw rtnl
stream into a file and restore one (reading it from stdin).

The problem is that there's no way to get the contents of the dump
file in a human readable form. The proposal is to add a command that
reads the rtnl stream from stdin and prints the data in a way the
usual "ip route list" does?

changes since v1:

* Take the magic at the beginning of the dump file into account
* Check for stdin (the dump is taken from) is not a tty

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 09:13:32 -07:00
Pavel Emelyanov
76c61b34a6 iproute: Add magic cookie to route dump file
In order to somehow verify that a blob contains route dump a
4-bytes magic is put at the head of the data and is checked
on restore.

Magic digits are taken from Portland (OR) coordinates :) Is
there any more reliable way of generating such?

Signed-of-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 09:10:51 -07:00
Stephen Hemminger
fa1f7441a9 Remove reference to multipath algorithms in usage
IP multipath algorithms support was removed several revisions ago.
Remove from usage as well
2012-07-26 16:12:20 -07:00
Stephen Hemminger
ff24746cca Convert to use rta_getattr_ functions
User new functions (inspired by libmnl) to do type safe access
of routeing attributes
2012-04-10 08:47:55 -07:00
Jorge Boncompte [DTI2]
49b730d7b2 iproute: show metrics as an unsigned value
Avoids showing negative metrics.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
2012-04-10 08:23:59 -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
Thomas Jarosch
25352af7c2 Fix file descriptor leak on error in iproute_flush_cache()
Detected by cppcheck.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
2011-10-07 11:18:09 -07:00
Andreas Henriksson
c0c44bfedd iproute2: Remove "monitor" from "ip route help" output
$ ip route help 2>&1 | grep monitor
ip route { add | del | change | append | replace | monitor } ROUTE
$ ip route monitor
Command "monitor" is unknown, try "ip route help".

(I guess what was really intended is "ip monitor route", so just remove
the argument from the help output.)

Originally reported by martin f krafft at http://bugs.debian.org/537681

While at it, also drop all non-existant (route,link,netns) monitor
arguments from the ip(8) man page.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2011-07-20 16:04:04 -07:00
Stephen Hemminger
d93b6b51e6 ip: iproute fix set never used warning 2011-06-20 14:34:11 -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
Gerrit Renker
81d03dc356 iproute: rename 'get_jiffies' since it uses msecs
The get_jiffies() function retrieves rtt-type values in units of
milliseconds. This patch updates the function name accordingly,
following the pattern given by dst_metric() <=> dst_metric_rtt().
2011-02-25 12:54:37 -08:00
Gerrit Renker
9b2cdc00da iproute: fix unit conversion of rtt/rttvar/rto_min
Since July 2008 (2.6.27, c1e20f7c8b9), the kernel stores the values for
RTAX_{RTT{,VAR},RTO_MIN} in milliseconds. When using a kernel > 2.6.27 with
the current iproute2, conversion of these values is broken in either way.

This patch
 * updates the code to pass and retrieve milliseconds;
 * since values < 1msec would be rounded up, also drops the usec/nsec variants;
 * since there is no way to query kernel HZ, also drops the jiffies variant.

Arguments such as
	rtt		3.23sec
	rto_min		0xff
	rto_min		0.200s
	rttvar		25ms
now all work as expected when reading back previously set values.
2011-02-25 12:51:48 -08:00
Gerrit Renker
94089ef772 utils: get_jiffies always uses base=0
get_jiffies() is in all places called in the same manner, with base=0;
simplify argument list by putting the constant value into the function.
2011-02-25 12:49:42 -08:00
Dan Smith
f4ff11e3e2 Add ip route save/restore
This patch adds save and restore commands to "ip route". Save dumps
the RTNL stream to stdout which can then be passed to restore later.
This may be helpful in some normal situations, and will allow C/R to
migrate the routing information in userspace.  Tweaking of the stream
can be done by userspace helpers to convert between versions and adjust
things like device indexes when restoring routes in a different
environment.

By factoring out some of the common bits of print_route() into
filter_nlmsg(), the "save" command can use the same selection logic
as "list," allowing the caller to save only specific routes as
necessary.

The only change since the RFC is the addition of manpage and doc
material.

Signed-off-by: Dan Smith <danms@us.ibm.com>
2010-12-01 11:24:58 -08:00
Eric Dumazet
b0373bfbbc ip: add RTA_MARK support
Adds support for RTA_MARK rt attribute added in linux-2.6.36

$ ip route get ADDR mark 4
192.168.20.110 dev eth1  src 192.168.20.108  mark 4
    cache  mtu 1500 advmss 1460 hoplimit 64

$ ip route get 192.168.20.108 from ADDR iif STRING mark 256
local 192.168.20.108 from 192.168.20.110 dev lo  src 192.168.20.108  mark 0x100
    cache <local,src-direct>  iif eth1

$ ip route list cache [ADDR] mark NUMBER

Hexadecimal output if mark >= 16
null marks are not displayed.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
2010-08-23 08:41:25 -07:00
Ulrich Weber
c73f3e02f8 iproute2: dont filter cached routes on iproute_get
iproute_get will return cloned routes for IPv4
and cloned as well non-cloned routes for IPv6.

Therefore RTM_F_CLONED flag should not be checked
for iproute_get routes. Check in print_route will
always fail because valid values are 0 and 1.

Signed-off-by: Ulrich Weber <uweber@astaro.com>
2010-08-23 08:13:35 -07:00
Ulrich Weber
62011a0b31 iproute2: use int instead of long for RTAX_HOPLIMIT compare
otherwise "if ((int)val == -1)" will never match on 64 bit systems

Signed-off-by: Ulrich Weber <uweber@astaro.com>
2010-07-23 09:01:01 -07:00
Ulrich Weber
2eca8d3d3e iproute2: use get_user_hz() for IPv6 print_route
as already done in IPv4 and metrics code part

Signed-off-by: Ulrich Weber <uweber@astaro.com>
2010-07-23 09:01:01 -07:00
Ulrich Weber
447928279c iproute2: filter routing entries based on clone flag
Before IPv6 routing cache entries were always displayed
if additional tables beside MAIN and LOCAL are installed.

Signed-off-by: Ulrich Weber <uweber@astaro.com>
2010-07-23 09:01:01 -07:00
laurent chavey
f5fd80039f Add initrwnd to iproute2
Add initrwnd option parsing to iproute. This option uses the new
rtnetlink init_rcvwnd to set the TCP initial receive window size
advertised by passive and active TCP connections.

Signed-off-by: Laurent Chavey <chavey@google.com>
2010-03-03 16:19:47 -08:00
Andreas Henriksson
63a0f20ac1 iproute2: drop equalize support
Currently you can configure "equalize" and it looks all fine and dandy.
The kernel has the interface defined, but apparently there's never actually
been any implementation for it (only a never merged patch in the 2.4 era).

I'm suggesting to drop the code to give any potential users of this feature
the benefit of receiving a proper error message. I see it unlikely that
this will be implemented in the near future, but if it ever happens
reviving the iproute2 side should be as easy as git revert this patch.

For more details see http://bugs.debian.org/149897
2010-02-09 10:58:51 -08:00
Gilad Ben-Yossef
71e5815105 iproute2 add hoplimit parsing and update usage and documentation
- Parse and handle the hoplimit ip route option and add it to the usage
  line and documentation.

- Add the missing reordering ip route option to the usage line.

- Add documentation for initcwnd ip route option.

Tested by setting hoplimit and retreiving it via "show".

Signed-off-by: Gilad Ben-Yossef <gilad@codefidence.com>
[ported to HEAD, fixed a bug with hoplimit lock handling, added documentation]
Signed-off-by: Ori Finkelman <ori@comsleep.com>
Signed-off-by: Yony Amit <yony@comsleep.com>
2009-12-01 15:51:44 -08:00
Stephen Hemminger
232642c28c Remove Changes: comments
Discourage developers from putting change log in comments
now that software has been under change control for 5 years.
2009-12-01 15:49:48 -08:00
Stephen Hemminger
ced61d7dc4 Handle default hoplimit
Default for hoplimit is -1 which should be displayed as zero.
2009-03-23 10:49:21 -07:00
Andreas Henriksson
f0b34d2d98 ip a flush: unnecessarily chatty when there's nothing to flush
On tis, 2008-07-22 at 20:21 +0200, martin f krafft wrote:
> piper:~|master|% sudo ip a flush dev eth0 >/dev/null
> Nothing to flush.
>
> It should just shut up, shouldn't it? :)

The patch below makes the "Nothing to flush" only visible when show
statistics flag is given, and then only to stdout rather then stderr.

$ sudo ./ip/ip -s addr flush dev skif
Nothing to flush.
$ sudo ./ip/ip addr flush dev skif
$

(See http://bugs.debian.org/492196 )
2008-09-15 13:57:12 -07:00
Stephen Hemminger
f31a37f79d fix problem caused by rtnl_send checks
Some usages of rtnl_send could cause errors (ie flush requests)
others do a listen afterwards.

Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
2008-01-31 21:38:58 -08:00
Stephen Hemminger
1fb0a998e1 remove extra newline from perror() calls
perror error adds a newline, so don't split error message
across two lines.
2008-01-26 11:08:31 -08:00
YOSHIFUJI Hideaki / 吉藤英明
7c73e1bd21 rto_min value display overflow
Reported by: Satoru SATOH <satoru.satoh@gmail.com>
"ip route show" does not print correct value when larger rto_min is
set (e.g. 3sec).

This problem is because of overflow in print_route() and
the patch below is a workaround fix for that.

[root test]# ./iproute2.git.org/ip/ip route show dev eth1
192.168.140.0/24  proto kernel  scope link  src 192.168.140.130
169.254.0.0/16  scope link
[root test]# ./iproute2.git.org/ip/ip route change 192.168.140.0/24
dev eth1 rto_min 3s
[root test]# ./iproute2.git.org/ip/ip route show dev eth1
192.168.140.0/24  scope link  rto_min lock 2ms     <-- wrong
169.254.0.0/16  scope link
[root test]# ./iproute2.git/ip/ip route show dev eth1  # patched version
192.168.140.0/24  scope link  rto_min lock 3000ms  <-- correct
169.254.0.0/16  scope link

This is a simpler fix.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-12-21 09:13:36 -08:00
Alexander Wirt
576c63ee59 Add parameters to usage help text.
Add src option to route help text (http://bugs.debian.org/226142).
Add prio option to rule prio help text (http://bugs.debian.org/213673).

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-17 09:58:11 -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
550967eecf remove support for IP multipath
IP multipath routing was so buggy that it was dropped from the
current kernel.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-12 14:38:30 -07:00
Rick Jones
54e0b2e71d rto support for ip command
Enable users of ip to specify the times for rtt, rttvar and rto_min
in human-friendly terms a la "tc" while maintaining backwards
compatability with the previous "raw" mechanism.  Builds upon
David Miller's uncommited patch to set rto_min.

Signed-off-by: Rick Jones <rick.jones2@hp.com>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-10-11 13:04:11 -07:00
Sridhar Samudrala
9ab4c85b9a Fix bug in display of ipv6 cloned/cached routes
This patch fixes a bug in the 'ip' command to display
IPv6 cloned routes.
  ip -6 route ls cache
returns empty even when there are cloned routes because of
of a missing else in print_route() routine.

Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
2007-08-22 10:55:47 -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
Stephen Hemminger
6a79240b6f Route metrics decode bug.
Array was not being offset correctly.

See http://bugs.archlinux.org/task/5669

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-10-26 08:47:00 -07:00
Patrick McHardy
34e9564753 Add support for larger number of routing tables
[IPROUTE]: Add support for larger number of routing tables

Support support for 2^32 routing tables by using the new RTA_TABLE
attribute for specifying tables > 255 and intepreting it if it is
sent by the kernel.

When tables > 255 are used on a kernel not supporting it an error will
occur because of the unknown netlink attribute.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-08-10 16:12:07 -07:00
Patrick McHardy
bd4bcdad77 Preparation for 32 bit table IDs
[IPROUTE]: Preparation for 32 bit table IDs

The route table filter uses an integer for the table number and the value
-1 to represent cloned routes. For 32 bit table IDs it needs to become an
unsigned, so this won't work anymore. Introduce a new filter flag "cloned"
and use instead of filter.tb = -1.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-08-10 16:11:53 -07:00
Patrick McHardy
e0b29fe7dd The current behaviour for IPv6 routing table filters is to derive the
table from the route type. This doesn't really work anymore now that IPv6
supports multiple tables. Add detection for IPv6 multiple table support
(relying on the fact that the first routes dumped belong to the local table
and have rtm_table == RT_TABLE_LOCAL with multiple tables) and handle it
like other protocols.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2006-08-10 13:56:13 -07:00
Patrick McHardy
f4f6d6407d Add support for multipath route realms 2006-08-04 10:51:01 -07:00
Stephen Hemminger
f38c733409 Cleanup mx_names table
use C99 initialization to match rtnetlink.h
2006-08-04 10:49:51 -07:00
Vince Worthington
a1f1143e8d Proposed patch to iproute to add Initial Max Congestion Window Size route tuning parameter
Vince Worthington wrote:
> Hello,
>
> We've been working with a customer of ours who was experiencing some
> latency issues, and in the process of helping them solve their problem
> we found that adding the ability to adjust the Initial Max Congestion
> Window size on a route, they were able to tune their routes to perform
> more favorably in their mixed Linux and Solaris environment.  There
> were a couple of other tuning steps necessary as well but we did find
> that the ability to set a larger initial max congestion window size
> was helpful in making Linux behave more like Solaris in low-latency
> situations.
>
> The kernel already supports this route attribute, this patch simply
> adds the option to iproute.c to provide a means to set it from userspace.
>
> I've attached the patch we used in test builds of the iproute packages
> we distribute in RHEL3 and RHEL4 for your consideration for possible
> acceptance and inclusion in iproute.  Please let us know if there is
> any further information you would need or if there is a more
> appropriate venue to submit this patch.
>
> Thanks,
> Vince Worthington
> Red Hat, Inc.

Stephen,

I apologize for the last patch I sent not applying cleanly to the latest
iproute2 sources.  I realized that this might impede any
review/acceptance of the patch and created a separate patch against the
20060323 build of iproute2, which seems to be the latest (by looking at
the website).

The previous patch wouldn't apply cleanly due to the label of the
ssthresh argument being corrected from REALMS to NUMBER.

Please let us know if there is any other information or assistance we
can be with this patch submission.

Thanks
Vince
2006-08-04 10:26:39 -07:00
shemminger
7849fb5591 Fix memcpy overwrite in iproute.c because of bits vs. bytes confusion 2005-10-12 22:49:50 +00:00
shemminger
351efcde4e Update header files to 2.6.14
Integrate support for DCCP and tcp_diag into ss
Add -batch to ip command
2005-09-01 19:21:50 +00:00
shemminger
f332d16924 Cleanup GCC4 warnings about signedness. 2005-07-05 22:37:15 +00:00
shemminger
02d2ae55c6 IPv4 multipath algorithm selection support 2005-06-23 17:31:27 +00:00
net[shemminger]!shemminger
5e8bc6316b Import patch iproute2-hz
(Logical change 1.159)
2005-03-14 18:44:54 +00:00
net[shemminger]!shemminger
f2111e6f51 Import patch iproute-typo.patch
(Logical change 1.145)
2005-03-10 18:12:41 +00:00
5!tgraf
87bc1f03ad tb buffer initialization is now done in the parser
(Logical change 1.129)
2005-01-18 22:11:58 +00:00
osdl.net!shemminger
50772dc51a Add ip rule flush capabilty and fix all the prototype changes
because of that code rewrites the nlmsghdr.

(Logical change 1.106)
2004-12-07 21:48:29 +00:00
osdl.net!shemminger
6dc9f01634 make all filtering handles take const args.
(Logical change 1.77)
2004-08-31 17:45:21 +00:00
osdl.org!shemminger
33551240de Handle case wher non-root user runs ip flush.
Timeout after attempts to delete fail.

(Logical change 1.14)
2004-06-08 22:51:46 +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