]> git.proxmox.com Git - mirror_iproute2.git/log
mirror_iproute2.git
5 years agoUse libbsd for strlcpy if available
Luca Boccassi [Wed, 31 Oct 2018 18:00:11 +0000 (18:00 +0000)]
Use libbsd for strlcpy if available

If libc does not provide strlcpy check for libbsd with pkg-config to
avoid relying on inline version.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agobpf: check map symbol type properly with newer llvm compiler
Yonghong Song [Mon, 29 Oct 2018 22:32:03 +0000 (15:32 -0700)]
bpf: check map symbol type properly with newer llvm compiler

With llvm 7.0 or earlier, the map symbol type is STT_NOTYPE.
  -bash-4.4$ cat t.c
  __attribute__((section("maps"))) int g;
  -bash-4.4$ clang -target bpf -O2 -c t.c
  -bash-4.4$ readelf -s t.o

  Symbol table '.symtab' contains 2 entries:
     Num:    Value          Size Type    Bind   Vis      Ndx Name
       0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
       1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    3 g

The following llvm commit enables BPF target to generate
proper symbol type and size.
  commit bf6ec206615b9718869d48b4e5400d0c6e3638dd
  Author: Yonghong Song <yhs@fb.com>
  Date:   Wed Sep 19 16:04:13 2018 +0000

      [bpf] Symbol sizes and types in object file

      Clang-compiled object files currently don't include the symbol sizes and
      types.  Some tools however need that information.  For example, ctfconvert
      uses that information to generate FreeBSD's CTF representation from ELF
      files.
      With this patch, symbol sizes and types are included in object files.

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
Reported-by: Yutaro Hayakawa <yhayakawa3720@gmail.com>
Hence, for llvm 8.0.0 (currently trunk), symbol type will be not NOTYPE, but OBJECT.
  -bash-4.4$ clang -target bpf -O2 -c t.c
  -bash-4.4$ readelf -s t.o

  Symbol table '.symtab' contains 3 entries:
     Num:    Value          Size Type    Bind   Vis      Ndx Name
       0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
       1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS t.c
       2: 0000000000000000     4 OBJECT  GLOBAL DEFAULT    3 g

This patch makes sure bpf library accepts both NOTYPE and OBJECT types
of global map symbols.

Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoss: Actually print left delimiter for columns
Stefano Brivio [Mon, 29 Oct 2018 22:04:25 +0000 (23:04 +0100)]
ss: Actually print left delimiter for columns

While rendering columns, we use a local variable to keep track of the
field currently being printed, without touching current_field, which is
used for buffering.

Use the right pointer to access the left delimiter for the current column,
instead of always printing the left delimiter for the last buffered field,
which is usually an empty string.

This fixes an issue especially visible on narrow terminals, where some
columns might be displayed without separation.

Reported-by: YoyPa <yoann.p.public@gmail.com>
Fixes: 691bd854bf4a ("ss: Buffer raw fields first, then render them as a table")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: YoyPa <yoann.p.public@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agobridge: fix vlan show stats formatting
Tobias Jungel [Fri, 26 Oct 2018 21:51:03 +0000 (23:51 +0200)]
bridge: fix vlan show stats formatting

The output of -statistics vlan show was broken previous change for json
output. This aligns the format to vlan show.

v2: fixed too greedy deletion that caused a -Wmaybe-uninitialized

Signed-off-by: Tobias Jungel <tobias.jungel@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoutils.h: provide fallback CLOCK_TAI definition
Peter Korsgaard [Sat, 27 Oct 2018 15:31:02 +0000 (17:31 +0200)]
utils.h: provide fallback CLOCK_TAI definition

q_{etf,taprio}.c uses CLOCK_TAI, which isn't exposed by glibc < 2.21 or
uClibc, breaking the build. Provide a fallback definition like it is done
for IPPROTO_MPLS and others.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoMerge branch 'iproute2-master' into iproute2-next
David Ahern [Tue, 23 Oct 2018 17:55:09 +0000 (10:55 -0700)]
Merge branch 'iproute2-master' into iproute2-next

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoip/geneve: fix ttl inherit behavior
Hangbin Liu [Mon, 22 Oct 2018 07:46:18 +0000 (15:46 +0800)]
ip/geneve: fix ttl inherit behavior

Currently when we add geneve with "ttl inherit", we only set ttl to 0, which
is actually use whatever default value instead of inherit the inner protocol's
ttl value.

To make a difference with ttl inherit and ttl == 0, we add an attribute
IFLA_GENEVE_TTL_INHERIT in kernel commit 52d0d404d39dd ("geneve: add ttl
inherit support"). Now let's use "ttl inherit" to inherit the inner
protocol's ttl, and use "ttl auto" to means "use whatever default value",
the same behavior with ttl == 0.

v2:
1) remove IFLA_GENEVE_TTL_INHERIT defination in if_link.h as it's already
   updated.
2) Still use addattr8() so we can enable/disable ttl inherit, as Michal
   suggested.

v3: Update man page

Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agov4.19.0
Stephen Hemminger [Tue, 23 Oct 2018 17:14:57 +0000 (10:14 -0700)]
v4.19.0

5 years agotc: htb: Print default value in hex
Phil Sutter [Tue, 23 Oct 2018 10:36:24 +0000 (12:36 +0200)]
tc: htb: Print default value in hex

Value of 'default' is assumed to be hexadecimal when parsing, so
consequently it should be printed in hex as well. This is a regression
introduced when adding JSON output.

As requested, also change JSON output to print the value as hex string.

Fixes: f354fa6aa5ff0 ("tc: jsonify htb qdisc")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotc: Remove pointless assignments in batch()
Phil Sutter [Thu, 18 Oct 2018 13:48:48 +0000 (15:48 +0200)]
tc: Remove pointless assignments in batch()

All these assignments are later overwritten without reading in between,
so just drop them.

