1156 Commits

Author SHA1 Message Date
David Ahern
5f044aca76 neigh: add support for NTF_SELF
http://lists.infradead.org/pipermail/libnl/2015-October/001995.html

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-11-01 18:18:16 +01:00
David Ahern
493bbd13e6 route/vrf: add VRF support
http://lists.infradead.org/pipermail/libnl/2015-October/001991.html

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
[thaller@redhat.com: slightly modified original patch]
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-11-01 17:54:03 +01:00
Thomas Haller
f25138d321 rtnl/link: merge branch 'vlan-protocol-serialize' 2015-10-21 19:05:16 +02:00
Thomas Haller
cef00e4f7b rtnl/link: indicate capability NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZE
Related: 0aca70083e51d97d0102c73852d31625f75c942b
2015-10-21 19:04:48 +02:00
skuklinski
0aca70083e route/link: IFLA_VLAN_PROTOCOL added to vlan_put_attrs
Fixes: 430eb4004ab7f93fd840e9836d4bc9220d3c406d

https://github.com/thom311/libnl/issues/90
https://github.com/thom311/libnl/pull/91
2015-10-21 18:58:35 +02:00
Thomas Haller
015899fd49 rtnl/link: document vlan-protocol to be exposed in network-byte order
Unfortunately this was done wrong. Instead of fixing it now
(and change behavior), document the behavior.

Fixes: 430eb4004ab7f93fd840e9836d4bc9220d3c406d

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-10-21 18:58:06 +02:00
Thomas Haller
7b9671c6d8 libnl-3.2.27 release
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-10-16 14:08:36 +02:00
Beniamino Galvani
6e69d9d12d route/link: add missing newlines after debug messages
http://lists.infradead.org/pipermail/libnl/2015-October/001977.html

Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-10-05 16:59:49 +02:00
Thomas Haller
6263a11bfc lib/attr: add nla utility functions for signed integers
Commit 7bb956501ccd58ed3bbffc59de996f056e178683 added nla functions for
s32. We preferibly add all signed integer operations at the same time.
Thus, also add s8, s16, and s64.

Also, previously the NLA_TYPE_MAX enum was not extended to have
NLA_S32. Fix that too.

Reported-By: Jiri Pirko <jiri@resnulli.us>
Fixes: 7bb956501ccd58ed3bbffc59de996f056e178683
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-10-05 16:52:41 +02:00
Thomas Haller
2a8a7c31e6 route: add capability indicating the behavior of rtnl_neigh_get()
A wrong behavior for rtnl_neigh_get() was introduced between 3.2.14 and 3.2.15
(commit 64fcb47a36ec12d7e7f00605f6a8952ce985dd08).

It was later fixed between 3.2.21 and 3.2.22
(commit 8571f58f23763d8db7365d02c9b27832ad3d7005).

Add a capability NL_CAPABILITY_RTNL_NEIGH_GET_FILTER_AF_UNSPEC_FIX
to indicate that this buggy behavior was fixed.

https://bugzilla.redhat.com/show_bug.cgi?id=1261028
http://lists.infradead.org/pipermail/libnl/2015-August/001951.html
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-09-29 18:35:34 +02:00
Thomas Haller
8d47c047a8 libnl-3.2.27-rc1 release
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-09-21 12:38:48 +02:00
Andrey Vagin
fd9d1da28c libnl: report an error if unexpected control data was received
Currently, we try to handle MSG_CTRUNC, but if msg_controllen is zero, we make
double free for the same address.

realloc(0, 0) returns non-zero address
realloc(addr, 0) returns zero and free(addr) has already been called

Then we call free(addr) again and get an error like this:

