]> git.proxmox.com Git - mirror_iproute2.git/log
mirror_iproute2.git
6 years agov4.15.0 v4.15.0
Stephen Hemminger [Mon, 29 Jan 2018 16:08:52 +0000 (08:08 -0800)]
v4.15.0

6 years agotc: fix second printing of requeues
Jakub Kicinski [Sat, 27 Jan 2018 09:19:04 +0000 (01:19 -0800)]
tc: fix second printing of requeues

Non-JSON tc qdisc output used to print the "requeues" statistic
twice.  Commit 4fcec7f3665b ("tc: jsonify stats2") tried to preserve
this behaviour for both standard output and JSON, but used the wrong
statistic (q.qlen).  Also duplicating keys in JSON is not allowed,
so the second occurrence should be completely skipped with JSON.

Fixes: 4fcec7f3665b ("tc: jsonify stats2")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip: address: fix stats64 JSON object name
Jakub Kicinski [Fri, 26 Jan 2018 19:30:35 +0000 (11:30 -0800)]
ip: address: fix stats64 JSON object name

The JSON object name for statistics in ip link show is "stats644".
Looks like a typo, commit d0e720111aad ("ip: ipaddress.c: add support
for json output") contains an example with the expected "stats64" name.

The fact that no one has noticed until now is probably an indication
that no one is using this object.  Hopefully it's not too late to fix
this, although IIUC this has already been in 4.13 and 4.14 releases :S

Fixes: d0e720111aad ("ip: ipaddress.c: add support for json output")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotc/lexer: let quotes actually start strings
Wolfgang Bumiller [Mon, 22 Jan 2018 10:53:46 +0000 (11:53 +0100)]
tc/lexer: let quotes actually start strings

The lexer will go with the longest match, so previously
the starting double quotes of a string would be swallowed by
the [^ \t\r\n()]+ pattern leaving the user no way to
actually use strings with escape sequences.
Fix this by not allowing this case to start with double
quotes.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 years agoiplink: Use ll_name_to_index() instead of if_nametoindex()
Serhey Popovych [Fri, 19 Jan 2018 16:44:03 +0000 (18:44 +0200)]
iplink: Use ll_name_to_index() instead of if_nametoindex()

While benefit from using ll_name_to_index() with populated
cache can potentially be exploited only in few places
(e.g. bridge fdb/mdb/vlan show routines) there is another
advantage of ll_name_to_index() over plain if_nametoindex():

  in case of if_nametoindex() failure ll_name_to_index()
  will attempt to get index from common name in form "if%d"
  that may be returned from ll_index_to_name().

This makes output from ip(8) coherent with it's input.

Note that most of the code already switched from plain
if_nametoindex() to ll_name_to_index() to cached variant.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agovti/vti6: Minor improvements
Serhey Popovych [Fri, 19 Jan 2018 16:44:02 +0000 (18:44 +0200)]
vti/vti6: Minor improvements

In prepare of link_vti.c and link_vti6.c merge:

  1) Make @fwmark of __u32 type instead of unsigned int
     in vti to match with rest tunneling code.

  2) Report when unable to translate @link network device
     name to index instead of silently exiting in vti6.

  3) Remove newline separating local/remote attributes
     from the ikey/okey in vti6 to match vti module.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoiptnl/ip6tnl: Unify ttl/hoplimit parsing routines
Serhey Popovych [Fri, 19 Jan 2018 16:44:01 +0000 (18:44 +0200)]
iptnl/ip6tnl: Unify ttl/hoplimit parsing routines

Handle "inherit" case properly for gre6 and ip6tnl.

Use get_u8() in gre to parse ttl/hoplimit.

Be consistent about "hlim" alias to ttl/hoplimit
support.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotunnel: Add space between encap-dport and encap-sport in non-JSON output
Serhey Popovych [Fri, 19 Jan 2018 16:44:00 +0000 (18:44 +0200)]
tunnel: Add space between encap-dport and encap-sport in non-JSON output

Fixes: bad76e6b1f44 ("ip/tunnel: Abstract tunnel encapsulation options printing")
Fixes: e2d4588331fc ("ip: link_gre.c: add json output support")
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotunnel: Return constant string without copying it
Serhey Popovych [Thu, 18 Jan 2018 14:04:36 +0000 (16:04 +0200)]
tunnel: Return constant string without copying it

We return constant string from tnl_strproto(), no need
to copy it to temporary buffer and then return such
buffer as const: return constant string instead.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agovti6/tunnel: Unify and simplify link type help functions
Serhey Popovych [Thu, 18 Jan 2018 14:04:35 +0000 (16:04 +0200)]
vti6/tunnel: Unify and simplify link type help functions

Both of these two changes are missing for link_vti6.c:

  commit 8b47135474cd ("ip: link: Unify link type help functions a bit")
  commit 561e650eff67 ("ip link: Shortify printing the usage of link type")

Replay them on link_vti6.c to bring link type help functions
inline with other tunneling code.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agovti/tunnel: Unify ikey/okey printing
Serhey Popovych [Thu, 18 Jan 2018 14:04:34 +0000 (16:04 +0200)]
vti/tunnel: Unify ikey/okey printing

For vti6 tunnel we print [io]key in dotted-quad notation
(ipv4 address) while in vti we do that in hex format.

For vti tunnel we print [io]key only if value is not
zero while for vti6 we miss such check.

Unify vti and vti6 tunnel [io]key output.

While here enlarge s2 buffer to the same size as in rest
of tunnel support code (64 bytes) and check return from
inet_ntop().

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agogre/tunnel: Print erspan_index using print_uint()
Serhey Popovych [Thu, 18 Jan 2018 14:04:33 +0000 (16:04 +0200)]
gre/tunnel: Print erspan_index using print_uint()

