dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

28 Commits

Author SHA1 Message Date
Andrew Collins 53ac502a2b Handle -NLE_AGAIN in nl_cache_mngr_data_ready
Since commit "nl: Return -NLE_AGAIN if non-blocking socket would block",
nl_cache_mngr_data_ready returns -NLE_AGAIN to callers on non-blocking sockets.
Change it to consider -NLE_AGAIN as a non-error case as it is expected behavior
with the nl_recv changes.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-06-27 01:12:36 +02: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
roopa 4d94ed5f6b Bug Fix: Add new fill socket to cache manager
This patch adds a new socket to cache manager to request fill's on.
cache manager today uses cm_sock to request dump from
the kernel. It also listens to netlink async events on the same sock.
The problem with this is that when libnl is waiting to process the
response to get dump request sent to the kernel during fill,
it may receive an async event, resulting in libnl complaining about
unexpected msg

This is usually reproducible when there is heavy netlink async event
traffic during nl_cache_mngr_add.

This patch adds a new cm_sync_sock to use for fill during cache manager
add cache.

The other option is to provide an api to set the cm_sync_sock. But since
this is a bug fix its probably better to fix the cache manager add api
like this patch does. Please suggest otherwise.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-19 10:15:04 +01:00
Thomas Graf cb82c2a545 use safe cache lookup variants internally
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-16 00:29:58 +01:00
roopa 30d862650b New cache manager add cache api
This patch is an attempt to add a new nl_cache_mngr_add_cache api
to allow adding an existing cache to cache manager.

Since the new api is similar to nl_cache_mngr_add
except for allocating the cache, the patch moves most of the
nl_cache_mngr_add code to nl_cache_mngr_add_cache and changes
nl_cache_mngr_add to call nl_cache_mngr_add_cache.

One use case for this api as pointed out by thomas would be to set cache
flags before associating the cache with a cache manager.

nl_cache_alloc_name("route/link", &cache);
nl_cache_set_flags(cache, NL_CACHE_AF_ITER);
nl_cache_mngr_add_cache(mngr, cache, ...);

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-12 21:51:03 +01: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 6f156a7b58 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>
2012-05-08 22:48:00 +02:00
Thomas Graf bd1e4d0384 cache: Add co_include_event allowing caches to provide their own nl_cache_include() implementation 2012-04-22 15:23:52 +02:00
Thomas Graf 2e93940a86 cache_mngr: Make providing the result pointer to nl_cache_mngr_add() optional 2012-04-21 15:51:43 +02:00
Thomas Graf 516536625f cache_mngr: Provide nl_cache_mngr_info() to pring cache manager details
Useful for debugging and testing
2012-04-21 15:48:37 +02:00
Thomas Graf 743756f3b4 cache_mngr: API doc updates 2012-04-21 15:22:04 +02:00
Thomas Graf a518a318d4 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.
2012-04-21 12:47:29 +02:00
Thomas Graf adbc568735 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.
2012-04-21 12:23:38 +02:00
Thomas Graf e34ed950bd cache_mngr: Automatically allocate socket if needed
The requirement to have the caller provide the socket does not
make much sense. Automatically allocate the socket if none was
provided.

This may also avoid some future abuse of reusing request sockets
for handling notifications.

Also rename cm_handle to cm_sock for clarity (no API change)
2012-04-21 12:11:45 +02:00
Thomas Graf c55acc438b cache_manager: Move documentation to doc/core.txt 2012-04-21 11:38:33 +02:00
Thomas Graf b32011254d 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.
2012-04-21 10:51:34 +02:00
Thomas Graf 653ea3457a cache_mngr: document uncommon error codes 2012-04-21 09:59:26 +02:00
Alexander Sack 9819717444 avoid dangling co_major_cache reference to NL_AUTO_PROVIDE caches 2012-01-11 12:31:40 +01:00
Thomas Graf 2bcd8ecd27 cache: event_filter() cache operation to filter notifications
Certain notifications need to be filtered out and should not be applied to
a cache when a cache is handled by a cache manager.
2011-10-21 11:31:15 +02:00
Thomas Graf c1073d6172 Documentation updates
Mostly killing doxygen warnings, some doc updates to caching
2011-03-22 00:40:26 +01:00
Andreas Fett 4ab22ccd47 add user data to change_func_t for caches
the patch below adds the possibility to
pass user data to callbacks of type
change_func_t when using the nl_cache_mngr_*
family of functions.

If there is any better way to do this,
without duplicating the code in
cache_mngr.c please let me know.
2010-10-13 13:41:57 +02:00
Thomas Graf 664e1deaeb Fix up naming changes 2008-12-10 18:16:31 +01:00
Thomas Graf 1155370f52 Rename struct nl_handle to struct nl_sock
The idea of a common handle is long revised and only misleading,
nl_handle really represents a socket with some additional
action handlers assigned to it.

Alias for nl_handle is kept for backwards compatibility.
2008-05-15 13:26:32 +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 080727d90b Free associated caches when freeing cache manager
Caches allocated by the cache manager must be freed again when the cache
manager itself is freed. However, the netlink socket is allocated
indepdently so it should not be freed.
2008-02-05 12:35:41 +01:00
Thomas Graf dbefb734d3 Fix documentation of cache manager. 2008-01-14 16:38:37 +01:00
Thomas Graf 12ed4a03d3 Fix cache manager to not give back a reference it does not own 2007-12-17 23:01:06 +01:00
Thomas Graf 44d362409d Initial import 2007-09-15 01:28:01 +02:00