dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

26 Commits

Author SHA1 Message Date
Emmanuel Thierry 979ea335b0 Wrong calcultation in nla_reserve
There seams to be an error in the calculation of needed space for the message in nla_reserve. The current size of the message is counted twice: Once in NLMSG_ALIGN, once in the condition below.
This causes nla_put_* calls to be rejected if the allocation size of the message has been strictly calculated by the caller.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-28 10:34:50 +02:00
Thomas Graf 3a6d256da5 attr: Fix typo in nla_is_nested()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-28 10:33:52 +02:00
Thomas Graf c07a6a30c2 attr: nla_is_nested() must access nla_type directly
Can't used nla_type() as it applies NLA_TYPE_MASK first

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-28 10:23:28 +02:00
Thomas Graf 1395c69901 attr: Warn application if nla_parse() observes same attribute multiple times
Use a debugging message to warn applications if an attribute is
found multiple times in the same message. It is perfectly valid
to rely on this behaviour but it is likely to indicate a bug.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-03-14 12:46:09 +01:00
Thomas Graf 64315f731c attr: No longer warn about attribute of type 0
The kernel will start using type 0 attributes for padding purposes.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-03-14 12:46:06 +01:00
Thomas Graf 60b370de8c attr: Do not enforce maximum length for NLA_FLAG attributes
Although wasteful, NLA_FLAG with non zero payload cause no harm
and should thus not be rejected.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-03-14 12:46:04 +01:00
Thomas Graf 9e6cdbf6fc attr: Add nla_nest_cancel() to remove partially added nested attributes
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-03-14 12:46:01 +01:00
Thomas Graf 9f8548b551 attr: Provide nla_is_nested() function
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-02-05 22:31:31 +01:00
Thomas Graf 9680f910f4 Move private header files to <netlink-private/*>
This clarifies the seperation between public and private
header files.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-01-24 13:51:24 +01:00
Thomas Graf 23c4ef67c7 Use NL_DBG() instead of printing warnings and errors to stderr
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-16 00:42:34 +01:00
Коренберг Марк 2bdcde7e8e 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.
2012-06-13 13:30:26 +02:00
Thomas Graf fec10a2823 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
2012-05-10 12:03:59 +02:00
Thomas Graf a0fe7a1c9a Omit empty nested attributes
Check for empty nested attributes in nla_nest_end() and omit the
attribute alltogether if is is the case.
2011-03-23 13:39:18 +01:00
Thomas Graf e52a09c507 nl: rename nlmsg_msg_size() to nlmsg_size(), nlmsg_len() -> nlmsg_datalen()
The old symbols are left around for compatibility.
2010-11-22 13:13:04 +01:00
Thomas Graf 93f992eac5 attr: Add padding if nested data does not end at an alignment boundry
This could happen if a user put an unaligned amount of data inside
an attribute with nlmsg_append().
2010-10-29 18:40:48 +02:00
Thomas Graf cc22992d0c Improved debugging messages while constructing messages/attributes 2010-10-29 18:34:27 +02:00
Thomas Graf d0e564548f Avoid memcpy()/memset() when reserving space for nested attributes 2010-10-29 00:16:40 +02:00
Thomas Graf d49018fd78 Introduce nla_strdup() to help parse strings attributes 2008-06-13 16:40:41 +02:00
Thomas Graf eed2afaab7 Remove obsolete nla_get_addr() and nla_get_data()
Replaces obsolete calls to nla_get_addr() and nla_get_data()
with nl_addr_alloc_attr() respectively nl_data_alloc_attr().

Also fixes missing error handling while parsing routing multipath
configuration.
2008-05-14 18:26:47 +02:00
Thomas Graf 8a3efffa5b Thread-safe error handling
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!
2008-05-14 17:49:44 +02:00
Thomas Graf 4be02ace48 Be liberal when receiving an empty nested attribute
No longer enforce at least one attribute in a container of nested
attributes. The application may do so itself by setting minlen
to NLA_HDRLEN.
2008-02-22 15:20:58 +01:00
Thomas Graf dbcdf91a99 Detailed attribute documentation
This patch extends and reorganizes the existing attribute documentation
and includes various verbose examples.
2008-01-30 13:16:48 +01:00
Thomas Graf 75a26f3fc5 Improve message/attribute construction documentation and add nlmsg_expand() 2008-01-14 16:46:17 +01:00
Thomas Graf 6de17f3308 Fix stale data pointers when constructing messages
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.
2008-01-14 16:17:56 +01:00
Patrick McHardy 936c9844b0 [LIBNL]: Fix format strings
Use %td for ptrdiff_t and %zu for size_t.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2007-12-13 12:09:45 +01:00
Thomas Graf 44d362409d Initial import 2007-09-15 01:28:01 +02:00