One is missing in JSON output because fprintf()
is used instead of print_uint().

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip/tunnel: Abstract tunnel encapsulation options printing
Serhey Popovych [Thu, 18 Jan 2018 14:04:32 +0000 (16:04 +0200)]
ip/tunnel: Abstract tunnel encapsulation options printing

Get rid of code duplications and consolidate encapsulation
options printing in single function - tnl_print_encap().

Introduce and use tnl_encap_str() to format encapsulation
option string according to tempate and given values to avoid
code duplication and simplify it.

Use print_string() instead of fputs() and fprintf() to
print encapsulation for !is_json_context().

Print "unknown" parameter for "encap" type in PRINT_FP
context using "%s " format specifier and benefit from
complite time string merge.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip/tunnel: Use print_0xhex() instead of print_string()
Serhey Popovych [Thu, 18 Jan 2018 14:04:31 +0000 (16:04 +0200)]
ip/tunnel: Use print_0xhex() instead of print_string()

No need for custom SPRINT_BUF() and snprintf() 0x%x
value to this buffer: we can use print_0xhex() instead
of print_string().

In link_iptnl.c use s2 instead of s1 buffer and remove
s1.

While there adjust fwmark option print order in iptnl
and ip6tnl to get it match each other.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip/tunnel: Simplify and unify tos printing
Serhey Popovych [Thu, 18 Jan 2018 14:04:30 +0000 (16:04 +0200)]
ip/tunnel: Simplify and unify tos printing

For ip tunnels tos can be 0 when not configured, 1 when
inherited from encapsulated packet and rest specifying
diffserv (rfc2474) or tos (rfc1349) bits. It is stored
in packet tos/diffserv field and returned in tos
netlink attribute to userspace.

Simplify and unify tos printing by using print_0xhex()
and print_string() instead of fprintf() to output values.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip/tunnel: Correct and unify ttl/hoplimit printing
Serhey Popovych [Thu, 18 Jan 2018 14:04:29 +0000 (16:04 +0200)]
ip/tunnel: Correct and unify ttl/hoplimit printing

Both ttl/hoplimit is from 1 to 255. Zero has special meaning:
use encapsulated packet value. In ip-link(8) -d output this
looks like "ttl/hoplimit inherit". In JSON we have "int" type
for ttl and therefore values from 0 (inherit) to 255.

To do the best in handling ttl/hoplimit we need to accept
both cases: missing attribute in netlink dump and zero value
for "inherit"ed case. Last one is broken since JSON output
introduction for gre/iptnl versions and was never true for
gre6/ip6tnl.

For all tunnels, except ip6tnl change JSON type from "int" to
"uint" to reflect true nature of the ttl.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoiplink: Use ll_index_to_name() instead of if_indextoname()
Serhey Popovych [Thu, 18 Jan 2018 14:04:28 +0000 (16:04 +0200)]
iplink: Use ll_index_to_name() instead of if_indextoname()

There are two reasons for switching to cached variant:

  1) ll_index_to_name() may return result from cache,
     eliminating expensive ioctl() to the kernel.

     Note that most of the code already switched from plain
     if_indextoname() to ll_index_to_name() to cached variant
     in print path because in most cases cache populated.

  2) It always return name in the form "if%d", even if
     entry is not in cache and ioctl() fails. This drops
     "link_index" from JSON output.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agodevlink: Ignore unknown attributes
Arkadi Sharshevsky [Wed, 17 Jan 2018 13:28:00 +0000 (15:28 +0200)]
devlink: Ignore unknown attributes

In case of extending the UAPI old packages would break.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoiplink: Fix "alias" parameter length calculations
Serhey Popovych [Thu, 18 Jan 2018 14:24:40 +0000 (16:24 +0200)]
iplink: Fix "alias" parameter length calculations

We need NEXT_ARG() to get *argv pointing to "alias"
parameter value. Overwise we get and check "alias"
string length.

Fixes: f88becf35e08 ("iplink: Process "alias" parameter correctly")
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoman: Document the meaning of zero in min/max_tx_rate parameters
Gal Pressman [Tue, 16 Jan 2018 13:42:00 +0000 (15:42 +0200)]
man: Document the meaning of zero in min/max_tx_rate parameters

Zero value in min/max_tx_rate has a special meaning of no rate limit,
document it.

Signed-off-by: Gal Pressman <galp@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
6 years agoipaddress: Make sure VF min/max rate API is supported before using it
Gal Pressman [Tue, 16 Jan 2018 13:41:59 +0000 (15:41 +0200)]
ipaddress: Make sure VF min/max rate API is supported before using it

When using the new minimum rate API and providing only one parameter
(minimum rate/maximum rate), we query the VF min and max rate regardless
of kernel support.
This resulted in segmentation fault in ipaddr_loop_each_vf, which tries
to access NULL pointer.

This patch identifies such cases by testing the VF table for NULL
pointer in IFLA_VF_RATE, and aborts the operation.
Aborting on the first VF is valid since if the kernel does not support
the new API for the first VF, it will not support it for the other VFs
as well.

Fixes: f89a2a05ffa9 ("Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool")
Cc: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Gal Pressman <galp@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
6 years agoiplink: Validate minimum tx rate is less than maximum tx rate
Gal Pressman [Tue, 16 Jan 2018 13:41:58 +0000 (15:41 +0200)]
iplink: Validate minimum tx rate is less than maximum tx rate

