Commit Graph

1020 Commits

Author SHA1 Message Date
Phil Sutter
515a766cd2 lib: Make check_enable_color() return boolean
As suggested, turn return code into true/false although it's not checked
anywhere yet.

Fixes: 4d82962ccc ("Merge common code for conditionally colored output")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-08-20 08:55:16 -07:00
Phil Sutter
ff1ab8edf8 Make colored output configurable
Allow for -color={never,auto,always} to have colored output disabled,
enabled only if stdout is a terminal or enabled regardless of stdout
state.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-08-20 08:54:06 -07:00
David Ahern
ea9f9b910e Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-08-15 09:56:30 -07:00
Phil Sutter
4d82962ccc Merge common code for conditionally colored output
Instead of calling enable_color() conditionally with identical check in
three places, introduce check_enable_color() which does it in one place.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-08-15 09:55:27 -07:00
Stephen Hemminger
31ad498a01 v4.18.0 2018-08-13 12:11:32 -07:00
David Ahern
74eb09ad56 Update kernel headers
Update kernel headers to commit
78cbac647e61 (Merge branch 'ip-faster-in-order-IP-fragments'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-08-12 14:23:31 -07:00
David Ahern
8b099da560 Update kernel headers
Update kernel headers to commit
aea5f654e6b7 ("net/sched: add skbprio scheduler")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-07-25 09:58:00 -07:00
Stephen Hemminger
7c16a8da6b uapi: fix tcp.h repair
Upstream define for TCP_REPAIR changed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-07-23 13:47:22 -07:00
David Ahern
204db84eb8 Update kernel headers
Update kernel headers to
a3eed83a1895 ("Merge branch 'qed-Add-support-for-phy-module-query'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-07-20 08:57:23 -07:00
Daniel Borkmann
f823f36012 bpf: implement btf handling and map annotation
Implement loading of .BTF section from object file and build up
internal table for retrieving key/value id related to maps in
the BPF program. Latter is done by setting up struct btf_type
table.

One of the issues is that there's a disconnect between the data
types used in the map and struct bpf_elf_map, meaning the underlying
types are unknown from the map description. One way to overcome
this is to add a annotation such that the loader will recognize
the relation to both. BPF_ANNOTATE_KV_PAIR(map_foo, struct key,
struct val); has been added to the API that programs can use.

The loader will then pick the corresponding key/value type ids and
attach it to the maps for creation. This can later on be dumped via
bpftool for introspection.

Example with test_xdp_noinline.o from kernel selftests:

  [...]

  struct ctl_value {
        union {
                __u64 value;
                __u32 ifindex;
                __u8 mac[6];
        };
  };

  struct bpf_map_def __attribute__ ((section("maps"), used)) ctl_array = {
        .type		= BPF_MAP_TYPE_ARRAY,
        .key_size	= sizeof(__u32),
        .value_size	= sizeof(struct ctl_value),
        .max_entries	= 16,
        .map_flags	= 0,
  };
  BPF_ANNOTATE_KV_PAIR(ctl_array, __u32, struct ctl_value);

  [...]

Above could also further be wrapped in a macro. Compiling through LLVM and
converting to BTF:

  # llc --version
  LLVM (http://llvm.org/):
    LLVM version 7.0.0svn
    Optimized build.
    Default target: x86_64-unknown-linux-gnu
    Host CPU: skylake

    Registered Targets:
      bpf    - BPF (host endian)
      bpfeb  - BPF (big endian)
      bpfel  - BPF (little endian)
  [...]

  # clang [...] -O2 -target bpf -g -emit-llvm -c test_xdp_noinline.c -o - |
    llc -march=bpf -mcpu=probe -mattr=dwarfris -filetype=obj -o test_xdp_noinline.o
  # pahole -J test_xdp_noinline.o

Checking pahole dump of BPF object file:

  # file test_xdp_noinline.o
  test_xdp_noinline.o: ELF 64-bit LSB relocatable, *unknown arch 0xf7* version 1 (SYSV), with debug_info, not stripped
  # pahole test_xdp_noinline.o
  [...]
  struct ctl_value {
	union {
		__u64              value;                /*     0     8 */
		__u32              ifindex;              /*     0     4 */
		__u8               mac[0];               /*     0     0 */
	};                                               /*     0     8 */

	/* size: 8, cachelines: 1, members: 1 */
	/* last cacheline: 8 bytes */
  };

Now loading into kernel and dumping the map via bpftool:

  # ip -force link set dev lo xdp obj test_xdp_noinline.o sec xdp-test
  # ip a
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 xdpgeneric/id:227 qdisc noqueue state UNKNOWN group default qlen 1000
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      inet 127.0.0.1/8 scope host lo
         valid_lft forever preferred_lft forever
      inet6 ::1/128 scope host
         valid_lft forever preferred_lft forever
  [...]
  # bpftool prog show id 227
  227: xdp  tag a85e060c275c5616  gpl
      loaded_at 2018-07-17T14:41:29+0000  uid 0
      xlated 8152B  not jited  memlock 12288B  map_ids 381,385,386,382,384,383
  # bpftool map dump id 386
   [{
        "key": 0,
        "value": {
            "": {
                "value": 0,
                "ifindex": 0,
                "mac": []
            }
        }
    },{
        "key": 1,
        "value": {
            "": {
                "value": 0,
                "ifindex": 0,
                "mac": []
            }
        }
    },{
  [...]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-07-17 19:38:44 -07:00
David Ahern
5081979176 Import btf.h from kernel headers
Import btf.h from kernel headers at commit
    2aa4a3378ad0 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next")
which is the last sync point.

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-07-17 19:37:50 -07:00
David Ahern
3eebc1d4f4 Update kernel headers
Update kernel headers to commit
2aa4a3378ad0 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-07-15 13:02:51 -07:00
Stephen Hemminger
dc3ef235f3 uapi: update bpf.h
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-07-07 09:56:27 -07:00
David Ahern
22ddbd8204 Update kernel headers
Update kernel headers to commit
ab8565af68001 ("Merge branch 'IP-listification-follow-ups'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-07-06 08:42:22 -07:00
Stephen Hemminger
776f1813b5 uapi: update headers from linux-net
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-06-08 10:27:13 -07:00
Stephen Hemminger
17678d3059 Merge ../iproute2-next 2018-06-08 10:27:04 -07:00
Stephen Hemminger
2d3dd6f6c1 v4.17.0 2018-06-08 10:11:50 -07:00
Stephen Hemminger
4be85d574e uapi: update bpf.h to include padding
Last minute upstream 4.17 change.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-06-08 10:09:21 -07:00
David Ahern
45c0dd7286 Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-06-01 08:17:23 -07:00
David Ahern
57ac202c78 Update kernel headers
Update kernel headers to commit
ae40832e53c3 ("bpfilter: fix a build err")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-05-30 08:06:19 -07:00
Pavel Maltsev
e2f5ceccda Allow to configure /var/run/netns directory
Currently NETNS_RUN_DIR is hardcoded and refers to /var/run/netns.
However, some systems (e.g. Android) doesn't have /var
which results in error attempts to create network namespaces on these
systems.  This change makes NETNS_RUN_DIR configurable at build time
by allowing to pass environment variable to make command.
Also, this change makes /etc/netns directory configurable through
NETNS_ETC_DIR environment variable.

For example: ./configure && NETNS_RUN_DIR=/mnt/vendor/netns make

Tested: verified that iproute2 with configuration mentioned above
creates namespaces in /mnt/vendor/netns

Signed-off-by: Pavel Maltsev <pavelm@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-05-23 15:16:53 -07:00
David Ahern
c2a569e63c Update kernel headers
Update kernel headers to commit
e89e59c08d1b ("Merge branch 'net-sfp-small-improvements'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-05-23 12:58:34 -07:00
David Ahern
4276e65290 Update kernel headers
Update kernel headers to commit
64a2658b58ab ("net: mscc: Add SPDX identifier")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-05-18 09:05:07 -07:00
David Ahern
fd95ec0e8e Update kernel headers
Update kernel headers to commit 53a7bdfb2a27
("dt-bindings: dsa: Remove unnecessary #address/#size-cells")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-05-09 20:52:52 -07:00
David Ahern
7732148d1d Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-05-05 11:07:47 -07:00
Toke Høiland-Jørgensen
4db2ff0db4 json_print: Fix hidden 64-bit type promotion
print_uint() will silently promote its variable type to uint64_t, but there
is nothing that ensures that the format string specifier passed along with
it fits (and the function name suggest to pass "%u").

Fix this by changing print_uint() to use a native 'unsigned int' type, and
introduce a separate print_u64() function for printing 64-bit values. All
call sites that were actually printing 64-bit values using print_uint() are
converted to use print_u64() instead.

Since print_int() was already using native int types, just add a
print_s64() to match, but don't convert any call sites. For symmetry,
also add a print_luint() method (with no users).

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-04-25 11:08:55 -07:00
David Ahern
075bf62a70 Update kernel headers
Update kernel headers to commit 292eba02dbb4
("net-next/hinic: add arm64 support")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-04-19 11:10:27 -07:00
Stephen Hemminger
811ee8943c uapi/sctp: update header from 4.17-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-04-10 10:50:00 -07:00
Stephen Hemminger
b7d3a4f009 uapi/tipc: update header from 4.17-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-04-10 10:49:41 -07:00
Stephen Hemminger
dcf7997bcd uapi/bpf: update kernel header from 4.17-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-04-10 10:48:56 -07:00
David Ahern
2c62a64d60 Merge branch 'iproute2-master' into iproute2-next
Conflicts:
	bridge/mdb.c
	misc/ss.c
	tc/tc.c

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-04-02 10:47:34 -07:00
Stephen Hemminger
4b6c4177ee v4.16.0 2018-04-02 10:06:08 -07:00
Stephen Hemminger
200e9d1961 uapi/if_ether: add definition of ether type field
Part of upstream commit
4bbb3e0e8239 ("net: Fix vlan untag for bridge and vlan_dev with reorder_hdr off")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-04-02 09:19:08 -07:00
Steve Wise
8958a15c04 rdma: Add MR resource tracking information
Sample output:

Without CAP_NET_ADMIN:

$ rdma resource show mr mrlen 65536
dev mlx4_0 mrlen 65536 pid 0 comm [nvme_rdma]
dev cxgb4_0 mrlen 65536 pid 0 comm [nvme_rdma]

With CAP_NET_ADMIN:

# rdma resource show mr mrlen 65536
dev mlx4_0 rkey 0x12702 lkey 0x12702 iova 0x85724a000 mrlen 65536 pid 0 comm [nvme_rdma]
dev cxgb4_0 rkey 0x68fe4e9 lkey 0x68fe4e9 iova 0x835b91000 mrlen 65536 pid 0 comm [nvme_rdma]

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-04-01 08:18:56 -07:00
David Ahern
9effc146b7 Update kernel headers
Update kernel headers to commit 5d22d47b9ed9
("Merge branch 'sfc-filter-locking'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-03-28 20:26:25 -07:00
David Ahern
54eae5f76d Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-03-27 12:33:02 -07:00
Luca Boccassi
ba2fc55b99 Drop capabilities if not running ip exec vrf with libcap
ip vrf exec requires root or CAP_NET_ADMIN, CAP_SYS_ADMIN and
CAP_DAC_OVERRIDE. It is not possible to run unprivileged commands like
ping as non-root or non-cap-enabled due to this requirement.
To allow users and administrators to safely add the required
capabilities to the binary, drop all capabilities on start if not
invoked with "vrf exec".
Update the manpage with the requirements.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-03-27 11:48:23 -07:00
Leon Romanovsky
2c6962cfaf rdma: Move RDMA UAPI header file to be under RDMA responsibility
In iproute2 package, the updates of UAPIs files are performed
after the needed feature lands in kernel's net-next tree.

Such development flow created delays to the rdma tool developers,
who uses rdma-next tree as a basis for their work.

Move RDMA UAPI file to be under rdma/ folder, so whole responsibility
of syncing this file will be on them.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-03-26 07:02:19 -07:00
David Ahern
4de0a06b34 Update kernel headers
Update kernel headers to commit a870a02cc963
("pktgen: use dynamic allocation for debug print buffer")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-03-13 17:59:59 -07:00
David Ahern
e9625d6aea Merge branch 'iproute2-master' into iproute2-next
Conflicts:
	bridge/mdb.c

Updated bridge/bridge.c per removal of check_if_color_enabled by commit
1ca4341d2c ("color: disable color when json output is requested")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-03-13 17:48:10 -07:00
Serhey Popovych
fe99adbca4 utils: Introduce and use nodev() helper routine
There is a couple of places where we report error in case of no network
device is found. In all of them we output message in the same format to
stderr and either return -1 or 1 to the caller or exit with -1.

Introduce new helper function nodev() that takes name of the network
device caused error and returns -1 to it's caller. Either call exit()
or return to the caller to preserve behaviour before change.

Use -nodev() in traffic control (tc) code to return 1.

Simplify expression for checking for argument being 0/NULL in @if
statement.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
2018-03-11 17:58:36 -07:00
David Ahern
8c278ecad0 Update kernel headers to 4.16.0-rc4+
Update kernel headers to commit 08a24239cd46
("Merge branch 'hns3-next'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-03-08 09:34:05 -08:00
Stephen Hemminger
d9d8c8393e json_writer: add SPDX Identifier (GPL-2/BSD-2)
I wrote this code so put SPDX License on it and intentionally
allow use in BSD code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-03-06 14:39:19 -08:00
David Ahern
cb4ade6e38 Import tc_em_ipt.h from kernel at commit 08009a760213
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-27 09:42:23 -08:00
David Ahern
02ffee14ae Update kernel headers to 08009a760213
Update kernel headers to commit 08009a760213
("net: make kmem caches as __ro_after_init")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-26 13:24:38 -08:00
Arkadi Sharshevsky
8cd6440958 devlink: Add support for devlink resource abstraction
Add support for devlink resource abstraction. The resources are
represented by a tree based structure and are identified by a name and
a size. Some resources can present their real time occupancy.

First the resources exposed by the driver can be observed, for example:

$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
  name kvd size 245760 unit entry
    resources:
      name linear size 98304 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
      name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
      name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128

Some resource's size can be changed. Examples:

$devlink resource set pci/0000:03:00.0 path /kvd/hash_single size 73088
$devlink resource set pci/0000:03:00.0 path /kvd/hash_double size 74368

The changes do not apply immediately, this can be validate by the 'size_new'
attribute, which represents the pending changed size. For example

$devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
  name kvd size 245760 unit entry size_valid false
  resources:
    name linear size 98304 size_new 147456 occ 0 unit entry size_min 0 size_max 147456 size_gran 128
    name hash_double size 60416 unit entry size_min 32768 size_max 180224 size_gran 128
    name hash_single size 87040 unit entry size_min 65536 size_max 212992 size_gran 128

In case of a pending change the nested resources present an indication
for a valid configuration of its children (sum of its children sizes
doesn't exceed the parent's size).

In order for the changes to take place hot reload is needed. The hot
reload through devlink will be introduced in the following patch.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-23 08:36:05 -08:00
Arkadi Sharshevsky
049c58539f devlink: mnlg: Add support for extended ack
Add support for extended ack.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-23 08:36:05 -08:00
Vincent Bernat
1ca4341d2c color: disable color when json output is requested
Instead of declaring -color and -json exclusive, ignore -color when
-json is provided. The rationale is to allow to put -color in an alias
for ip while still being able to use -json. -color is merely a
presentation suggestion and we can assume there is nothing to color in
the JSON output.

Signed-off-by: Vincent Bernat <vincent@bernat.im>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-23 08:18:33 -08:00
Stephen Hemminger
4328b687b4 ip: always print interface name in color
Even in brief mode the interface name should be printed
in color if desired. This makes output consistent across
regular and brief mode.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-21 08:42:04 -08:00
Stephen Hemminger
a8beadb5f6 uapi: update if_ether compat headers
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-20 10:48:32 -08:00
David Ahern
07ed8df604 Update kernel headers to 4.16.0-rc2+
Update kernel headers to commit f5c0c6f4299f
("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-19 20:06:04 -08:00
Serhey Popovych
f5b50a18ae utils: Introduce and use print_name_and_link() to print name@link
There is at least three places implementing same things: two in
ipaddress.c print_linkinfo() & print_linkinfo_brief() and one in
bridge/link.c.

They are diverge from each other very little: bridge/link.c does not
support JSON output at the moment and print_linkinfo_brief() does not
handle IFLA_LINK_NETNS case.

Introduce and use print_name_and_link() routine to handle name@link
output in all possible variations; respect IFLA_LINK_NETNS attribute to
handle case when link is in different namespace; use ll_idx_n2a() for
interface name instead of "<nil>" to share logic with other code (e.g.
ll_name_to_index() and ll_index_to_name()) supporting such template.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-16 08:14:22 -08:00
Serhey Popovych
fcac966526 utils: Introduce and use get_ifname_rta()
Be consistent in handling of IFLA_IFNAME attribute in all places: if
there is no attribute report bug to stderr and use ll_idx_n2a() as
last measure to get name in "if%u" format instead of "<nil>".

Use check_ifname() to validate network device name: this catches both
unexpected return from kernel and ll_idx_n2a().

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-16 08:14:20 -08:00
Serhey Popovych
fe269b6e7c utils: Reimplement ll_idx_n2a() and introduce ll_idx_a2n()
Now all users of ll_idx_n2a() replaced with ll_index_to_name() we can
move it's functionality to ll_index_to_name() and implement index to
name conversion using snprintf() and "if%u".

Use %u specifier in "if%..." template consistently: network device
indexes are always greather than zero.

Also introduce ll_idx_n2a() conterpart: ll_idx_a2n() that is used
to translate name of the "if%u" form to index using sscanf().

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-16 08:14:13 -08:00
Serhey Popovych
5433656705 ip: Use single variable to represent -pretty
After commit a233caa0aa ("json: make pretty printing optional") I get
following build failure:

    LINK     rtmon
    ../lib/libutil.a(json_print.o): In function `new_json_obj':
    json_print.c:(.text+0x35): undefined reference to `show_pretty'
    collect2: error: ld returned 1 exit status
    make[1]: *** [rtmon] Error 1
    make: *** [all] Error 2

It is caused by missing show_pretty variable in rtmon.

On the other hand tc/tc.c there are two distinct variables and single
matches() call that handles -pretty option thus setting show_pretty
will never happen. Note that since commit 44dcfe8201 ("Change
formatting of u32 back to default") show_pretty is used in tc/f_u32.c
so this is first place where -pretty introduced.

Furthermore other utilities like misc/ifstat.c and misc/nstat.c define
pretty variable, however only for their own purposes. They both support
JSON output and thus depend show_pretty in new_json_obj().

Assuming above use common variable to represent -pretty option, define
it in utils.c and declare in utils.h that is commonly used. Replace
show_pretty with pretty.

Fixes: a233caa0aa ("json: make pretty printing optional")
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-16 08:13:36 -08:00
Serhey Popovych
9cc173d485 utils: Introduce and use inet_prefix_reset()
Initializing @inet_prefix using C initializers or memset() seems
inefficient and unnecessary: only small part of ->data[] field will be
used to store address corresponding to ->family.

Instead initialize ->flags with zero and assume no other fields accessed
before checking corresponding bits in ->flags. For example special
helpers (e.g. is_addrtype_*()) can be used to ensure that @inet_prefix
contains valid ip or ipv6 address.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-14 09:00:26 -08:00
Stephen Hemminger
766fa4ac33 include: update rdma header from 4.16-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-13 16:42:00 -08:00
Stephen Hemminger
663c3cb231 iproute: implement JSON and color output
Add JSON and color output formatting to ip route command.
Similar to existing address and link output.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-10 08:20:39 -08:00
Stephen Hemminger
a233caa0aa json: make pretty printing optional
Since JSON is intended for programmatic consumption, it makes
sense for the default output format to be concise as possible.

For programmer and other uses, it is helpful to keep the pretty
whitespace format; therefore enable it with -p flag.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-10 08:15:08 -08:00
Serhey Popovych
9a7bd5442b ip: Introduce get_rtnl_link_stats_rta() to get link statistics
Assume all statistics in ip(8) represented either by IFLA_STATS64 or
IFLA_STATS is 64 bit. It is clean that we can store __u32 counters of
@struct rtnl_link_stats in __u64 counters in @struct rtnl_link_stats64.

New get_rtnl_link_stats_rta() follows __print_link_stats() behaviour on
handling of stats attribute: copy no more than size of data structure
and no less than attribute length zeroing rest.

Drop print_link_stats32() as it's functionality can be handled by 64bit
variant. Move code from __print_link_stats() to print_link_stats64() and
finally rename print_link_stats64() to __print_link_stats().

More users of introduced function will come in future.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-07 16:15:28 -08:00
Stephen Hemminger
c30c7b6e35 include: update UAPI types.h
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-05 17:21:27 -08:00
Stephen Hemminger
25226777b8 include: update interface UAPI from 4.15-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-05 17:21:01 -08:00
Stephen Hemminger
a0fc63ed68 include: update rdma uapi from 4.15-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-05 17:20:14 -08:00
Stephen Hemminger
d707207f4d include: update netfilter headers from 4.15-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-05 17:19:32 -08:00
Stephen Hemminger
d857a7fd4b include: update uapi with BPF from 4.15-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-02-05 17:18:53 -08:00
Serhey Popovych
f7af0dc580 ip: Consolidate ip, xdp and lwtunnel parse/dump prototypes in ip_common.h
Having iplink_parse() and @struct iplink_req in include/utils.h does not
reflect it's IP nature: move to ip/ip_common.h.

Move contents of ip/iplink_xdp.h and ip/iproute_lwtunnel.h to
ip/ip_common.h since they are small (i.e. only two function prototypes):
ip/iplink_bridge.c and ip/iplink_vrf.c prototypes already there.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-02 14:55:12 -08:00
David Ahern
1e24e773f1 Merge branch 'iproute2-master' into iproute2-next
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-01-29 08:24:57 -08:00
Stephen Hemminger
50b8a842e8 v4.15.0 2018-01-29 08:08:52 -08:00
Jakub Kicinski
097415d510 tc: red: JSON-ify RED output
Make JSON output work with RED Qdiscs.  Float/double printing
helpers have to be added/uncommented to print the probability.
Since TC stats in general are not split out to a separate object
the xstats printed by this patch are not separated either.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-01-26 12:59:55 -08:00
Serhey Popovych
27c523e209 utils: Introduce get_addr_rta() and inet_addr_match_rta()
First is used to get address from netlink attribute to
inet_prefix data structure. Use memcpy() with constant
value to let complier optimize by replacing a call by
inlining load/store instructions.

Second is used to match address in given netlink attribute
with one given as reference. It matches successfully if
no attribute is given (@rta is NULL), reference address
family is AF_UNSPEC or it's length isn't given; fails if
get_attr_rta() can't get attribute or it's family does
not match reference; calls inet_addr_match() to get final
verdict.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-01-25 09:31:16 -08:00
Serhey Popovych
6caad8f505 ip: Get rid of inet_get_addr()
Both geneve and vxlan modules are converted to
use get_addr() we can replace inet_get_addr()
in less problematic places and finally get
rid of inet_get_addr().

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-01-21 09:38:26 -08:00
Serhey Popovych
7bf5e876d0 utils: Fast inet address classification after get_addr()
It looks very useful to receive additional information
from get_addr_1() and get_addr() about address to simplify
caller and get rid of code duplications.

For now following information can be returned:

  1) address is unspecified (zero)
  2) address is multicast
  3) address is internet: family is either AF_INET or
     AF_INET6.

More information can be added in the future.

Introduce inline helpers to make code using this new
address classification interface more self explaining:

  bool is_addrtype_inet(inet_prefix *addr)
    true if @addr is inet address

  bool is_addrtype_inet_unspec(inet_prefix *addr)
    true if @addr is unspecified inet address

  bool is_addrtype_inet_multi(inet_prefix *addr)
    true if @addr is multicast inet address

  bool is_addrtype_inet_not_unspec(inet_prefix *addr)
    true if @addr is not unspecified inet address
    false if @addr is not inet or unspecified inet

  bool is_addrtype_inet_not_multi(inet_prefix *addr)
    true if @addr is not multicast inet address
    false if @addr is not inet or multicast inet

Last two are useful for case when we need inet address
that is not unspecified or multicast.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-01-21 09:38:21 -08:00
David Ahern
c0788a09d4 Update kernel headers to 4.15-rc8
Update kernel headers to commit 30c3e9d47035
("l2tp: remove switch block in l2tp_nl_cmd_session_create()")

Signed-off-by: David Ahern <dsahern@gmail.com>
2018-01-19 12:33:41 -08:00
Chris Mi
72a2ff3916 lib/libnetlink: Add a new function rtnl_talk_iov
rtnl_talk can only send a single message to kernel. Add a new function
rtnl_talk_iov that can send multiple messages to kernel.
rtnl_talk_iov takes struct iovec * and iovlen as arguments.

Signed-off-by: Chris Mi <chrism@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-01-14 09:03:33 -08:00
Stephen Hemminger
a366508913 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>
2018-01-09 08:08:03 -08:00
David Ahern
f82517f80d Update headers from 4.15-rc3
Update kernel headers to commit f39a5c01c3d2 ("Merge branch
'nfp-flower-add-Geneve-tunnel-support'")

Signed-off-by: David Ahern <dsahern@gmail.com>
2017-12-20 15:17:59 -08:00
Stephen Hemminger
2c6aaad949 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>
2017-12-16 10:00:43 -08:00
Stephen Hemminger
4b072e9b49 uapi: tun add eBPF based queue selection method
Upstream commit 96f84061620c6325a2ca9a9a05b410e6461d03c3
    tun: add eBPF based queue selection method

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-12-11 16:03:27 -08:00
Stephen Hemminger
b7f5fd3698 uapi: add access to snd_cwnd and other sock_ops
From upstream kernel commit f19397a5c65665d66e3866b42056f1f58b7a366b
    bpf: Add access to snd_cwnd and others in sock_ops

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-12-11 16:01:17 -08:00
Stephen Hemminger
39be47fb5e update headers from 4.15-rc2
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-12-05 17:30:29 -08:00
Jakub Kicinski
65fdae3d18 bpf: allow loading programs for a specific ifindex
For BPF offload we need to specify the ifindex when program is
loaded now.  Extend the bpf common code to accommodate that.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-26 11:57:57 -08:00
Jakub Kicinski
4a847fcb51 bpf: expose bpf_parse_common() and bpf_load_common()
Expose bpf_parse_common() and bpf_load_common() functions
for those users who may want to modify the parameters to
load after parsing is done.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-26 11:57:57 -08:00
Jakub Kicinski
399db8392b bpf: rename bpf_parse_common() to bpf_parse_and_load_common()
bpf_parse_common() parses and loads the program.  Rename it
accordingly.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-26 11:57:57 -08:00
Jakub Kicinski
3f0b9e620c bpf: split parse from program loading
Parsing command line is currently done together with potentially
loading a new eBPF program.  This makes it more difficult to
provide additional parameters for loading (which may come after
the eBPF program info on the command line).

Split the two (only internally for now).  Verbose parameter
has to be saved in struct bpf_cfg_in to be carried between
the stages.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-26 11:57:57 -08:00
Jakub Kicinski
51be754690 bpf: allocate opcode table in struct bpf_cfg_in
struct bpf_cfg_in already carries a pointer to sock_filter ops.
It's currently set to a local variable in bpf_parse_opt_tbl(),
shared between parsing and loading stages.  Move the array
entirely to struct bpf_cfg_in, this will allow us to split
parsing and loading.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-26 11:57:57 -08:00
Jakub Kicinski
f20ff2f195 bpf: keep parsed program mode in struct bpf_cfg_in
bpf_parse() will parse command line arguments to find out the
program mode.  This mode will later be needed at loading time.
Instead of keeping it locally add it to struct bpf_cfg_in,
this will allow splitting parsing and loading stages.

enum bpf_mode has to be moved to the header file, because C
doesn't allow forward declaration of enums.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-26 11:57:57 -08:00
Jakub Kicinski
658cfebc27 bpf: pass program type in struct bpf_cfg_in
Program type is needed both for parsing and loading of
the program.  Parsing may also induce the type based on
signatures from __bpf_prog_meta.  Instead of passing
the type around keep it in struct bpf_cfg_in.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-26 11:57:57 -08:00
Stephen Hemminger
6054c1ebf7 SPDX license identifiers
For all files in iproute2 which do not have an obvious license
identification, mark them with SPDK GPL-2

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-24 12:21:35 -08:00
Nishanth Devarajan
927e3cfb52 tc: B.W limits can now be specified in %.
This patch adapts the tc command line interface to allow bandwidth limits
to be specified as a percentage of the interface's capacity.

Adding this functionality requires passing the specified device string to
each class/qdisc which changes the prototype for a couple of functions: the
.parse_qopt and .parse_copt interfaces. The device string is a required
parameter for tc-qdisc and tc-class, and when not specified, the kernel
returns ENODEV. In this patch, if the user tries to specify a bandwidth
percentage without naming the device, we return an error from userspace.

Signed-off-by: Nishanth Devarajan<ndev2021@gmail.com>
2017-11-24 11:22:13 -08:00
Stephen Hemminger
7b8c436c30 update headers from 4.15-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-24 09:07:42 -08:00
Lorenzo Colitti
05b3b344b2 iproute2: fixes to compile on some systems.
1. Put the declarations of strlcpy and strlcat inside
   an #ifdef NEED_STRLCPY. Their declarations were already in a
   similar #ifdef.
2. In bpf_scm.h, include sys/un.h for struct sockaddr_un.
3. In utils.h, include time.h for struct timeval.

Tested: builds on ubuntu 14.04 with "make clean distclean; ./configure && make -j64"
Tested: 4.14.1 builds on Android with Android-specific #ifndefs for missing library code
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
2017-11-20 10:38:58 -08:00
Stephen Hemminger
a60742aaf4 Merge branch 'master' into net-next 2017-11-13 10:35:17 -08:00
Stephen Hemminger
212b52299e v4.14.1 2017-11-13 10:09:57 -08:00
Stephen Hemminger
9edf7016e8 Merge branch 'master' into net-next 2017-11-12 16:30:14 -08:00
Stephen Hemminger
7d14d00795 v4.14.0 2017-11-12 16:29:43 -08:00
Stephen Hemminger
cd458a7764 update kernel headers from 4.14 net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-12 15:58:11 -08:00
Stephen Hemminger
840d95d348 update kernel headers
To 4.14 final kernel version
Note: SPDX tag added by upstream

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-12 15:55:49 -08:00
Stephen Hemminger
ba914908eb Update kernel headers with new SPDK identifier
The kernel header sanitizisation process now puts SPDK GPLv2
license comment on files.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-07 11:02:41 +09:00
Stephen Hemminger
665ef5a5c0 Update kernel headers from 4.14-rc8 nete-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-07 11:02:08 +09:00
Stephen Hemminger
fe388b9e0c update kernel headers from 4.14-rc7 net-next 2017-11-01 22:15:50 +01:00
Stephen Hemminger
0ac0017a1a Update kernel headers from net-next (4.14-rc6)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-31 18:04:13 +01:00
Stephen Hemminger
c1606c44b3 Merge branch 'master' into net-next 2017-10-31 18:03:12 +01:00
Stephen Hemminger
e348889289 Update kernel headers based on 4.14-rc7
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-31 18:01:51 +01:00
Stephen Hemminger
1d2cfcf8b5 update kernel headers
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-27 08:31:26 +02:00
Stephen Hemminger
7fde8cfddc include: add TCP fastopen option
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-27 08:30:48 +02:00
Stephen Hemminger
fa19d6bc01 bpf: update header file
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-27 08:28:36 +02:00
Hangbin Liu
86bf43c7c2 lib/libnetlink: update rtnl_talk to support malloc buff at run time
This is an update for 460c03f3f3 ("iplink: double the buffer size also in
iplink_get()"). After update, we will not need to double the buffer size
every time when VFs number increased.

With call like rtnl_talk(&rth, &req.n, NULL, 0), we can simply remove the
length parameter.

With call like rtnl_talk(&rth, nlh, nlh, sizeof(req), I add a new variable
answer to avoid overwrite data in nlh, because it may has more info after
nlh. also this will avoid nlh buffer not enough issue.

We need to free answer after using.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2017-10-26 12:29:29 +02:00
Stephen Hemminger
66e40a4a86 update headers for TC and TIPC from net-next 2017-10-25 12:40:47 +02:00
Stephen Hemminger
75209f840b Merge branch 'master' into net-next 2017-10-16 09:25:56 -07:00
Petr Vorel
4b73d52f8a color: Rename enum
COLOR_NONE is more descriptive than COLOR_CLEAR.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2017-10-16 09:24:11 -07:00
Petr Vorel
24b058a2a4 color: Fix another ip segfault when using --color switch
Commit 959f1428 ("color: add new COLOR_NONE and disable_color function")
introducing color enum COLOR_NONE, which is not only duplicite of
COLOR_CLEAR, but also caused segfault, when running ip with --color
switch, as 'attr + 8' in color_fprintf() access array item out of
bounds. Thus removing it and restoring "magic" offset + 7.

Reproduce with:
$ ip -c a

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2017-10-16 09:24:11 -07:00
Petr Vorel
e6849a5722 color: Fix ip segfault when using --color switch
Commit d0e72011 ("ip: ipaddress.c: add support for json output")
introduced passing -1 as enum color_attr. This is not only wrong as no
color_attr has value -1, but also causes another segfault in color_fprintf()
on this setup as there is no item with index -1 in array of enum attr_colors[].
Using COLOR_CLEAR is valid option.

Reproduce with:
$ COLORFGBG='0;15' ip -c a

NOTE: COLORFGBG is environmental variable used for defining whether user
has light or dark background.
COLORFGBG="0;15" is used to ask for color set suitable for light background,
COLORFGBG="15;0" is used to ask for color set suitable for dark background.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2017-10-16 09:24:11 -07:00
Stephen Hemminger
4999c57733 Merge branch 'master' into net-next 2017-10-11 11:07:20 -07:00
Ivan Delalande
7c72df5a95 utils: add print_escape_buf to format and print arbitrary bytes
Keep it as simple as possible for now: just escape anything that is not
isprint-able, is among the "escape" parameter or '\' as an octal escape
sequence. This should be pretty easy to extend if any other user needs
something more complex in the future.

Signed-off-by: Ivan Delalande <colona@arista.com>
2017-10-11 11:04:47 -07:00
Stephen Hemminger
e9b0d82dfa uapi: add include linux/vm_sockets_diag.h
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-11 10:49:25 -07:00
Stephen Hemminger
07682b88d8 Merge branch 'master' into net-next 2017-10-11 10:47:55 -07:00
Stephen Hemminger
237a52731b rdma: move headers to uapi
And update with version from upstream.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-11 10:47:28 -07:00
Stephen Hemminger
f53da99ad7 update uapi headers from 4.14-rc4 net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-11 10:43:38 -07:00
Stephen Hemminger
92503441cc Merge branch 'master' into net-next 2017-10-11 10:43:13 -07:00
Lorenzo Colitti
596b1c94aa iproute: build more easily on Android
iproute2 contains a bunch of kernel headers, including uapi ones.
Android's libc uses uapi headers almost directly, and uses a
script to fix kernel types that don't match what userspace
expects.

For example: https://issuetracker.google.com/36987220 reports
that our struct ip_mreq_source contains "__be32 imr_multiaddr"
rather than "struct in_addr imr_multiaddr". The script addresses
this by replacing the uapi struct definition with a #include
<bits/ip_mreq.h> which contains the traditional userspace
definition.

Unfortunately, when we compile iproute2, this definition
conflicts with the one in iproute2's linux/in.h.

Historically we've just solved this problem by running "git rm"
on all the iproute2 include/linux headers that break Android's
libc.  However, deleting the files in this way makes it harder to
keep up with upstream, because every upstream change to
an include file causes a merge conflict with the delete.

This patch fixes the problem by moving the iproute2 linux headers
from include/linux to include/uapi/linux.

Tested: compiles on ubuntu trusty (glibc)

Signed-off-by: Elliott Hughes <enh@google.com>
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
2017-10-11 10:35:45 -07:00
Stephen Hemminger
60509b997d Merge branch 'master' into net-next 2017-10-02 08:04:13 -07:00
Stephen Hemminger
1db903def7 update headers from net-next rc
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-02 08:03:45 -07:00
Phil Sutter
625df645b7 Check user supplied interface name lengths
The original problem was that something like:

| strncpy(ifr.ifr_name, *argv, IFNAMSIZ);

might leave ifr.ifr_name unterminated if length of *argv exceeds
IFNAMSIZ. In order to fix this, I thought about replacing all those
cases with (equivalent) calls to snprintf() or even introducing
strlcpy(). But as Ulrich Drepper correctly pointed out when rejecting
the latter from being added to glibc, truncating a string without
notifying the user is not to be considered good practice. So let's
excercise what he suggested and reject empty, overlong or otherwise
invalid interface names right from the start - this way calls to
strncpy() like shown above become safe and the user has a chance to
reconsider what he was trying to do.

Note that this doesn't add calls to check_ifname() to all places where
user supplied interface name is parsed. In many cases, the interface
must exist already and is therefore looked up using ll_name_to_index(),
so if_nametoindex() will perform the necessary checks already.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2017-10-02 08:01:21 -07:00
Julien Fortin
429f314ef7 lib: json_print: rework 'new_json_obj' drop FILE* argument
As Stephen Hemminger mentioned on the last submission the new_json_obj
function is always called with fp == stdout, so right now, there's no
need of this extra argument.

The background for the rework is the following:
The ip monitor didn't call `new_json_obj` (even for in non json context),
so the static FILE* _fp variable wasn't initialized, thus raising a
SIGSEGV in ipaddress.c. This patch should fix this issue for good, new
paths won't have to call `new_json_obj`.

How to reproduce:

$ ip -t mon label link
(gdb) bt
.#0  _IO_vfprintf_internal (s=s@entry=0x0, format=format@entry=0x45460d “%d: “, ap=ap@entry=0x7fffffff7f18) at vfprintf.c:1278
.#1  0x0000000000451310 in color_fprintf (fp=0x0, attr=<optimized out>, fmt=0x45460d “%d: “) at color.c:108
.#2  0x000000000044a856 in print_color_int (t=t@entry=PRINT_ANY, color=color@entry=4294967295, key=key@entry=0x4545fc “ifindex”,
    fmt=fmt@entry=0x45460d “%d: “, value=<optimized out>) at ip_print.c:132
.#3  0x000000000040ccd2 in print_int (value=<optimized out>, fmt=0x45460d “%d: “, key=0x4545fc “ifindex”, t=PRINT_ANY) at ip_common.h:189
.#4  print_linkinfo (who=<optimized out>, n=0x7fffffffa380, arg=0x7ffff77a82a0 <_IO_2_1_stdout_>) at ipaddress.c:1107
.#5  0x0000000000422e13 in accept_msg (who=0x7fffffff8320, ctrl=0x7fffffff8310, n=0x7fffffffa380, arg=0x7ffff77a82a0 <_IO_2_1_stdout_>) at ipmonitor.c:89
.#6  0x000000000044c58f in rtnl_listen (rtnl=0x672160 <rth>, handler=handler@entry=0x422c70 <accept_msg>, jarg=0x7ffff77a82a0 <_IO_2_1_stdout_>)
    at libnetlink.c:761
.#7  0x00000000004233db in do_ipmonitor (argc=<optimized out>, argv=0x7fffffffe5a0) at ipmonitor.c:310
.#8  0x0000000000408f74 in do_cmd (argv0=0x7fffffffe7f5 “mon”, argc=3, argv=0x7fffffffe588) at ip.c:116
.#9  0x0000000000408a94 in main (argc=4, argv=0x7fffffffe580) at ip.c:311

Fixes: 6377572f ("ip: ip_print: add new API to print JSON or regular format output")
Reported-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2017-09-29 10:10:47 -07:00
Daniel Borkmann
0b4b35e1e8 json: move json printer to common library
Move the json printer which is based on json writer into the
iproute2 library, so it can be used by library code and tools
other than ip. Should probably have been done from the beginning
like that given json writer is in the library already anyway.
No functional changes.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Julien Fortin <julien@cumulusnetworks.com>
2017-09-22 10:06:43 -07:00
Stephen Hemminger
44cf841560 BPF: update headers from 4.14-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-09-20 18:00:55 -07:00
Stephen Hemminger
01e5409371 Merge branch 'net-next' 2017-09-05 09:48:36 -07:00
Stephen Hemminger
39740278a8 v4.13.0 2017-09-05 09:39:32 -07:00
Stephen Hemminger
4a5b3035de update headers from 4.14 merge
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-09-05 09:38:31 -07:00
Stephen Hemminger
a17a01145f Merge branch 'master' into net-next 2017-09-05 09:33:29 -07:00
Daniel Borkmann
a0b5b7cf5c bpf: consolidate dumps to use bpf_dump_prog_info
Consolidate dump of prog info to use bpf_dump_prog_info() when possible.
Moving forward, we want to have a consistent output for BPF progs when
being dumped. E.g. in cls/act case we used to dump tag as a separate
netlink attribute before we had BPF_OBJ_GET_INFO_BY_FD bpf(2) command.

Move dumping tag into bpf_dump_prog_info() as well, and only dump the
netlink attribute for older kernels. Also, reuse bpf_dump_prog_info()
for XDP case, so we can dump tag and whether program was jited, which
we currently don't show.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2017-09-05 09:26:34 -07:00
Stephen Hemminger
2e706e12d9 Merge branch 'master' into net-next
Needed to add JSON support to tclass.
2017-09-01 12:17:48 -07:00
Phil Sutter
8d15e012a3 utils: Implement strlcpy() and strlcat()
By making use of strncpy(), both implementations are really simple so
there is no need to add libbsd as additional dependency.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2017-09-01 12:10:54 -07:00
Stephen Hemminger
8707fd8c93 update headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-30 08:26:43 -07:00
Stephen Hemminger
b43b5b9acc devlink: header update
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-24 15:31:57 -07:00
Stephen Hemminger
fb14560b76 add ERSPAN headers
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-23 10:05:08 -07:00
Stephen Hemminger
a4b8e88d87 Merge branch 'master' into net-next 2017-08-21 17:14:19 -07:00
Leon Romanovsky
74bd75c2b6 rdma: Add basic infrastructure for RDMA tool
RDMA devices are cross-functional devices from one side,
but very tailored for the specific markets from another.

Such diversity caused to spread of RDMA related configuration
across various tools, e.g. devlink, ip, ethtool, ib specific and
vendor specific solutions.

This patch adds ability to fill device and port information
by reading RDMA netlink.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
2017-08-21 17:07:44 -07:00
Leon Romanovsky
afdc119410 utils: Move BIT macro to common header
BIT() macro was implemented and used by devlink for now, but following
patches of rdmatool will reuse the same macro, so put it in common
header file.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
2017-08-21 17:07:44 -07:00
Stephen Hemminger
18d7817c60 update kernel headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-21 16:55:15 -07:00
Julien Fortin
7252f16b2d json_writer: add new json handlers (null, float with format, lluint, hu)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2017-08-17 18:02:40 -07:00
Julien Fortin
5df6077259 ip: add new command line argument -json (mutually exclusive with -color)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2017-08-17 18:02:40 -07:00
Julien Fortin
959f142863 color: add new COLOR_NONE and disable_color function
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2017-08-17 18:02:40 -07:00
Stephen Hemminger
b7f7c1b817 include: add pfkeyv2.h drop ipv6.h
pfkeyv2.h is include by ipsec.
linux/ipv6.h is not included by any code in current tree.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-15 16:43:16 -07:00
Stephen Hemminger
e0495b84ab seg6: add include/linux/seg6_local.h
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-15 16:35:30 -07:00
Stephen Hemminger
3af3d358a3 more BPF headers update
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-10 16:42:35 -07:00
Stephen Hemminger
96421f92ef include: update headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-09 08:35:26 -07:00
Stephen Hemminger
566421c8f7 Merge branch 'master' into net-next 2017-08-04 09:54:44 -07:00
Stephen Hemminger
b6432e68ac iproute: Add support for extended ack to rtnl_talk
Add support for extended ack error reporting via libmnl.
Add a new function rtnl_talk_extack that takes a callback as an input
arg. If a netlink response contains extack attributes, the callback is
is invoked with the the err string, offset in the message and a pointer
to the message returned by the kernel.

If iproute2 is built without libmnl, it will still work but
extended error reports from kernel will not be available.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-04 09:54:00 -07:00
Stephen Hemminger
72e4ea5eb6 update headers from 4.13 net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-03 16:12:40 -07:00
Stephen Hemminger
cc21ebe843 update headers from 4.13-rc4
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-08-03 15:57:26 -07:00
Stephen Hemminger
c369dc803b Update headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-07-31 20:55:27 -07:00
Stephen Hemminger
edadd6b076 Merge branch 'master' into net-next 2017-07-18 17:31:09 -07:00
Daniel Borkmann
779525cd77 bpf: dump id/jited info for cls/act programs
Make use of TCA_BPF_ID/TCA_ACT_BPF_ID that we exposed and print the ID
of the programs loaded and use the new BPF_OBJ_GET_INFO_BY_FD command
for dumping further information about the program, currently whether
the attached program is jited.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2017-07-18 17:20:45 -07:00
Daniel Borkmann
612ff099a1 bpf: support loading map in map from obj
Add support for map in map in the loader and add a small example program.
The outer map uses inner_id to reference a bpf_elf_map with a given ID
as the inner type. Loading maps is done in three passes, i) all non-map
in map maps are loaded, ii) all map in map maps are loaded based on the
inner_id map spec of a non-map in map with corresponding id, and iii)
related inner maps are attached to the map in map with given inner_idx
key. Pinned objetcs are assumed to be managed externally, so they are
only retrieved from BPF fs.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2017-07-18 17:20:45 -07:00
Stephen Hemminger
517771e271 update headers to 4.13-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-07-18 17:16:56 -07:00
Stephen Hemminger
f0b9b79572 update kernel headers from net-next
Just as net-next merge window opens.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-07-17 18:32:03 -07:00
Stephen Hemminger
ef513fb04e Merge branch 'master' into net-next 2017-07-05 09:12:16 -07:00
Stephen Hemminger
cdb90ce406 v4.12.0 2017-07-05 09:07:31 -07:00
Stephen Hemminger
79e7918a2a Merge branch 'master' into net-next 2017-07-05 09:07:30 -07:00
Krister Johansen
f005b700cf iptunnel: add support for mpls/ip to sit tunnels
Original-Author: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
2017-07-05 09:04:59 -07:00
Stephen Hemminger
35a004dc8a update kernel headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-06-27 16:11:12 -07:00
Stephen Hemminger
39f3776b50 update headers to get TCA_TUNNEL_CSUM
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-06-16 09:06:47 -07:00
Stephen Hemminger
be8b93e3e2 Merge branch 'master' into net-next 2017-06-15 08:32:53 -07:00
Stephen Hemminger
a9ae195a21 xfrm: get #define's from linux includes
Use linux/ipsec.h and linux/in.h to get the definition of IP related
protocols.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-06-14 10:25:39 -07:00
Stephen Hemminger
b68581d43e more bpf header updates
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-06-14 09:52:44 -07:00
Arkadi Sharshevsky
8a38e44fad bridge: Distinguish between externally learned vs offloaded FDBs
Distinguish between externally learned vs offloaded FDBs. This is done
in order to indicate that FDBs added by software was successfully
offloaded.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2017-06-14 09:50:25 -07:00
Stephen Hemminger
410556ad99 update headers from net-next (bpf and tc)
More BPF and tc_action values.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-06-08 10:56:14 -07:00
Stephen Hemminger
d9bcafb4fe updated headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-06-05 12:31:52 -07:00
Stephen Hemminger
a5445c56e1 Merge branch 'master' into net-next 2017-06-05 12:31:19 -07:00
Oliver Hartkopp
efe459c76d ip: link add vxcan support
Since commit a8f820a380a2a06 ('can: add Virtual CAN Tunnel driver (vxcan)')
for Linux 4.12 a virtual CAN tunnel driver analogue to veth is available in
Linux.

This patch adds the ability to create vxcan device pairs.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-06-05 12:27:32 -07:00
Stephen Hemminger
309d5c2f83 Merge branch 'master' into net-next 2017-05-30 17:55:17 -07:00
David Ahern
4ad875944f ip address: Export ip_linkaddr_list
ipaddr_list_flush_or_save generates a list of nlmsg's for links and
optionally for addresses. Move the code into ip_linkaddr_list and
export it along with the supporting infrastructure.

API to use this function is:
        struct nlmsg_chain linfo = { NULL, NULL};
        struct nlmsg_chain ainfo = { NULL, NULL};

        ip_linkaddr_list(family, filter_req, &linfo, &ainfo);

        ... error checking and code looping over linfo/ainfo ...

        free_nlmsg_chain(&linfo);
        free_nlmsg_chain(&ainfo);

Signed-off-by: David Ahern <dsahern@gmail.com>
2017-05-30 17:54:03 -07:00
Stephen Hemminger
8612ca2f13 update headers to get IFLA_EVENT
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-05-30 10:14:01 -07:00
Stephen Hemminger
0071f3d058 update headers to get changes for TCA_FLOWER
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-05-26 17:12:41 -07:00
Stephen Hemminger
d4473c0257 update to current net-next headers 2017-05-26 17:11:02 -07:00
Stephen Hemminger
cda81a4ea5 include: remove no longer used iptables_common.h
Reported-by: Baruch Siach <baruch@tkos.co.il>

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-05-22 13:22:22 -07:00
Stephen Hemminger
a2325adf0f update headers from 4.12-rc2
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-05-22 11:06:29 -07:00
David Ahern
4af4471606 ip: add support for more MPLS labels
Kernel now supports up to 30 labels but not defined as part of the uapi.
iproute2 handles up to 8 labels but in a non-consistent way. Update ip
to handle more labels, but in a more programmatic way.

For the MPLS address family, the data field in inet_prefix is used for
labels.  Increase that field to 64 u32's -- 64 as nothing more than a
convenient power of 2 number.

Update mpls_pton to take the length of the address field, convert that
length to number of labels and add better error handling to the parsing
of the user supplied string.

Signed-off-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
2017-05-22 11:03:02 -07:00
Stephen Hemminger
76557951f5 update kernel headers during 4.12 merge window
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-05-05 09:48:54 -07:00
Stephen Hemminger
5bffc12ef4 Merge branch 'net-next' 2017-05-03 09:28:10 -07:00
Stephen Hemminger
cbc7929b21 v4.11.0 2017-05-01 09:32:25 -07:00
Stephen Hemminger
7ff1fce549 update headers to 4.11 net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-05-01 09:27:46 -07:00
Stephen Hemminger
0e3cdd9ce0 remove unused header file sysctl.h
Not referred to in current source tree.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-04-21 17:47:30 -07:00
Stephen Hemminger
5b0aa88737 update kernel headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-04-21 17:41:33 -07:00
Stephen Hemminger
85dd6ab510 add seg6.h kernel headers
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-04-16 10:21:34 -07:00
Stephen Hemminger
2c6a0636e2 Update kernel headers from 4.11 net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-04-16 10:19:32 -07:00
David Ahern
0da8250be8 ip vrf: Add command name next to pid
'ip vrf pids' is used to list processes bound to a vrf, but it only
shows the pid leaving a lot of work for the user. Add the command
name to the output. With this patch you get the more user friendly:

    $ ip vrf pids mgmt
     1121  ntpd
     1418  gdm-session-wor
     1488  gnome-session
     1491  dbus-launch
     1492  dbus-daemon
     1565  sshd
     ...

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2017-04-16 10:19:32 -07:00
David Ahern
f443565f8d ip vrf: Add command name next to pid
'ip vrf pids' is used to list processes bound to a vrf, but it only
shows the pid leaving a lot of work for the user. Add the command
name to the output. With this patch you get the more user friendly:

    $ ip vrf pids mgmt
     1121  ntpd
     1418  gdm-session-wor
     1488  gnome-session
     1491  dbus-launch
     1492  dbus-daemon
     1565  sshd
     ...

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2017-04-16 10:06:33 -07:00
David Ahern
3ad6d17638 netlink: Add flag to suppress print of nlmsg error
Allow callers of the dump API to handle nlmsg errors (e.g., an
unsupported feature). Setting RTNL_HANDLE_F_SUPPRESS_NLERR in the
rtnl_handle avoids unnecessary messages to the users in some case.
For example,

  RTNETLINK answers: Operation not supported

when probing for support of a new feature.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2017-04-14 16:00:15 -07:00
Stephen Hemminger
45f78b4dec update kernel headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-04-04 14:57:46 -07:00
Stephen Hemminger
b285ba9ea4 update headers from net-next (post 4.11-rc3)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-03-20 10:18:50 -07:00
Stephen Hemminger
10b9d499b6 Merge branch 'master' into net-next 2017-03-20 10:18:17 -07:00
Stephen Hemminger
cfca3b356a update headers from 4.11-rc3
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-03-20 10:17:01 -07:00
Stephen Hemminger
2099b98385 update headers from net-next
Get TCA_DUMP_INVISIBLE and SCTP changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-03-14 16:36:36 -07:00
Stephen Hemminger
8fded9ffad update kernel headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-03-13 08:32:13 -07:00
Stephen Hemminger
a4280cfa72 update headers from 4.11-rc2
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-03-13 08:30:55 -07:00
Petr Vorel
54eab4c79a color: use "light" colors for dark background
COLORFGBG environment variable is used to detect dark background.

Idea and a bit of code is borrowed from Vim, thanks.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-03-03 09:58:05 -08:00
Stephen Hemminger
3f34574d0f Update headers based on 4.11 merge window
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-02-23 08:58:11 -08:00
Stephen Hemminger
ae429903d7 update headers from net-next
updated sctp.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-02-20 08:53:50 -08:00
Stephen Hemminger
29926015ea Merge branch 'master' into net-next 2017-02-20 08:51:22 -08:00
Stephen Hemminger
f36ba8a4cd v4.10.0 2017-02-20 08:47:52 -08:00
Stephen Hemminger
835784525a update headers from 4.10-rc8
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-02-18 16:05:37 -08:00
Stephen Hemminger
cad5493448 update headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-02-17 15:30:50 -08:00
Stephen Hemminger
985091aa8c update headers from bridge tunnel metadata
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-02-07 11:52:49 -08:00
Yotam Gigi
0b1abd84fb tc: Add support for the sample tc action
The sample tc action allows sampling packets matching a classifier. It
peeks randomly packets, and samples them using the psample netlink
channel. The user can specify the psample group, which the packet will be
sampled to, the sampling rate and the packet truncation (to save
kernel-user traffic).

The sampled packets contain informative metadata, for example, the input
interface and the original packet length.

The action syntax:
tc filter add [...] \
	action sample rate <RATE> group <GROUP> [trunc <SIZE>]
	[...]

Where:
  RATE := The sampling rate which is the ratio of packets observed at the
	  data source to the samples generated
  GROUP := the psample module sampling group
  SIZE := optional truncation size

An example for a common usecase of the sample tc action: to sample ingress
traffic from interface eth1, one may use the commands:

tc qdisc add dev eth1 handle ffff: ingress

tc filter add dev eth1 parent ffff: \
       matchall action sample rate 12 group 4

Where the first command adds an ingress qdisc and the second starts
sampling randomly with an average of one sampled packet per 12 packets
on dev eth1 to psample group 4.

Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Yotam Gigi <yotamg@mellanox.com>
2017-02-06 14:24:52 -08:00
Stephen Hemminger
17c4c446bd tcp: header file update
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-02-06 14:08:07 -08:00
Stephen Hemminger
b479a7d75b update kernel headers from net-next 2017-01-29 20:31:31 -08:00
Stephen Hemminger
a044b36af3 update kernel headers from 4.10 net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-01-20 09:28:36 -08:00
Stephen Hemminger
9174b4cf3e Merge branch 'master' into net-next 2017-01-20 09:27:57 -08:00
Stephen Hemminger
6166cc35be update kernel headers (from 4.10-rc4)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-01-20 09:26:27 -08:00
Jamal Hadi Salim
1c570c50a3 utils: make hex2mem available to all users
hex2mem() api is useful for parsing hexstrings which are then packed in
a stream of chars.

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
2017-01-17 08:45:22 -08:00
Stephen Hemminger
facfc5c1c0 include: remove unused header
not used by any source here

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-01-13 14:11:12 -08:00
Stephen Hemminger
65047fa641 add more uapi header files
In order to ensure no backward/forward compatiablity problems,
make sure that all kernel headers used come from the local copy.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-01-12 17:54:39 -08:00
Stephen Hemminger
e2ade8cefb kernel headers update
For flower, etc.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-01-12 17:45:30 -08:00
Stephen Hemminger
e467a283b1 minor kernel header update
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-01-09 12:09:26 -08:00
Stephen Hemminger
176b6b7329 update kernel headers 2016-12-21 15:58:49 -08:00
David Ahern
463d9efaa2 libnetlink: Add variant of rtnl_talk that does not display RTNETLINK answers error
iplink_vrf has 2 functions used to validate a user given device name is
a VRF device and to return the table id. If the user string is not a
device name ip commands with a vrf keyword show a confusing error
message: "RTNETLINK answers: No such device".

Add a variant of rtnl_talk that does not display the "RTNETLINK answers"
message and update iplink_vrf to use it.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2016-12-13 10:20:16 -08:00
David Ahern
1dafceb1c9 Add filesystem APIs to lib
Add make_path to recursively call mkdir as needed to create a given
path with the given mode.

Add find_cgroup2_mount to lookup path where cgroup2 is mounted. If it
is not already mounted, cgroup2 is mounted under /var/run/cgroup2 for
use by iproute2.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2016-12-13 10:20:16 -08:00
David Ahern
08bd33d77f move cmd_exec to lib utils
Code move only; no functional change intended.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2016-12-13 10:20:16 -08:00
David Ahern
10e51a76a9 bpf: Add BPF_ macros
Based on version in kernel repo, samples/bpf/libbpf.h

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2016-12-13 10:20:15 -08:00
David Ahern
869d889eed bpf: export bpf_prog_load
Code move only; no functional change intended.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2016-12-13 10:20:15 -08:00
David Ahern
fc4ccce038 lib bpf: Add support for BPF_PROG_ATTACH and BPF_PROG_DETACH
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
2016-12-13 10:20:15 -08:00
Thomas Graf
b15f440e78 lwt: BPF support for LWT
Adds support to configure BPF programs as nexthop actions via the LWT
framework.

Example:
   ip route add 192.168.253.2/32 \
     encap bpf out obj lwt_len_hist_kern.o section len_hist \
     dev veth0

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-12-12 15:32:54 -08:00
Stephen Hemminger
ba2a2124ec update to net-next headers (pre 4.10 rc)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-12-12 15:26:55 -08:00
Stephen Hemminger
2a56c090e4 Merge branch 'master' into net-next 2016-12-12 15:24:40 -08:00
Stephen Hemminger
ae0969c893 v4.9.0 2016-12-12 15:07:42 -08:00
Stephen Hemminger
dc5622cb66 update to 4.9 release headers
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-12-12 15:06:18 -08:00
Daniel Borkmann
c7272ca720 bpf: add initial support for attaching xdp progs
Now that we made the BPF loader generic as a library, reuse it
for loading XDP programs as well. This basically adds a minimal
start of a facility for iproute2 to load XDP programs. There
currently only exists the xdp1_user.c sample code in the kernel
tree that sets up netlink directly and an iovisor/bcc front-end.

Since we have all the necessary infrastructure in place already
from tc side, we can just reuse its loader back-end and thus
facilitate migration and usability among the two for people
familiar with tc/bpf already. Sharing maps, performing tail calls,
etc works the same way as with tc. Naturally, once kernel
configuration API evolves, we will extend new features for XDP
here as well, resp. extend dumping of related netlink attributes.

Minimal example:

  clang -target bpf -O2 -Wall -c prog.c -o prog.o
  ip [-force] link set dev em1 xdp obj prog.o       # attaching
  ip [-d] link                                      # dumping
  ip link set dev em1 xdp off                       # detaching

For the dump, intention is that in the first line for each ip
link entry, we'll see "xdp" to indicate that this device has an
XDP program attached. Once we dump some more useful information
via netlink (digest, etc), idea is that 'ip -d link' will then
display additional relevant program information below the "link/
ether [...]" output line for such devices, for example.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
2016-12-09 12:44:12 -08:00
Stephen Hemminger
3dd0bb51d7 update kernel headers from net-next
Net-next now closed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-12-09 12:40:07 -08:00
Stephen Hemminger
e6fee79104 Merge branch 'master' into net-next 2016-12-09 12:38:51 -08:00
Stephen Hemminger
e49aef96bb update kernel headers 2016-12-09 12:38:35 -08:00
Stephen Hemminger
d646916993 Revert "devlink: Add option to set and show eswitch inline mode"
This reverts commit b9dcf9c282.

Intended for net-next
2016-12-09 12:37:19 -08:00
Stephen Hemminger
143a704bf8 update kernel headers from net-next
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-12-02 14:54:33 -08:00
Amir Vadai
d57639a475 tc/act_tunnel: Introduce ip tunnel action
This action could be used before redirecting packets to a shared tunnel
device, or when redirecting packets arriving from a such a device.

The 'unset' action is optional. It is used to explicitly unset the
metadata created by the tunnel device during decap. If not used, the
metadata will be released automatically by the kernel.
The 'set' operation, will set the metadata with the specified values for
the encap.

For example, the following flower filter will forward all ICMP packets
destined to 11.11.11.2 through the shared vxlan device 'vxlan0'. Before
redirecting, a metadata for the vxlan tunnel is created using the
tunnel_key action and it's arguments:

$ tc filter add dev net0 protocol ip parent ffff: \
    flower \
      ip_proto 1 \
      dst_ip 11.11.11.2 \
    action tunnel_key set \
      src_ip 11.11.0.1 \
      dst_ip 11.11.0.2 \
      id 11 \
    action mirred egress redirect dev vxlan0

Signed-off-by: Amir Vadai <amir@vadai.me>
2016-12-02 14:12:09 -08:00
Amir Vadai
aab0f61043 libnetlink: Introduce rta_getattr_be*()
Add the utility functions rta_getattr_be16() and rta_getattr_be32(), and
change existing code to use it.

Signed-off-by: Amir Vadai <amir@vadai.me>
2016-12-02 14:12:09 -08:00
Stephen Hemminger
bf9a0aff36 Update kernel headers for XDP and tcp_info
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-12-01 10:52:30 -08:00
Stephen Hemminger
328374dcfe Merge branch 'master' into net-next 2016-12-01 10:29:12 -08:00
Roi Dayan
b9dcf9c282 devlink: Add option to set and show eswitch inline mode
This is needed for some HWs to do proper macthing and steering.
Possible values are none, link, network, transport.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2016-11-29 19:17:20 -08:00
Daniel Borkmann
e42256699c bpf: make tc's bpf loader generic and move into lib
This work moves the bpf loader into the iproute2 library and reworks
the tc specific parts into generic code. It's useful as we can then
more easily support new program types by just having the same ELF
loader backend. Joint work with Thomas Graf. I hacked a rough start
of a test suite to make sure nothing breaks [1] and looks all good.

  [1] https://github.com/borkmann/clsact/blob/master/test_bpf.sh

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2016-11-29 12:35:32 -08:00
Stephen Hemminger
1a97748be4 update net-next headers 2016-11-29 11:43:40 -08:00
Stephen Hemminger
6e2e71e16e update headers based on 4.9-rc7 2016-11-29 11:41:58 -08:00
Phil Sutter
5dec02d7b4 include: Add linux/sctp.h
Add sanitized UAPI linux/sctp.h header file.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-11-29 11:41:57 -08:00
Stephen Hemminger
e770979cf1 update kernel headers to 4.9-net-next 2016-10-26 11:20:29 -07:00
Stephen Hemminger
c07a36c3db Revert "iproute2: macvlan: add "source" mode"
This reverts commit f33b727610.

The upstream changes are not in 4.9
2016-10-26 11:15:09 -07:00
michael-dev@fami-braun.de
f33b727610 iproute2: macvlan: add "source" mode
Adjusting iproute2 utility to support new macvlan link type mode called
"source".

Example of commands that can be applied:
  ip link add link eth0 name macvlan0 type macvlan mode source
  ip link set link dev macvlan0 type macvlan macaddr add 00:11:11:11:11:11
  ip link set link dev macvlan0 type macvlan macaddr del 00:11:11:11:11:11
  ip link set link dev macvlan0 type macvlan macaddr flush
  ip -details link show dev macvlan0

Based on previous work of Stefan Gula <steweg@gmail.com>

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>

Cc: steweg@gmail.com
2016-10-12 15:22:14 -07:00
Stephen Hemminger
b96306f8d9 Merge branch 'master' into net-next 2016-10-09 19:04:50 -07:00
Stephen Hemminger
63ec17a3da v4.8.0 2016-10-09 19:00:11 -07:00
Stephen Hemminger
d99272470a update headers from pre 4.9 (net-next) 2016-10-09 18:55:58 -07:00
Stephen Hemminger
16c2a51dc4 update bpf.h 2016-09-21 16:28:56 -07:00
Stephen Hemminger
e8a67bc4cf update kernel headers from net-next 2016-09-20 09:31:42 -07:00
Stephen Hemminger
88ba11bc08 Merge branch 'master' into net-next 2016-09-01 09:11:10 -07:00
Stephen Hemminger
3cad6e5f25 update kernel headers from 4.8-rc4 2016-09-01 09:10:43 -07:00
Nikolay Aleksandrov
56e3eb4c34 ip: route: fix multicast route dumps
If we have multicast routes and do ip route show table all we'll get the
following output:
 ...
 multicast ???/32 from ???/32  table default  proto static  iif eth0
The "???" are because the rtm_family is set to RTNL_FAMILY_IPMR instead
(or RTNL_FAMILY_IP6MR for ipv6). Add a simple workaround that returns the
real family based on the rtm_type (always RTN_MULTICAST for ipmr routes)
and the rtm_family. Similar workaround is already used in ipmroute, and
we can use this helper there as well.

After the patch the output is:
multicast 239.10.10.10/32 from 0.0.0.0/32  table default  proto static  iif eth0

Also fix a minor whitespace error and switch to tabs.

Reported-by: Satish Ashok <sashok@cumulusnetworks.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-09-01 08:41:37 -07:00
Stephen Hemminger
60ba41ad7f update TIPC headers 2016-08-29 11:06:02 -07:00
Nikolay Aleksandrov
7abf5de677 bridge: vlan: add support to display per-vlan statistics
This patch adds support for the stats argument to the bridge
vlan command which will display the per-vlan statistics and the device
each vlan belongs to with its flags. The supported command filtering
options are dev and vid. Also the man page is updated to explain the new
option.
The patch uses the new RTM_GETSTATS interface with a filter_mask to dump
all bridges and ports vlans. Later we can add support for using the
per-device dump and filter it in the kernel instead.

Example:
$ bridge -s vlan show
port             vlan id
br0               1 Egress Untagged
                    RX: 2536 bytes 20 packets
                    TX: 2536 bytes 20 packets
                  101
                    RX: 43158 bytes 50 packets
                    TX: 43158 bytes 50 packets
eth1              1 Egress Untagged
                    RX: 2536 bytes 20 packets
                    TX: 2536 bytes 20 packets
                  100
                    RX: 0 bytes 0 packets
                    TX: 0 bytes 0 packets
                  101
                    RX: 43158 bytes 50 packets
                    TX: 43158 bytes 50 packets
                  102
                    RX: 16897 bytes 93 packets
                    TX: 0 bytes 0 packets

The format is the same as bridge vlan show but with stats, even though
under the hood the calls done to the kernel are different.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-08-29 10:58:40 -07:00
Stephen Hemminger
380656f8c4 update headers to 4.8-rc2 net-next 2016-08-25 08:49:07 -07:00
Stephen Hemminger
9f9e2bb88e update BPF headers 2016-08-25 08:46:25 -07:00
Sabrina Dubroca
2b68cb77cd libgenl: introduce genl_init_handle
All users of genl have the same code to open a genl socket and resolve
the family for their specific protocol.  Introduce a helper to initialize
the handle, and use it in all the genl code.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
2016-08-17 13:59:21 -07:00
Stephen Hemminger
80c4bc6a3e Merge branch 'master' into net-next 2016-08-08 09:27:28 -07:00
Stephen Hemminger
4ecc96f8b6 v4.7.0 2016-08-08 08:58:39 -07:00
Stephen Hemminger
dc00db9e84 update kernel headers 2016-08-08 08:51:22 -07:00
Stephen Hemminger
ba91cd9d86 include: update net-next XDP headers 2016-07-20 12:24:59 -07:00
Stephen Hemminger
a951428058 update headers files to current net-next 2016-07-15 11:55:14 -07:00
Stephen Hemminger
ba5783cbf3 Merge branch 'master' into net-next 2016-07-15 11:49:41 -07:00
Eli Cohen
d91fb3f4c7 Add support for configuring Infiniband GUIDs
Add two NLA's that allow configuration of Infiniband node or port GUIDs
by referencing the IPoIB net device set over the physical function. The
format to be used is as follows:

ip link set dev ib0 vf 0 node_guid 00:02:c9:03:00:21:6e:70
ip link set dev ib0 vf 0 port_guid 00:02:c9:03:00:21:6e:78

Signed-off-by: Eli Cohen <eli@mellanox.com>
2016-07-15 11:25:36 -07:00
Stephen Hemminger
4824bb4151 update kernel header (4.7 net-next) 2016-07-06 21:14:57 -07:00
Stephen Hemminger
3b6d9ab2e2 update kernel headers (net-next) 2016-06-21 11:29:20 -07:00
Stephen Hemminger
7d057fc292 Merge branch 'master' into net-next 2016-06-21 11:28:32 -07:00
Stephen Hemminger
5b26063c25 if: add missing kernel headers
Add kernel headers for all headers that included by current source.
2016-06-21 11:24:52 -07:00
Stephen Hemminger
ec09118749 fib_rules.h update header file
Add new L3MDEV (clone from net-next)
2016-06-14 16:33:48 -07:00
Stephen Hemminger
c68780826d minor header update from net-next 2016-06-08 09:39:03 -07:00
Sabrina Dubroca
609640f5f0 utils: provide get_hex to read a hex digit from a char
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
2016-06-08 09:30:41 -07:00
Sabrina Dubroca
9f7401fa49 utils: add get_be{16, 32, 64}, use them where possible
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
2016-06-08 09:30:37 -07:00
Sabrina Dubroca
89ae502056 utils: make hexstring_a2n provide the number of hex digits parsed
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
2016-06-08 09:30:31 -07:00
Stephen Hemminger
de70bd2f6b tc: update headers for TCA_POLICE
These are from linux-net but will be in next rc.
2016-05-31 13:02:28 -07:00
Stephen Hemminger
5c33c95924 add if_macsec header
Current version from 4.7-pre-rc1
2016-05-23 16:10:43 -07:00
Stephen Hemminger
0a99e7badf update kernel headers (from 4.7-rc1) 2016-05-23 09:06:11 -07:00
Stephen Hemminger
1d63d8c606 Merge branch 'master' into net-next 2016-05-18 11:57:28 -07:00
Stephen Hemminger
bbe2abdf3d vv4.6.0 2016-05-18 11:56:02 -07:00
David Ahern
b0a4ce620e ip link: Add support for kernel side filtering
Kernel gained support for filtering link dumps with commit dc599f76c22b
("net: Add support for filtering link dump by master device and kind").
Add support to ip link command. If a user passes master device or
kind to ip link command they are added to the link dump request message.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2016-05-18 11:52:14 -07:00
Stephen Hemminger
866f6d77bf Merge branch 'master' into net-next 2016-05-16 11:20:40 -07:00
Stephen Hemminger
29b7968926 add tc_ife.h 2016-05-16 11:13:05 -07:00
Stephen Hemminger
31ce6e0101 update kernel headers from net-next
Take sanitized headers for davem net-next
2016-05-13 14:56:31 -07:00
Stephen Hemminger
0c9ffc0b0a devlink: update uapi header
Get santized version from net-next
2016-05-13 14:49:40 -07:00
Stephen Hemminger
7fd86a9676 Merge branch 'master' into net-next 2016-05-13 14:44:48 -07:00
Stephen Hemminger
8a781d7e25 update kernel headers to 4.6-rc6
Close to final upstream headers
2016-05-13 14:41:45 -07:00
Stephen Hemminger
7aca60c0eb Revert "devlink: implement shared buffer support"
This reverts commit b56700bf8a.
2016-05-13 14:38:47 -07:00
Stephen Hemminger
c3d25ec392 Revert "devlink: implement shared buffer occupancy control"
This reverts commit a60ebcb6f3.
2016-05-13 14:38:38 -07:00
Stephen Hemminger
b76b93ddac update kernel headers from net-next 2016-04-24 22:30:46 -07:00
Stephen Hemminger
32c0b9b7a8 update kernel headers from net-next 2016-04-22 10:01:12 -07:00
Stephen Hemminger
8b5be9ecff update inet_diag.h header 2016-04-19 08:06:11 -07:00
Stephen Hemminger
6065805922 Merge branch 'master' into net-next 2016-04-19 08:01:55 -07:00
Jiri Pirko
a60ebcb6f3 devlink: implement shared buffer occupancy control
Use kernel shared buffer occupancy control commands to make snapshot and
clear occupancy watermarks. Also, allow to show occupancy values in a
nice way.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2016-04-19 08:01:05 -07:00
Jiri Pirko
b56700bf8a devlink: implement shared buffer support
Implement kernel devlink shared buffer interface. Introduce new object
"sb" and allow to browse the shared buffer parameters and also change
configuration.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2016-04-19 08:01:05 -07:00
Jiri Pirko
ebaf76b55e list: add list_add_tail helper
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2016-04-19 08:01:05 -07:00
Jiri Pirko
f1239ca1f9 list: add list_for_each_entry_reverse macro
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2016-04-19 08:01:05 -07:00
Stephen Hemminger
39afc4b08e Merge branch 'master' into net-next 2016-04-11 22:15:41 +00:00
Daniel Borkmann
4dd3f50af4 tc, bpf: add support for map pre/allocation
Follow-up to kernel commit 6c9059817432 ("bpf: pre-allocate hash map
elements"). Add flags support, so that we can pass in BPF_F_NO_PREALLOC
flag for disallowing preallocation. Update examples accordingly and also
remove the BPF_* map helper macros from them as they were not very useful.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2016-04-11 21:54:47 +00:00
Daniel Borkmann
0395711c52 tc, bpf: add new csum and tunnel signatures
Add new signatures for BPF_FUNC_csum_diff, BPF_FUNC_skb_get_tunnel_opt
and BPF_FUNC_skb_set_tunnel_opt.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2016-04-11 21:53:58 +00:00