dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

30 Commits

Author SHA1 Message Date
Thomas Graf df66b0f267 genl: Fix cb reference leak in genl_ctrl_probe_by_name()
nl_socket_get_cb() bumps the cb reference counter

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-02 11:51:53 +02:00
Thomas Graf ad545f2854 genl: Update mt_id of cache ops when resolving genl id
The cache layer uses the message type array stored in the cache
ops to lookup which cache a message belongs to. Update to the
the message array with the resolved generic netlink id to make
it compatible with the caching API.

Allows to use nl_cache_refill() and others for generic netlink
based caches with dynamic generic netlink ids.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-01 11:21:22 +02:00
Thomas Graf aad041c46f genl: Provide internal function to resolve name to id
Like genl_ops_resolve() but uses its own socket.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-01 11:14:49 +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
Коренберг Марк (ноутбук дома) 787f14dbe3 genl/family flags can be damaged during the auto-indentation.
"-" was never used in the names of the flags. "_" was used in all places
of the library. So, I just changed the undescore to the minus.

Automatic indentation can insert spaces on either side of the minus,
so the library will be compiled, but will not be usable (in this part of the code),
as the parser will split words by white space, and the flag "admin - perm"
will never work.
2012-10-19 22:16:44 +06:00
Коренберг Марк 49c94c3490 genl_ctrl_probe_by_name: fix checking of genlmsg_put() return value
It's a pointer! not an error code :) nasty bugs
2012-08-30 22:53:54 +06: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 49fe936b8e genl: cleanup genl_ctrl_resolve()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-06-13 13:23:04 +02:00
Thomas Graf 69da6af3e4 genl: Wait for ACK after successful ctrl reply
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-06-13 13:19:06 +02:00
Neil Horman 0c408aad1f 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>
2012-06-03 13:52:16 +02:00
Thomas Graf faef2fa45f 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.
2012-06-01 11:48:08 +02:00
Thomas Graf 3656b6f908 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.
2012-05-31 13:37:57 +02:00
Thomas Graf 71b442b955 genl: Add genlmsg_hdr()
Explicit function to calculate the genl hdr based on nlh
2012-05-31 13:13:50 +02:00
Thomas Graf 0b70de5155 genl: updates to API reference documentation 2012-05-31 13:11:48 +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 8bbcd2208e genl: Make genl_unregister() a NOP if NULL pointer is passed 2012-04-22 11:12:01 +02:00
Jiri Pirko 7adaad784f genl: genl_ctrl_grp_by_name: fix retval in case group id not found
Now the return value in case group id is not find is 0. Change it to
return -NLE_OBJ_NOTFOUND which makes more sense. This should not break
anything because genl_ctrl_grp_by_name is static and called only from
genl_ctrl_resolve_grp. genl_ctrl_resolve_grp already might return
-NLE_OBJ_NOTFOUND.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
2011-08-31 12:35:56 +02:00
Thomas Graf cf5577d280 constify struct trans_tbl 2010-11-17 16:09:08 +01:00
dima 2dbc1ca76c Generic Netlink multicast groups support
I have a patch against commit d378220c96
extending libnl with a facility to receive generic netlink messages sent
to multicast groups.

Essentially it add one new function genl_ctrl_resolve_grp which
prototype looks like this
int genl_ctrl_resolve_grp(struct nl_sock *sk, const char *family_name,
        const char *grp_name)
It resolves  the family name and the group name to group id. Then
the returned id can be used in nl_socket_add_membership to subscribe
to multicast messages.

Besides that it adds two more functions

uint32_t nl_socket_get_peer_groups(struct nl_sock *sk)
void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups)

allowing to modify the socket peer groups field. So it's possible to
multicast messages from the user space using the legacy interface.
Looks like there is no way (or I was not able to find one?) to modify
the netlink socket destination group from the user space, when the
group id is greater then 32.
2010-10-14 13:46:02 +02:00
Thomas Graf 6782b6f709 restructure module documentation order
split hiearchy into one top level module per library
2008-12-10 18:12:30 +01:00
Thomas Graf 13ab2441ce Remove XML dumping
Bloats the library, not frequently used
2008-06-17 03:04:19 +02:00
Thomas Graf d844307024 Remove old line counting while dumping 2008-05-23 23:45:14 +02:00
Thomas Graf 28233246cd Allow parser callbacks to return NL_OK, NL_SKIP, NL_EXIT
Obsoletes internal P_ACCEPT/P_IGNORE
2008-05-15 14:01:57 +02: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 13c85b6633 Add missing @{ for doxygen to build genl documentation 2008-01-10 17:03:34 +01:00
Thomas Graf c8a0a5cdfb Added additional parsing and validation functions for generic netlink
Also adds better example documentation for generic netlink
2008-01-10 12:35:38 +01:00
Thomas Graf 155ad439a4 Fix memory leak when parsing netlink messages into caches
The reference created by the parsers was never given back.
2007-12-17 16:52:41 +01:00
Thomas Graf 3040a1d625 Export interface to define caches
This interface was internal so far which required all code defining
caches to be compiled with the sources available.

In order to simplify the interface, the co_msg_parser prototype was
changed to take the struct nl_parser_param directly instead of a
void *. It used to be void * because the co_msg_parser was directly
passed as the NL_CB_VALID callback function.
2007-09-17 13:36:16 +02:00
Thomas Graf 44d362409d Initial import 2007-09-15 01:28:01 +02:00