According to the documentation (man ip-link), the minimum TXRATE should
be always <= Maximum TXRATE, but commit f89a2a05ffa9 ("Add support to
configure SR-IOV VF minimum and maximum Tx rate through ip tool") didn't
enforce it.

Fixes: f89a2a05ffa9 ("Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool")
Cc: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Gal Pressman <galp@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
6 years agoipaddress: Use family_name() for better code reuse
Serhey Popovych [Fri, 12 Jan 2018 18:03:39 +0000 (20:03 +0200)]
ipaddress: Use family_name() for better code reuse

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agotc: Optimize gact action lookup
Phil Sutter [Fri, 12 Jan 2018 11:20:21 +0000 (12:20 +0100)]
tc: Optimize gact action lookup

When adding a filter with a gact action such as 'drop', tc first tries
to open a shared object with equivalent name (m_drop.so in this case)
before trying gact. Avoid this by matching the action name against those
handled by gact prior to calling get_action_kind().

Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
6 years agotests: make sure rand_dev suffix has 6 chars
Christian Ehrhardt [Wed, 10 Jan 2018 15:11:37 +0000 (16:11 +0100)]
tests: make sure rand_dev suffix has 6 chars

The change to limit the read size from /dev/urandom is a tradeoff.
Reading too much can trigger an issue, but so it could if the
suggested 250 random chars would not contain enough [:alpha:] chars.
If they contain:
 a) >=6 all is ok
 b) [1-5] the devname would be shorter than expected (non fatal).
 c) 0 things would break

In loops of hundreds of thousands it always was (a) for my, but since
if occuring in a test it might be hard to track what happened avoid
this issue by retrying on the length condition.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotests: read limited amount from /dev/urandom
Christian Ehrhardt [Wed, 10 Jan 2018 15:11:36 +0000 (16:11 +0100)]
tests: read limited amount from /dev/urandom

In some test environments like e.g. Ubuntu & Debian autopkgtest it
can happen that while generating random device names the pipes
between tr and head are considered dead while processing.
That prints (non fatal) issues like:
  Running ip/link/new_link.t [iproute2-this/4.13.0-17-generic]: tr:
write error: Broken pipe
  tr: write error
  PASS

This only happens if reading an infinite amount of chars with the
read from urandom, so reading a defined amount fixes the issue.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoifcfg/rtpr: convert to POSIX shell
Mike Frysinger [Tue, 9 Jan 2018 23:19:59 +0000 (18:19 -0500)]
ifcfg/rtpr: convert to POSIX shell

These files are already mostly written in POSIX shell, so convert their
shebangs to /bin/sh and tweak the few bashisms in here.

URL: https://crbug.com/756559
Reported-by: Pat Erley <perley@chromium.org>
Signed-off-by: Mike Frysinger <vapier@chromium.org>
6 years agomark shell scripts +x
Mike Frysinger [Tue, 9 Jan 2018 23:20:03 +0000 (18:20 -0500)]
mark shell scripts +x

This makes it easier to execute locally for testing.

Signed-off-by: Mike Frysinger <vapier@chromium.org>
6 years agotc: remove no longer relevant README
Stephen Hemminger [Wed, 10 Jan 2018 16:21:22 +0000 (08:21 -0800)]
tc: remove no longer relevant README

This document described how kernel and tc used to handle
timing. In last two years, kernel has switched over to using
ktime. Nothing to see here, move along.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip6tnl/tunnel: Output hoplimit before encapsulation limit
Serhey Popovych [Wed, 10 Jan 2018 15:53:15 +0000 (17:53 +0200)]
ip6tnl/tunnel: Output hoplimit before encapsulation limit

To follow gre6 output print hoplimit before encapsulation
limit in link_ip6tnl.c.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agogre6/tunnel: Output flowlabel after tclass
Serhey Popovych [Wed, 10 Jan 2018 15:53:14 +0000 (17:53 +0200)]
gre6/tunnel: Output flowlabel after tclass

To follow ip6tnl output print flowlabel after tclass
in link_gre6.c.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip6/tunnel: Unify encap_limit printing
Serhey Popovych [Wed, 10 Jan 2018 15:53:13 +0000 (17:53 +0200)]
ip6/tunnel: Unify encap_limit printing

Use %u format specifier to print it in link_gre6.c and
make code more readable.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip6/tunnel: Unify flowlabel printing
Serhey Popovych [Wed, 10 Jan 2018 15:53:12 +0000 (17:53 +0200)]
ip6/tunnel: Unify flowlabel printing

Use @s2 buffer to store string representation of
flowlabel and get rid of extra SPRINT_BUF(): no
need to preserve @s2 contents for later.

Use print_string(PRINT_ANY, ...) with prepared by
snprintf() string for both PRINT_JSON and PRINT_FP
cases.

Omit flowlabel from output if no flowinfo attribute
is given and IP6_TNL_F_USE_ORIG_FLOWLABEL isn't set.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip6/tunnel: Unify tclass printing
Serhey Popovych [Wed, 10 Jan 2018 15:53:11 +0000 (17:53 +0200)]
ip6/tunnel: Unify tclass printing

Use @s2 buffer to store string representation of
tclass and get rid of extra SPRINT_BUF(): no
need to preserve @s2 contents for later.

Use print_string(PRINT_ANY, ...) with prepared by
snprintf() string for both PRINT_JSON and PRINT_FP
cases.

While there use __u32 for flowinfo in link_gre6.c
and check for IFLA_GRE_FLOWINFO attribute presense.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip6tnl/tunnel: Do not print obscure flowinfo
Serhey Popovych [Wed, 10 Jan 2018 15:53:10 +0000 (17:53 +0200)]
ip6tnl/tunnel: Do not print obscure flowinfo

It is implementation internal and main purpose
of printing it seems debugging.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip6/tunnel: Fix tclass output
Serhey Popovych [Wed, 10 Jan 2018 15:53:09 +0000 (17:53 +0200)]
ip6/tunnel: Fix tclass output

In link_gre6.c it seems copy paste error: tclass is 8 bits,
not 20 as flowlabel.

In link_iptnl.c rename "flowinfo_tclass" to "tclass" as it
correct name since flowinfo is implementation internal name
used to label combined within u32 attribute tclass and
flowlabel.