*** Error in `./task_diag_all': double free or corruption (fasttop): 0x0000000000f9c160 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x77e9d)[0x7f360ed96e9d]
/lib64/libc.so.6(+0x7f53c)[0x7f360ed9e53c]
/lib64/libc.so.6(cfree+0x4c)[0x7f360eda2e9c]
/lib64/libnl-3.so.200(nl_recv+0x221)[0x7f360f2f6361]
/lib64/libnl-3.so.200(nl_recvmsgs_report+0x555)[0x7f360f2f6a95]
/lib64/libnl-3.so.200(nl_recvmsgs+0x9)[0x7f360f2f6d89]
./task_diag_all[0x400f8d]
/lib64/libc.so.6(__libc_start_main+0xf0)[0x7f360ed3f790]
./task_diag_all[0x401169]

http://lists.infradead.org/pipermail/libnl/2015-September/001965.html

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-09-21 11:57:45 +02:00
Steffen Vogel
69851e24c7 doc: enable generation of Doxygen tagfile for libnl API reference
This enables other projects which are using Doxygen for documentation
to automatically create hyperlinks to libnl's API reference.

See: http://www.stack.nl/~dimitri/doxygen/manual/external.html

https://github.com/thom311/libnl/pull/89
2015-09-19 16:22:29 +02:00
Thomas Haller
2955fd003d route/link: merge branch 'vlan-flags'
http://lists.infradead.org/pipermail/libnl/2015-September/001961.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-09-03 18:24:01 +02:00
Jiří Klimeš
1300137170 vlan: add MVRP VLAN flag
Kernel patch:   http://patchwork.ozlabs.org/patch/219040/
iproute2 patch: http://patchwork.ozlabs.org/patch/219364/

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-09-03 18:21:02 +02:00
Jiří Klimeš
003a63a494 vlan: add VLAN flags to trans_tbl to print them properly
nl-link-list only showed reorder_hdr.

$ ip -d link show dev em1.444
28: em1.444@em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether 3c:97:0e:58:1d:c1 brd ff:ff:ff:ff:ff:ff promiscuity 0
    vlan protocol 802.1Q id 444 <REORDER_HDR,GVRP,LOOSE_BINDING>
      ingress-qos-map { 1:3 4:2 }
      egress-qos-map { 2:6 9:5 }
$ /usr/sbin/nl-link-list --details -i 28
em1.444 ether 3c:97:0e:18:2e:a1 <broadcast,multicast,up,running,lowerup> slave-of em1 group 0 vlan-id 444
    mtu 1500 txqlen 0 weight 0 qdisc noqueue index 28
    txq 1 rxq 1 brd ff:ff:ff:ff:ff:ff state up mode default carrier up
    vlan-info id 444 <reorder_hdr,>    vlan protocol <129>
      ingress vlan prio -> qos/socket prio mapping:
      1 -> 0x000003, 4 -> 0x000002,
      egress qos/socket prio -> vlan prio mapping:
      0x000002 -> 6, 0x000009 -> 5,
  ...

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-09-03 18:21:02 +02:00
Tobias Klauser
d3d610407d route/link: add missing link_attrs translations
Add LINK_ATTR_NSFD, LINK_ATTR_NS_PID and LINK_ATTR_LINK_NETNSID to the
link_attrs translation table after they were added in commits
760bfabad8cd ("add link netns support") and 66aab65595fb ("route/link:
add support for IFLA_LINK_NETNSID") respectively.

http://lists.infradead.org/pipermail/libnl/2015-August/001959.html

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-31 11:51:13 +02:00
Thomas Haller
eaa75b7c7d socket: fix assertion in nl_connect() when all ports are already in use
When generating a port fails a few times (because they are already in used
outside of libnl's knowledge), we would back off generating a local
port and instead let kernel decide.

There was however a bug in nl_connect() that caused an assertion:

    BUG at file position socket.c:147:_nl_socket_used_ports_release_all
    app: socket.c:147: _nl_socket_used_ports_release_all: Assertion `0' failed.

Fixes: 96e1e5bdc2e803700055395cc3c428fa2525d1ca
2015-08-24 18:01:42 +02:00
Thomas Haller
fa380b409a route/link: merge support for 'netnsid' (fixes)
Fix previous patches to have link_netnsid as signed int32_t.

