Commit graph

730 commits

Author SHA1 Message Date
f24c9ba26a route/tc: improved statistics dump (just alignment) 2015-07-19 16:25:40 +02:00
82e0a27f58 route/qdisc: added more attributes to netem dump 2015-07-19 16:24:50 +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
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: 7de5be85bf

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: 7de5be85bf

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-26 18:04:34 +02:00
Thomas Haller
79effc5b35 neigh: accept "norarp" in rtnl_neigh_state2str()
Commit 6a9335f101 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: 44d362409d

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-26 17:20:38 +02:00
Cong Wang
7de5be85bf ipvlan: add ipvlan support
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-19 18:03:55 +02:00
Thomas Haller
a9c789ccd4 lib: fix spelling of NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK
Instead of NL_CAPABILITY_NL_RECV_FAIL_TRUNK_NO_PEEK.

Fixes: bbdcaea9a7

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-05 11:28:59 +02:00
Thomas Egerer
bbdcaea9a7 lib: return error if an incomplete message was read
If recvmsg indicates that the message read was truncated libnl retries
to read the complete message after increasing the message buffer. This
only works if the message flags MSG_PEEK | MSG_TRUNC are set. If
NL_MSG_PEEK is not enabled on the nl_sock structure, flags are left
empty and the rest of the truncated message is discarded, hence a
subsequent recvmsg returns the next message (in case of a multipart
message, the NLMSG_DONE) is read and returned.
This patch aborts message processing if the message was truncated and
the NL_MSG_PEEK flags was not activated for the nl_sock structure.

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

[thaller@redhat.com: add NL_CAPABILITY_NL_RECV_FAIL_TRUNK_NO_PEEK]

Signed-off-by: Thomas Egerer <hakke_007@gmx.de>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-05 08:40:02 +02:00
Thomas Haller
e206c255d8 utils: add missing link layer protocol translations
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-04 23:06:24 +02:00
Tobias Klauser
1dbe738e1e utils: update link layer protocol translations
Update the private copy of linux/if_arp.h and hook up the not yet
defined ARPHRD_* types in the llprotos translation table. Reorder the
entries such that they correspond to the order they're defined in
linux/if_arp.h. Also remove the #ifdef guards since these are
unnecessary given that the private copy of the kernel header is used.

http://lists.infradead.org/pipermail/libnl/2015-May/001883.html

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-04 23:06:09 +02:00
Thomas Haller
75dcd01756 route/link: fix memleaks in link_msg_parser()
http://lists.infradead.org/pipermail/libnl/2015-May/001880.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-06-04 22:49:56 +02:00
Thomas Haller
4818248634 lib/doc: clearify return value of send_simple() functions
The return value of the *nl_send_simple() functions is
inconsistent and not according to the documentation.

nl_send_simple() is document to return the number of bytes sent.
Other *nl_send_simple() functions are documented to return 0 on
success -- for the most part.
See also commit b70174668b which
changed behavior of nl_rtgen_request() to be according to documenation.

Don't change behavior again, only adjust the documentation.

http://lists.infradead.org/pipermail/libnl/2015-May/001872.html

Reported-by: Xiao Jia <stfairy@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-05-12 15:56:50 +02:00
Thomas Haller
c3dd6a7355 xfrm: trival refactoring initialization of stack-allocated arguments to nl_send_simple()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-05-12 14:56:57 +02:00
Tobias Klauser
4e115113c9 xfrm: fix potential NULL dereference
If xfrmnl_sel_alloc() returns NULL, the daddr and saddr members are
still accessed, leading to a potential NULL dereference. The same is the
case for xfrmnl_user_tmpl_alloc(). Fix this by returning NULL right away
if allocation fails.

http://lists.infradead.org/pipermail/libnl/2015-May/001874.html

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-05-12 13:14:26 +02:00
Tobias Klauser
a214e75457 route/tc: remove unnecessary check for tc_kind member of struct rtnl_tc
The tc_kind member of struct rtnl_tc (and all types which can be
converted to it) is defined as an array and can thus never be
NULL.

http://lists.infradead.org/pipermail/libnl/2015-April/001869.html

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-05-05 16:14:20 +02:00
Tobias Klauser
6af196f03f utils: Add translations for NETLINK_RDMA and NETLINK_CRYPTO
Add translations for NETLINK_RDMA and NETLINK_CRYPTO to nlfamilies,
allowing to use nl_nlfamily2str() and nl_str2nlfamily() for these
families.

