Commit Graph

206 Commits

Author SHA1 Message Date
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