Commit Graph

1020 Commits

Author SHA1 Message Date
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
Stephen Hemminger
bc9fb25788 update kernel headers
Headers up to date with 4.6-net-next
2016-04-11 13:44:50 -07:00
Stephen Hemminger
6268b08c13 update kernel headers
Update from 4.6-rc3
2016-04-11 13:40:40 -07:00
Jiri Pirko
a3c4b484a1 add devlink tool
Add new tool called devlink which is userspace counterpart of devlink
Netlink socket.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2016-03-27 10:57:15 -07:00
Jiri Pirko
4952b45946 include: add linked list implementation from kernel
Rename hlist.h to list.h while adding it to be aligned with kernel

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2016-03-27 10:56:11 -07:00
Stephen Hemminger
e9e9365b56 scrub out whitespace issues
Run script that removes trailing whitespace everywhere.
2016-03-27 10:50:14 -07:00
Phil Sutter
7faf1588a7 lib/utils: introduce rt_addr_n2a_rta()
This simple macro eases calling rt_addr_n2a() with data from an rt_attr
pointer.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-27 10:37:35 -07:00
Phil Sutter
d49f934c10 lib/utils: introduce format_host_rta()
This simple macro eases calling format_host() with data from an rt_attr
pointer.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-27 10:37:35 -07:00
Phil Sutter
2e96d2ccd0 utils: make rt_addr_n2a() non-reentrant by default
There is only a single user who needs it to be reentrant (not really,
but it's safer like this), add rt_addr_n2a_r() for it to use.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-27 10:37:34 -07:00
Phil Sutter
a418e45164 make format_host non-reentrant by default
There are only three users which require it to be reentrant, the rest is
fine without. Instead, provide a reentrant format_host_r() for users
which need it.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-27 10:37:34 -07:00
Phil Sutter
a1121aa1f5 color: introduce color helpers and COLOR_CLEAR
This adds two helper functions which map a given data field to a color,
so color_fprintf() statements don't have to be duplicated with only a
different color value depending on that data field's value. In order for
this to work in a generic way, COLOR_CLEAR has been added to serve as a
fallback default of uncolored output.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2016-03-27 10:37:34 -07:00
Stephen Hemminger
b7e0091a92 update kernel headers to 4.6 (pre rc1) 2016-03-21 12:02:32 -07:00
Stephen Hemminger
165303e57f Merge branch 'master' into net-next 2016-03-14 16:05:00 -07:00
Stephen Hemminger
162b3ce92e v4.5.0 2016-03-14 16:02:31 -07:00
Stephen Hemminger
2421ab750a update to current 4.5-rc net-next headers 2016-03-02 09:30:56 -08:00
Stephen Hemminger
9e99e49528 ss: display not_sent and min_rtt info
Display new info from net-next kernel.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-02-17 17:44:39 -08:00
Stephen Hemminger
385caeb13b Revert "tipc: add peer remove functionality"
This reverts commit f9dec657e4.

Since this code is not in upstream kernel, it shouldn't be in iproute2
2016-02-09 10:51:32 -08:00
Stephen Hemminger
8593b2cac0 Update header files from net-next 2016-02-09 10:49:03 -08:00
Nikolay Aleksandrov
8c0f7a1630 iplink: bridge: export read-only timers
Netlink already provides hello_timer, tcn_timer, topology_change_timer
and gc_timer, so let's make them visible.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
2016-02-09 10:42:03 -08:00
Daniel Borkmann
92a36995b3 tc, bpf, examples: further bpf_api improvements
Add a couple of improvements to tc's BPF api, that facilitate program
development.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2016-02-07 11:27:38 -08:00
Stephen Hemminger
7321b7db6f update headers (post 4.4 merge window) 2016-01-18 09:40:13 -08:00
Stephen Hemminger
2505780c20 Merge branch 'net-next' 2016-01-18 09:37:45 -08:00
Richard Alpe
f9dec657e4 tipc: add peer remove functionality
This enables a user to remove an offline peer from the kernel data
structures. This could for example be useful when deliberately scaling
in peer nodes in a cloud environment.

Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
2016-01-11 08:39:15 -08:00
Stephen Hemminger
92a0236a3c v4.4.0 2016-01-11 08:33:03 -08:00
Stephen Hemminger
19ec5f8393 Revert "tipc: add peer remove functionality"
This reverts commit d4585a4bb1.
This commit is meant for later kernel.
2016-01-11 08:31:46 -08:00
Richard Alpe
d4585a4bb1 tipc: add peer remove functionality
This enables a user to remove an offline peer from the kernel data
structures. This could for example be useful when deliberately scaling
in peer nodes in a cloud environment.

Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
2016-01-06 09:24:25 -08:00
Stephen Hemminger
a4c89d8087 update most kernel headers
still have issues with xtables
2016-01-06 09:14:29 -08:00
Stephen Hemminger
5cd1adba79 Update to current iptables headers
Keep in sync with current iptables upstream
2016-01-03 15:14:27 -08:00
Daniel Borkmann
fd7f9c7fd1 bpf: minor fix in api and bpf_dump_error() usage
Fix a whitespace in bpf_dump_error() usage, and also a missing closing
bracket in ntohl() macro for eBPF programs.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2015-12-17 17:22:25 -08:00
Stephen Hemminger
741c20b024 include: update kernel headers
Current headers for net-next
2015-12-17 17:21:53 -08:00
Stephen Hemminger
00a2a1748b Merge branch 'master' into net-next 2015-12-17 17:21:15 -08:00
Tom Herbert
5866bddd9a ila: Add support for ILA lwtunnels
This patch:
 - Adds a utility function for parsing a 64 bit address
 - Adds a utility function for converting a 64 bit address to ASCII
 - Adds and ILA encap type in lwt tunnels

Signed-off-by: Tom Herbert <tom@herbertland.com>
2015-12-17 17:07:07 -08:00
Daniel Borkmann
41d6e33fc9 examples, bpf: further improve examples
Improve example files further and add a more generic set of possible
helpers for them that can be used.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
2015-12-10 08:56:45 -08:00
Daniel Borkmann
f6793eec46 {f, m}_bpf: allow for user-defined object pinnings
The recently introduced object pinning can be further extended in order
to allow sharing maps beyond tc namespace. F.e. maps that are being pinned
from tracing side, can be accessed through this facility as well.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
2015-11-29 11:55:16 -08:00
Stephen Hemminger
fece33c195 Merge branch 'master' into net-next 2015-11-29 11:53:43 -08:00
Phil Sutter
8e72880f6b libnetlink: introduce nc_flags
Allow for a filter to ignore certain nlmsg_flags.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-11-29 11:47:29 -08:00
Daniel Borkmann
32e93fb7f6 {f,m}_bpf: allow for sharing maps
This larger work addresses one of the bigger remaining issues on
tc's eBPF frontend, that is, to allow for persistent file descriptors.
Whenever tc parses the ELF object, extracts and loads maps into the
kernel, these file descriptors will be out of reach after the tc
instance exits.

Meaning, for simple (unnested) programs which contain one or
multiple maps, the kernel holds a reference, and they will live
on inside the kernel until the program holding them is unloaded,
but they will be out of reach for user space, even worse with
(also multiple nested) tail calls.

For this issue, we introduced the concept of an agent that can
receive the set of file descriptors from the tc instance creating
them, in order to be able to further inspect/update map data for
a specific use case. However, while that is more tied towards
specific applications, it still doesn't easily allow for sharing
maps accross multiple tc instances and would require a daemon to
be running in the background. F.e. when a map should be shared by
two eBPF programs, one attached to ingress, one to egress, this
currently doesn't work with the tc frontend.

This work solves exactly that, i.e. if requested, maps can now be
_arbitrarily_ shared between object files (PIN_GLOBAL_NS) or within
a single object (but various program sections, PIN_OBJECT_NS) without
"loosing" the file descriptor set. To make that happen, we use eBPF
object pinning introduced in kernel commit b2197755b263 ("bpf: add
support for persistent maps/progs") for exactly this purpose.

The shipped examples/bpf/bpf_shared.c code from this patch can be
easily applied, for instance, as:

 - classifier-classifier shared:

  tc filter add dev foo parent 1: bpf obj shared.o sec egress
  tc filter add dev foo parent ffff: bpf obj shared.o sec ingress

 - classifier-action shared (here: late binding to a dummy classifier):

  tc actions add action bpf obj shared.o sec egress pass index 42
  tc filter add dev foo parent ffff: bpf obj shared.o sec ingress
  tc filter add dev foo parent 1: bpf bytecode '1,6 0 0 4294967295,' \
     action bpf index 42

The toy example increments a shared counter on egress and dumps its
value on ingress (if no sharing (PIN_NONE) would have been chosen,
map value is 0, of course, due to the two map instances being created):

  [...]
          <idle>-0     [002] ..s. 38264.788234: : map val: 4
          <idle>-0     [002] ..s. 38264.788919: : map val: 4
          <idle>-0     [002] ..s. 38264.789599: : map val: 5
  [...]

... thus if both sections reference the pinned map(s) in question,
tc will take care of fetching the appropriate file descriptor.

The patch has been tested extensively on both, classifier and
action sides.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2015-11-23 16:10:44 -08:00
Stephen Hemminger
0198930b55 update kernel headers to 4.4-rc1
Post merge window changes
2015-11-23 15:53:04 -08:00
Stephen Hemminger
115b4d8873 Merge branch 'master' into net-next 2015-11-03 16:38:15 -08:00
Stephen Hemminger
6720eceff7 v4.3.0 2015-11-03 16:34:46 -08:00
Stephen Hemminger
dddf1b4412 add new IFLA_VF_TRUST netlink attribute 2015-10-23 15:47:07 -07:00
Stephen Hemminger
c518d3a7f7 update bpf kernel header 2015-10-22 23:43:35 -07:00
Stephen Hemminger
651dccbee7 Merge branch 'master' into net-next 2015-10-22 23:42:37 -07:00
Daniel Borkmann
d583e88ebc ip, realms: also allow to pass in raw realms value
If get_rt_realms() fails, try to get a possible raw u32 realms
value for the u32 RTA_FLOW/FRA_FLOW attribute, as it might be
useful to directly configure the hex value itself. And only if
that fails, then bail out.

The source realm is provided in the upper u16 (mask: 0xffff0000)
and the destination realm through the lower u16 part (mask:
0x0000ffff). This can be useful for tc's bpf realm matcher, but
also a full hex/mask param can be provided already for matching
through iptables' --realm cmdline option, for example.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2015-10-22 23:40:51 -07:00
Stephen Hemminger
89bb4c6aca update kernel headers
Track upstream
2015-10-22 23:36:49 -07:00
Roopa Prabhu
1e5293056a lwtunnel: Add encapsulation support to ip route
This patch adds support to parse and print lwtunnel
encapsulation attributes attached to routes for MPLS
and IP tunnels.

example:
Add ipv4 route with mpls encap attributes:

Examples:

  MPLS:
  $ ip route add 40.1.2.0/30 encap mpls 200 via inet 40.1.1.1 dev eth3
  $ ip route show
  40.1.2.0/30  encap mpls 200 via 40.1.1.1 dev eth3

  Add ipv4 multipath route with mpls encap attributes:
  $ ip route add 10.1.1.0/30 nexthop encap mpls 200 via 10.1.1.1 dev eth0 \
		    nexthop encap mpls 700 via  40.1.1.2 dev eth3
  $ ip route show
  10.1.1.0/30
    nexthop encap mpls 200  via 10.1.1.1  dev eth0 weight 1
    nexthop encap mpls 700  via 40.1.1.2  dev eth3 weight 1

  IP:
  $ ip route add 10.1.1.1/24 encap ip id 200 dst 20.1.1.1 dev vxlan0

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Jiri Benc <jbenc@redhat.com>
2015-10-16 16:13:22 -07:00
Stephen Hemminger
e569c5c0fd add tunnel header files from net-next uapi
Files needed for new lwtunnel code.
2015-10-16 16:13:05 -07:00
Stephen Hemminger
c6646c1ea5 Merge branch 'master' into net-next 2015-10-16 16:03:32 -07:00
Roopa Prabhu
303cc9cbee libnetlink: introduce rta_nest and u8, u16, u64 helpers for nesting within rtattr
This patch introduces two new api's rta_nest and rta_nest_end to
nest attributes inside a rta attribute represented by 'struct rtattr'
as required to construct a nexthop. Also adds rta_addattr* variants
for u8, u16 and u64 as needed to support encapsulation.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Jiri Benc <jbenc@redhat.com>
2015-10-16 16:00:47 -07:00
Daniel Borkmann
faa8a46300 f_bpf: allow for optional classid and add flags
When having optional classid, most minimal command can be sth
like:

  tc filter add dev foo parent X: bpf obj prog.o

Therefore, adapt the code so that a next argument will not be
enforced as the case currently.

Also, minor cleanup on the classid, where we should rather
have used addattr32(), and add flags for exec configuration,
for example (using short notation):

  tc filter add dev foo parent X: bpf da obj prog.o

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
2015-10-12 09:41:05 -07:00
David Ahern
0d238ca2b8 ip neigh: Add support for filtering dumps by master device
Add support for filtering neighbor dumps by master device. Kernel side
support provided by commit 21fdd092acc7. Since the feature is not
available in older kernels the user is given a warning message if the
kernel does not support the request.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2015-10-12 09:39:37 -07:00
Stephen Hemminger
23e905096c update kernel headers for net-next 2015-10-12 09:34:18 -07:00
Stephen Hemminger
6b53cb66e8 update kernel headers 2015-10-12 09:22:29 -07:00
Stephen Hemminger
4e39bfb93a update kernel headers to 4.3 net-next 2015-09-23 16:18:34 -07:00
Phil Sutter
5c32fa1d69 comment: Fix remaining listings of wrong FSF address
This patch follows the changes of commit 4d98ab0 ("Fix FSF address in
file headers"), fixing file headers added after it.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2015-09-23 15:58:54 -07:00
Stephen Hemminger
8d62f3e294 update kernel headers to 4.2-net-next 2015-08-31 16:35:00 -07:00
Stephen Hemminger
f1e225beef Merge branch 'master' into net-next 2015-08-31 16:32:10 -07:00
Stephen Hemminger
ec4ef6aebd v4.2.0 2015-08-31 16:31:15 -07:00
Andy Gospodarek
5d295bb8e1 add support for brief output for link and addresses
This adds support for slightly less output than is normally provided by
'ip link show' and 'ip addr show'.  This is a bit better when you have a
host with lots of interfaces.  Sample output:

$ ip -br link show
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
p2p1             UP             08:00:27:ee:0b:3b <BROADCAST,MULTICAST,UP,LOWER_UP>
p7p1             UP             08:00:27:9d:62:9f <BROADCAST,MULTICAST,UP,LOWER_UP>
p8p1             DOWN           08:00:27:dc:d8:ca <NO-CARRIER,BROADCAST,MULTICAST,UP>
p9p1             UP             08:00:27:76:d9:75 <BROADCAST,MULTICAST,UP,LOWER_UP>
p7p1.100@p7p1    UP             08:00:27:9d:62:9f <BROADCAST,MULTICAST,UP,LOWER_UP>

$ ip -br -4 addr show
lo               UNKNOWN        127.0.0.1/8
p2p1             UP             192.168.56.2/24
p7p1             UP             70.0.0.1/24
p8p1             DOWN           80.0.0.1/24
p9p1             UP             10.0.5.15/24
p7p1.100@p7p1    UP             200.0.0.1/24

$ ip -br -6 addr show
lo               UNKNOWN        ::1/128
p2p1             UP             fe80::a00:27ff:feee:b3b/64
p7p1             UP             7000::1/8 fe80::a00:27ff:fe9d:629f/64
p8p1             DOWN           8000::1/8
p9p1             UP             fe80::a00:27ff:fe76:d975/64
p7p1.100@p7p1    UP             fe80::a00:27ff:fe9d:629f/64

$ ip -br addr show p7p1
p7p1             UP             70.0.0.1/24 7000::1/8 fe80::a00:27ff:fe9d:629f/64

v2: Now with color support!
v3: Better field width estimation (except netdev names to keep output at a
decent width) and whitespace fixup.

Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
2015-08-31 16:24:10 -07:00
Stephen Hemminger
75d67d356e update kernel headers to 4.2-net-next 2015-08-23 10:10:44 -07:00
Stephen Hemminger
dfc3d015f6 Merge branch 'master' into net-next 2015-08-23 10:09:46 -07:00
Stephen Hemminger
fcc16c2287 provide common json output formatter
Formatting JSON is moderately painful.
Provide a simple API to do the syntax formatting.
2015-08-23 10:05:29 -07:00
Stephen Hemminger
9a6422c243 Merge branch 'master' into net-next 2015-08-13 19:42:41 -07:00
Zhang Shengju
e3c27c2db6 utils: add missing return value
Add missing return value to fix warnings

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
2015-08-13 19:41:48 -07:00
Stephen Hemminger
892e21248c remove unnecessary extern
No need for extern on function prototypes.
2015-08-13 14:09:58 -07:00
Stephen Hemminger
8fcba79ed5 update header files from 4.2 net-next 2015-08-12 09:18:04 -07:00
Stephen Hemminger
4f3489cd58 update to net-next (4.3) headers 2015-08-10 11:21:20 -07:00
Stephen Hemminger
089d93d6f2 update kernel headers from net-next
Align with upstream kernel.
2015-07-31 18:13:56 -07:00
Stephen Hemminger
a3563ede2d update to 4.2-net-next headers 2015-07-28 16:42:12 -07:00
Stephen Hemminger
ec7aff5c4f ip: fix all the checkpatch warnings
Zhang Shengju some places where tabs were not being used.
Go ahead and fix all the trival checkpatch warnings in ip/ip.c
Also fix bridge.c
2015-07-26 21:50:22 -07:00
Stephen Hemminger
b0085d0ee9 update kernel headers for 4.2-rc1 2015-07-20 14:57:18 -07:00
Stephen Hemminger
f5386e1150 headers update
if_tun: new ioctl value
libc-compat.h: add definitions for kernel build
2015-07-06 14:47:26 -07:00
Michal Kubeček
38db20ff2d include: add copy of tipc.h
Copy of kernel include/uapi/linux/tipc.h is needed to build on systems
with pre-3.16 kernel headers.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2015-07-06 14:47:05 -07:00
Stephen Hemminger
0c4a90c446 Merge branch 'master' into net-next 2015-06-26 14:08:49 -07:00
Stephen Hemminger
e3006d5210 v4.1.0 2015-06-26 12:28:25 -07:00
Stephen Hemminger
ff631c3a10 update to 4.2-pre-rc headers
This update is to santized kernel headers from net-next.
With one change for fixing the in.h header incompatiablity
(already sent upstream).
2015-06-25 22:34:26 -04:00
John W. Linville
f4739b2ee7 iplink_geneve: add tos configuration at link creation
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2015-06-25 15:16:31 -04:00
John W. Linville
f4c05c2e99 iplink_geneve: add ttl configuration at link creation
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2015-06-25 15:16:31 -04:00
Stephen Hemminger
439951f8bf pkt_cls: update header
Upstream changes removed some kernel only stuff from header file.
2015-05-28 09:18:28 -07:00
Stephen Hemminger
03371c7d98 Merge branch 'master' into net-next
Conflicts:
	include/linux/tcp.h
	lib/libnetlink.c
2015-05-28 09:18:01 -07:00
Stephen Hemminger
ebfe49224b update to 4.1-rc5 headers
Pull in some changes like RTN_F_EXTERNAL
2015-05-27 18:27:42 -07:00
Stephen Hemminger
c079e121a7 libnetlink: add size argument to rtnl_talk
There have been several instances where response from kernel
has overrun the stack buffer from the caller. Avoid future problems
by passing a size argument.

Also drop the unused peer and group arguments to rtnl_talk.
2015-05-27 13:00:21 -07:00
Nicolas Dichtel
449b824ad1 ipmonitor: allows to monitor in several netns
With this patch, it's now possible to listen in all netns that have an nsid
assigned into the netns where the socket is opened.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-05-21 15:28:56 -07:00
Nicolas Dichtel
0628cddd9d libnetlink: introduce rtnl_listen_filter_t
There is no functional change with this commit. It only prepares the next one.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-05-21 15:28:56 -07:00
Stephen Hemminger
f9b004020a Merge branch 'master' into net-next 2015-05-21 14:52:42 -07:00
Stephen Hemminger
8f42ceaf24 Update kernels for net-next
Get latest files
2015-05-21 14:52:08 -07:00
Stephen Hemminger
cbb99f7fbe Update to latest kernel headers
Also add tipc_netlink.h for later TIPC support
2015-05-21 14:41:11 -07:00
Stephen Hemminger
270763546a update headers to 4.1-rc1 net-next 2015-05-04 09:04:59 -07:00
Mathias Nyman
d7bd2db52c ip: Add color output option
It is hard to quickly find what you are looking for in the output of the
ip command. Color helps.

This patch adds a '-c' flag to highlight these with individual colors:
  - interface name
  - ip address
  - mac address
  - up/down state

Signed-off-by: Mathias Nyman <m.nyman@iki.fi>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
2015-05-04 08:39:17 -07:00
Stephen Hemminger
aeedd8e1e7 update headers to reflect BPF changes
Reclone sanitized headers from 4.1-rc
2015-04-29 12:33:24 -07:00
Nicolas Dichtel
b765eda924 libnamespaces: fix warning about syscall()
The warning was:
In file included from namespace.c:14:0:
../include/namespace.h: In function ‘setns’:
../include/namespace.h:37:2: warning: implicit declaration of function ‘syscall’ [-Wimplicit-function-declaration]

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-04-27 11:41:46 -07:00
Nicolas Dichtel
d652ccbf81 netns: allow to dump and monitor nsid
Two commands are added:
 - ip netns list-id
 - ip monitor nsid

A cache is also added to remember the association between the iproute2 netns
name (from /var/run/netns/) and the nsid.
To avoid interfering with the rth socket, a new rtnl socket (rtnsh) is used to
get nsid (we may send rtnl request during listing on rth).

Example:
$ ip netns list-id
nsid 0 (iproute2 netns name: foo)
$ ip monitor nsid
Deleted nsid 0 (iproute2 netns name: foo)
nsid 16 (iproute2 netns name: bar)

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-04-20 10:02:38 -07:00
Stephen Hemminger
94f665387e update kernel headers and add tc_connmark.h
Needed for later tc action patches
2015-04-13 10:49:33 -07:00
Stephen Hemminger
93531fac41 Merge branch 'master' into net-next 2015-04-13 09:39:46 -07:00
Stephen Hemminger
aed6d85d15 v4.0.0 2015-04-13 08:55:11 -07:00
Daniel Borkmann
6256f8c9e4 tc, bpf: finalize eBPF support for cls and act front-end
This work finalizes both eBPF front-ends for the classifier and action
part in tc, it allows for custom ELF section selection, a simplified tc
command frontend (while keeping compat), reusing of common maps between
classifier and actions residing in the same object file, and exporting
of all map fds to an eBPF agent for handing off further control in user
space.

It also adds an extensive example of how eBPF can be used, and a minimal
self-contained example agent that dumps map data. The example is well
documented and hopefully provides a good starting point into programming
cls_bpf and act_bpf.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
2015-04-10 13:31:19 -07:00
Stephen Hemminger
e46efaed0f update kernel headers for net-next
Current santized kernel headers from net-next
2015-04-10 13:18:38 -07:00
Stephen Hemminger
bd733e4088 Merge branch 'master' into net-next
Conflicts:
	man/man8/ip-route.8.in
2015-04-07 08:56:14 -07:00
Vadim Kochan
8b90a9907e tc class: Ignore if default class name file does not exist
If '-nm' specified that do not fail if there is no
default class names file in /etc/iproute2.

Changed default class name file cls_names -> tc_cls.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-04-07 08:31:56 -07:00
Eric W. Biederman
dacc5d4197 add basic mpls support to iproute
- Pull in the uapi mpls.h
- Update rtnetlink.h to include the mpls rtnetlink notification multicast group.
- Define AF_MPLS in utils.h if it is not defined from elsewhere
  as is done with AF_DECnet

The address syntax for multiple mpls labels is a complete invention.
When I looked there seemed to be no wide spread convention for talking
about an mpls label stack in text for.  Sometimes people did:
"{ Label1, Label2, Label3 }", sometimes people would do:
"[ label3, label2, label1 ]", and most of the time label
stacks were not explicitly shown at all.

The syntax I wound up using, so it would not have spaces and so it
would visually distinct from other kinds of addresses is.

label1/label2/label3 Where label1 is the label at the top of the label
stack and label3 is the label at the bottom on the label stack.

When there is a single label this matches what seems to be convention
with other tools.  Just print out the numeric value of the mpls label.

The netlink protocol for labels uses the on the wire format for a
label stack. The ttl and traffic class are expected to be 0.  Using
the on the wire format is common and what happens with other address
types. BGP when passing label stacks also uses this technique with the
exception that the ttl byte is not included making each label in a BGP
label stack 3 bytes instead of 4.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-03-24 15:45:23 -07:00
Eric W. Biederman
93ae283594 add support for the RTA_VIA attribute
Add support for the RTA_VIA attribute that specifies an address family
as well as an address for the next hop gateway.

To make it easy to pass this reorder inet_prefix so that it's tail
is a proper RTA_VIA attribute.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-03-24 15:45:23 -07:00