summaryrefslogtreecommitdiffstats
path: root/lib/msg.c
Commit message (Collapse)AuthorAgeFilesLines
* dump_attrs: "NLA_F_NESTED" => nla_is_nested(nla)Коренберг Марк (дома)2013-04-261-2/+2
|
* msg: Pretty print generic netlink header in nl_msg_dump()Thomas Graf2013-04-021-41/+97
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* msg: Pretty print error message header even if incompleteThomas Graf2013-03-141-15/+24
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* msg: Pretty print padding attributes in nl_msg_dump()Thomas Graf2013-03-141-3/+7
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Use thread-safe strerror_r() instead of strerror()Thomas Graf2013-02-281-1/+2
| | | | | | | We have only ever fed well known error codes into strerror() so it should never have been a problem though. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Move private header files to <netlink-private/*>Thomas Graf2013-01-241-1/+1
| | | | | | | This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* nlmsg_ok comparison between signed and unsignedEric Paris2013-01-031-1/+1
| | | | | | | | | | | | | | | | | The nlmsg_ok macro has a comparison between an int and a size_t (unsigned int). The C spec says the int is cast to unsigned int before the comparison. This is a problem as the audit system will send skb's with skb->len == nlhhdr->nlmsg_len which are NOT aligned. Thus you can end up with remaining being negative. So the comparison becomes (unsigned int)(-1) >= (unsigned int)16 Which turns out to be true! It should clearly be false. So if we cast the size_t to an int we get a signed comparison and it works. (This is what linux/netlink.h and all of the kernel netlink headers do) Signed-off-by: Eric Paris <eparis@redhat.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* use safe cache lookup variants internallyThomas Graf2012-11-151-6/+14
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Fix types-related warnings based on clang diagnosticsКоренберг Марк2012-06-131-4/+4
| | | | | | | | | | | | | | | | | 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.
* doc: documentation restructuringThomas Graf2012-05-101-142/+10
| | | | | | | | | | - 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
* Make some functions and global variables staticPavel Roskin2011-08-111-2/+2
|
* documentation updatesThomas Graf2011-07-141-6/+0
|
* Documentation updatesThomas Graf2011-03-211-1/+1
| | | | Mostly killing doxygen warnings, some doc updates to caching
* __nlmsg_alloc(): Guarantee minimal message size of at least the headerThomas Graf2011-03-171-0/+3
|
* nl: rename nlmsg_msg_size() to nlmsg_size(), nlmsg_len() -> nlmsg_datalen()Thomas Graf2010-11-221-13/+45
| | | | The old symbols are left around for compatibility.
* constify struct trans_tblThomas Graf2010-11-171-1/+1
|
* Improved debugging messages while constructing messages/attributesThomas Graf2010-10-291-2/+2
|
* Fix use of uninitialized data at the end of netlink messageThomas Graf2010-10-281-1/+1
| | | | | | | The netlink message buffer is preallocated to a page and later expanded as needed. Everything was properly paded and zeroed out except for the unused part at the end. Use calloc() to allocate the buffer.
* Patch for unexpectedly aligned messagesMarc de Kruijf2009-09-021-1/+1
| | | | | | | | | | | | I found the following bug, where nlmsg_ok() in lib/msg.c would incorrectly return 'true' when the input argument 'remaining' was a negative number. This happens when the message is not aligned the way that libnl expects (although it is still legal). In the comparison of the signed and unsigned numbers on line 284, the signed number gets converted to an unsigned number, which is unexpected and naturally produces a bug. My patch is below. The cast is ugly, but it fixes the problem.
* restructure module documentation orderThomas Graf2008-12-101-1/+1
| | | | split hiearchy into one top level module per library
* Replace NL_KEEP code with proper message reference countingThomas Graf2008-10-141-10/+30
| | | | | | Adds reference counting to netlink messages so callbacks can hold on to a message without using the broken keep message flag.
* Thread-safe error handlingThomas Graf2008-05-141-12/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order for the interface to become more thread safe, the error handling was revised to no longer depend on a static errno and error string buffer. This patch converts all error paths to return a libnl specific error code which can be translated to a error message using nl_geterror(int error). The functions nl_error() and nl_get_errno() are therefore obsolete. This change required various sets of function prototypes to be changed in order to return an error code, the most prominent are: struct nl_cache *foo_alloc_cache(...); changed to: int foo_alloc_cache(..., struct nl_cache **); struct nl_msg *foo_build_request(...); changed to: int foo_build_request(..., struct nl_msg **); struct foo *foo_parse(...); changed to: int foo_parse(..., struct foo **); This pretty much only leaves trivial allocation functions to still return a pointer object which can still return NULL to signal out of memory. This change is a serious API and ABI breaker, sorry!
* Improve performance by using malloc() over calloc() in critical placesThomas Graf2008-05-071-1/+3
| | | | | | | As pointed out by Regis Hanna, a considerable performance gain can be achieved by using malloc() over calloc() when allocating netlink message buffers. This is likely due to the fact that we use a complete page for each message.
* Improve message/attribute construction documentation and add nlmsg_expand()Thomas Graf2008-01-141-14/+51
|
* Fix stale data pointers when constructing messagesThomas Graf2008-01-141-23/+45
| | | | | | | | | | | | | | | | Patrick McHardy reported a problem where pointers to the payload of a netlink message as returned by f.e. the nesting helpers become stale when the payload data chunk is reallocated. In order to avoid further problems, the payload chunk is no longer extended on the fly. Instead the allocation is made during netlink message object allocation time with a default size of a page which should be fine for the majority of all users. Additionally the functions nlmsg_alloc_size() and nlmsg_set_default_size() have been added to allocate messages of a particular length and to modify the default message size.
* Added additional parsing and validation functions for generic netlinkThomas Graf2008-01-101-2/+10
| | | | Also adds better example documentation for generic netlink
* Fix nl_msg_parse() to not give back a reference it does not ownThomas Graf2007-12-171-1/+0
|
* [LIBNL]: Fix format stringsPatrick McHardy2007-12-131-3/+3
| | | | | | Use %td for ptrdiff_t and %zu for size_t. Signed-off-by: Patrick McHardy <kaber@trash.net>
* Cache message type association interface cleanupsThomas Graf2007-10-111-9/+15
|
* Initial importThomas Graf2007-09-141-0/+931