dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

29 Commits

Author SHA1 Message Date
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
roopa 1481f97d36 route cache: This patch adds route priority to route object oo_id_attrs
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>
2013-01-23 11:02:51 +01:00
roopa 29b71371e7 route cache: Fix handling of ipv6 multipath routes
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>
2012-12-17 15:16:02 +01:00
Thomas Graf 00132b4696 cache: provide safe variant of nl_cache_mngt_require() and use it
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>
2012-11-16 01:11:55 +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
Коренберг Марк (ноутбук дома) fedb862ea5 ROUTE_DIFF result was not used in some place in route_compare 2012-10-19 22:16:44 +06:00
Justin Mayfield b62e019afa single nexthop flags bug
I ran into a bug today related to how Linux handles a route's nexthop
flags when there is just one nexthop.  Namely Linux expects the flags
to be OR'd into the rtm_flags field when there is only one nexthop and
so rtnl_route_build_msg needs to check the number of nexthops and
store the nexthops flags into this field prior to calling
nlmsg_append(...&rtmsg).

Conversely the rtnl_route_parse function needs to pull these lower
0xff bits when a single nexthop is detected.

Attached is my patch.  I don't like the slight duplication of doing
the rtnl_route_get_nnexthops check twice but it seemed to be the least
turmoil of any solution I thought of.
2012-08-29 12:27:06 +02:00
Loïc Touraine 97d2460fab route_clone : fix segmentation fault using nl_cache_subset to filter routes
reset the nb nhops to 0 (dst->rt_nr_nh = 0) before setting the dst->nhops
from the src->nhops
2012-08-29 12:14:59 +02:00
Michele Baldessari 8222519f85 Fix the always false if (a->rt_nr_nh != a->rt_nr_nh) test
Fix the always false if (a->rt_nr_nh != a->rt_nr_nh) test and compare
properly the a and b structs
2012-08-29 12:00:24 +02: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
Romary Sonrier 965fd78042 missing extended Table attribute for lib/route/
I found a small bug in libnl, about extended table id ( above 256 ).

Signed-off-by: Romary Sonrier <romary@sonrier.com>
Signed-off-by: Thomas Graf <tgraf@redhat.com>
2012-03-06 10:15:30 +01:00
Michael Altizer 790966d69a Only use the MULTIPATH attribute when adding routes with more than one next hop.
Only use the MULTIPATH attribute when adding routes with more than one
next hop.
This solves issues with two scenarios:
1. Adding an IPv4 route to a kernel configured without
CONFIG_IP_ROUTE_MULTIPATH=y.
2. Adding an IPv6 route in general, since the MULTIPATH attribute is not
supported there.

Signed-off-by: Michael Altizer <xiche@verizon.net>
2011-10-10 11:44:10 +02:00
Thomas Graf 6d93b831dd route: Remove dead link_cache variable 2011-09-13 23:16:09 +02:00
Pavel Roskin bbe5e94253 Put "break" inside the "if" block in route_compare() 2011-08-11 14:49:51 +02:00
Daniel Walter f0603a467b add missing checks for ROUTE_ATTR_MULTIPATH
attached patch adds missing checks for ROUTE_ATTR_MULTIPATH
when dealing with multipath routing.

Affected functions

rtnl_route_remove_nexthop
rtnl_route_get_nexthops
rtnl_route_get_nnexthops
2011-03-22 13:11:09 +01:00
Thomas Graf cf5577d280 constify struct trans_tbl 2010-11-17 16:09:08 +01:00
Thomas Graf 10424b20c1 Rename nl_get_hz() to nl_get_user_hz() to indicate it's not the in-kernel HZ value 2010-11-17 11:55:42 +01:00
Thomas Graf 420438c71f Remove NL_DUMP_ENV code
Dumping objects as environment variables has never been implemented
completely and only increases the size of the library for no real
purpose. Integration into scripts is better achieved by implementing
a python module anyway.
2010-10-20 15:32:45 +02:00
David Lamparter 2b3fabab9e route_obj: don't add empty destination to nlmsg
don't try to give the kernel an empty RTA_DST attribute. this would
previously happening on trying to delete the default route as returned
from the kernel. the kernel doesn't add a RTA_DST atttribute, so libnl
does nl_addr_alloc(0) and inserts a zero-length RTA_DST attribute into
the deletion request, which the kernel then refuses with ERANGE.

Signed-off-by: David Lamparter <equinox@diac24.net>
2010-10-13 15:21:14 +02:00
Thomas Graf 7072675b40 Improved printing of route cache entries 2008-06-16 23:59:09 +02:00
Thomas Graf d844307024 Remove old line counting while dumping 2008-05-23 23:45:14 +02:00
Thomas Graf eed2afaab7 Remove obsolete nla_get_addr() and nla_get_data()
Replaces obsolete calls to nla_get_addr() and nla_get_data()
with nl_addr_alloc_attr() respectively nl_data_alloc_attr().

Also fixes missing error handling while parsing routing multipath
configuration.
2008-05-14 18:26:47 +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
Ben Gamsa cc9c6d6384 Added two new functions to facilitate processing the nexthop entries for routes.
Added rtnl_route_foreach_nexthop() to walk the list of nexthops invoking a
caller-provided callback for each nexthop entry, and added rtnl_route_nexthop_n()
to retrieve the Nth nexthop entry in the list.
2008-05-08 17:54:37 +02:00
Thomas Graf 48e1e5c472 Speed up metrics comparison
Using rtnl_route_get_metric() for route comparison became a bottleneck
because each metric which was not available resulted in the generation
of an error message. This changeset avoids this by accessing rt_metrics
and rt_metrics_mask directly while comparing route objects.
2008-05-08 12:47:26 +02:00
Thomas Graf d6cd72555d Fix dumping of iif route attribute 2008-05-05 17:09:56 +02:00
Thomas Graf 535e831622 Big routing code rework (API/ABI BREAK!)
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.
2008-04-29 23:31:30 +02:00
Thomas Graf 4649886288 Represent default route with destination address length zero
So far the destination address for default routes was NULL
which complicated the handling of routes in general. By
assigning a address of length zero they can be compared
to each other.

This allows the cache manager to properly handle default
routes.
2007-12-19 19:41:01 +01:00
Thomas Graf 44d362409d Initial import 2007-09-15 01:28:01 +02:00