http://lists.infradead.org/pipermail/libnl/2015-August/001941.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-17 23:02:39 +02:00
Thomas Haller
2fc97e66e7 route/link: make link_netnsid argument (signed) int32_t
Fixes: 66aab65595fb20bf166936fcfa4c8568b58f7f68

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-17 23:02:00 +02:00
Thomas Haller
7bb956501c lib/attr: add nla utility functions for s32
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-17 23:01:57 +02:00
Thomas Haller
8818a571e7 route/link: merge support for 'netnsid'
http://lists.infradead.org/pipermail/libnl/2015-August/001941.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-17 17:14:12 +02:00
Thomas Haller
66aab65595 route/link: add support for IFLA_LINK_NETNSID
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-17 17:13:54 +02:00
Thomas Haller
f808b84a5d include/linux: update copy of kernel header "if_link.h"
Taken from upstream kernel commit b953c0d234bc72e8489d3bf51a276c5c4ec85345
(v4.1), file 'include/uapi/linux/if_link.h' (after `make headers_install`).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-17 17:07:30 +02:00
Thomas Haller
fa47237cf5 lib/socket: in nl_socket_set_fd() always reset the local port
Even if the local port of @sk already equals to the port of
the file descriptor @fd, we want to release a possibly generated
port and set NL_OWN_PORT.

Fixes: 2d61e890379888907a93ddd0a04187b130629f6f
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 18:12:48 +02:00
Tobias Klauser
ffe58f3203 route/link: Remove unnecessary NULL check before release_link_info()
release_link_info() already check whether link->l_info_ops is not NULL
before accessing it, thus there is no need to do the same before calling
it.

http://lists.infradead.org/pipermail/libnl/2015-July/001929.html

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 16:12:49 +02:00
Thomas Haller
85b0038c8b socket: fix autogeneration of local ports for more then 1024 sockets
http://lists.infradead.org/pipermail/libnl/2015-June/001889.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 16:06:27 +02:00
Thomas Haller
96e1e5bdc2 socket: add fallback for nl_connect() by trying to bind to unspecified local port
libnl allows the user to explicitly set the local port before connecting
the socket. A more convenient way is to leave the local port unspecified
and let libnl generate a port id.

As it is, generate_local_port() would try at most 1024 ports, that
means if a user tries to connect more sockets, the automatism will
fail.

Kernel also supports choosing the local port itself (via netlink_autobind()).
So, this could be fixed by always leaving the port unspecified and let
kernel decide on the port. For that we could entirely drop generate_local_port().

There are however problems with that:

  - it is unclear why generate_local_port() was even introduced in the
    first place instead of always relying kernel. This code already
    appeared in libnl-1, so maybe there was a good reason for it or
    it is necessary on some kernel versions.

  - The deprecated libnl-1 library also uses a form of generate_local_port().
    Its first guess would always be getpid(), but the problem is that
    it would not retry on EADDRINUSE. Currently libnl-3 generates ports in
    a different sequence and will not generate a conflicting port (until it
    already exhausted 1016 other ports).
    Hence, currently if your application uses libnl1 and libnl3
    together, the automatism might just work without conflicts
    (commit 1f734a8f892abcd3f81637df4a089155aca1b66a).
    Accidently, kernel/netlink_autobind() also first tries the process
    id as port. That means, if we change libnl-3 to leave the decision
    to kernel, and
      - the application connects sockets both via libnl-1 and libnl-3
      - and the libnl-3 socket happens to connect first
    then the libnl-1 socket would fail to connect without retrying
    another port.

  - Removing generate_local_port() entirely changes behavior in the
    following case:

        sk = nl_socket_alloc();
        /* accessing local port before connecting the socket used to
         * freeze the local port to the generated value. */
        port = nl_socket_get_local_port(sk);
        nl_connect(sk, NETLINK_...);