This makes it necessary to update the private copy of linux/netlink.h
and also includes the rename of NETLINK_INET_DIAG to NETLINK_SOCK_DIAG
in upstream commit 7f1fb60c4fc9fb29 ("inet_diag: Partly rename inet_ to
sock_") and the removal of the duplicate NLMSG_ALIGN in the
NLMSG_LENGTH() macro in upstream commit a88b9ce5ad4fc633 ("netlink:
remove duplicated NLMSG_ALIGN").

http://lists.infradead.org/pipermail/libnl/2015-April/001868.html

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-05-05 16:04:57 +02:00
Thomas Haller
8f5c65beee libnl-3.2.26 release
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-30 13:17:17 +02:00
Jonas Johansson
31d7d19393 neigh: add support for NDA_VLAN nl attribute
[thaller@redhat.com: modified patch to parse NDA_VLAN and diff vlan]

http://lists.infradead.org/pipermail/libnl/2015-March/001861.html

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-23 09:27:23 +01:00
Thomas Haller
c242e25c45 route/link: fix indention in inet6_dump_details()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-22 20:55:59 +01:00
Thomas Haller
860ea27a46 utils: add code comment about capability number assignment
Also reserve a range of capabilities (0x7000 to 0x7FFF) that we won't
use upstream. Add a macro NL_CAPABILITY_IS_USER_RESERVED() to check
if the capability is in that range.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-19 12:26:53 +01:00
Thomas Haller
24d333075a lib/socket: detect protocol in nl_socket_set_fd()
With support for socket option SO_PROTOCOL we don't need the protocol
argument to nl_socket_set_fd(). Maybe we should drop the protocol argument
and just not support nl_socket_set_fd() on older systems. But instead
keep the argument and allow passing -1 to autodetect it.

If the user sets a protocol option, we check via getsockopt() that the
value is correct and error out otherwise.

On older kernels, the user must set the value. Otherwise
nl_socket_set_fd() will fail.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-06 12:57:43 +01:00
Thomas Haller
a9c879abbe build: fix path to linker version scripts for out-of-tree build
Fixes: e7d57da0dd

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-05 19:11:27 +01:00
Thomas Haller
2d61e89037 lib/socket: add nl_socket_set_fd() function
This is based on the patch by sagil@infinidat.com, but heavily modified.

Add a function nl_socket_set_fd(), I renamed it from nl_connect_fd().

Now nl_connect() and nl_socket_set_fd() are implemented independently as
they share little code. But they have similar functionality:
to initialize a libnl socket and set it's file descriptor.

A user who wants libnl to setup the socket can continue to use nl_connect().
A user with special requirements should setup the socket entirely. That includes
calling socket() (with or without SOCK_CLOEXEC), bind(), setting buffer size.

For the same reason I dropped nl_create_fd(). It didn't do much more then
calling socket() -- which the user can do directly.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-05 12:10:28 +01:00
Sagi Lowenhardt
f91e6959ea add socket nl_connect_fd() & nl_create_fd()
-    Added option to create socket (fd) without bind.
     It is now possible to forward the socket fd to another child process...
     ...later use nl_connect_fd() to connect to socket from the child process.

-    Added option to disable CLOEXEC even if defined (in socket.h)
     'nl_socket_enable_cloexec' & 'nl_socket_disable_cloexec'
     No change to current default behavior.

 Signed-off-by: Sagi Lowenhardt <sagil@infinidat.com>
2015-03-05 11:27:27 +01:00
Thomas Haller
9614acf4c4 lib/nl: preserve s_local if nl_connect() fails
s_local.nl_pid is used to track the generated port unless NL_OWN_PORT is set.
Ensure that getsockname() doesn't overwrite the value and possibly reset
the local port manually to release the generated port.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-05 11:26:22 +01:00
Thomas Haller
15824e4273 lib/socket: remove NL_SOCK_BUFSIZE_SET socket flag
The flag was not actually used.

NL_SOCK_BUFSIZE_SET was only set by nl_socket_set_buffer_size().
Note that you can only call nl_socket_set_buffer_size() on a socket that
is already connected via nl_connect().

On first call, nl_connect() would always see NL_SOCK_BUFSIZE_SET unset, and
call nl_socket_set_buffer_size().

Since the flag was never unset, when trying to connect a socket a second
time, we would not set the buffer size again. Which was a bug.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-05 11:25:20 +01:00
Cong Wang
d8f080d94f cls: add rtnl_u32_get_classid() API
[thaller@redhat.com: modified patch to use rtnl_tc_data_peek()]

http://lists.infradead.org/pipermail/libnl/2015-March/001841.html

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-04 20:31:37 +01:00
Thomas Haller
e89aec9bc1 route/tc: add internal rtnl_tc_data_peek() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-04 14:55:38 +01:00
Cong Wang
df25df5857 act: correct file path for mirred.c
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-25 10:07:55 +01:00
Lubomir Rintel
6ea5230690 build: fix parallel make
Add missing inter-library dependencies.

Fixes: e7d57da0dd

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-18 14:25:59 +01:00
Lubomir Rintel
f545295104 lib: log errors from platform
nl_syserr2nlerr() reduces a lot of platform errors to NLE_FAILURE --
"Unspecific failure" which makes it somehow hard to track down the real reason
behind a failure.

Logging them with level of 4 makes it a little less painful.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-17 13:34:01 +01:00
Rohan Joyce
6f891f6c0c lib: add const-ness to appropriate parameters in addr, attr, data
This patch changes the signatures of some functions to allow const pointers in
places where a const qualified pointer is enough access for what the function
does (e.g. nla_get_u8). It also changes some functions that take a pointer
parameter and return a pointer derived from it to use the strchr idiom.

This is not exhaustive in terms of places where const can be added, but it's
a decent chunk that should not make the external api any more restrictive.

http://lists.infradead.org/pipermail/libnl/2015-February/001826.html

Signed-off-by: Rohan Joyce <rojoyce.github@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-16 11:20:18 +01:00
Cong Wang
e75a1c373a route/tc: add rtnl_tc_stat2str() and rtnl_tc_str2stat()
[thaller@redhat.com: add symbols to libnl-route-3.sym]

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-02 18:22:47 +01:00
Cong Wang
6d5b9ab8ae route/act: add skbedit action
[thaller@redhat.com: changed whitespace and libnl-route.sym]

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-02 18:16:11 +01:00
Thomas Haller
e7d57da0dd build: add individual linker version scripts for shared libraries
Instead of using a shared version script 'libnl.sym', add individual
linker scripts for all libnl libraries.

For now, the content of the version script is unchanged and this
patch does not have any externally visible changes.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-02 17:28:06 +01:00
Thomas Haller
3a8d6cfd56 idiag: fix set of identifying properties for idiag_msg_obj
The key for a struct idiag_msg_obj should be
'family x src x dst x sport x dport'.

http://lists.infradead.org/pipermail/libnl/2014-November/001768.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 16:57:28 +01:00
Thomas Haller
1c61ac3f4e idiag: fix idiagnl_compare() to compare all attributes
This is not important for nl_object_identical() which only considers
the required attributes. But for using nl_object_diff() or nl_object_filter(),
all attributes must be compared.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 16:55:27 +01:00
Thomas Haller
f4020ebde5 idiag: make objects 'idiag_vegasinfo' and 'idiag_meminfo' comparable
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 16:55:15 +01:00
Thomas Haller
9d4bc0345a idiag: don't dump unset properties of idiag_msg
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 16:50:46 +01:00
Thomas Haller
a60b3e46e7 route/addr: consider CACHEINFO in addr_compare()/nl_object_diff()
Indicate this change of behavior with the capability
NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO.

This is a behavioral change as we now consider an additional
field when comparing addresses.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 12:53:38 +01:00
Thomas Haller
b5a6d365e4 object: fix returning UINT_MAX for uint32_t in nl_object_diff()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 12:00:41 +01:00
Thomas Haller
b54775d316 route/link: return -NLE_OPNOTSUPP in rtnl_link_get_kernel() for old kernels
Older kernels without patch a3d1289126e7b14307074b76bf1677015ea5036f do
not support rtnl_getlink() by ifname. Detect this situation and fail
with -NLE_OPNOTSUPP instead of -NLE_INVAL.

This changes behavior in returning a different error code for this
case.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 10:34:57 +01:00
Thomas Haller
8b023fd441 nl: add function nl_pickup_keep_syserr()
nl_pickup() converts error codes from netlink into
nl error codes using nl_syserr2nlerr(). The latter function
mangles different error codes to the same nl error code.

Add a new function, that returns both the nl error code
and the original error code.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 10:24:03 +01:00
Thomas Haller
16d16b9a76 trival: white space fix in lib/nl.c
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 10:24:03 +01:00
Thomas Haller
f0e3017d0e idiag: fix idiagnl_exts2str()
idiagnl_exts2str() is used to print req->idiag_ext,
which is the extention types combined as flags, such as
( (1 << (INET_DIAG_TOS - 1)) | (1 << (INET_DIAG_MEMINFO - 1)) ).

This function was wrong from the beginning because the string lookup
array had indexes such as 'INET_DIAG_TOS', instead of '(1 << (INET_DIAG_TOS - 1)'.

Fix also idiagnl_attrs2str() which now converts an extension
type (e.g. INET_DIAG_TOS) to a string. Still this function is
deprecated, as the function name is not clear and it is not
used or very useful.

Fixes: 22eb2569a5
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-25 12:28:29 +01:00
Thomas Haller
91e61c8f05 idiag: add missing enum types for idiagnl_exts2str()
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-25 12:28:29 +01:00