Thomas Graf [Wed, 29 Aug 2012 10:05:51 +0000 (12:05 +0200)]
Fix build warning after const char ** convert
Commit 25d640da4a caused the following build warning:
../include/netlink/utils.h:47:15: note: expected 'const char **' but argument is of type 'char **'
route/link/inet6.c:300:11: warning: passing argument 2 of 'nl_cancel_down_bytes' from incompatible pointer type [enabled by default]
Коренберг Марк [Fri, 8 Jun 2012 14:15:06 +0000 (20:15 +0600)]
Fix types-related warnings based on clang diagnostics
1. Fix some places where unsigned value compared < 0
2. Fix obsolete %Z specifier to more portable %z
3. Some erroneous types substitution
4. nl_msec2str() - 64-bit msec is now properly used,
Only safe changes. I mean int <--> uint32_t and signed/unsigned fixes.
Some functinos require size_t argument instead of int, but changes of
signatures of that functions is terrible thing.
Also, I do not pretend for a full list of fixes.
Just to shut up clang -Wall -Wextra
One more thing. ifindex. I don't change that because changes will
be too big for simple fix.
Andrew Collins [Mon, 11 Jun 2012 16:44:42 +0000 (10:44 -0600)]
Add 'ingress' to the list of recognized TC handles.
Currently, rtnl_tc_handle2str understands the ingress handle but
rtnl_tc_str2handle does not. This change lets rtnl_tc_str2handle
recognize 'ingress' as a valid handle as well.
Flags properties description and implementation fixed
1. Address, Link and Vlan classes affected with same bug
2. Flags property are not designed as set class. Setting to property will
not replace flags, just add flags to set. So, jist document that, and
fixed obvious logick.
Neil Horman [Fri, 1 Jun 2012 16:59:24 +0000 (12:59 -0400)]
genl: modify genl_ctrl_resolve and friends to allow for module auto-loading
Generic netlink has the ability to autoload modules in response to a request for
a family. Currently libnl uses a GETFAMILY call with the NLM_F_DUMP flag to
list all the available families, but doing so neglects the possibility of an
autoloaded module. This patch modifies the genl code to probe the kernel for a
specific family rather than dumping a list of all the currenlty available ones,
making autoload work properly.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Thomas Graf <tgraf@redhat.com>
Thomas Graf [Fri, 1 Jun 2012 09:48:08 +0000 (11:48 +0200)]
genl: Support registration of families without depending on caches
Introduces the functions genl_register_family() and
genl_unregister_family() to register a Generic Netlink family
which does not implement a cachable type.
API users can direct received messages into genl_handle_msg() which
will validate the messages and call the callback functions defined
in the commands definition.
See test/test-genl.c for an example on how to use it.
Thomas Graf [Thu, 31 May 2012 11:37:57 +0000 (13:37 +0200)]
genl: Add genlmsg_user_hdr(), genlmsg_user_data(), and genlmsg_user_datalen()
These functions deprecate the function genlmsg_data() which did not
allow to specify the length of the user header. Use of the new API
will make code much clearer. The old function is still kept around
for backwards compatibility but marked deprecated in the API reference.
Andrew Collins [Sat, 26 May 2012 00:08:06 +0000 (18:08 -0600)]
correct HTB rtable/HZ calculations
The HTB implementation in libnl uses units of microseconds in a number
of places where it seems TC is expecting time in units of ticks, which
causes actual rates much higher than requested. Additionally, libnl
uses USER_HZ for calculating buffer and cbuffer sizes, which can
result in much larger buffers than necessary on systems with high
resolution timers.
Note that the TBF qdisc uses microseconds incorrectly in two spots as
well, I fixed this but did not test.
A C [Fri, 25 May 2012 19:45:45 +0000 (13:45 -0600)]
add fwmark mask support
The fw classifier allows a mask to be set, which is necessary for some
complex shaping/firewall scenarios. The attached patch adds support
for it to libnl.
Bushman, Jeff [Wed, 16 May 2012 15:50:25 +0000 (11:50 -0400)]
Fix for dumping objects to a buffer instead of file descriptor
Attached is a patch to fix two problems with dumping objects to a buffer in=
stead of a file descriptor.
One was a problem in detecting the end of the buffer in the newline code.
The other was a problem with clearing the whole buffer before printing each=
object.
Isaac [Sun, 13 May 2012 05:37:48 +0000 (22:37 -0700)]
FTBFS with musl libc: Missing includes
Hello,
libnl 3.2.9 does not build with musl libc, without patching.
I' using a current musl libc (http://www.etalabs.net/musl/)
with linux 2.6.32 headers.
At first there were a couple problems on the musl side, but those are
resolved.
However, I found some other issues:
First, two files were missing
#include <byteswap.h>:
lib/netfilter/log_msg.c
lib/netfilter/queue_msg.c
These files used __bswap_64 (which should be bswap_64), a macro
declared in byteswap.h
Second, I got this error after fixing that:
In file included from nf-queue.c:16:
./include/linux/netfilter.h:53: error: field in has incomplete type
./include/linux/netfilter.h:54: error: field in6 has incomplete type
I found that src/nf-queue.c is missing an
#include <netinet/in.h>
Attached is a patch which resolves these issues. I've tested with both
musl and glibc, and it builds cleanly on both.
Thomas Graf [Thu, 10 May 2012 10:03:59 +0000 (12:03 +0200)]
doc: documentation restructuring
- changes the modules hierarchy to better represent the set of libaries
- list the header file that needs to be included
- remove examples/doc from api ref that is included in the guide
- add references to the guide
- fix doxygen api linking for version 1.8.0
- readd doxygen mainpage to config file
- fix a couple of doxygen doc bugs
Justin Mayfield [Thu, 10 May 2012 03:08:30 +0000 (21:08 -0600)]
__str2flags fix
I found a minor bug in __str2flags where empty strings or short strings
will match all or many flags respectively. Basically the test needs to
ensure the test string is the same length as the table entry before
doing a strncasecmp to avoid doing just a prefix test.
Thomas Graf [Wed, 9 May 2012 13:02:40 +0000 (15:02 +0200)]
doc: add section about addressing
Adds a new section to netlink fundamentals explaining the common
addressing use cases and illustrates kernel->user, user->user,
and user->kernel communication.
Thomas Graf [Wed, 9 May 2012 08:06:24 +0000 (10:06 +0200)]
doc: Check documentation generation requirements with autoconf
Adds --enable-doc/--disable-doc, if omitted doc will only be build
if requirements are met. If explicitely enabled, configure script
will fail if requirements are not met.
Thomas Graf [Tue, 8 May 2012 20:48:00 +0000 (22:48 +0200)]
nl: Fix return value of nl_recvmsgs()
Apparently the change to have nl_recvmsgs() return the number of
parsed messages broke nl_wait_for_ack() among other applications.
This patch reverts to the old behaviour and provides a new function
nl_recvmsgs_report() which provides the additional information for
use by the cache manager and possibly other applications.
Reported-by: Scott Bonar <sbonar@cradlepoint.com> Signed-off-by: Thomas Graf <tgraf@redhat.com>
Thomas Graf [Sat, 21 Apr 2012 10:47:29 +0000 (12:47 +0200)]
cache_mngr: Let nl_cache_mngr_data_ready() read multiple messages
Having nl_recvmsgs() return the number of read messages allows
to continue reading until the underlying recvmsg() will return
EAGAIN for the non blocking socket.
Thomas Graf [Sat, 21 Apr 2012 10:23:38 +0000 (12:23 +0200)]
cache_mngr: Fix memory corruption after resizing
The reallocated part of the enlarged association array was left
uninitialized which would have resulted in trying to free random
pointers.
This was a theoretical bug because it wasn't possible to register
more than 32 cache types since no netlink family supports that
many individual cache types.
Nevertheless this patch fixes the bug and also reduces the default
size of the allocation table and expandations a bit to reduce the
memory footprint slightly.
Thomas Graf [Sat, 21 Apr 2012 08:51:34 +0000 (10:51 +0200)]
cache_mngr: Don't modify callback setup of socket
Instead, clone it and modify a temporary copy. Although it is not
recommended to use the same socket for requests and to serve a
cache manager, this change might prevent some unwanted side effects
if done so.
Nicolas CARRIER [Fri, 13 Apr 2012 11:51:44 +0000 (13:51 +0200)]
Memory leak in classid.c
I'm using libnl in a program which I give to valgrind
in order to track memory errors / leaks. When my program
exits, it complains about non-freed memory, allocated in
3 places in classid.c, at lines 280, 284 and 289.
It seems related to the module's constructor classid_init
which allocates resources, with no destructor to free it.
The attached patch tries to fix this issue by registering
a destructor which performs the tree liberation at exit.
Thierry Reding [Thu, 16 Feb 2012 11:57:42 +0000 (12:57 +0100)]
Add new nl_cache_clone() function.
The function can be used to make a copy of an existing cache. It is very
similar to nl_cache_subset() except that it allows no filtering but
copies every object.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> Signed-off-by: Thomas Graf <tgraf@redhat.com>
Support plug qdisc - queue traffic until explicit release
The plug qdisc supports two operations - plug and unplug. When the
qdisc receives a plug ("buffer") command via netlink request,
packets arriving henceforth are buffered until a corresponding unplug
command is received. Depending on the type of unplug ("release_one"
or "release_indefinite"), the queue can be unplugged indefinitely or
selectively.
The plug qdisc allows a user to implement network output buffering
(aka output commit), used commonly in checkpoint based fault tolerance
systems. It also supports a general purpose queue plug/unplug
functionality.
Brett Ciphery [Sun, 29 Jan 2012 17:19:00 +0000 (12:19 -0500)]
add new function to provide neighbour event parsing
the neighbour parsing function was previously not accessible, so
custom callback functions had to handle the decoding itself.
rtnl_neigh_parse is introduced and implemented in much the same way
as rtnl_route_parse.
Signed-off-by: Brett Ciphery <brett.ciphery@windriver.com> Signed-off-by: Thomas Graf <tgraf@redhat.com>
Torsten Hilbrich [Thu, 12 Jan 2012 11:28:18 +0000 (12:28 +0100)]
link: fix regression in link message parser
In a simple test program that queries the source IP for a given
destination address I get a crash in the call to rtnl_link_alloc_cache.
Here is the stack trace (created with version 3.2.4):
Program received signal SIGSEGV, Segmentation fault.
0xb7eb7553 in strlen () from /lib/libc.so.6
(gdb) bt
#0 0xb7eb7553 in strlen () from /lib/libc.so.6
#1 0xb7eb7285 in strdup () from /lib/libc.so.6
#2 0xb7fcc305 in nla_strdup (nla=0x0) at attr.c:1033
#3 0xb7f9c173 in link_msg_parser (ops=0xb7fc2940, who=0x804b330, n=0x804c3e8, pp=0xbffffbf8) at route/link.c:486
#4 0xb7fcd485 in nl_cache_parse (ops=0xb7fc2940, who=0x804b330, nlh=0x804c3e8, params=0xbffffbf8) at cache.c:724
#5 0xb7fcd547 in update_msg_parser (msg=0x804b328, arg=0xbffffbb8) at cache.c:531
#6 0xb7fd1f25 in nl_cb_call (cb=<optimized out>, msg=<optimized out>, type=<optimized out>) at ../include/netlink-local.h:126
#7 recvmsgs (cb=<optimized out>, sk=<optimized out>) at nl.c:729
#8 nl_recvmsgs (sk=0x804b2d0, cb=0x804b368) at nl.c:780
#9 0xb7fcd5fd in __cache_pickup (sk=0x804b2d0, cache=<optimized out>, param=0xbffffbf8) at cache.c:560
#10 0xb7fcd83f in nl_cache_pickup (sk=0x804b2d0, cache=0x804b308) at cache.c:593
#11 0xb7fcd8c8 in nl_cache_refill (sk=0x804b2d0, cache=0x804b308) at cache.c:780
#12 0xb7f9d1fc in rtnl_link_alloc_cache (sk=0x804b2d0, family=4, result=0xbffffcd4) at route/link.c:868
#13 0x08048fd0 in libnl_init (data=<optimized out>) at helper_route.c:60
#14 iproute_get_source (destination=0xbffffeff "127.0.0.1",
source=0xbffffd0f "\b\004c\370\267\364_\370\267\260\224\004\b8\375\377\277e\024\347\267\320\016\377\267\273\224\004\b\364_\370\267\260\224\004\b", source_size=17)
at helper_route.c:105
#15 0x08048e6a in main (argc=2, argv=0xbffffde4) at ip_route_get.c:25
The attached patch (against 3.2.4) solves the problem, fixing something that
looks like a typo. The bug is still present in current Git master.