Maybe the issues are minor and it would simplify the code just to get
rid of the cruft. But instead fix the issue without changing behavior.
Just keep trying with generate_local_port() first, before fallback to
kernel.

Reported-by: Julien Courtat <julien.courtat@6wind.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>

http://lists.infradead.org/pipermail/libnl/2015-June/001889.html
2015-08-14 16:04:15 +02:00
Thomas Haller
f78c3e8239 socket: clear port when unable to generate local port
When running out of local ports, _nl_socket_generate_local_port_no_release()
would leave the socket with port UINT32_MAX. That means if nl_connect()
fails due to out-of-ports, it would leave the port id assigned to an
invalid port and the socket instance was not re-usable until the user
called nl_socket_set_local_port(). Fix that by resetting the local port
to zero.

Thereby, also change generate_local_port() to return zero when
running out of ports. zero is a more natural value for ~no port found~.
It also matches the port that _nl_socket_generate_local_port_no_release()
uses when failing to generate a port.

Also ensure that zero cannot be returned as valid port by generate_local_port().
Arguably, that would only be possible if (getpid() & 0x3FFFFF)
returns zero. Just be extra cautious.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 15:51:26 +02:00
Thomas Haller
c38022898a lib/route: merge fixes to dump_details
http://lists.infradead.org/pipermail/libnl/2015-July/001933.html
http://lists.infradead.org/pipermail/libnl/2015-July/001932.html
http://lists.infradead.org/pipermail/libnl/2015-July/001931.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 15:25:31 +02:00
Steffen Vogel
6871a3b6ac route/qdisc: fixe printing whitespace in qdisc_dump_details()
And whitespace (source code) fix.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 15:24:34 +02:00
Thomas Haller
2b985e200b route/tc: use plain format string in rtnl_tc_dump_stats()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 15:19:07 +02:00
Steffen Vogel
ed4d891232 route/tc: improved statistics dump (just alignment)
9 digits for for B/s don't make sense to me. It's just breaks the alignment.

[thaller@redhat.com: whitespace fixes]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 15:19:07 +02:00
Steffen Vogel
5cd9cce1af route/qdisc: added more attributes to netem dump
I added all the netem attributes (except for limit) to the NL_DUMP_DETAILS section.

[thaller@redhat.com: whitespace fixes]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-08-14 14:55:02 +02:00
Jörg Krause
d0406d3838 lib/nl: add missing header
CMSG_NXTHDR requires <linux/socket.h>. This fix a build error with the musl
C library:

