summaryrefslogtreecommitdiff
path: root/lib/route
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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>
* link: Support IFLA_PROMISCUITY link attributeThomas Graf2012-10-091-40/+79
| | | | | | | * read-only attribute * dumped in details sections "promisc-mode (N users)" Signed-off-by: Thomas Graf <tgraf@redhat.com>
* asprintf related fixed in yy parserКоренберг Марк2012-08-301-10/+14
| | | | | | | | | | | | 1. According to man asprintf: If memory allocation wasn't possible, or some other error occurs, these functions will return -1, and the contents of strp is undefined. 2. Sometimes, errp was not filled at all. In high-level code, free(errp) will called, so segmantation fault may appear in case of error in parser 3. The most cases of using asprintf is to report about allocation fail. So, probability of allocation of asprintf buffer is very high. And that will lead to trash in errp. 4. For simple casses I decide to replace asprintf with strdup
* route: Document ROUTE_CACHE_CONTENT flagThomas Graf2012-08-301-0/+4
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* "%llu" replaced with "%" PRIu64Коренберг Марк (дома)2012-08-304-27/+38
| | | | | | | | | | | | | | | | | | | | | On some architectures, uint64_t is defined as: typedef unsigned long long int __u64; on another architectures as: typedef unsigned long int __u64; So, according to man 3 printf, uint64_t should be printed as "%llu" on some architectures, and as "%lu" on another. The same for scanf. To eliminate that challenge, there is inttypes.h, in which appropriate constants are defined for current architecture. 32-bit types (and even 16 and 8 bit types) should be printed using such constants if printed variable defined as uint_XXXt or intXXXt type. But in reality 32-bit and less types does not gain run-time error (except in scanf), because they pushed to stack as 32-bit values at least. So, I decide not to fix that.
* single nexthop flags bugJustin Mayfield2012-08-291-1/+7
| | | | | | | | | | | | | | | | 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.
* route_clone : fix segmentation fault using nl_cache_subset to filter routesLoïc Touraine2012-08-291-0/+3
| | | | | reset the nb nhops to 0 (dst->rt_nr_nh = 0) before setting the dst->nhops from the src->nhops
* Fix the always false if (a->rt_nr_nh != a->rt_nr_nh) testMichele Baldessari2012-08-291-1/+1
| | | | | Fix the always false if (a->rt_nr_nh != a->rt_nr_nh) test and compare properly the a and b structs
* tbf: fix false missing attrStephane Fillod2012-08-091-1/+1
| | | | Fix false missing attribute in tbf_msg_fill() when applying a tbf qdisc.
* Fix types-related warnings based on clang diagnosticsКоренберг Марк2012-06-139-14/+17
| | | | | | | | | | | | | | | | | 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.
* link: rtnl_link_get_kernel() should only wait for ACK if AUTO-ACK is onThomas Graf2012-06-131-1/+1
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add 'ingress' to the list of recognized TC handles.Andrew Collins2012-06-111-0/+5
| | | | | | Currently, rtnl_tc_handle2str understands the ingress handle but rtnl_tc_str2handle does not. This change lets rtnl_tc_str2handle recognize 'ingress' as a valid handle as well.
* netem: Use ARRAY_SIZE()Thomas Graf2012-06-081-1/+1
|
* rtnl_netem_set_delay_distribution: fix possible segfaultКоренберг Марк (ноутбук дома)2012-06-081-3/+4
| | | | fix counting of elements in array. Just typo, as I think.
* Fix compilation with clangКоренберг Марк (ноутбук дома)2012-06-071-4/+5
| | | | | classid_exit unnecessarily used gcc-only closure. conversion to simple static function works OK.
* correct HTB rtable/HZ calculationsAndrew Collins2012-05-293-9/+9
| | | | | | | | | | | | The HTB implementation in libnl uses units of microseconds in a number of places where it seems TC is expecting time in units of ticks, which causes actual rates much higher than requested. Additionally, libnl uses USER_HZ for calculating buffer and cbuffer sizes, which can result in much larger buffers than necessary on systems with high resolution timers. Note that the TBF qdisc uses microseconds incorrectly in two spots as well, I fixed this but did not test.
* add fwmark mask supportA C2012-05-291-1/+30
| | | | | | The fw classifier allows a mask to be set, which is necessary for some complex shaping/firewall scenarios. The attached patch adds support for it to libnl.
* doc: documentation restructuringThomas Graf2012-05-102-4/+3
| | | | | | | | | | - 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
* route: Add FIXME to rtnl_route_nh_set_gateway() to fix return valueThomas Graf2012-05-091-0/+1
| | | | Reported-by: Justin Mayfield <jmayfield@cradlepoint.com>
* u32: add support for hashingAdrian Ban2012-05-081-0/+85
|
* Memory leak in classid.cNicolas CARRIER2012-04-191-4/+12
| | | | | | | | | | | | | I'm using libnl in a program which I give to valgrind in order to track memory errors / leaks. When my program exits, it complains about non-freed memory, allocated in 3 places in classid.c, at lines 280, 284 and 289. It seems related to the module's constructor classid_init which allocates resources, with no destructor to free it. The attached patch tries to fix this issue by registering a destructor which performs the tree liberation at exit.
* missing extended Table attribute for lib/route/Romary Sonrier2012-03-062-0/+7
| | | | | | | 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>
* Support plug qdisc - queue traffic until explicit releaseShriram Rajagopalan2012-02-141-0/+177
| | | | | | | | | | | | | | | | | | | | | | | The plug qdisc supports two operations - plug and unplug. When the qdisc receives a plug ("buffer") command via netlink request, packets arriving henceforth are buffered until a corresponding unplug command is received. Depending on the type of unplug ("release_one" or "release_indefinite"), the queue can be unplugged indefinitely or selectively. The plug qdisc allows a user to implement network output buffering (aka output commit), used commonly in checkpoint based fault tolerance systems. It also supports a general purpose queue plug/unplug functionality. The associated kernel module is available in David Miller's net-next tree, commit: c3059be16c9ef29c05f0876a9df5fea21f29724f This patch introduces userspace tools and API, to control the qdisc via netlink messages. Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca> Signed-off-by: Thomas Graf <tgraf@redhat.com>
* add new function to provide neighbour event parsingBrett Ciphery2012-01-301-1/+18
| | | | | | | | | | the neighbour parsing function was previously not accessible, so custom callback functions had to handle the decoding itself. rtnl_neigh_parse is introduced and implemented in much the same way as rtnl_route_parse. Signed-off-by: Brett Ciphery <brett.ciphery@windriver.com> Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: fix regression in link message parserTorsten Hilbrich2012-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a simple test program that queries the source IP for a given destination address I get a crash in the call to rtnl_link_alloc_cache. Here is the stack trace (created with version 3.2.4): Program received signal SIGSEGV, Segmentation fault. 0xb7eb7553 in strlen () from /lib/libc.so.6 (gdb) bt #0 0xb7eb7553 in strlen () from /lib/libc.so.6 #1 0xb7eb7285 in strdup () from /lib/libc.so.6 #2 0xb7fcc305 in nla_strdup (nla=0x0) at attr.c:1033 #3 0xb7f9c173 in link_msg_parser (ops=0xb7fc2940, who=0x804b330, n=0x804c3e8, pp=0xbffffbf8) at route/link.c:486 #4 0xb7fcd485 in nl_cache_parse (ops=0xb7fc2940, who=0x804b330, nlh=0x804c3e8, params=0xbffffbf8) at cache.c:724 #5 0xb7fcd547 in update_msg_parser (msg=0x804b328, arg=0xbffffbb8) at cache.c:531 #6 0xb7fd1f25 in nl_cb_call (cb=<optimized out>, msg=<optimized out>, type=<optimized out>) at ../include/netlink-local.h:126 #7 recvmsgs (cb=<optimized out>, sk=<optimized out>) at nl.c:729 #8 nl_recvmsgs (sk=0x804b2d0, cb=0x804b368) at nl.c:780 #9 0xb7fcd5fd in __cache_pickup (sk=0x804b2d0, cache=<optimized out>, param=0xbffffbf8) at cache.c:560 #10 0xb7fcd83f in nl_cache_pickup (sk=0x804b2d0, cache=0x804b308) at cache.c:593 #11 0xb7fcd8c8 in nl_cache_refill (sk=0x804b2d0, cache=0x804b308) at cache.c:780 #12 0xb7f9d1fc in rtnl_link_alloc_cache (sk=0x804b2d0, family=4, result=0xbffffcd4) at route/link.c:868 #13 0x08048fd0 in libnl_init (data=<optimized out>) at helper_route.c:60 #14 iproute_get_source (destination=0xbffffeff "127.0.0.1", source=0xbffffd0f "\b\004c\370\267\364_\370\267\260\224\004\b8\375\377\277e\024\347\267\320\016\377\267\273\224\004\b\364_\370\267\260\224\004\b", source_size=17) at helper_route.c:105 #15 0x08048e6a in main (argc=2, argv=0xbffffde4) at ip_route_get.c:25 The attached patch (against 3.2.4) solves the problem, fixing something that looks like a typo. The bug is still present in current Git master.
* rtnl_link_bond_add: allow to allocate bond name in case NULL is givenJiri Pirko2011-11-111-4/+1
| | | | Signed-off-by: Jiri Pirko <jpirko@redhat.com>
* link: allow to add/get linkinfo of unknown typeJiri Pirko2011-11-111-22/+54
| | | | | | | | store type kind in rtnl_link independently. That would allow to use this value even if type_ops are not present. This allows for example to create devices of type unknown to libnl. Signed-off-by: Jiri Pirko <jpirko@redhat.com>
* add missing IFLA_MASTER fillupJiri Pirko2011-11-071-0/+3
| | | | | | this makes all set_master functions work. Signed-off-by: Jiri Pirko <jpirko@redhat.com>
* link: generic link enslaving APIThomas Graf2011-11-071-0/+123
| | | | | | Adds rtnl_link_enslave() / rtnl_link_release() providing a genreic link enslaving/release API for use with all link types which use the IFLA_MASTER property.
* link: Ignore bridging notifications in link cache managerThomas Graf2011-10-211-0/+14
| | | | | RTM_DELLINK and RTM_NEWLINK bridging notifications should not delete/add entries to a link cache.
* Only use the MULTIPATH attribute when adding routes with more than one next hop.Michael Altizer2011-10-101-1/+11
| | | | | | | | | | | | 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>
* Fix rtnl_link object memory leak when freeing rtnl_addr objects.Michael Altizer2011-10-101-0/+1
| | | | Signed-off-by: Michael Altizer <xiche@verizon.net>
* bonding: API to create/enslave/releaseThomas Graf2011-09-161-0/+176
| | | | | | | | | | | | | | Although it has been possible to create bonding devices, enslave and release using the regular link API. The added API simplifies usage and hides some of the compatibility logic. F.e. enslave() and release() will both verify that the master assignment has in fact been changed and return -NLE_OPNOTSUPP if it did not. Also the API will make sure to use RTM_NEWLINK or RTM_SETLINK depending on what is availble. Examples are provided in src/ as nl-link-enslave.c and nl-link-release.c
* link: Eat ACK followed by RTM_NEWLINK when requesting single linkThomas Graf2011-09-141-0/+4
| | | | | | When requesting a single link with RTM_GETLINK (no dump) the RTM_NEWLINK carrying the answer will be followed by an ACK we have to wait for.
* route: Remove dead link_cache variableThomas Graf2011-09-131-3/+0
|
* fix license of lib/route/pktloc.cThomas Graf2011-09-081-3/+4
| | | | | | | | As Jan Engelhardt pointed out, pktloc.c is currently licenses under the GPL rather than the LGPL. This is a result of its previous existance in src/ which is GPL licensed. I missed to change its license when moving it to lib/. Since I am the only contributor to the code, I am changing the license hereby.
* 64bit unaligned accessBryan Phillippe2011-09-011-7/+17
| | | | This patch fixes an unaligned access for IPv6. On systems with strict alignment requirements, the unaligned access will either result in garbage data or a crash.
* htb: fix misplaced memset() overwriting already set htb prio optionThomas Graf2011-08-121-2/+2
| | | | Reported by Richard Cesar <spidla@spidlas.cz>
* link: fix unaligned access to 64bit link statsBryan Phillippe2011-08-121-27/+37
|
* Put "break" inside the "if" block in route_compare()Pavel Roskin2011-08-111-2/+4
|