Commit graph

389 commits

Author SHA1 Message Date
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
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
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
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
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
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
David Chappelle
50a76998ac route: remove unnecessary include of private linux/if.h
Including linux/if.h in netlink/route/link.h causes issues
in cases where libnl is used in conjuntion with other third
party libraries that include net/if.h. Seems to be a long
checkered history of symbol collisions between these two
files. As it turns out, including linux/if.h from within
netlink/route/link.h is actually unecessary. I resurrected
a forgotten path from this thread:

    http://lists.infradead.org/pipermail/libnl/2012-April/000525.html

By removing the include as the patch suggests we can get
around the nuissance of the symbol collisions.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-17 10:07:49 +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
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
Thomas Haller
364ab3daf6 dbg: save errno from modification in NL_DBG()
Evaluating the logging statement might overwrite the errno. Save and
restore it so that NL_DBG() preserves the errno.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-05 10:30:24 +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
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
b56f88c9b3 build: mark header linux-private/linux/veth.h as noinst_HEADERS
Fixes: 9dc6e6da90
2014-12-09 17:57:17 +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
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
0e13bb44b8 idiag: reorder idiagnl.h to have deprecated functions at the top
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
6bf68e60e4 idiag: deprecate IDIAG_TIMER_* value for IDIAGNL_TIMER_*
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
94039ca48a idiag: deprecate IDIAG_SS_* socket states
These values mirror TCP_* socket states from 'netinit/tcp.h'.
There is no good reason to expose a copy of those values.
User space should use the original values (if they care).
The only value that is actually useful is IDIAGNL_SS_ALL.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
3b5226e3a2 idiag: deprecate netlink message type defines in idiagnl.h
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
22eb2569a5 idiag: deprecate IDIAG_ATTR_* enumeration
IDIAG_ATTR_* were a copy of the INET_DIAG_* extension kernel
flags. Redefining them is wrong, user space should continue
to use the values provided via the kernel headers.

Also they were misused as change flags (ce_mask), which they are not.

Deprecate the IDIAG_ATTR_* flags and redefine them to what the
originally are: INET_DIAG_*.

Also deprecated idiagnl_attrs2str() because there is already
idiagnl_exts2str(). idiagnl_attrs2str() in the sense of libnl change
flags (ce_mask) makes no sense.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
cd8cd2dae2 idiag: deprecate idiagnl_msg_obj_ops variable in public API
This internal structure should never have been exposed publically.
It as introduced as public API in v3.2.23.

For now, don't remove it as it would be an API/ABI break.

Fixes: 81d2b1d509
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
a3c0c04eff idiag: add copy of kernel header include/linux/inet_diag.h
Taken from upstream kernel commit bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9
(v3.17), file 'include/uapi/linux/inet_diag.h'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Cong Wang
b54f6d8023 idiag: add a copy of linux/sock_diag.h
When we test idiag on 3.4 kernel, we always get ERANGE.
This is because libnl has its own copy for SK_MEMINFO_*,
which is actually newer than 3.4, where SK_MEMINFO_VARS
is larger than kernel's.

We add a copy from latest kernel, so on older kernel
libnl should still compile. Note, for kernel < 3.6
we don't have SK_MEMINFO_BACKLOG, we have to relax
the minlen.

'sock_diag.h' comes from v3.17 kernel sources
(bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9), file
'include/uapi/linux/sock_diag.h'.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 13:21:15 +01:00
Holger Eitzenberger
0020ba1212 cache: avoid duplicate check on initial dump
The cache pickup does a check for duplicates for some time now.

However, the pickup in nl_cache_refill() explicitely clears the
cache, so the pickup doesn't need to actually do the dupe check,
as uniqueness is already guaranteed be Netlink subsystem.

And avoiding the dup check is beneficitial for performance
reasons, as the current algorithm is O(n^2).

http://lists.infradead.org/pipermail/libnl/2014-October/001680.html

Fixes: 96bb7c9a4c
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:58:13 +01:00
Thomas Haller
8759c20beb route/cls: minor fixes in for match mark filters
- whitespace
- fix newline and whitespace in output of u32_dump_details()
- let rtnl_u32_del_mark() clear U32_ATTR_MARK

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:32:29 +01:00
Sagi Lowenhardt
3844b15d73 route/cls: support 'match mark' u32 filters
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:28:55 +01:00
Lubomir Rintel
b0d0d339cd link/inet6: add support for tokenized interface identifiers
http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

[thaller@redhat.com: Add OOM handling, fix whitespace issues]

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

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-08 16:47:43 +02:00
Jörg Krause
e003951945 netlink/netlink.h: fix build including <poll.h> with the musl C library
https://github.com/thom311/libnl/pull/64

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-30 09:33:46 +02:00
Thomas Haller
d6f761bc4e build: move copy of linux headers to private directory
libnl3 contains a private copy of some kernel header files.

Normally, users are expected to install libnl and specify
-I$PREFIX/include/libnl3 as include path. As the private kernel
header files are not installed, this works fine.

However, it can be convenient to build against the libnl source
directory, without installing libnl. In this case, the private kernel
header files shaddow the system provided ones. This is undesired.

Move these files to a different directory to avoid this clash.

http://lists.infradead.org/pipermail/libnl/2014-September/001645.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
2014-09-24 16:00:31 +02:00
Thomas Graf
da80033c2f nf: nfnl_*_str2copy_mode() should return int
... to be able to return a negative error code for unknown modes.

[thaller@redhat.com: This is potentially an ABI break, but since
the size of the enum is implementation defined, it seems
anyway unstable to have them as function arguments/return values.]

http://lists.infradead.org/pipermail/libnl/2014-August/001616.html

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 13:03:30 +02:00
Cong Wang
cacc24ea66 qdisc: add hfsc qdisc support
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 19:03:56 +02:00
Cong Wang
f904fabcb4 tc: save error code for rtnl_tc_data_check()
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 19:03:50 +02:00
Dan Williams
558f966782 link/inet6: add link IPv6 address generation mode support
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 18:45:51 +02:00
Dan Williams
b51815a9db link: update copy of kernel header include/linux/if_link.h
The next patch will use some of these defines, so update.

Taken from upstream kernel commit bc91b0f07ada5535427373a4e2050877bcc12218,
file 'include/uapi/linux/if_link.h'.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 00:39:24 +02:00
Thomas Graf
99050f2248 cache: Declare nl_cache_ops_set_flags()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 11:04:07 +02:00
Thomas Graf
17f1c386df act: Declare rtnl_act_change()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 11:04:07 +02:00
Thomas Graf
a1593c234a neightbl: Declare rtnl_neightbl_set_gc_interval()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 11:04:07 +02:00
Thomas Graf
a13010435a link/ip6tnl: Declare rtnl_link_is_ip6_tnl()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 11:04:07 +02:00
Thomas Graf
69dd5ecea9 htb: Declare rtnl_htb_set_level()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 11:04:07 +02:00
Thomas Haller
fc249f81c7 style: require comma after __ADD() macro
$ sed -i 's/^\([\t ]\+\<__ADD\> \?([^)]\+)\) *$/\1,/' `git grep -w -l __ADD`

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 10:57:31 +02:00
Dan Williams
9dc6e6da90 veth: add kernel header linux/veth.h for VETH defines
Similar to what's done with <linux/if_link.h>, make sure used defines
actually exist.  Otherwise building on even slightly older kernels
fails.

Taken from upstream kernel commit 1860e379875dfe7271c649058aeddffe5afd9d0d
(tag: v3.15), file 'include/uapi/linux/veth.h'.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-25 22:37:41 +02:00