Fixes: 485d0c6001c4a ("tc: Add batchsize feature for filter and actions")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotipc: Drop unused variable 'genl'
Phil Sutter [Thu, 18 Oct 2018 13:48:09 +0000 (15:48 +0200)]
tipc: Drop unused variable 'genl'

Although initialized by call to libmnl, the variable is used only in a
call to sizeof(). Drop it and call sizeof with its type instead.

Fixes: f043759dd4928 ("tipc: add new TIPC configuration tool")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoip-route: Fix parse_encap_seg6() srh parsing
Phil Sutter [Thu, 18 Oct 2018 13:44:14 +0000 (15:44 +0200)]
ip-route: Fix parse_encap_seg6() srh parsing

In case caller did not specify 'segs' parameter, parse_srh() would read
garbage while iterating over 'segbuf'. Avoid this by initializing
'segbuf' to an empty string.

Fixes: e8493916a8ede ("iproute: add support for SR-IPv6 lwtunnel encapsulation")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agordma: Don't pass garbage to rd_check_is_filtered()
Phil Sutter [Thu, 18 Oct 2018 12:35:50 +0000 (14:35 +0200)]
rdma: Don't pass garbage to rd_check_is_filtered()

Variables 'src_port' and 'dst_port' are initialized only if attributes
RDMA_NLDEV_ATTR_RES_SRC_ADDR or RDMA_NLDEV_ATTR_RES_DST_ADDR are
present. Make sure to pass them over to rd_check_is_filtered() only if
that is the case.

Fixes: 9a362cc71a455 ("rdma: Add CM_ID resource tracking information")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoip-route: Fix for memleak in error path
Phil Sutter [Thu, 18 Oct 2018 12:30:31 +0000 (14:30 +0200)]
ip-route: Fix for memleak in error path

If call to rta_addattr_l() failed, parse_encap_seg6() would leak memory.
Fix this by making sure calls to free() are not skipped.

Fixes: bd59e5b1517b0 ("ip-route: Fix segfault with many nexthops")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agordma: Fix for ineffective check in add_filter()
Phil Sutter [Thu, 18 Oct 2018 11:41:54 +0000 (13:41 +0200)]
rdma: Fix for ineffective check in add_filter()

With 'name' field defined as array in struct filters, it will always
contain a value irrespective of whether a name was assigned or not.

Fix this by turning the field into a const char pointer.

Fixes: 1174be72d1b4c ("rdma: Add filtering infrastructure")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agodevlink: Fix error reporting in cmd_resource_set()
Phil Sutter [Thu, 18 Oct 2018 11:28:23 +0000 (13:28 +0200)]
devlink: Fix error reporting in cmd_resource_set()

resource_path_parse() returns either zero or a negative error code,
hence the negated value must be passed to strerror().

Fixes: 8cd644095842a ("devlink: Add support for devlink resource abstraction")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotestsuite: Fix make check when need build generate_nlmsg
Petr Vorel [Tue, 25 Sep 2018 12:49:56 +0000 (14:49 +0200)]
testsuite: Fix make check when need build generate_nlmsg

make check from top level Makefile defines several flags which break
building generate_nlmsg:

$ make check
make -C tools
gcc  -Wall -Wstrict-prototypes  -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wformat=2 -O2 -I../include -I../include/uapi -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -DNETNS_RUN_DIR=\"/var/run/netns\" -DNETNS_ETC_DIR=\"/etc/netns\" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -DHAVE_SETNS -DHAVE_SELINUX -DHAVE_ELF -DHAVE_LIBMNL -I/usr/include/libmnl -DNEED_STRLCPY -DHAVE_LIBCAP ../lib/libutil.a ../lib/libnetlink.a -lselinux -lelf -lmnl -lcap  -I../../include -include../../include/uapi/linux/netlink.h -o generate_nlmsg generate_nlmsg.c ../../lib/libnetlink.c -lmnl
gcc: error: ../lib/libutil.a: No such file or directory
gcc: error: ../lib/libnetlink.a: No such file or directory
make[2]: *** [Makefile:5: generate_nlmsg] Error 1
make[1]: *** [Makefile:40: generate_nlmsg] Error 2