```
undefined reference to `__cmsg_nxthdr'
```

https://github.com/thom311/libnl/pull/83
2015-08-14 14:33:56 +02:00
Thomas Haller
d21790bf96 ipvlan: fix return error code for rtnl_link_ipvlan_get_mode()
rtnl_link_ipvlan_get_mode() was just introduced as new API. Fix the
error code to return -NLE_INVAL instead of -NLE_OPNOTSUPP.

http://lists.infradead.org/pipermail/libnl/2015-June/001921.html
2015-07-10 11:01:32 +02:00
Коренберг Марк
e29c979e88 nf: fix potential bug in nfnl_queue_msg_set_payload() when malloc() failed
Suppose the case:
1. message have already some payload
2. malloc() failed

In that case:
1. msg->queue_msg_payload become NULL
2. msg->queue_msg_payload_len stay non-zero

Now when malloc() error occurs, nothing changed.

https://github.com/thom311/libnl/pull/83
2015-07-10 10:06:21 +02:00
Thomas Haller
54e4ca7886 build: merge branch 'kolyshkin-build-cleanups'
https://github.com/thom311/libnl/pull/84
2015-07-09 22:49:19 +02:00
Kir Kolyshkin
4caa5cda2c doc/Makefile.am: don't use asciidoc if disabled
In case doc/configure.ac hasn't found asciidoc or any of its
prerequisites (such as pygmentize), make shouldn't try to run it.
One such case ("gendoc" target) is covered while the other
("%.html" target) is not. Fix it by adding a proper ifdef.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
2015-07-09 22:43:18 +02:00
Kir Kolyshkin
60ac492058 doc/configure.ac: simplify python check
A check for python binary that was originally introduced by commit
183e869 is needed because python is used for a couple of preprocessors
(doxygen-link.py and resolve-asciidoc-refs.py) and therefore it is
impossible to build docs without python.

While it is right to check for python, the check was both wrong and
excessive. Instead of just checking for python binary, it checked for
various versions of python and set a few variables that are not needed
here. More to say, the absense of python binary was not treated as
being fatal like it should.

Fix both problems by using AC_CHECK_PROG for python, terminating the
build in the same way as with doxygen absense. Also, remove the
m4/ax_python.m4 which is no longer needed.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
2015-07-09 22:43:18 +02:00
Kir Kolyshkin
d95915c9ce m4/ax*.m4: remove
These files, as well as the proper configure.ac calls, were added
by commit f443be6, but the calls were later removed by commit b4b853e,
so these are no longer needed.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
2015-07-09 22:43:18 +02:00
Kir Kolyshkin
dd5336992f m4/ax_python.m4: remove
This file is no longer needed since commit db13843 which copied it
to doc/ subdir and removed the call to AX_PYTHON from configure.ac.

That commit should have moved it rather than copied, let's fix it.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
2015-07-09 22:43:18 +02:00
matben2
34ccb7210f link: set ifi_change in link message
The ifi_change field can be set with the mask of the flags that need
to be changed as part of the link message to the kernel. This means only
the specific flags that have been changed will be modified in the kernel,
rather than the entire flags entry.

[thaller@redhat.com: add capability to indicate the change in behavior]

https://github.com/thom311/libnl/pull/86
2015-07-09 22:33:32 +02:00
Thomas Haller
371226b834 ipvlan: don't check for valid @mode argument in rtnl_link_ipvlan_set_mode()
In the future kernel might support more modes. Don't be so
strict in rtnl_link_ipvlan_set_mode() and accept any uint16
mode.
This way when adding new modes, rtnl_link_ipvlan_set_mode() does not
need to be changed.

If the user passes an invalid value and sends a message to the kernel,
it will be rejected there.

http://lists.infradead.org/pipermail/libnl/2015-June/001902.html

Fixes: 7de5be85bf9aa3eb9f022e4813226135e89adec2

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-26 18:06:06 +02:00
Thomas Haller
b4afcadc30 ipvlan: fix signature of rtnl_link_ipvlan_get_mode() to signal error
http://lists.infradead.org/pipermail/libnl/2015-June/001902.html

Fixes: 7de5be85bf9aa3eb9f022e4813226135e89adec2

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-26 18:04:34 +02:00
Thomas Haller
089a28212d neigh: merge branch 'neigh-typo'
https://github.com/thom311/libnl/pull/79
2015-06-26 17:20:59 +02:00
Thomas Haller
79effc5b35 neigh: accept "norarp" in rtnl_neigh_state2str()
Commit 6a9335f101e22cd5eaba4dfcf0a44e2c3097b4ab fixed a typo in the
string-to-flags conversion. At least for rtnl_neigh_str2state()
we want to continue to parse "norarp" for backward compatiblity.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-26 17:20:43 +02:00
Tobias Jungel
6a9335f101 neigh: fix type for NUD_NOARP flag in trans_tbl
Translate NUD_NOARP to "noarp", instead of "norarp".

https://github.com/thom311/libnl/pull/79

Fixes: 44d362409d5469aed47d19e7908d19bd194493a4

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-26 17:20:38 +02:00
Thomas Haller
12e87e444d ipvlan: merge branch 'add-ipvlan'
http://lists.infradead.org/pipermail/libnl/2015-June/001902.html
2015-06-19 18:04:50 +02:00
Cong Wang
f99d48cc40 ipvlan: add a testcase for ipvlan
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-19 18:03:59 +02:00