Commit Graph

35 Commits

Author SHA1 Message Date
Matteo Croce
8589eb4efd treewide: refactor help messages
Every tool in the iproute2 package have one or more function to show
an help message to the user. Some of these functions print the help
line by line with a series of printf call, e.g. ip/xfrm_state.c does
60 fprintf calls.
If we group all the calls to a single one and just concatenate strings,
we save a lot of libc calls and thus object size. The size difference
of the compiled binaries calculated with bloat-o-meter is:

        ip/ip:
        add/remove: 0/0 grow/shrink: 5/15 up/down: 103/-4796 (-4693)
        Total: Before=672591, After=667898, chg -0.70%
        ip/rtmon:
        add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-54 (-54)
        Total: Before=48879, After=48825, chg -0.11%
        tc/tc:
        add/remove: 0/2 grow/shrink: 31/10 up/down: 882/-6133 (-5251)
        Total: Before=351912, After=346661, chg -1.49%
        bridge/bridge:
        add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-459 (-459)
        Total: Before=70502, After=70043, chg -0.65%
        misc/lnstat:
        add/remove: 0/1 grow/shrink: 1/0 up/down: 48/-486 (-438)
        Total: Before=9960, After=9522, chg -4.40%
        tipc/tipc:
        add/remove: 0/0 grow/shrink: 1/1 up/down: 18/-62 (-44)
        Total: Before=79182, After=79138, chg -0.06%

While at it, indent some strings which were starting at column 0,
and use tabs where possible, to have a consistent style across helps.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-05-20 14:35:07 -07:00
Benedict Wong
a6af9f2e61 xfrm: add option to hide keys in state output
ip xfrm state show currently dumps keys unconditionally. This limits its
use in logging, as security information can be leaked.

This patch adds a nokeys option to ip xfrm ( state show | monitor ), which
prevents the printing of keys. This allows ip xfrm state show to be used
in logging without exposing keys.

Signed-off-by: Benedict Wong <benedictwong@google.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-21 08:31:20 -08:00
Stephen Hemminger
fa92d8cb09 ipxfrm: make local functions static
Make functions only used in ipxfrm.c static.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-19 11:42:44 -08:00
David Ahern
cd554f2c2f Tree wide: Drop sockaddr_nl arg
No function, filter, or print function uses the sockaddr_nl arg,
so just drop it.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
2018-10-22 09:43:48 -07:00
Nathan Harold
b8e7799003 iproute2: fix 'ip xfrm monitor all' command
Currently, calling 'ip xfrm monitor all' will
actually invoke the 'all-nsid' command because the
soft-match for 'all-nsid' occurs before the precise
match for 'all'. This patch rearranges the checks
so that the 'all' command, itself an alias for
invoking 'ip xfrm monitor' with no argument, can
be called consistent with the syntax for other ip
commands that accept an 'all'.

Signed-off-by: Nathan Harold <nharold@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-06-01 15:57:26 -04:00
Stephen Hemminger
9f1370c0e5 netlink route attribute cleanup
Use the new helper functions rta_getattr_u* instead of direct
cast of RTA_DATA().  Where RTA_DATA() is a structure, then remove
the unnecessary cast since RTA_DATA() is void *

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-02-24 08:56:38 -08:00
Phil Sutter
2e96d2ccd0 utils: make rt_addr_n2a() non-reentrant by default
There is only a single user who needs it to be reentrant (not really,
but it's safer like this), add rt_addr_n2a_r() for it to use.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-27 10:37:34 -07:00
Stephen Hemminger
56f5daac98 ip: code cleanup
Run all the ip code through checkpatch and have it fix the obvious stuff.
2016-03-21 11:52:19 -07:00
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
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
Nicolas Dichtel
b6ec53e300 xfrmmonitor: allows to monitor in several netns
With this patch, it's now possible to listen in all netns that have an nsid
assigned into the netns where is socket is opened.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-05-21 15:28:56 -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
Stephen Hemminger
9339077928 xfrm: fix build with later kernel headers
Need to include netinet/in.h to get the correct glibc headers
instead of getting definitions in linux/in6.h
2015-04-10 13:17:54 -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
Vadim Kochan
c16298bea0 ip xfrm mon: Add objects list to the usage output
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-02-21 16:43:23 -08:00
Vadim Kochan
5bf9f5c5a0 ip xfrm: Allow to specify "all" option for monitor
Just to be aligned with the usage output.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-02-21 16:43:23 -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
Stephen Hemminger
4d98ab00de Fix FSF address in file headers 2013-12-06 15:05:07 -08: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
d1f28cf181 ip: make local functions static 2013-02-12 11:38:35 -08:00
Florian Westphal
598a42c091 ip: xfrm: report nat-t/encapsulation portmapping updates
Signed-off-by: Florian Westphal <fw@strlen.de>
2012-03-15 14:49:03 -07:00
David Ward
cbec021913 xfrm: Update documentation
The ip(8) man page and the "ip xfrm [ XFRM-OBJECT ] help" command output
are updated to include missing options, fix errors, and improve grammar.
There are no functional changes made.

The documentation for the ip command has many different meanings for the
same formatting symbols (which really needs to be fixed). This patch makes
consistent use of brackets [ ] to indicate optional parameters, pipes | to
mean "OR", braces { } to group things together, and dashes - instead of
underscores _ inside of parameter names. The parameters are listed in the
order in which they are parsed in the source code.

There are several parameters and options that are still not mentioned or
need to be described more thoroughly in the "COMMAND SYNTAX" section of
the ip(8) man page. I would appreciate help from the developers with this.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
2011-07-11 10:12:06 -07:00
Masahide NAKAMURA
efe69c1b72 ip: xfrm: Fix flush message.
Fix xfrm state or policy flush message.
And minor updates are included:
o Use static buffer to show unknown value as string.
o Show policy type (ptype) only when kernel specified it.
o Clean-up xfrm_monitor.

Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-09-05 12:56:51 +01:00
Stephen Hemminger
81c61790d5 Eliminate trailing whitespace
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-13 17:05:50 -08:00
jamal
7b8225122d update xfrm monitoring to use nl_mgrp
Stephen,
I will wait until you sync all these patches ive sent; then send a
couple more then i will be done.

cheers,
jamal

[XFRM] update xfrm monitoring to use nl_mgrp

Signed-off-by: J Hadi Salim <hadi@cyberus.ca>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-13 17:04:27 -08:00
jamal
c9fd974bd8 update xfrm async events
[XFRM] update xfrm async events

Report abbreviated async xfrm aevents.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-13 17:04:22 -08: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
Masahide NAKAMURA
c54f31eeb3 XFRM: support report message by monitor.
Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:03:34 -08:00
Stephen Hemminger
77219712bf Fix XFRM monitor
The change to hold open the netlink socket (for ip batch mode),
broke XFRM monitoring.

Bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=383133

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-09-25 17:27:37 -07:00
shemminger
669ae748d6 Minor fixes from Masahide for XFRM dynamic keying 2005-11-07 18:39:30 +00:00
shemminger
c595c790a0 Fix XFRM bugs introduced by batching code.
Re-introduces the SA and policy add/del events
2005-11-01 23:03:03 +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
90f93024a0 Monitor time patch from Masahide NAKAMURA 2005-06-07 21:55:55 +00:00
linux-ipv6.org!nakam
f9cb3a2fe2 (Logical change 1.175) 2005-03-22 16:13:21 +00:00
linux-ipv6.org!nakam
bf82c4c0d3 Initial revision 2005-03-22 16:13:21 +00:00