To fix it reset CFLAGS in sub Makefile and remove LDLIBS entirely (as
required -lmnl flag was specified in 5dc2204c ("testsuite: add libmnl").

Fixes: 8804a8c0 ("Makefile: Add check target")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoiplink: Remove flags argument from iplink_get
David Ahern [Fri, 19 Oct 2018 19:55:44 +0000 (12:55 -0700)]
iplink: Remove flags argument from iplink_get

iplink_get has 1 caller and the flags arg is 0, so just remove it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoTree wide: Drop sockaddr_nl arg
David Ahern [Fri, 19 Oct 2018 20:42:36 +0000 (13:42 -0700)]
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>
5 years agoMerge branch 'iproute2-master' into iproute2-next
David Ahern [Mon, 22 Oct 2018 16:43:33 +0000 (09:43 -0700)]
Merge branch 'iproute2-master' into iproute2-next

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoutil: spelling fix
Stephen Hemminger [Thu, 18 Oct 2018 20:23:38 +0000 (13:23 -0700)]
util: spelling fix

5 years agotipc: spelling fix
Stephen Hemminger [Thu, 18 Oct 2018 20:23:30 +0000 (13:23 -0700)]
tipc: spelling fix

5 years agoip: spelling fixes
Stephen Hemminger [Thu, 18 Oct 2018 20:23:11 +0000 (13:23 -0700)]
ip: spelling fixes

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotc: spelling fixes
Stephen Hemminger [Thu, 18 Oct 2018 20:22:51 +0000 (13:22 -0700)]
tc: spelling fixes

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoconfig: spelling fixes
Stephen Hemminger [Thu, 18 Oct 2018 20:22:25 +0000 (13:22 -0700)]
config: spelling fixes

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoexamples: fix spelling errors
Stephen Hemminger [Thu, 18 Oct 2018 20:18:56 +0000 (13:18 -0700)]
examples: fix spelling errors

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agodoc/man: spelling fixes
Stephen Hemminger [Thu, 18 Oct 2018 20:15:45 +0000 (13:15 -0700)]
doc/man: spelling fixes

Use ispell and codespell to find/fix spelling errors in documentation
and man pages.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoip-addrlabel: Fix printing of label value
Phil Sutter [Mon, 15 Oct 2018 20:20:58 +0000 (22:20 +0200)]
ip-addrlabel: Fix printing of label value

Passing the return value of RTA_DATA() to rta_getattr_u32() is wrong
since that function will call RTA_DATA() by itself already.

Fixes: a7ad1c8a6845d ("ipaddrlabel: add json support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoutils: fix get_rtnl_link_stats_rta stats parsing
Lorenzo Bianconi [Wed, 10 Oct 2018 15:00:58 +0000 (17:00 +0200)]
utils: fix get_rtnl_link_stats_rta stats parsing

iproute2 walks through the list of available tunnels using netlink
protocol in order to get device info instead of reading
them from proc filesystem. However the kernel reports device statistics
using IFLA_INET6_STATS/IFLA_INET6_ICMP6STATS attributes nested in
IFLA_PROTINFO one but iproutes expects these info in
IFLA_STATS64/IFLA_STATS attributes.
The issue can be triggered with the following reproducer:

$ip link add ip6d0 type ip6tnl mode ip6ip6 local 1111::1 remote 2222::1
$ip -6 -d -s tunnel show ip6d0
ip6d0: ipv6/ipv6 remote 2222::1 local 1111::1 encaplimit 4 hoplimit 64
tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000)
Dump terminated

Fix the issue introducing IFLA_INET6_STATS attribute parsing

Fixes: 3e953938717f ("iptunnel/ip6tunnel: Use netlink to walk through
tunnels list")

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
5 years agouapi: add snmp header file
Lorenzo Bianconi [Wed, 10 Oct 2018 15:00:57 +0000 (17:00 +0200)]
uapi: add snmp header file

Introduce snmp header file. It will be used in subsequent patch in
order to parse device statistics reported in
IFLA_INET6_STATS/IFLA_INET6_ICMP6STATS netlink attributes

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agomacsec: fix off-by-one when parsing attributes
Sabrina Dubroca [Fri, 12 Oct 2018 15:34:12 +0000 (17:34 +0200)]
macsec: fix off-by-one when parsing attributes

I seem to have had a massive brainfart with uses of
parse_rtattr_nested(). The rtattr* array must have MAX+1 elements, and
the call to parse_rtattr_nested must have MAX as its bound. Let's fix
those.

Fixes: b26fc590ce62 ("ip: add MACsec support")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agojson: make 0xhex handle u64
Sabrina Dubroca [Fri, 12 Oct 2018 15:34:32 +0000 (17:34 +0200)]
json: make 0xhex handle u64

Stephen converted macsec's sci to use 0xhex, but 0xhex handles
unsigned int's, not 64 bits ints. Thus, the output of the "ip macsec
show" command is mangled, with half of the SCI replaced with 0s:

# ip macsec show
11: macsec0: [...]
    cipher suite: GCM-AES-128, using ICV length 16
    TXSC: 0000000001560001 on SA 0

# ip -d link show macsec0
11: macsec0@ens3: [...]
    link/ether 52:54:00:12:01:56 brd ff:ff:ff:ff:ff:ff promiscuity 0
    macsec sci 5254001201560001 [...]

where TXSC and sci should match.

Fixes: c0b904de6211 ("macsec: support JSON")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agobridge: fdb: Fix for missing keywords in non-JSON output
Phil Sutter [Tue, 9 Oct 2018 12:44:08 +0000 (14:44 +0200)]
bridge: fdb: Fix for missing keywords in non-JSON output

While migrating to JSON print library, some keywords were dropped from
standard output by accident. Add them back to unbreak output parsers.

Fixes: c7c1a1ef51aea ("bridge: colorize output and use JSON print library")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoMerge branch 'master' into iproute2-next
David Ahern [Sun, 14 Oct 2018 02:31:37 +0000 (19:31 -0700)]
Merge branch 'master' into iproute2-next

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agobridge: add support for backup port
Nikolay Aleksandrov [Fri, 12 Oct 2018 11:42:55 +0000 (14:42 +0300)]
bridge: add support for backup port

This patch adds support for the new backup port option that can be set
on a bridge port. If the port's carrier goes down all of the traffic
gets redirected to the configured backup port. We add the following new
arguments:
$ ip link set dev brport type bridge_slave backup_port brport2
$ ip link set dev brport type bridge_slave nobackup_port

$ bridge link set dev brport backup_port brport2
$ bridge link set dev brport nobackup_port

The man pages are updated respectively.
Also 2 minor style adjustments:
- add missing space to bridge man page's state argument
- use lower starting case for vlan_tunnel in ip-link man page (to be
consistent with the rest)

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoipneigh: support for NTF_EXT_LEARNED flag on neigh entries
Roopa Prabhu [Thu, 11 Oct 2018 20:45:10 +0000 (13:45 -0700)]
ipneigh: support for NTF_EXT_LEARNED flag on neigh entries

Adds new option extern_learn to set NTF_EXT_LEARNED flag
on neigh entries.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: use local variable
Stephen Hemminger [Tue, 9 Oct 2018 16:46:11 +0000 (09:46 -0700)]
libnetlink: use local variable

Now that err->error is in local variable, use it consistently.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agolibnetlink: fix use-after-free of message buf
Vlad Buslov [Mon, 8 Oct 2018 20:52:26 +0000 (23:52 +0300)]
libnetlink: fix use-after-free of message buf

In __rtnl_talk_iov() main loop, err is a pointer to memory in dynamically
allocated 'buf' that is used to store netlink messages. If netlink message
is an error message, buf is deallocated before returning with error code.
However, on return err->error code is checked one more time to generate
return value, after memory which err points to has already been
freed. Save error code in temporary variable and use the variable to
generate return value.

Fixes: c60389e4f9ea ("libnetlink: fix leak and using unused memory on error")
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotc: jsonify output of q_fifo
Jakub Kicinski [Fri, 5 Oct 2018 00:08:34 +0000 (17:08 -0700)]
tc: jsonify output of q_fifo

Print limits correctly in JSON context.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoMerge branch 'taprio-scheduler' into iproute2-next
David Ahern [Sun, 7 Oct 2018 17:37:57 +0000 (10:37 -0700)]
Merge branch 'taprio-scheduler' into iproute2-next

Vinicius Costa Gomes  says:

====================

This is the iproute2 side of the taprio v1 series.

====================

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agotaprio: Add manpage for tc-taprio(8)
Vinicius Costa Gomes [Fri, 5 Oct 2018 23:25:22 +0000 (16:25 -0700)]
taprio: Add manpage for tc-taprio(8)

This documents the parameters and provides an example of usage.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agotc: Add support for configuring the taprio scheduler
Vinicius Costa Gomes [Fri, 5 Oct 2018 23:25:21 +0000 (16:25 -0700)]
tc: Add support for configuring the taprio scheduler

This traffic scheduler allows traffic classes states (transmission
allowed/not allowed, in the simplest case) to be scheduled, according
to a pre-generated time sequence. This is the basis of the IEEE
802.1Qbv specification.

Example configuration:

tc qdisc replace dev enp3s0 parent root handle 100 taprio \
          num_tc 3 \
  map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
  queues 1@0 1@1 2@2 \
  base-time 1528743495910289987 \
  sched-entry S 01 300000 \
  sched-entry S 02 300000 \
  sched-entry S 04 300000 \
  clockid CLOCK_TAI

The configuration format is similar to mqprio. The main difference is
the presence of a schedule, built by multiple "sched-entry"
definitions, each entry has the following format:

     sched-entry <CMD> <GATE MASK> <INTERVAL>

The only supported <CMD> is "S", which means "SetGateStates",
following the IEEE 802.1Qbv-2015 definition (Table 8-6). <GATE MASK>
is a bitmask where each bit is a associated with a traffic class, so
bit 0 (the least significant bit) being "on" means that traffic class
0 is "active" for that schedule entry. <INTERVAL> is a time duration
in nanoseconds that specifies for how long that state defined by <CMD>
and <GATE MASK> should be held before moving to the next entry.

This schedule is circular, that is, after the last entry is executed
it starts from the first one, indefinitely.

The other parameters can be defined as follows:

 - base-time: specifies the instant when the schedule starts, if
  'base-time' is a time in the past, the schedule will start at

        base-time + (N * cycle-time)

   where N is the smallest integer so the resulting time is greater
   than "now", and "cycle-time" is the sum of all the intervals of the
   entries in the schedule;

 - clockid: specifies the reference clock to be used;

The parameters should be similar to what the IEEE 802.1Q family of
specification defines.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Add helper for getting a __s32 from netlink msgs
Jesus Sanchez-Palencia [Fri, 5 Oct 2018 23:25:19 +0000 (16:25 -0700)]
libnetlink: Add helper for getting a __s32 from netlink msgs

This function retrieves a signed 32-bit integer from a netlink message
and returns it.

Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoinclude: Add helper to retrieve a __s64 from a netlink msg
Vinicius Costa Gomes [Fri, 5 Oct 2018 23:25:18 +0000 (16:25 -0700)]
include: Add helper to retrieve a __s64 from a netlink msg

This allows signed 64-bit integers to be retrieved from a netlink
message.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoutils: Implement get_s64()
Vinicius Costa Gomes [Fri, 5 Oct 2018 23:25:17 +0000 (16:25 -0700)]
utils: Implement get_s64()

Add this helper to read signed 64-bit integers from a string.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoUpdate kernel headers
David Ahern [Sun, 7 Oct 2018 17:29:25 +0000 (10:29 -0700)]
Update kernel headers

update kernel headers to commit:
72438f8cef4e ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agotc: flower: expose hardware offload count
Vlad Buslov [Wed, 3 Oct 2018 20:44:48 +0000 (23:44 +0300)]
tc: flower: expose hardware offload count

Recently flower classifier was updated to expose count of devices that
filter is offloaded to. Add support to print this counter as 'in_hw_count'.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
5 years agovxlan: show correct ttl inherit info
Hangbin Liu [Thu, 27 Sep 2018 07:28:36 +0000 (15:28 +0800)]
vxlan: show correct ttl inherit info

We should only show ttl inherit when IFLA_VXLAN_TTL_INHERIT supplied.
Otherwise show the ttl number, or auto when it is 0.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoMerge branch 'hdrs-for-dump-req' into iproute2-next
David Ahern [Wed, 3 Oct 2018 01:40:37 +0000 (18:40 -0700)]
Merge branch 'hdrs-for-dump-req' into iproute2-next

David Ahern says:

====================

iproute2 currently uses ifinfomsg as the header for all dumps using the
wilddump headers. This is wrong as each message type actually has its own
header type. While the kernel has traditionally let it go as it for the
most part only uses the family entry, the use of kernel side filters is
increasing to alter what is returned on a request. The kernel side filters
really need to use the proper header type.

To that end, fix iproute2 to use the proper header struct for the GET type.

====================

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Rename rtnl_wilddump_stats_req_filter to rtnl_statsdump_req_filter
David Ahern [Sat, 29 Sep 2018 17:12:59 +0000 (10:12 -0700)]
libnetlink: Rename rtnl_wilddump_stats_req_filter to rtnl_statsdump_req_filter

rtnl_wilddump_stats_req_filter only takes RTM_GETSTATS as the type argument
so rename to rtnl_statsdump_req_filter for consistency with other request
functions and hardcode the type argument.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Rename rtnl_wilddump_* to rtnl_linkdump_*
David Ahern [Sat, 29 Sep 2018 16:56:57 +0000 (09:56 -0700)]
libnetlink: Rename rtnl_wilddump_* to rtnl_linkdump_*

Rename rtnl_wilddump_req_filter to rtnl_linkdump_req_filter,
rtnl_wilddump_request to rtnl_linkdump_req and
rtnl_wilddump_req_filter_fn to rtnl_linkdump_req_filter_fn.

In all cases drop the type argument which at this point is only
RTM_GETLINK and hardcode in the functions.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req
David Ahern [Sat, 29 Sep 2018 16:51:08 +0000 (09:51 -0700)]
libnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req

Add rtnl_nsiddump_req for namespace id dumps using the proper rtgenmsg
as the header. Convert existing RTM_GETNSID dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETNEIGHTBL dumps to use rtnl_neightbldump_req
David Ahern [Sat, 29 Sep 2018 16:47:41 +0000 (09:47 -0700)]
libnetlink: Convert GETNEIGHTBL dumps to use rtnl_neightbldump_req

Add rtnl_neightbldump_req for neighbor table dumps using the proper ndtmsg
as the header. Convert existing RTM_GETNEIGHTBL dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETNEIGH dumps to use rtnl_neighdump_req
David Ahern [Sat, 29 Sep 2018 16:42:40 +0000 (09:42 -0700)]
libnetlink: Convert GETNEIGH dumps to use rtnl_neighdump_req

Add rtnl_neighdump_req for neighbor dumps using the proper ndmsg
as the header. Convert existing rtnl_wilddump_request for RTM_GETNEIGH
to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETRULE dumps to use rtnl_ruledump_req
David Ahern [Sat, 29 Sep 2018 16:34:57 +0000 (09:34 -0700)]
libnetlink: Convert GETRULE dumps to use rtnl_ruledump_req

Add rtnl_ruledump_req for fib fule dumps using the proper fib_rule_hdr
as the header. Convert existing RTM_GETRULE dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETNETCONF dumps to use rtnl_netconfdump_req
David Ahern [Sat, 29 Sep 2018 16:29:29 +0000 (09:29 -0700)]
libnetlink: Convert GETNETCONF dumps to use rtnl_netconfdump_req

Add rtnl_netconfdump_req for netconf dumps using the proper netconfmsg
as the header. Convert existing RTM_GETNETCONF dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETMDB dumps to use rtnl_mdbdump_req
David Ahern [Sat, 29 Sep 2018 17:44:18 +0000 (10:44 -0700)]
libnetlink: Convert GETMDB dumps to use rtnl_mdbdump_req

Add rtnl_mdbdump_req for mdb dumps using the proper br_port_msg as
the header. Convert existing RTM_GETMDB dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req
David Ahern [Sat, 29 Sep 2018 17:43:15 +0000 (10:43 -0700)]
libnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req

Add rtnl_addrlbldump_req for address label dumps using the proper
ifaddrlblmsg as the header. Convert existing RTM_GETADDRALBEL dumps
to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETROUTE dumps to use rtnl_routedump_req
David Ahern [Sat, 29 Sep 2018 15:46:31 +0000 (08:46 -0700)]
libnetlink: Convert GETROUTE dumps to use rtnl_routedump_req

Add rtnl_routedump_req for route dumps using the proper rtmsg
as the header. Convert existing RTM_GETROUTE dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: Convert GETADDR dumps to use rtnl_addrdump_req
David Ahern [Sat, 29 Sep 2018 15:41:46 +0000 (08:41 -0700)]
libnetlink: Convert GETADDR dumps to use rtnl_addrdump_req

Add rtnl_addrdump_req for address dumps using the proper ifaddrmsg
as the header. Convert existing RTM_GETADDR dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agotc_util: Add support for showing TCA_STATS_BASIC_HW statistics
Eelco Chaudron [Tue, 2 Oct 2018 07:27:18 +0000 (03:27 -0400)]
tc_util: Add support for showing TCA_STATS_BASIC_HW statistics

Add support for showing hardware specific counters to easy
troubleshooting hardware offload.

$ tc -s filter show dev enp3s0np0 parent ffff:
filter protocol ip pref 1 flower chain 0
filter protocol ip pref 1 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 2.0.0.0
  src_ip 1.0.0.0
  ip_flags nofrag
  in_hw
        action order 1: mirred (Egress Redirect to device eth1) stolen
        index 1 ref 1 bind 1 installed 0 sec used 0 sec
        Action statistics:
        Sent 534884742 bytes 8915697 pkt (dropped 0, overlimits 0 requeues 0)
        Sent software 187542 bytes 4077 pkt
        Sent hardware 534697200 bytes 8911620 pkt
        backlog 0b 0p requeues 0
        cookie 89173e6a44447001becfd486bda17e29

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agotc: f_flower: add geneve option match support to flower
Pieter Jansen van Vuuren [Fri, 28 Sep 2018 14:03:39 +0000 (16:03 +0200)]
tc: f_flower: add geneve option match support to flower

Allow matching on options in Geneve tunnel headers.

The options can be described in the form
CLASS:TYPE:DATA/CLASS_MASK:TYPE_MASK:DATA_MASK, where CLASS is
represented as a 16bit hexadecimal value, TYPE as an 8bit
hexadecimal value and DATA as a variable length hexadecimal value.

e.g.
 # ip link add name geneve0 type geneve dstport 0 external
 # tc qdisc add dev geneve0 ingress
 # tc filter add dev geneve0 protocol ip parent ffff: \
     flower \
       enc_src_ip 10.0.99.192 \
       enc_dst_ip 10.0.99.193 \
       enc_key_id 11 \
       geneve_opts 0102:80:1122334421314151/ffff:ff:ffffffffffffffff \
       ip_proto udp \
       action mirred egress redirect dev eth1

Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoipneigh: update man page and help for router
Roopa Prabhu [Sun, 30 Sep 2018 02:48:11 +0000 (19:48 -0700)]
ipneigh: update man page and help for router

While at it also add missing text for proxy in the man page.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agobridge: fdb: add support for sticky flag
Nikolay Aleksandrov [Thu, 27 Sep 2018 13:35:12 +0000 (16:35 +0300)]
bridge: fdb: add support for sticky flag

Add support for the new sticky flag that can be set on fdbs and update the
man page.

CC: David Ahern <dsahern@gmail.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoUpdate kernel headers
David Ahern [Fri, 28 Sep 2018 17:51:15 +0000 (10:51 -0700)]
Update kernel headers

Update kernel headers to commit
a804e5e218754 ("selftests: forwarding: test for bridge sticky flag")

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoipneigh: support setting of NTF_ROUTER on neigh entries
Roopa Prabhu [Tue, 25 Sep 2018 21:15:39 +0000 (14:15 -0700)]
ipneigh: support setting of NTF_ROUTER on neigh entries

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoMerge branch 'iproute2-master' into iproute2-next
David Ahern [Fri, 28 Sep 2018 16:52:41 +0000 (09:52 -0700)]
Merge branch 'iproute2-master' into iproute2-next

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agolibnetlink: don't return error on success
Stephen Hemminger [Tue, 25 Sep 2018 08:08:48 +0000 (10:08 +0200)]
libnetlink: don't return error on success

Change to error handling broke normal code.

Fixes: c60389e4f9ea ("libnetlink: fix leak and using unused memory on error")
Reported-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotestsuite: add libmnl
Stephen Hemminger [Tue, 25 Sep 2018 07:59:37 +0000 (09:59 +0200)]
testsuite: add libmnl

Supporting external ack requires libmnl now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoMakefile: Add check target
Petr Vorel [Fri, 21 Sep 2018 20:29:16 +0000 (22:29 +0200)]
Makefile: Add check target

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoiplink_vxlan: take into account preferred_family creating vxlan device
Lorenzo Bianconi [Fri, 21 Sep 2018 13:34:25 +0000 (15:34 +0200)]
iplink_vxlan: take into account preferred_family creating vxlan device

Take into account the configured preferred_family if neither saddr or
daddr are provided since otherwise vxlan kernel module will use IPv4 as
default remote inet family neglecting the one provided by userspace.
This behaviour was originally in commit 97d564b90ccb ("vxlan: use
preferred address family when neither group or remote is specified").
The issue can be triggered with the following reproducer:

$ip -6 link add vxlan1 type vxlan id 42 dev enp0s2 \
     proxy nolearning l2miss l3miss
$bridge fdb add 46:47:1f:a7:1c:25 dev vxlan1 dst 2000::2
RTNETLINK answers: Address family not supported by protocol

Fixes: 1e9b8072de2c ("iplink_vxlan: Get rid of inet_get_addr()")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoiplink: fix incorrect any address handling for ip tunnels
Hangbin Liu [Tue, 18 Sep 2018 09:48:40 +0000 (17:48 +0800)]
iplink: fix incorrect any address handling for ip tunnels

After commit d42c7891d26e4 ("utils: Do not reset family for default, any,
all addresses"), when call get_addr() for any/all addresses, we will set
addr->flags to ADDRTYPE_INET_UNSPEC if family is AF_INET/AF_INET6, which
makes is_addrtype_inet() checking passed and assigns incorrect address
to kernel. The ip link cmd will return error like:

]# ip link add ipip1 type ipip local any remote 1.1.1.1
RTNETLINK answers: Numerical result out of range

Fix it by using is_addrtype_inet_not_unspec() to avoid unspec addresses.

geneve, vxlan are not affected as they use AF_UNSPEC family when call
get_addr()

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: d42c7891d26e4 ("utils: Do not reset family for default, any, all addresses")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoMakefile: add help target
Stephen Hemminger [Fri, 21 Sep 2018 16:15:26 +0000 (09:15 -0700)]
Makefile: add help target

Add help target to Makefile

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotestsuite: Warn about empty $(IPVERS)
Petr Vorel [Wed, 19 Sep 2018 23:36:24 +0000 (01:36 +0200)]
testsuite: Warn about empty $(IPVERS)

alltests target requires having symlink created by configure target
(default target). Without that there is no test being run.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotestsuite: Generate generate_nlmsg when needed
Petr Vorel [Wed, 19 Sep 2018 23:36:23 +0000 (01:36 +0200)]
testsuite: Generate generate_nlmsg when needed

Commit 886f2c43 added generate_nlmsg.c. Running alltests
target, which uses the binary required to run 'make -C tools' before.

Fixes: 886f2c43 testsuite: Generate nlmsg blob at runtime
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotestsuite: Fix missing generate_nlmsg
Petr Vorel [Wed, 19 Sep 2018 23:36:22 +0000 (01:36 +0200)]
testsuite: Fix missing generate_nlmsg

Commit ad23e152 caused generate_nlmsg to be always missing:

$ make alltests
make: ./tools/generate_nlmsg: Command not found

Create testclean: to remove only results directory.

Fixes: ad23e152 testsuite: remove all temp files and implement make clean
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoiplink: add ipvtap support
Hangbin Liu [Wed, 19 Sep 2018 03:03:29 +0000 (11:03 +0800)]
iplink: add ipvtap support

IPVLAN and IPVTAP are using the same functions and parameters. So we can
just add a new link_util with id ipvtap. Others are the same.

Acked-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoMerge branch 'iproute2-master' into iproute2-next
David Ahern [Fri, 21 Sep 2018 00:50:55 +0000 (17:50 -0700)]
Merge branch 'iproute2-master' into iproute2-next

Conflicts:
ip/iproute_lwtunnel.c

In addition to merge conflict between bd59e5b1517b and 94a8722f2f78,
updated the code added by the latter commit based on the change of the
former (ie., added ret = to the new rta_addattr_l).

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agordma: Fix representation of PortInfo CapabilityMask
Leon Romanovsky [Sun, 16 Sep 2018 17:28:13 +0000 (20:28 +0300)]
rdma: Fix representation of PortInfo CapabilityMask

The port capability mask represents IBTA PortInfo specification,
but as it is written in description of kernel commit 2f944c0fbf58
("RDMA: Fix storage of PortInfo CapabilityMask in the kernel"),
the bit 26 was mistakenly overwritten.

The rdmatool followed it too and mislead users by presenting wrong
value. Since it never showed proper value, we update the whole
port_cap_mask to comply with IBTA and show real HW values.

Fixes: da990ab40a92 ("rdma: Add link object")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agolibnetlink: fix leak and using unused memory on error
Stephen Hemminger [Thu, 13 Sep 2018 19:33:38 +0000 (12:33 -0700)]
libnetlink: fix leak and using unused memory on error

If an error happens in multi-segment message (tc only)
then report the error and stop processing further responses.
This also fixes refering to the buffer after free.

The sequence check is not necessary here because the
response message has already been validated to be in
the window of the sequence number of the iov.

Reported-by: Mahesh Bandewar <mahesh@bandewar.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Mahesh Bandewar <maheshb@google.com>
5 years agoq_cake: Also print nonat, nowash and no-ack-filter keywords
Toke Høiland-Jørgensen [Fri, 14 Sep 2018 13:51:39 +0000 (15:51 +0200)]
q_cake: Also print nonat, nowash and no-ack-filter keywords

Similar to the previous patch for no-split-gso, the negative keywords for
'nat', 'wash' and 'ack-filter' were not printed either. Add those well.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agobridge/mdb: fix missing new line when show bridge mdb
Hangbin Liu [Wed, 12 Sep 2018 01:39:44 +0000 (09:39 +0800)]
bridge/mdb: fix missing new line when show bridge mdb

The bridge mdb show is broken on current iproute2. e.g.
]# bridge mdb show
34: br0  veth0_br  224.1.1.2  temp 34: br0  veth0_br  224.1.1.1  temp

After fix:
]# bridge mdb show
34: br0  veth0_br  224.1.1.2  temp
34: br0  veth0_br  224.1.1.1  temp

v2: Use json print lib as Stephen suggested.
v3: No need to use is_json_context() as print_string() could handle both cases.
v4: use new function print_nl() to print new line in non-json mode.

Reported-by: Ying Xu <yinxu@redhat.com>
Fixes: c7c1a1ef51aea ("bridge: colorize output and use JSON print library")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoq_cake: Add printing of no-split-gso option
Toke Høiland-Jørgensen [Tue, 11 Sep 2018 22:32:16 +0000 (00:32 +0200)]
q_cake: Add printing of no-split-gso option

When the GSO splitting was turned into dual split-gso/no-split-gso options,
the printing of the latter was left out. Add that, so output is consistent
with the options passed.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agolib: introduce print_nl
Stephen Hemminger [Tue, 11 Sep 2018 15:29:33 +0000 (08:29 -0700)]
lib: introduce print_nl

Common pattern in iproute commands is to print a line seperator
in non-json mode. Make that a simple function.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoip-route: Fix segfault with many nexthops
Phil Sutter [Thu, 6 Sep 2018 13:31:51 +0000 (15:31 +0200)]
ip-route: Fix segfault with many nexthops

It was possible to crash ip-route by adding an IPv6 route with 37
nexthop statements. A simple reproducer is:

| for i in `seq 37`; do
|  nhs="nexthop via 1111::$i "$nhs
| done
| ip -6 route add 3333::/64 $nhs

The related code was broken in multiple ways:

* parse_one_nh() assumed that rta points to 4kB of storage but caller
  provided just 1kB. Fixed by passing 'len' parameter with the correct
  value.

* Error checking of rta_addattr*() calls in parse_one_nh() and called
  functions was completely absent, so with above fix in place output
  flood would occur due to parser looping forever.

While being at it, increase message buffer sizes to 4k. This allows for
at most 144 nexthops.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotc/mqprio: Print extra info on invalid args.
Caleb Raitto [Thu, 6 Sep 2018 21:01:17 +0000 (14:01 -0700)]
tc/mqprio: Print extra info on invalid args.

Print the name of the argument that wasn't understood.

Signed-off-by: Caleb Raitto <caraitto@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agogenl: remove unnecessary extern
Stephen Hemminger [Mon, 10 Sep 2018 18:53:07 +0000 (11:53 -0700)]
genl: remove unnecessary extern

extern not necessary on function prototype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agotc/fifo: remove unnecessary prototype
Stephen Hemminger [Mon, 10 Sep 2018 18:50:22 +0000 (11:50 -0700)]
tc/fifo: remove unnecessary prototype

The prototype for prio_print_opt is already in tc_util.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agobridge: fix vlan show formatting
Stephen Hemminger [Thu, 6 Sep 2018 13:42:46 +0000 (14:42 +0100)]
bridge: fix vlan show formatting

The output of vlan show was broken previous change to use json_print.
Clean the code up and return to original format.

Note: the JSON syntax has changed to make the bridge vlan
show more like other outputs (e.g. ip -j li show).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agobridge: use print_json for some outputs
Stephen Hemminger [Thu, 6 Sep 2018 13:15:36 +0000 (14:15 +0100)]
bridge: use print_json for some outputs

Rather than using is_json_context(), use the print_string functions
which handle both cases.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agobridge: minor change to mdb print
Stephen Hemminger [Thu, 6 Sep 2018 13:14:46 +0000 (14:14 +0100)]
bridge: minor change to mdb print

Get port ifname once rather than on both sides of if(is_json_context).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoman: Change numtc to num_tc
Caleb Raitto [Wed, 5 Sep 2018 20:23:33 +0000 (13:23 -0700)]
man: Change numtc to num_tc

The argument parser only accepts num_tc:

https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/tc/q_mqprio.c#n55

Signed-off-by: Caleb Raitto <caraitto@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agouapi: update ib_verbs
Stephen Hemminger [Fri, 31 Aug 2018 22:03:49 +0000 (15:03 -0700)]
uapi: update ib_verbs

Merge current uapi from 4.19-rc1

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoMerge branch 'netem-slot-param' into iproute2-next
David Ahern [Thu, 30 Aug 2018 18:08:43 +0000 (11:08 -0700)]
Merge branch 'netem-slot-param' into iproute2-next

Yousuk Seung  says:

====================

This series adds support for the new "slot" netem parameter for
slotting. Slotting is an approximation of shared media that gather up
packets within a varying delay window before delivering them nearly at
once.

====================

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoq_netem: slotting with non-uniform distribution
Yousuk Seung [Mon, 27 Aug 2018 02:42:30 +0000 (19:42 -0700)]
q_netem: slotting with non-uniform distribution

Extend slotting with support for non-uniform distributions. This is
similar to netem's non-uniform distribution delay feature.

Syntax:
   slot distribution DISTRIBUTION DELAY JITTER [packets MAX_PACKETS] \
      [bytes MAX_BYTES]

The syntax and use of the distribution table is the same as in the
non-uniform distribution delay feature. A file DISTRIBUTION must be
present in TC_LIB_DIR (e.g. /usr/lib/tc) containing numbers scaled by
NETEM_DIST_SCALE. A random value x is selected from the table and it
takes DELAY + ( x * JITTER ) as delay. Correlation between values is not
supported.

Examples:
  Normal distribution delay with mean = 800us and stdev = 100us.
  > tc qdisc add dev eth0 root netem slot distribution normal \
    800us 100us

  Optionally set the max slot size in bytes and/or packets.
  > tc qdisc add dev eth0 root netem slot distribution normal \
    800us 100us bytes 64k packets 42

Signed-off-by: Yousuk Seung <ysseung@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoq_netem: support delivering packets in delayed time slots
Dave Taht [Mon, 27 Aug 2018 02:42:29 +0000 (19:42 -0700)]
q_netem: support delivering packets in delayed time slots

Slotting is a crude approximation of the behaviors of shared media such
as cable, wifi, and LTE, which gather up a bunch of packets within a
varying delay window and deliver them, relative to that, nearly all at
once.

It works within the existing loss, duplication, jitter and delay
parameters of netem. Some amount of inherent latency must be specified,
regardless.

The new "slot" parameter specifies a minimum and maximum delay between
transmission attempts.

The "bytes" and "packets" parameters can be used to limit the amount of
information transferred per slot.

Examples of use:

tc qdisc add dev eth0 root netem delay 200us \
        slot 800us 10ms bytes 64k packets 42

A more correct example, using stacked netem instances and a packet limit
to emulate a tail drop wifi queue with slots and variable packet
delivery, with a 200Mbit isochronous underlying rate, and 20ms path
delay:

tc qdisc add dev eth0 root handle 1: netem delay 20ms rate 200mbit \
         limit 10000
tc qdisc add dev eth0 parent 1:1 handle 10:1 netem delay 200us \
         slot 800us 10ms bytes 64k packets 42 limit 512

Signed-off-by: Yousuk Seung <ysseung@google.com>
Signed-off-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agotc: support conversions to or from 64 bit nanosecond-based time
Dave Taht [Mon, 27 Aug 2018 02:42:28 +0000 (19:42 -0700)]
tc: support conversions to or from 64 bit nanosecond-based time

Using a 32 bit field to represent time in nanoseconds results in a
maximum value of about 4.3 seconds, which is well below many observed
delays in WiFi and LTE, and barely in the ballpark for a trip past the
Earth's moon, Luna.

Using 64 bit time fields in nanoseconds allows us to simulate
network diameters of several hundred light-years. However, only
conversions to and from ns, us, ms, and seconds are provided.

The iproute2 64 bit api uses signed values for time. Being able to
represent positive or negative time allows us to calculate +/- deltas
between, for example, the CLOCK_TAI and CLOCK_REALTIME clocks.

Time related utility functions in tc_util.c are moved to lib/utils.c.

Signed-off-by: Yousuk Seung <ysseung@google.com>
Signed-off-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agoMerge branch 'iproute2-master' into iproute2-next
David Ahern [Thu, 30 Aug 2018 18:04:05 +0000 (11:04 -0700)]
Merge branch 'iproute2-master' into iproute2-next

Signed-off-by: David Ahern <dsahern@gmail.com>
5 years agotc/htb: remove unused variable
Florent Fourcot [Thu, 30 Aug 2018 14:38:54 +0000 (16:38 +0200)]
tc/htb: remove unused variable

Since introduction of htb module, this variable has never been used.

Signed-off-by: Florent Fourcot <florent.fourcot@wifirst.fr>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 years agoiproute: make clang happy
Mahesh Bandewar [Thu, 23 Aug 2018 01:01:37 +0000 (18:01 -0700)]
iproute: make clang happy

These are primarily fixes for "string is not string literal" warnings
/ errors (with -Werror -Wformat-nonliteral). This should be a no-op
change. I had to replace couple of print helper functions with the
code they call as it was becoming harder to eliminate these warnings,
however these helpers were used only at couple of places, so no
major change as such.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>