Fixes: 1facc1c61c07 ("ip: link_ip6tnl.c: add json output support")
Fixes: 2e706e12d9b0 ("Merge branch 'master' into net-next")
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotc: Fix filter protocol output
Jamal Hadi Salim [Sun, 7 Jan 2018 14:43:28 +0000 (09:43 -0500)]
tc: Fix filter protocol output

Fixes: 249284ff5a44 ("tc: jsonify filter core")
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
6 years agoinclude: update ethernet headers
Stephen Hemminger [Tue, 9 Jan 2018 16:06:06 +0000 (08:06 -0800)]
include: update ethernet headers

Incorporate upstream changes to fix compliation with MUSL.
See commit 6926e041a892
 ("uapi/if_ether.h: prevent redefinition of struct ethhdr")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoss: fix NULL pointer access when parsing unix sockets with oldformat
Antonio Quartulli [Sat, 6 Jan 2018 18:31:50 +0000 (02:31 +0800)]
ss: fix NULL pointer access when parsing unix sockets with oldformat

When parsing and printing the unix sockets in unix_show(),
if the oldformat is detected, the peer_name member of the sockstat
object is left uninitialized (NULL).
For this reason, if a filter has been specified on the command line,
a strcmp() will crash when trying to access it.

Avoid crash by checking that peer_name is not NULL before
passing it to strcmp().

Cc: Stefano Brivio <sbrivio@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoss: fix crash when skipping disabled header field
Antonio Quartulli [Sat, 6 Jan 2018 18:31:49 +0000 (02:31 +0800)]
ss: fix crash when skipping disabled header field

When the first header field is disabled (i.e. when passing the -t
option), field_flush() is invoked with the `buffer` global variable
still zero'd.
However, in field_flush() we try to access buffer.cur->len
during variables initialization, thus leading to a SIGSEGV.

It's interesting to note that this bug appears only when the code
is compiled with -O0, because the compiler is smart
enough to immediately jump to the return statement if optimizations
are enabled and skip the faulty instruction.

Cc: Stefano Brivio <sbrivio@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip fou: pass family attribute as u8
Filip Moc [Sun, 7 Jan 2018 14:28:13 +0000 (15:28 +0100)]
ip fou: pass family attribute as u8

This fixes fou on big-endian systems.

Signed-off-by: Filip Moc <dev@moc6.cz>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoRestore --no-print-directory option for silent builds
David Ahern [Sat, 6 Jan 2018 03:42:05 +0000 (19:42 -0800)]
Restore --no-print-directory option for silent builds

Commit 69fed534a533 ("change how Config is used in Makefile's") removed
Config from Makefile. Config had the checks to set VERBOSE based on user
request and VERBOSE is used to add the --no-print-directory argument.
Since Config is gone, add the relevant setup for VERBOSE to Makefile
to restore quieter builds by default.

Fixes: 69fed534a533 ("change how Config is used in Makefile's")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agolink_iptnl: Open "encap" JSON object
Serhey Popovych [Tue, 2 Jan 2018 21:27:59 +0000 (23:27 +0200)]
link_iptnl: Open "encap" JSON object

It seems missing pair of open_json_object()/close_json_object()
in iptnl implementation.

Note that we open "encap" JSON object in ip6tnl.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agolink_iptnl: Print tunnel mode
Serhey Popovych [Tue, 2 Jan 2018 21:27:58 +0000 (23:27 +0200)]
link_iptnl: Print tunnel mode

Tunnel mode does not appear in parameters print for iptnl
supported tunnels like ipip and sit, while printed for
ip6tnl.

Print tunnel mode as "proto" field name for JSON and
without any name when printing to cli to follow ip6tnl
behaviour.

For non JSON output we have:

   $ ip -d link show dev sit1

Before:
-------
17: sit1@NONE: <NOARP> mtu 1480 qdisc noop state DOWN ...
    link/sit X.X.X.X brd 0.0.0.0 promiscuity 0
    sit remote any local X.X.X.X ...
        ~~~

After:
------
17: sit1@NONE: <NOARP> mtu 1480 qdisc noop state DOWN ...
    link/sit X.X.X.X brd 0.0.0.0 promiscuity 0
    sit any remote any local X.X.X.X ...
        ^^^

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agolink_iptnl: Kill code duplication
Serhey Popovych [Tue, 2 Jan 2018 21:27:57 +0000 (23:27 +0200)]
link_iptnl: Kill code duplication

Both sit and ipip "mode" parameter handling nearly the same.
Except for sit we have "ip6ip" mode: check it only when
configuring sit.

Note that there is no need strcmp(lu->id, "ipip"): if it is
not sit it is "ipip" because we have only these two link util
defined in module.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agodevlink, rdma, tipc: properly define TARGETS without HAVE_MNL
Matthias Schiffer [Wed, 3 Jan 2018 15:28:52 +0000 (16:28 +0100)]
devlink, rdma, tipc: properly define TARGETS without HAVE_MNL

Leaving a variable with a generic name such as TARGETS undefined would lead
to Make picking up its value from the environment. Avoid this by always
defining TARGETS in the Makefiles.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
6 years agoman: fix small formatting errors
Luca Boccassi [Tue, 2 Jan 2018 17:42:16 +0000 (18:42 +0100)]
man: fix small formatting errors

