dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

810 Commits

Author SHA1 Message Date
roopa 0bd14aa2d6 Add NL_CACHE_AF_ITER support during refill and resync
This patch adds support to iter over all supported families
during cache fill and resync.

The motivation for this was previously introduced at
http://lists.infradead.org/pipermail/libnl/2012-November/000734.html
In short, this patch allows caches to request dump on all supported
families instead of only AF_UNSPEC as done today.

With feedback from thomas this patch makes the iter over all families
conditional on per cache flag NL_CACHE_AF_ITER

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-12 21:51:07 +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
roopa dd8a87da96 Add support for per cache flags
This patch adds support for per cache flags
and adds a flag NL_CACHE_AF_ITER to iter over all
supported families when filling the cache.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-12 21:51:02 +01:00
Thomas Graf c83ecb38c1 doc: Revert to default stylesheet
Use of a custom stylesheet breaks with almost every release of doxygen
and is thus completely unuseable.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-12 10:26:38 +01:00
Thomas Graf 3132db5162 addr: rtnl_addr_set_peer() is limited to IPv4
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-11 21:01:19 +01:00
Thomas Graf 5a0476032e addr: Return -NLE_AF_NOSUPPORT when trying to set unsupported attributes
- multicast and anycast address only supported with IPv6
- brodcast address only supported with IPv4

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-11 16:36:29 +01:00
Thomas Graf 7e075c600d doc: update Doxygen layout file to latest format
Sigend-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-11 11:21:34 +01:00
Thomas Graf b66d26711a hashtable: remove doc section crashing doxygen
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-11 11:21:10 +01:00
Thomas Graf 59a6b003a9 hashtable: Fix reference leak in nl_hashtable_free()
The reference counter of the linked object must be dec'ed
before freeing the node or the reference is leaked.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 10:52:26 +01:00
Thomas Graf ae1e236809 hashtable: Add API reference documentation
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 10:50:16 +01:00
Thomas Graf 5641c0ea61 Hash: Properly prefix hash functions
Do not pollute public namespace with unprefixed functions.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 10:22:26 +01:00
roopa a2207c7beb Add hash support to route cache
This patch adds keygen function to route object

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 00:13:05 +01:00
roopa 6f24cf12ca Add hash support to neigh cache
This patch adds keygen function to the neigh object

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 00:12:57 +01:00
roopa e16e8fdcdb Add hash support to link cache
This patch adds keygen function to link cache

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 00:12:51 +01:00
roopa 55c0e036b0 Add hash support in cache mngr
This patch adds support to create, delete modify hash table for a cache

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 00:12:44 +01:00
roopa c6f89ed02f Add nl hashtable structures and access functions
This patch adds the required structures and access functions to create
and manage hashtables for netlink cache objects

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 00:12:36 +01:00
roopa a8741fab8e Add hash function
This patch adds a hash function for hashing libnl objects.

This hash function is from:
http://ccodearchive.net/info/hash.html

The original code was modified to remove unwanted dependencies,
unwanted code and fixes to header file locations

One requirement with this hash function is, hashing over multiple fields of an
un-packed struct requires that the struct be zeroed, otherwise random padding
bytes will change the hash.

Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-10 00:12:08 +01:00
Thomas Graf 665464cde5 nl: Improve API doc of nl_send_simple()
Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-11-08 21:17:32 +01:00
Thomas Graf b28c25eb23 nl: Improve API doc of nl_connect() and nl_close()
Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-11-08 13:41:54 +01:00
Thomas Graf fd6f205f8a nl: Allow to overwrite nl_send()
Up to now only calls to nl_send_auto() could be overwritten with
nl_cb_overwrite_send(). This patch extends the capability to
nl_send()

Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-11-08 13:19:07 +01:00
Thomas Graf b132ee7e27 nl: improve API doc of transmit functions
Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-11-08 01:29:12 +01:00
Thomas Graf a721c1d445 doc: increase dot max graph nodes to 100 2012-11-08 00:11:13 +01:00
Thomas Graf 8f47501741 nl: improve nl_sendto() docs and error checks
Make nl_sendto() return NLE_INVAL if provided buffer is NULL
and make it return NLE_BAD_SOCK if the socket is not connected.

Add note in docs about lack of NL_CB_MSG_OUT invokation
2012-11-06 17:48:28 +01:00
Thomas Graf b25f26b896 socket: document nl_socket_get_fd() 2012-11-06 17:36:53 +01:00
Thomas Graf 65f97deb63 nl_recv: fix indent style 2012-11-06 14:27:34 +01:00
Thomas Graf 220d8e141d nl_recv: return NLE_INVAL if socket address pointer is NULL 2012-11-06 14:24:09 +01:00
Thomas Graf eb36066909 nl_recv: return NLE_INVAL if buf is NULL 2012-11-06 14:22:50 +01:00
Thomas Graf fb42f19e2e nl_recv: improve function documentation 2012-11-06 14:21:18 +01:00
Thomas Graf 6d52ae6440 nl_recv: Don't update *buf in error path
iov.iov_base is either NULL or invalid
2012-11-06 00:21:35 +01:00
Thomas Graf ceb8fb9e87 Document buffer size limitations of nl_recv() 2012-11-06 00:19:28 +01:00
roopa bc7c822f54 Add support for updating objects in the cache
This patch adds support to update a cache object during cache_include instead
of the current approach of deleting the original object and adding a new one.
This operation is conditional on the object implementing the operation. If
the update is not successful, cache_include falls back to the existing cache
inclusion process of deleting and adding the object.

It adds a new object operation called oo_update. oo_update takes two objects
as arguments, first being the existing cache object that needs update, the
second argument being the new object. Currently it is left to the implementor
to use the msg type to decide wether to delete or add the new object attributes
to the old one. But the operation type or msg type can be easily made part of the
object arguments.

