Commit Graph

1054 Commits

Author SHA1 Message Date
Thomas Haller
c7ae0c7d67 python: fix package meta data in setup.py
http://lists.infradead.org/pipermail/libnl/2015-January/001802.html

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-01-12 14:17:38 +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
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
bf4b042ed1 idiag: merge branch 'idiag-compare-all'
oo_compare() is also relevant for nl_object_diff() and nl_object_filter().
Compare all fields so that comparing idiag_meminfo_obj works properly.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 16:57:08 +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
cb75576df0 route: merge branch 'route-link-get-kernel-opnotsupp'
http://lists.infradead.org/pipermail/libnl/2014-November/001769.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-27 10:36:13 +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
cc474698b8 idiag: merge branch 'idiag-exts2str-fix'
http://lists.infradead.org/pipermail/libnl/2014-November/001762.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-25 12:31:40 +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
Thomas Haller
77771ba26f cache: assert in nl_cache_mngt_register() for valid oo_keygen() function
oo_keygen() requires oo_compare(). Assert in nl_cache_mngt_register().

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

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-25 10:44:26 +01:00
Thomas Haller
60ad8251f8 idiag: merge branch 'idiag-fixes'
Deprecate all of the IDIAG_* defines in 'idiagnl.h'.
Names exposed by libnl should have the prefix IDIAGNL_*
instead.

But actually, most of these values were copies from other
system headers. The user should instead use the original defines
anyway.

Also, several fixes of the idiag_msg_obj, which had a broken
oo_clone() function and missing oo_compare().

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:46:47 +01:00
Thomas Haller
fac840d1f3 idiag: add a oo_compare() function for idiag_msg objects
Having a oo_keygen() function only makes sense together with a
oo_compare() function because after hashing, you still have to compare
the objects for equality (in case of hash collission).

Fixes: 9c066b9271
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:44:47 +01:00
Thomas Haller
8eea9e927f idiag: add change attributes for idiag_msg_obj
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:39:27 +01:00
Thomas Haller
2ee5cf55f3 idiag: remove clone functions from trivial structures
A oo_clone() function is only needed for complex sturctures
to deep copy an object.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:39:27 +01:00
Thomas Haller
39ca54ab4d idiag: fix idiagnl_msg_clone()
For one, we did not clone all pointer values. Hence, every cloned
object was very broken and resulted in dangling pointers and
double free/unref.

Apparently nobody was really using this function up to now.

Also, fix the return cases for NLE_NOMEM, so that we did not assume
ownership of pointers in 'src'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:36:52 +01:00
Thomas Haller
f40fd71701 idiag: fix memory leak in idiagnl_msg_set_cong()
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
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
fffc7ecedd idiag: fix out of bound error parsing idiag messages
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
Thomas Haller
5fbd45e667 route: merge branch 'route-tc-fixes'
http://lists.infradead.org/pipermail/libnl/2014-November/001738.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:23:14 +01:00
Thomas Haller
703989eb12 route: make rtnl_tc_clone() more robust against NLE_NOMEM
When oo_clone() fails, the new object is freed. Make sure 'dst'
does not own parts of 'src'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:21:59 +01:00
Thomas Haller
24ad51518f route: set missing TCA_ATTR_XSTATS changes flags in rtnl_tc_msg_parse()
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:21:20 +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
Cong Wang
9c066b9271 idiag: provide a hash function for idiag objects
Without ->oo_keygen, libnl will use linear search
for cache objects. This is extremely slow for idiag
when we have a lot of TCP connections. Provide a
hash function for idiag so that libnl will be able
to lookup a hashtable.

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

Cc: Thomas Graf <tgraf@suug.ch>
Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 10:49:34 +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
15178401c2 route/cls: merge branch 'route-cls-u32-match-mark'
http://lists.infradead.org/pipermail/libnl/2014-November/001699.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:32:41 +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
Thomas Haller
d65c32a720 link: fix memory leaks due to repeated calls to .io_alloc()
All the io_alloc() implementation unconditionally allocated
new memory, thus leaking memory if called more then once.
Fix io_alloc() implementations not to allocate new memory
if not needed.

