summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Move private header files to <netlink-private/*>Thomas Graf2013-01-2484-161/+161
| | | | | | | This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* route cache: This patch adds route priority to route object oo_id_attrsroopa2013-01-231-2/+7
| | | | | | | | | | | | | | | | | The kernel allows multiple entries in the main table which differ in the priority value. In libnl currently, since priority is not part of the base netlink route message, it is not used as part of the key. This patch includes priority in the key/oo_id_attrs and defaults the value to zero for messages where priority is not included. One point to note is that the actual selection of route from multiple options is done implicitly in the kernel by storing the routes in sort priority order, but there is no explicit communication to a client of libnl of that. Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: fix reference leak in rtnl_link_af_data_compare()Thomas Graf2013-01-181-5/+10
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Add af data compare to link objectsroopa2013-01-181-2/+20
| | | | | | | | | | | | | | | | | | | | | | Today the link compare function does not compare af data of a link. We have found a need for this to get approriate change callbacks when af_data of a link changes. This patch adds support to compare af_data to link_compare function. This patch today only adds support to compare af_data set by PROTINFO attributes. It can be extended to support compares of af_data set by AF_SPEC attributes It has been tested for AF_BRIDGE objects. In case of AF_BRIDGE objects, this helps with bridge port change notification callbacks. Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add new rtnl_link_af_data_compare function to compare af_dataroopa2013-01-181-0/+32
| | | | | | | | This patch adds a new api rtnl_linl_af_data_compare to compare link af_data Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add ao_compare support to bridge family af_dataroopa2013-01-121-1/+21
| | | | | | | | | | | | | This patch adds support for ao_compare operation to bridge link af data operations. Adds field ce_mask to struct bridge_data to work with the ATTR attributes. I can submit separate patches to introduce mask field to ATTR macros. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Add new nl_cache_find apiroopa2013-01-112-0/+61
| | | | | | | | | | | | | | | | | This patch adds new cache find api nl_cache_find api was suggested by Thomas. Unlike nl_cache_search, this patch uses nl_object_match_filter() to look for an object match. Am not sure this matches what was decided on the list few weeks back. I will be happy to make any changes. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: add carrier supportFlavio Leitner2013-01-111-1/+58
| | | | | Signed-off-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: make sure the user has specified a callbackmihai.dontu@gmail.com2013-01-061-1/+2
| | | | | | | | | | In cache_include(), the user callback is used even though one might not have been specified, leading to a crash. This happens, for example, when NetworkManager calls nl_cache_include() with the change_cb argument set to NULL. Fix it by making sure the callback points to a valid address. Signed-off-by: Mihai Dontu <mihai.dontu@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* nlmsg_ok comparison between signed and unsignedEric Paris2013-01-041-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>
* Fix file descriptor leak on errorThomas Jarosch2012-12-271-4/+12
| | | | | | | Detected by cppcheck Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Take cache_ops lock when modifying cache ops flagsThomas Graf2012-12-271-0/+2
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache pickup: Avoid duplicates during cache pickuproopa2012-12-211-3/+23
| | | | | | | | | | | | | | This patch adds search and replace/update functionality to cache pickup_cb. This change is required to avoid duplicates getting into the cache during pickup. Also helps updating existing objects during cache pickup. We have seen this in cases of ipv6 equal cost multipath routes changes v1 to v2: - Updated documentation Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* Bug Fix: cache_include: Fix object ref release after successful object updateroopa2012-12-171-1/+1
| | | | | | | | The current code does a rtnl_link_put on new object instead of old object. This patch fixes it. None of the caches have support for object update, so this should not have affected anyone yet. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* route cache: Fix handling of ipv6 multipath routesroopa2012-12-171-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two ways kernel handles ipv6 equal cost multipath routes depending on which kernel version you are looking at. older kernels without ipv6 ECMP support, accept the below ECMP routes, #ip -6 route add 2001::/16 nexthop via fe80:2::2 dev swp1 #ip -6 route add 2001::/16 nexthop via fe80:2::3 dev swp1 store them as separate routes and pick the last one during lookup. Newer kernels, after the support for equal cost multipath routes was added http://patchwork.ozlabs.org/patch/188562/, now accept multipath routes added individually using the above 'ip -6 route' format OR sent using RTA_MULTIPATH with the below command #ip -6 route add 2001::/16 nexthop via fe80:2::2 dev swp1 nexthop via fe80:2::3 dev swp1 And the kernel now stores and treats them as equal cost multipath routes during lookups. However in all cases above, netlink notifications to ipv6 ECMP route adds and deletes come separately for each next hop. Example libnl notification in the above case with both old and new kernels: inet6 2001::/16 table main type unicast scope global priority 0x400 protocol boot nexthop via fe80:2::2 dev swp1 inet6 2001::/16 table main type unicast scope global priority 0x400 protocol boot nexthop via fe80:2::3 dev swp1 Since they are separate route notifications for objects with same key, libnl replaces the existing ones and hence only the last route update sticks. This patch uses the oo_update feature to not replace but update an existing route if its a ipv6 equal cost multipath route. The object after an update looks like the below (similar to ipv4 ECMP routes): inet6 2001::/16 table main type unicast scope global priority 0x400 protocol boot nexthop via fe80:2::2 dev swp1 nexthop via fe80:2::3 dev swp1 Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Reviewed-by: Nolan Leake <nolan@cumulusnetworks.com> Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: socket-CAN helper functionsBenedikt Spranger2012-11-291-0/+359
| | | | | | | Add helper functions to make socket-CAN configuration easy. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: basic socket-CAN supportBenedikt Spranger2012-11-292-1/+405
| | | | | | | | | | | | | Controller Area Network (CAN) is a networking technology which has widespread use in automation, embedded devices and automotive fields. The socket-CAN package is an implementation of CAN protocols for Linux. All socket-CAN related configurations are carried out through Netlink. Add basic socket-CAN support to libnl to be able to configure CAN devices with libnl. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* build: resolve lex failureJan Engelhardt2012-11-271-2/+2
| | | | | | | | | | | This is an addendum to 0a9d5fcfa4c3fe8c930103f7639723dfd1ae4889, which forgot to change ${LEX} to ${FLEX} in lib/Makefile.am. On openSUSE, /usr/bin/lex is a wrapper that calls `flex -l ...`. libnl however requires flex, not lex or a compat mode thereof, so using ${FLEX} is the proper thing to do. Signed-off-by: Jan Engelhardt <jengelh@inai.de>
* cache: only continue iterating over co_groups if it is availableThomas Graf2012-11-261-2/+5
| | | | | | | | A co_groups == NULL must enter the loop to trigger the initial fill of the cache but may never bump the grp pointer as doing so prevents the loop from being escaped correctly. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Bug Fix: Add new fill socket to cache managerroopa2012-11-191-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* cache: provide safe variant of nl_cache_mngt_require() and use itThomas Graf2012-11-1611-17/+69
| | | | | | | | This makes runtime removal of cache operations possible if non-safe API is not in use by application. The non-safe API will be removed in the next major version. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Use NL_DBG() instead of printing warnings and errors to stderrThomas Graf2012-11-165-9/+9
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: hold a reference to the cache ops while a cache is provided over itThomas Graf2012-11-161-4/+16
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* use safe cache lookup variants internallyThomas Graf2012-11-164-11/+24
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Provide safe versions of nl_cache_ops_associate() and ↵Thomas Graf2012-11-161-18/+76
| | | | | | nl_cache_ops_lookup() Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Add reference counter to cache operationsThomas Graf2012-11-161-3/+29
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Protect registration of af and link ops with rwlockThomas Graf2012-11-151-17/+57
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: rwlock accesses to cache operationsThomas Graf2012-11-151-8/+46
| | | | | | Puts an rwlock around 'cache_ops'. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* lock abstraction layerThomas Graf2012-11-151-22/+6
| | | | | | Hide pthread availability and enablement behind internal API Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Hold cache reference while a cache is being providedThomas Graf2012-11-151-2/+6
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Add reference counter to cachesThomas Graf2012-11-151-7/+27
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add master support to rtnl_neigh for AF_BRIDGE objectsroopa2012-11-151-2/+22
| | | | | | | | | | | | | | | | | | | | AF_BRIDGE neigh objects can be uniquely identified by the family, lladdr and bridge ifindex. This patch adds bridge ifindex to AF_BRIDGE neigh objects. Things will be ok even without this patch with just family and lladdr if we assume that we will have unique lladdr's accross bridges in a system. Kernel does not send the bridge ifindex in the AF_BRIDGE fdb/neigh message. This patch tries to get that info by a link cache lookup and adds it to the bridge neigh object 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> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add AF_BRIDGE support to neigh cacheroopa2012-11-151-10/+36
| | | | | | | | | | | | | This patch adds AF_BRIDGE to the list of families supported by the cache. Implements oo_id_attrs_get to declare separate id attributes for AF_UNSPEC and AF_BRIDGE neigh objects 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> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add AF_BRIDGE support to link cacheroopa2012-11-141-19/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch was previously submitted as the first approach in RFC http://lists.infradead.org/pipermail/libnl/2012-November/000730.html It adds support for AF_BRIDGE family in link cache. And the key for link object lookups will now be ifindex and family. This allows for AF_UNSPEC rtnl link objects to co-exist with the AF_BRIDGE link objects in the same cache. I have changed some of the rtnl_link api's to explicitly check for AF_UNSPEC to not break existing apps. I will submit a new patch to introduce equivalent rtnl_bridge_link_* api's. We had also discussed updating the existing link objects with AF_BRIDGE attributes, but realized that the updates to link objects will be both AF_UNSPEC and AF_BRIDGE. And that would change link cache to always update existing objects, resulting in comparing and updating close to thirty attributes at cache_include time which seems like a overkill. 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> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* addr: Support setting local/peer/anycast/multicast/broadcast address to NULLThomas Graf2012-11-121-20/+40
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Move nl_cache_ops_set_flags() to cache_mngt.cThomas Graf2012-11-122-10/+13
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Fix typo in API doc of nl_cache_set_flags()Thomas Graf2012-11-121-1/+1
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add NL_CACHE_AF_ITER support during refill and resyncroopa2012-11-121-19/+41
| | | | | | | | | | | | | | | 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>
* New cache manager add cache apiroopa2012-11-121-21/+65
| | | | | | | | | | | | | | | | | | | 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>
* Add support for per cache flagsroopa2012-11-121-0/+21
| | | | | | | | 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>
* addr: rtnl_addr_set_peer() is limited to IPv4Thomas Graf2012-11-111-0/+3
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* addr: Return -NLE_AF_NOSUPPORT when trying to set unsupported attributesThomas Graf2012-11-111-1/+14
| | | | | | | - multicast and anycast address only supported with IPv6 - brodcast address only supported with IPv4 Signed-off-by: Thomas Graf <tgraf@suug.ch>
* hashtable: remove doc section crashing doxygenThomas Graf2012-11-111-7/+0
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* hashtable: Fix reference leak in nl_hashtable_free()Thomas Graf2012-11-101-0/+3
| | | | | | | 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>
* hashtable: Add API reference documentationThomas Graf2012-11-101-1/+61
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Hash: Properly prefix hash functionsThomas Graf2012-11-102-2/+2
| | | | | | Do not pollute public namespace with unprefixed functions. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add hash support to route cacheroopa2012-11-101-0/+47
| | | | | | | | | | 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>
* Add hash support to neigh cacheroopa2012-11-101-0/+46
| | | | | | | | | | 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>
* Add hash support to link cacheroopa2012-11-101-0/+23
| | | | | | | | | | 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>
* Add hash support in cache mngrroopa2012-11-101-3/+68
| | | | | | | | | | 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>