The motivation for this change is explained below in the context of including
support for AF_BRIDGE objects into the link cache.

libnl today deletes an object before it includes an identical object.
But for some objects like the AF_BRIDGE objects this does not work well.
link cache uses the ifindex as its key in object searches.
If link cache were to support AF_BRIDGE family objects, todays implementation,
	- will replace the original link object with the bridge port link object
	  for add notifications
	- And a bridge port delete notification from kernel would delete the
	link object from the cache leaving the cache without the link object
	until the kernel sends another notification for that link

The bridge port link notification contains some base link object attributes
plus bridge specific protocol info attributes. In such cases we think an
operation to update the existing object in place in cache might be useful.

This can be made to work for AF_INET6 link objects too.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
2012-11-05 13:58:50 +01:00
roopa 690264a193 Add new object op oo_id_attrs_get
The current oo_id_attrs nl_object op allows a fixed
id attribute list for an cache. But a cache with multiple families
may need to specify different id attributes for different families.

An example for this is the bridge fdb entries in the neigh cache:
neigh entries belonging to the AF_UNSPEC family use
(NEIGH_ATTR_IFINDEX | NEIGH_ATTR_DST | NEIGH_ATTR_FAMILY) as id attributes.
AF_BRIDGE fdb entries which also support the same msg type, will need to use
(NEIGH_ATTR_LLADDR | NEIGH_ATTR_FAMILY) as id attributes.
Today you cannot specify different set of attributes to two families belonging
to the same cache.

This patch adds a new object function oo_id_attrs_get to get the attributes.
An example implementation of oo_id_attrs_get for the neigh cache will
look like:
static uint32_t neigh_id_attrs_get(struct nl_object *obj)
{
        struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj;

        if (neigh->n_family == AF_BRIDGE)
                return (NEIGH_ATTR_LLADDR | NEIGH_ATTR_FAMILY);
        else
                return (NEIGH_ATTR_IFINDEX | NEIGH_ATTR_DST | NEIGH_ATTR_FAMILY);
}

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
2012-11-05 13:31:55 +01:00
Michele Baldessari 3750e2ac31 Set err and free ntbl when leaving neightbl_msg_parser
Make sure we leave neightbl_msg_parser() by setting the proper err variable and
freeing ntbl
2012-10-29 18:16:58 +01:00
Michele Baldessari 16e54c4e6e Add missing va_end() calls
Add missing va_end() calls on all error paths
2012-10-29 18:16:58 +01:00
Michele Baldessari 503270c1c8 Remove unreachable code
This code gets never called anyway
2012-10-29 18:16:58 +01:00
Rich Fought a8ef3525c8 Add configure option to disable pthreads support 2012-10-26 12:19:26 -07:00
Thomas Graf 609b47961b Merge branch 'master' of https://github.com/rmfought/libnl 2012-10-26 12:48:22 +02:00
Thomas Graf 3c1ab421ee add missing '}' in __cplusplus namespaces
Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-10-23 15:28:24 +02:00
Thomas Graf 785f810b95 Merge branch 'fixes' of https://github.com/socketpair/libnl 2012-10-22 12:24:19 +02:00
Thomas Graf 5535f59746 Don't include doc/ in toplevel dist
On a second thought, don't include doc/ in dist at all and distribute it
separately. The doc source files are available in the git tree anyway.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-10-22 12:09:03 +02:00
Rich Fought d2fff93cce Source cleanup for upstream 2012-10-19 11:18:52 -07:00
Коренберг Марк (дома) 420e4623fd nl_recv(): work with credentials only if "creds" given and NL_SOCK_PASSCRED set 2012-10-19 23:51:59 +06:00
Коренберг Марк (дома) da694e6c7b nl_recv(): small code cleanups
1. memset around nla is unnecessary
2. calloc() is unnecessary. malloc() used instead.
2012-10-19 23:49:30 +06:00
Коренберг Марк (дома) 2249eaebd4 nl_recv(): EWOULDBLOCK return value also checked 2012-10-19 23:49:30 +06:00
Коренберг Марк (дома) 69468517d0 nl_recv(): Memory allocation errors are handled properly now
1. all cleanup actions (like free()) now located at the end of function
2. in case of error or EOF, *buf and *creds (if given) set to NULL
   This protect from invalid code at user's side, like:
   char *buf;
   x = nl_recv(..., &buf, ...);
   if (x<=0)
      goto cleanup;
   cleanup:
      free(buf);
3. all intermediate buffers are stored into local variables, and user's
   variables only touches at the end.
2012-10-19 23:48:46 +06:00
Коренберг Марк (ноутбук дома) 9d6b104ec8 nl_recv(): "else if" logick simplified and refined 2012-10-19 22:43:17 +06:00
Коренберг Марк (дома) e7ec197da3 nf-log example: correct copy-range parsing 2012-10-19 22:43:17 +06:00
Коренберг Марк (ноутбук дома) e1b67fb23f Clang diagnostics
Based on clang diagnostics:

1. lib/nl.c: recvmsgs(): nla filling with zeros commented.
2. lib/route/classid.c: & lib/route/pktloc.c:
   remove zero-filling of struct stat
3. lib/route/qdisc/htb.c: Fix htb_qdisc_msg_fill(): fix zero-filling
4. ematch/container.c: container_parse:
   commented why only 4 bytes are copied
   len marked as unused to eliminate compiler warning
2012-10-19 22:32:59 +06:00
Коренберг Марк (ноутбук дома) fedb862ea5 ROUTE_DIFF result was not used in some place in route_compare 2012-10-19 22:16:44 +06: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