This happens for example in link_msg_parser() which first
calls rtnl_link_set_type():

    #0  macvlan_alloc (link=0x609d50) at route/link/macvlan.c:56
    #1  0x00007ffff7b99a78 in rtnl_link_set_type (link=link@entry=0x609d50, type=type@entry=0x609a94 "macvlan") at route/link.c:2233
    #2  0x00007ffff7b99c28 in link_msg_parser (ops=<optimized out>, who=<optimized out>, n=<optimized out>, pp=0x7fffffffd870) at route/link.c:547
    #3  0x00007ffff7dea109 in nl_cache_parse (ops=0x7ffff7dd8600 <rtnl_link_ops>, who=0x603338, nlh=0x6098a0, params=0x7fffffffd870) at cache.c:914
    #4  0x00007ffff7dea15b in update_msg_parser (msg=<optimized out>, arg=<optimized out>) at cache.c:668
    #5  0x00007ffff7def7bf in nl_cb_call (msg=<optimized out>, type=<optimized out>, cb=<optimized out>) at ../include/netlink-private/netlink.h:142
    #6  recvmsgs (cb=0x6057a0, sk=0x6034c0) at nl.c:952
    #7  nl_recvmsgs_report (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1003
    #8  0x00007ffff7defb79 in nl_recvmsgs (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1027
    #9  0x00007ffff7de9668 in __cache_pickup (sk=0x6034c0, cache=0x603510, param=param@entry=0x7fffffffd870) at cache.c:701
    #10 0x00007ffff7dea08d in nl_cache_pickup (sk=<optimized out>, cache=<optimized out>) at cache.c:753
    #11 0x0000000000400d56 in main ()

and later ops->io_parse():

    #0  macvlan_alloc (link=0x609d50) at route/link/macvlan.c:56
    #1  0x00007ffff7baae9d in macvlan_parse (link=0x609d50, data=<optimized out>, xstats=<optimized out>) at route/link/macvlan.c:79
    #2  0x00007ffff7b99c80 in link_msg_parser (ops=<optimized out>, who=<optimized out>, n=<optimized out>, pp=0x7fffffffd870) at route/link.c:567
    #3  0x00007ffff7dea109 in nl_cache_parse (ops=0x7ffff7dd8600 <rtnl_link_ops>, who=0x603338, nlh=0x6098a0, params=0x7fffffffd870) at cache.c:914
    #4  0x00007ffff7dea15b in update_msg_parser (msg=<optimized out>, arg=<optimized out>) at cache.c:668
    #5  0x00007ffff7def7bf in nl_cb_call (msg=<optimized out>, type=<optimized out>, cb=<optimized out>) at ../include/netlink-private/netlink.h:142
    #6  recvmsgs (cb=0x6057a0, sk=0x6034c0) at nl.c:952
    #7  nl_recvmsgs_report (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1003
    #8  0x00007ffff7defb79 in nl_recvmsgs (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1027
    #9  0x00007ffff7de9668 in __cache_pickup (sk=0x6034c0, cache=0x603510, param=param@entry=0x7fffffffd870) at cache.c:701
    #10 0x00007ffff7dea08d in nl_cache_pickup (sk=<optimized out>, cache=<optimized out>) at cache.c:753
    #11 0x0000000000400d56 in main ()

https://github.com/thom311/libnl/issues/59

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 19:35:46 +02: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 Haller
1e3f316081 build/trivial: prettify makefiles by wrapping long lines
Signed-off-by: Thomas Haller <thaller@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
2014-09-24 16:00:26 +02:00
Cong Wang
a2b9f33fd4 idiag: fix a typo in idiagnl_req_set_ifindex()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 07:50:25 +02:00
Sébastien Barré
1578095b8a build: generate libnl-idiag-3.0.pc
That file was not generated due to a missing line in Makefile.am
and configure.ac

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

Signed-off-by: Sébastien Barré <sebastien.barre@uclouvain.be>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-22 11:06:05 +02:00
Thomas Haller
cea532d296 Merge branch 'enovance-sa_fixup'
https://github.com/thom311/libnl/pull/62

[thaller@redhat.com: I changed the original patches
 to indent with tabs (vs. spaces) and reworded the
 commit messages.]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 13:27:33 +02:00
Nicolas PLANEL
592d665fbc cls: check data before memcpy() it
[thaller@redhat.com: I modified the condition "if (data && len)"
 in the original patch to just check "len > 0".
 Note that all call sites of meta_alloc() make sure to pass a
 valid data pointer with a non-zero length (anything else would
 be a bug). But indeed, calling memcpy with invalid src pointer
 is undefined behavior, even if len is zero.]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 13:22:22 +02:00
Nicolas PLANEL
06140c3ec9 xfrm: fix xfrm_sa_msg_parser() to return the value from the callback
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 13:00:46 +02:00