summaryrefslogtreecommitdiffstats
path: root/lib/route
Commit message (Collapse)AuthorAgeFilesLines
* nl: Print file:line:func in debugging messages and provide --disable-debug ↵Thomas Graf2013-04-022-1/+7
| | | | | | | | | to disable debugging Compiling libnl with --disable-debug will result in the ignorance of the 'NLDBG' environment variable. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* rtnl-addr: Fix invalid call to nl_addr_set_prefixlen() if neither local or ↵Thomas Graf2013-03-141-4/+7
| | | | | | peer address are present Signed-off-by: Thomas Graf <tgraf@suug.ch>
* rtnl-addr: Inherit prefix length to nl_addr objs in rtnl_addr_set_prefixlen()Thomas Graf2013-03-141-3/+32
| | | | | | | | | | | | Previously if using rtnl_addr_set_prefixlen() the new prefix length was not forwarded to the corresponding 'struct nl_addr' objects associated with address already and thus the comparison function would fail. This patch also clears the internal ADDR_ATTR_PREFIXLEN flag if the prefix length has been reset. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Use thread-safe strerror_r() instead of strerror()Thomas Graf2013-02-281-2/+2
| | | | | | | We have only ever fed well known error codes into strerror() so it should never have been a problem though. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Fix rtnl_link_af_data_compare return valueroopa2013-02-241-7/+11
| | | | | | | | | | | | | | | | | | | | This patch fixes a bug where because of the af_ops check being first in the function, we were returning ~0 if af_ops was null even if both objects really did not have af_data and we should be returning 0. Its better to have the af_data present check before anything else. So, Rearranged some of the code in rtnl_link_af_data_compare. Changes include: - Do the attribute present check before anything else - If ao_compare op not present, return ~0 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>
* link: move af_data_compare to the endroopa2013-02-241-6/+6
| | | | | | | | | | | | | | In the current code if rtnl_link_af_data_compare returns value > 0 we mark PROTINFO attribute in the diff mask and return without comparing flags. This patch makes af_data to be the last thing we compare. 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>
* bond: Provide rtnl_link_bond_alloc()Thomas Graf2013-02-141-14/+27
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* vlan: Provide rtnl_link_vlan_alloc()Thomas Graf2013-02-141-1/+22
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* bridge: Provide rtnl_link_bridge_alloc()Thomas Graf2013-02-141-0/+21
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* bridge: Support the new bridging attributesThomas Graf2013-02-071-12/+362
| | | | | | | | | | | | | This provides support for the new bridging attributes provided in IFLA_PROTINFO while maintaining backwards compatibility with older kernels. A set of new API functions are exported to access the bridging information. rtnl_link_bridge_has_ext_info() can be used to check whether a bridge object has been constructed based on the newly available attributes or the old message format. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Free and realloc af specific data upon rtnl_link_set_family()Thomas Graf2013-02-051-0/+6
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Hold af_ops reference for each AF_SPEC block during lifetime of link ↵Thomas Graf2013-02-051-4/+6
| | | | | | object Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Modify link policy on the stackThomas Graf2013-02-051-2/+5
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Keep reference to af_ops during lifetime of link objectThomas Graf2013-02-051-0/+4
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Fix af_ops leak on ENOMEMThomas Graf2013-02-051-1/+3
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* can: Fix nested message creation in can_put_attrs()Holger Dengler2013-02-011-0/+2
| | | | | | Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de> Signed-off-by: Holger Dengler <dengler@linutronix.de> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* neigh: Remove check for AF_UNSPEC in rtnl_neigh_get()Thomas Graf2013-02-011-2/+2
| | | | | | | | | | | | | This check was introduces to not accidently return AF_BRIDGE objects to unaware API users as they do differ in structure. However, such objects are only available if explicitely requests using the NL_CACHE_AF_ITER flag or by using arg1 == AF_BRIDGE for the cache. Therefore remove this check and allow rtnl_neigh_get() to be used to fetch any neighbor object of a cache. Reported-by: Maxime Bizon <mbizon@freebox.fr> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link cache: remove AF_UNSPEC check in rtnl_get_link and rtnl_get_link_by_nameroopa2013-01-311-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch reverts back the AF_UNSPEC check introduced by AF_BRIDGE changes at http://lists.infradead.org/pipermail/libnl/2012-November/000796.html After the addition of AF_BRIDGE support, link cache can now contain objects of type AF_BRIDGE. To make sure existing api's did not return AF_BRIDGE objects and surprise existing callers, I introduced the check for AF_UNSPEC. But from what Andy Wang reported, rtnl_link_get_by_name returns the first link object with matching ifindex and that could have not only been AF_UNSPEC but also of family AF_INET6. And his app always got an AF_INET6 object prior to the patch that introduced the AF_UNSPEC check. I could just add AF_INET6 family check along with AF_UNSPEC in the apis and that should work well. But thinking about it some more, removing the AF_UNSPEC change seems to be safer at this point. That way this api will retain its semantics and return the first object with matching ifindex. It could be of any supported family. The user will know if the cache contains bridge objects, because they are available only with the cache flag NL_CACHE_AF_ITER. Besides, if new users want to search for a specific object, nl_cache_find is a better option. Reported-by: Andy Wang <Andy.Wang@watchguard.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* can: add helper function to get CAN bus stateBenedikt Spranger2013-01-251-0/+19
| | | | | | Add a helper function to get the CAN bus state. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
* Move private header files to <netlink-private/*>Thomas Graf2013-01-2450-127/+127
| | | | | | | 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>
* 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>
* 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-291-0/+404
| | | | | | | | | | | | | 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>
* cache: provide safe variant of nl_cache_mngt_require() and use itThomas Graf2012-11-167-9/+30
| | | | | | | | 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-151-1/+1
| | | | 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>
* 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>
* 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>
* Add hash support to route cacheroopa2012-11-091-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-091-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-091-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>
* Set err and free ntbl when leaving neightbl_msg_parserMichele Baldessari2012-10-291-1/+1
| | | | | Make sure we leave neightbl_msg_parser() by setting the proper err variable and freeing ntbl
* Remove unreachable codeMichele Baldessari2012-10-291-5/+0
| | | | This code gets never called anyway
* Clang diagnosticsКоренберг Марк (ноутбук дома)2012-10-194-7/+13
| | | | | | | | | | | | 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
* ROUTE_DIFF result was not used in some place in route_compareКоренберг Марк (ноутбук дома)2012-10-191-1/+1
|
* link: Support link groupingThomas Graf2012-10-091-1/+38
| | | | | | | | | | New functions: rtnl_link_set_group(link, group) rtnl_link_get_group(link) The group identifier is printed in the brief section as "group N" Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: Include IFLA_NUM_TX_QUEUES and IFLA_NUM_RX_QUEUES when building messagesThomas Graf2012-10-091-0/+6
| | | | Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: Only print "promisc-mode" if users > 0Thomas Graf2012-10-091-1/+1
| | | | Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: Support IFLA_NUM_TX_QUEUES and IFLA_NUM_RX_QUEUESThomas Graf2012-10-091-0/+85
| | | | | | | | | | New functions: rtnl_link_set_num_tx_queues(link, nqueues) rtnl_link_get_num_tx_queues(link) rtnl_link_set_num_rx_queues(link, nqueues) rtnl_link_get_num_rx_queues(link) Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: correctly set LINK_ATTR_PROMISCUITYThomas Graf2012-10-091-2/+2
| | | | Signed-off-by: Thomas Graf <tgraf@redhat.com>