Lintian detected the following formatting errors:

 man/man8/devlink-sb.8.gz 230: warning: macro `b' not defined
 man/man8/ip-link.8.gz 1243: warning: macro `in-8' not defined
  (possibly missing space after `in')
 man/man8/tc-u32.8.gz `R' is a string (producing the registered sign),
  not a macro.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoman: routel/routef: don't mention filesystem paths
Luca Boccassi [Sat, 30 Dec 2017 10:31:17 +0000 (11:31 +0100)]
man: routel/routef: don't mention filesystem paths

The filesytem paths to these scripts might be different on various
distros, so don't mention it in the manpages. It is not really useful
information anyway.

Originally submitted as Debian bug:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=561424

Reported-by: jidanni@jidanni.org
Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoman: ip-address: document 15-char limit for LABEL
Luca Boccassi [Sat, 30 Dec 2017 10:31:16 +0000 (11:31 +0100)]
man: ip-address: document 15-char limit for LABEL

Trying to set a label longer than 15 characters returns an error:
 RTNETLINK answers: Numerical result out of range

Document the limit in the manpage.

Originally reported as a Debian bug:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661886

Reported-by: Gabor Kiss <kissg@ssg.ki.iif.hu>
Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoman: add more keywords to ip.8 short description
Luca Boccassi [Sat, 30 Dec 2017 10:31:15 +0000 (11:31 +0100)]
man: add more keywords to ip.8 short description

A Debian user suggested adding more network-related keywords to the
ip manpage, so that manpage-scraping and indexing software like
apropos can do a better job of categorizing the programs.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=877983

Suggested-by: Lynoure Braakman <lynoure@gmail.com>
Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoman: drop references to Debian-specific paths
Luca Boccassi [Sat, 30 Dec 2017 10:31:14 +0000 (11:31 +0100)]
man: drop references to Debian-specific paths

Documentation should be distribution-agnostic - any specific quirks
should be handled by downstream maintainers, if necessary.
Remove mentions of Debian paths and package names.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip/tunnel: Document "external" parameter
Serhey Popovych [Thu, 28 Dec 2017 11:11:42 +0000 (13:11 +0200)]
ip/tunnel: Document "external" parameter

Add it to ip-link(8) "type gre" output help message
as well as to ip-link(8) page.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agovxcan,veth: Forbid "type" for peer device
Serhey Popovych [Thu, 28 Dec 2017 11:01:04 +0000 (13:01 +0200)]
vxcan,veth: Forbid "type" for peer device

It is already given for original device we configure this
peer for.

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

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

Before:
-------

<no output, no netdevs created>

After:
------

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

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoqdisc: print offload indication
Yuval Mintz [Tue, 26 Dec 2017 09:48:45 +0000 (11:48 +0200)]
qdisc: print offload indication

Use the newly added TCA_HW_OFFLOAD indication from kernel
to print a consistent 'offloaded' message to user when listing qdiscs.

Signed-off-by: Yuval Mintz <yuvalm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agogre6/tunnel: Do not submit garbage in flowinfo
Serhey Popovych [Wed, 27 Dec 2017 11:28:15 +0000 (13:28 +0200)]
gre6/tunnel: Do not submit garbage in flowinfo

We always send flowinfo to the kernel. If flowlabel/tclass
was set first to non-inherit value and then reset to
inherit we do not clear flowlabel/tclass part in flowinfo,
send it to kernel and can get from the kernel back.

Even if we check for IP6_TNL_F_USE_ORIG_TCLASS and
IP6_TNL_F_USE_ORIG_FLOWLABEL when printing options
sending invalid flowlabel/tclass to the kernel seems
bad idea.

Note that ip6tnl always clean corresponding flowinfo
parts on inherit.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agogre,ip6tnl/tunnel: Fix noencap- support
Serhey Popovych [Wed, 27 Dec 2017 11:28:14 +0000 (13:28 +0200)]
gre,ip6tnl/tunnel: Fix noencap- support

We must clear bit, not set all but given bit.

Fixes: 858dbb208e39 ("ip link: Add support for remote checksum offload to IP tunnels")
Fixes: 73516e128a5a ("ip6tnl: Support for fou encapsulation"
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agoip/tunnel: No need to free answer after rtnl_talk() on error
Serhey Popovych [Wed, 20 Dec 2017 07:57:10 +0000 (09:57 +0200)]
ip/tunnel: No need to free answer after rtnl_talk() on error

Since rtnl_talk() never returns with answer buffer allocated
on error we do not need to release it manually. After this
initializing answer with NULL before rtnl_talk() is useless.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agoutils: ll_addr: Handle ARPHRD_IP6GRE in ll_addr_n2a()
Serhey Popovych [Wed, 20 Dec 2017 07:57:09 +0000 (09:57 +0200)]
utils: ll_addr: Handle ARPHRD_IP6GRE in ll_addr_n2a()

ll_addr_n2a() correctly prints tunnel endpoints for gre, ipip, sit
and ip6tnl, but not for ip6gre. Fix this by adding ARPHRD_IP6GRE to
IPv6 tunnel endpoing address conversion.

Before:
-------

$ ip link show
...
18: ip6tnl0: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group default
    link/tunnel6 :: brd ::
19: ip6gre0: <NOARP> mtu 1456 qdisc noop state DOWN mode DEFAULT group default
    link/gre6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd \
00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00

After:
------

$ ip link show
...
18: ip6tnl0: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group default
    link/tunnel6 :: brd ::
19: ip6gre0: <NOARP> mtu 1456 qdisc noop state DOWN mode DEFAULT group default
    link/gre6 :: brd ::

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agoiproute: "list/flush/save default" selected all of the routes
Alexander Zubkov [Sun, 17 Dec 2017 11:09:00 +0000 (12:09 +0100)]
iproute: "list/flush/save default" selected all of the routes

When running "ip route list default" and not specifying address family,
one will get all of the routes instead of just default only. The same
is for "exact default" and "match default".

It behaves in such a way because default route with unspecified family
has the same all-zeroes value like no prefix specified at all. Thus
following code blindly ignores the fact, that prefix was actually
specified.

This patch adds the flag PREFIXLEN_SPECIFIED to the default route too.
And then checks its value when filtering routes.

Signed-off-by: Alexander Zubkov <green@msu.ru>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoiproute: list/flush/save filter also by metric
Alexander Zubkov [Sun, 17 Dec 2017 12:02:11 +0000 (13:02 +0100)]
iproute: list/flush/save filter also by metric

Metric is one of the "unique key" fields of the route in Linux. But
still one can not use its value in filter while running ip list.
Because of this writing checks in scripts for example is incovenient.

Signed-off-by: Alexander Zubkov <green@msu.ru>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agolink_vti6: Always add local/remote endpoint attributes
Serhey Popovych [Mon, 18 Dec 2017 17:48:05 +0000 (19:48 +0200)]
link_vti6: Always add local/remote endpoint attributes

All tunnels already support for parsing/adding zero
endpoints and vti6 isn't an exception.

This check was added as part of commit 2a80154fde40
(vti6: fix local/remote any addr handling) and looks
too restrictive as purpose of change is to avoid
endpoint configuration from uninitialized data.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agolink_ip6tnl: Use IN6ADDR_ANY_INIT to initialize local/remote endpoints
Serhey Popovych [Mon, 18 Dec 2017 17:48:04 +0000 (19:48 +0200)]
link_ip6tnl: Use IN6ADDR_ANY_INIT to initialize local/remote endpoints

Use specialized helper to initialize endpoint addresses with
zeros instead of open coding this. This unifies initialization
style with other ipv6 tunnel variants (i.e. gre6 and vti6).

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip/tunnel: Use tnl_parse_key() to parse tunnel key
Serhey Popovych [Mon, 18 Dec 2017 17:48:03 +0000 (19:48 +0200)]
ip/tunnel: Use tnl_parse_key() to parse tunnel key

It is added with
commit a7ed1520ee96 ("ip/tunnel: introduce tnl_parse_key()")
to avoid code duplication in ip6?tunnel.c.

Reuse it for gre/gre6 and vti/vti6 tunnel rtnl
configuration interface with the same purpose
it is used in tunnel ioctl interface in ip6?tunnel.c.

While there change type of key variables from
unsigned integer to __be32 to reflect nature of the
value they store and place error message in
tnl_parse_key() on a single line to make single
call to fprintf().

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoiplink: Kill redundant network device name checks
Serhey Popovych [Mon, 18 Dec 2017 18:54:08 +0000 (20:54 +0200)]
iplink: Kill redundant network device name checks

Since commit 625df645b703 (Check user supplied interface name lengths)
iplink_parse() validates network device name using check_ifname()
helpers.

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

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoiplink: Process "alias" parameter correctly
Serhey Popovych [Mon, 18 Dec 2017 18:54:07 +0000 (20:54 +0200)]
iplink: Process "alias" parameter correctly

Do not stop parameters processing after "alias" parameter: it might
not be a last one. Seems copy pasted from "type" parameter code.

Check it's length does not exceed IFALIASZ - 1. Better we warn
than get RTNL error.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoiplink: Improve index parameter handling
Serhey Popovych [Mon, 18 Dec 2017 18:54:06 +0000 (20:54 +0200)]
iplink: Improve index parameter handling

Correctly check for valid network device index supplied on
command line: indexes are always greather than zero. Check
for duplicate "index" argument.

Initialize @index to 0 to simplify handling it in iplink_modify().
Other callers (link_veth.c, iplink_vxcan.c) already did so.

No need to initialize ifi_index with 0 since it is already
initialized at the @struct req initialization time and not
modified in iplink_parse().

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoutils: fix makeargs stack overflow
Stephen Hemminger [Mon, 18 Dec 2017 19:10:53 +0000 (11:10 -0800)]
utils: fix makeargs stack overflow

The makeargs() function did not handle end of string correctly
and would reference past end of string.

Found by fuzzing with ASAN.

Reported-by:Bug Basher <iamliketohack@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoss: fix crash with invalid command input file
Stephen Hemminger [Mon, 18 Dec 2017 17:51:02 +0000 (09:51 -0800)]
ss: fix crash with invalid command input file

If given an invalid input file with -F flag, ss would crash.
Examples of invalid input are line to long, or null file.

Found by fuzzing with ASAN.

Reported-by:Bug Basher <iamliketohack@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip: validate vlan value for vlan info
Stephen Hemminger [Fri, 15 Dec 2017 02:17:43 +0000 (18:17 -0800)]
ip: validate vlan value for vlan info

The VLAN tag must be 0..4095 to be valid.
Better to trap it here.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoip: gre: fix IFLA_GRE_LINK attribute sizing
Serhey Popovych [Wed, 13 Dec 2017 19:36:02 +0000 (21:36 +0200)]
ip: gre: fix IFLA_GRE_LINK attribute sizing

Attribute IFLA_GRE_LINK is 32 bit long, not 8 bit.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agoip/tunnel: Use get_addr() instead of get_prefix() for local/remote endpoints
Serhey Popovych [Wed, 13 Dec 2017 19:36:01 +0000 (21:36 +0200)]
ip/tunnel: Use get_addr() instead of get_prefix() for local/remote endpoints

Manual page ip-link(8) states that both local and remote accept
IPADDR not PREFIX. Use get_addr() instead of get_prefix() to
parse local/remote endpoint address correctly.

Force corresponding address family instead of using preferred_family
to catch weired cases as shown below.

Before this patch it is possible to create tunnel with commands:

  ip    li add dev ip6gre2 type ip6gre local fe80::1/64 remote fe80::2/64
  ip -4 li add dev ip6gre2 type ip6gre local 10.0.0.1/24 remote 10.0.0.2/24

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agoip/tunnel: Unify setup and accept zero address for local/remote endpoints
Serhey Popovych [Wed, 13 Dec 2017 19:36:00 +0000 (21:36 +0200)]
ip/tunnel: Unify setup and accept zero address for local/remote endpoints

It is fully legal to submit zero (INADDR_ANY/IN6ADDR_ANY_INIT)
value for local and/or remote endpoints for all tunnel drivers:
no need additionally check this in userspace.

Note that all tunnel specific code already can pass zero address
to the kernel.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
6 years agoip: add vxcan/veth to ip-link man page
Oliver Hartkopp [Sat, 16 Dec 2017 11:38:57 +0000 (12:38 +0100)]
ip: add vxcan/veth to ip-link man page

veth and vxcan both create a vitual tunnel between a pair of virtual network
devices. This patch adds the content for the now supported vxcan netdevices
and the documentation to create peer devices for vxcan and veth.

Additional remove 'can' that accidently was on the list of link types which
can be created by 'ip link add' as 'can' devices are real network devices.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoss: add missing path MTU parameter
Roman Mashak [Fri, 15 Dec 2017 14:27:42 +0000 (09:27 -0500)]
ss: add missing path MTU parameter

v3:
   Rebase and use out() instead of printf().
v2:
   Print the path MTU immediately after the MSS, as it is easier to parse
   for humans (suggested by Neal Cardwell).

Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoinclude: qdisc offload defines
Stephen Hemminger [Sat, 16 Dec 2017 18:00:43 +0000 (10:00 -0800)]
include: qdisc offload defines

UAPI changes from upstream:
net: sched: Add TCA_HW_OFFLOAD
pkt_sched: Remove TC_RED_OFFLOADED from uapi

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotc: fix command "tc actions del" hang issue
Chris Mi [Thu, 14 Dec 2017 09:09:00 +0000 (18:09 +0900)]
tc: fix command "tc actions del" hang issue

If command is RTM_DELACTION, a non-NULL pointer is passed to rtnl_talk().
Then flag NLM_F_ACK is not set on n->nlmsg_flags and netlink_ack() will
not be called. Command tc will wait for the reply for ever.

Fixes: 86bf43c7c2fd ("lib/libnetlink: update rtnl_talk to support malloc buff at run time")
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Chris Mi <chrism@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotc: fix json array closing
Jiri Pirko [Wed, 13 Dec 2017 19:56:16 +0000 (20:56 +0100)]
tc: fix json array closing

Fixes: 2704bd625583 ("tc: jsonify actions core")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
6 years agoip: add vxcan to help text
Oliver Hartkopp [Wed, 13 Dec 2017 20:21:28 +0000 (21:21 +0100)]
ip: add vxcan to help text

Add missing tag 'vxcan' inside the help text which was missing in commit
efe459c76d35f ('ip: link add vxcan support').

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
6 years agoShow 'external' link mode in output
Phil Dibowitz [Tue, 12 Dec 2017 21:54:06 +0000 (13:54 -0800)]
Show 'external' link mode in output

Recently `external` support was added to the tunnel drivers, but there is no way
to introspect this from userspace. This adds support for that.

Now `ip -details link` shows it:

```
7: tunl60@NONE: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group
default qlen 1
    link/tunnel6 :: brd :: promiscuity 0
    ip6tnl external any remote :: local :: encaplimit 0 hoplimit 0 tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000) addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
```

Signed-off-by: Phil Dibowitz <phil@ipom.com>
6 years agotc: bash-completion: add missing 'classid' keyword
Davide Caratti [Tue, 12 Dec 2017 15:45:15 +0000 (16:45 +0100)]
tc: bash-completion: add missing 'classid' keyword

users of 'matchall' filter can specify a value for the class id: update
bash-completion accordingly.

Fixes: b32c0b64fa2b ("tc: bash-completion: Add support for matchall")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
6 years agoss: Implement automatic column width calculation
Stefano Brivio [Tue, 12 Dec 2017 00:46:33 +0000 (01:46 +0100)]
ss: Implement automatic column width calculation

Group fitting fields into lines and space them equally using the
remaining screen width for each line. If columns don't fit on
one line, break them into the least possible amount of lines and
keep them aligned across lines.

This is done by:
 - recording the length of the longest item in each column during
   formatting and buffering (which was added in the previous patch)
 - fitting as many fields as possible on each line of output
 - distributing the remaining padding space equally between the
   columns

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
6 years agoss: Buffer raw fields first, then render them as a table
Stefano Brivio [Tue, 12 Dec 2017 00:46:32 +0000 (01:46 +0100)]
ss: Buffer raw fields first, then render them as a table

This allows us to measure the maximum field length for each
column before printing fields and will permit us to apply
optimal field spacing and distribution. Structure of the output
buffer with chunked allocation is described in comments.

Output is still unchanged, original spacing is used.

Running over one million sockets with -tul options by simply
modifying main() to loop 50,000 times over the *_show()
functions, buffering the whole output and rendering it at the
end, with 10 UDP sockets, 10 TCP sockets, while throwing
output away, doesn't show significant changes in execution time
on my laptop with an Intel i7-6600U CPU:

- before this patch:
$ time ./ss -tul > /dev/null
real 0m29.899s
user 0m2.017s
sys 0m27.801s

- after this patch:
$ time ./ss -tul > /dev/null
real 0m29.827s
user 0m1.942s
sys 0m27.812s

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
6 years agoss: Introduce columns lightweight abstraction
Stefano Brivio [Tue, 12 Dec 2017 00:46:31 +0000 (01:46 +0100)]
ss: Introduce columns lightweight abstraction

Instead of embedding spacing directly while printing contents,
logically declare columns and functions to buffer their content,
to print left and right spacing around fields, to flush them to
screen, and to print headers.

This makes it a bit easier to handle layout changes and prepares
for full output buffering, needed for optimal spacing in field
output layout.

Columns are currently set up to retain exactly the same output
as before. This needs some slight adjustments of the values
previously calculated in main(), as the width value introduced
here already includes the width of left delimiters and spacing
is not explicitly printed anymore whenever a field is printed.
These calculations will go away altogether once automatic width
calculation is implemented.

We can also remove explicit printing of newlines after the final
content for a given line is printed, flushing the last field on
a line will cause field_flush() to print newlines where
appropriate.

No changes in output expected here.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
6 years agoss: Replace printf() calls for "main" output by calls to helper
Stefano Brivio [Tue, 12 Dec 2017 00:46:30 +0000 (01:46 +0100)]
ss: Replace printf() calls for "main" output by calls to helper

This is preparation work for output buffering, which will allow
us to use optimal spacing and alignment of logical "columns".

The new out() function is just a re-implementation of a typical
libc's printf(), except that the return value of vfprintf() is
ignored as no callers use it. This implementation will be
replaced in the next patches to provide column width adjustment
and adequate spacing.

All printf() calls that output parts of the socket list are now
replaced by calls to out(). Output of summary and version is
excluded from this.

No functional differences here, output not affected.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
6 years agoss: remove duplicate assignment
Roman Mashak [Mon, 11 Dec 2017 21:24:31 +0000 (16:24 -0500)]
ss: remove duplicate assignment

Fixes: 8250bc9ff4e5 ("ss: Unify inet sockets output")
Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotc: util: Don't call NEXT_ARG_FWD() in __parse_action_control()
Michal Privoznik [Fri, 8 Dec 2017 10:18:07 +0000 (11:18 +0100)]
tc: util: Don't call NEXT_ARG_FWD() in __parse_action_control()

Not all callers want parse_action_control*() to advance the
arguments. For instance act_parse_police() does the argument
advancing itself.

Fixes: e67aba559581 ("tc: actions: add helpers to parse and print control actions")
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoss: print tcpi_rcv_ssthresh
Wei Wang [Fri, 8 Dec 2017 00:12:00 +0000 (16:12 -0800)]
ss: print tcpi_rcv_ssthresh

tcpi_rcv_ssthresh is an important stats when debugging receive side
behavior.
Add it to the ss output.

Signed-off-by: Wei Wang <weiwan@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
6 years agoupdate headers from 4.15-rc2
Stephen Hemminger [Wed, 6 Dec 2017 01:30:22 +0000 (17:30 -0800)]
update headers from 4.15-rc2

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agoman: tc-csum.8: Fix inconsistency in example description
Phil Sutter [Wed, 29 Nov 2017 17:34:09 +0000 (18:34 +0100)]
man: tc-csum.8: Fix inconsistency in example description

Commit 6bbe5e6290db5 ("man: tc-csum.8: Fix example") changed both source
and destination IP addresses in example code but missed to update the
example's description accordingly.

Fixes: 6bbe5e6290db5 ("man: tc-csum.8: Fix example")
Signed-off-by: Phil Sutter <phil@nwl.cc>
6 years agoman: add -json option to tc manpage
Jiri Pirko [Mon, 27 Nov 2017 08:09:04 +0000 (09:09 +0100)]
man: add -json option to tc manpage

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
6 years agovxlan: Make id optional when modifying a link
Robert Shearman [Tue, 28 Nov 2017 11:16:50 +0000 (11:16 +0000)]
vxlan: Make id optional when modifying a link

Specifying the IFLA_VXLAN_LINK attribute on a vxlan link modify is
optional in the kernel, so make the id argument optional for "ip link
set ..." to avoid a user needing to specify it when changing another
attribute.

Signed-off-by: Robert Shearman <rs823p@att.com>
6 years agogre: Fix ttl inherit option
Robert Shearman [Tue, 28 Nov 2017 11:16:21 +0000 (11:16 +0000)]
gre: Fix ttl inherit option

Specifying "... ttl inherit" currently does nothing on a GRE link
modify since the previous ttl value is retrieved up front. Fix this by
explicitly setting ttl to 0 when "inherit" is specified for the
option, since 0 represents the semantics of inherit.

Signed-off-by: Robert Shearman <rs823p@att.com>
6 years agolink_gre6: Detect invalid encaplimit values
Phil Sutter [Tue, 28 Nov 2017 15:49:58 +0000 (16:49 +0100)]
link_gre6: Detect invalid encaplimit values

Looks like a typo: get_u8() returns 0 on success and -1 on error, so the
error checking here was ineffective.

Fixes: a11b7b71a6eba ("link_gre6: really support encaplimit option")
Signed-off-by: Phil Sutter <phil@nwl.cc>
6 years agom_mirred: style cleanups
Stephen Hemminger [Sun, 26 Nov 2017 20:42:17 +0000 (12:42 -0800)]
m_mirred: style cleanups

Fix whitespace and long lines.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agom_gact: whitespace cleanup
Stephen Hemminger [Sun, 26 Nov 2017 20:38:21 +0000 (12:38 -0800)]
m_gact: whitespace cleanup

Fix whitespace errors reported by checkpatch

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agom_action: style cleanup
Stephen Hemminger [Sun, 26 Nov 2017 20:36:15 +0000 (12:36 -0800)]
m_action: style cleanup

Break long lines, and use bool where possible.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agom_vlan: style cleanups
Stephen Hemminger [Sun, 26 Nov 2017 20:28:55 +0000 (12:28 -0800)]
m_vlan: style cleanups

Break long lines and make duplicated code into function.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 years agotc: jsonify vlan action
Jiri Pirko [Sat, 25 Nov 2017 14:48:35 +0000 (15:48 +0100)]
tc: jsonify vlan action

Add json output to vlan action.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
6 years agotc: jsonify mirred action
Jiri Pirko [Sat, 25 Nov 2017 14:48:34 +0000 (15:48 +0100)]
tc: jsonify mirred action

Add json output to mirred action.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
6 years agotc: jsonify gact action
Jiri Pirko [Sat, 25 Nov 2017 14:48:33 +0000 (15:48 +0100)]
tc: jsonify gact action

Add json output to gact action.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>