summaryrefslogtreecommitdiffstats
path: root/lib/object.c
Commit message (Collapse)AuthorAgeFilesLines
* Move private header files to <netlink-private/*>Thomas Graf2013-01-241-1/+1
| | | | | | | This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Add new nl_cache_find apiroopa2013-01-111-0/+22
| | | | | | | | | | | | | | | | | 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>
* use safe cache lookup variants internallyThomas Graf2012-11-151-2/+4
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add nl hashtable structures and access functionsroopa2012-11-091-0/+21
| | | | | | | | | | | 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>
* Add support for updating objects in the cacheroopa2012-11-051-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add new object op oo_id_attrs_getroopa2012-11-051-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix types-related warnings based on clang diagnosticsКоренберг Марк2012-06-131-2/+2
| | | | | | | | | | | | | | | | | 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.
* Fix for dumping objects to a buffer instead of file descriptorBushman, Jeff2012-05-181-0/+3
| | | | | | | | Attached is a patch to fix two problems with dumping objects to a buffer in= stead of a file descriptor. One was a problem in detecting the end of the buffer in the newline code. The other was a problem with clearing the whole buffer before printing each= object.
* doc: documentation restructuringThomas Graf2012-05-101-2/+14
| | | | | | | | | | - 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
* object: Add functions to access the object type, cache and object opsThomas Graf2012-04-241-1/+54
|
* Provide nl_object_dump_buf() to easily dump to buffersThomas Graf2011-04-101-0/+10
|
* Documentation updatesThomas Graf2011-03-211-2/+4
| | | | Mostly killing doxygen warnings, some doc updates to caching
* Fix rule attribute comparisonPatrick McHardy2010-04-191-0/+2
| | | | | | | | | | | | Rules don't have unique identifiers, so all attributes are compared by initializing the ID mask to ~0. This doesn't work however since nl_object_identical verifies whether the ID attributes are actually present before comparing the objects, which is never the case. Work around by using the intersection of present attributes when comparing two rule objects. Signed-off-by: Patrick McHardy <kaber@trash.net>
* nl_object_clone: properly clone ce_mask fieldAlexander Sack2009-07-201-0/+1
| | | | | based on my finding, ce_mask needs to be identical on clones; otherwise some functions (like "dump") will treat clones differently.
* nl_object_priv() is inline, so define it in the headerPavel Roskin2009-04-161-5/+0
|
* Thread-safe error handlingThomas Graf2008-05-141-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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!
* Big routing code rework (API/ABI BREAK!)Thomas Graf2008-04-291-1/+1
| | | | | | | | | | Adds all missing routing attributes and brings the routing related code to a working state. In the process the API was broken several times with the justification that nobody is using this code yet. The changes include new example code which is also a prototype for how plain CLI tools could look like to control routes.
* Initial importThomas Graf2007-09-141-0/+386