summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* cgroup classifier improvementsThomas Graf2010-10-283-26/+124
| | | | | | | | | | | - enabled again - ematch support - cli tools module Example: nl-qdisc-add --dev eth0 --parent root --id 1: htb nl-cls-add --dev eth0 --parent 1: --id dead: cgroup nl-class-add --dev eth0 --parent 1: --id 1:<CGROUP> htb --rate 77mbit
* basic: Only add ematches to message if availableThomas Graf2010-10-281-1/+5
|
* Tons of ematch workThomas Graf2010-10-2811-179/+950
| | | | | | | | | | - Fixes a bunch of bugs related to ematches - Adds support for the nbyte ematch - Adds a bison/flex parser for ematch expressions, expressions may look like this: ip.length > 256 && pattern(ip6.src = 3ffe::/16) documenation on syntax follows - adds ematch support to the basic classifier (--ematch EXPR)
* Fix use of uninitialized data at the end of netlink messageThomas Graf2010-10-281-1/+1
| | | | | | | The netlink message buffer is preallocated to a page and later expanded as needed. Everything was properly paded and zeroed out except for the unused part at the end. Use calloc() to allocate the buffer.
* Avoid memcpy()/memset() when reserving space for nested attributesThomas Graf2010-10-281-4/+7
|
* Extended pktloc to support nbyte locations for ipv6, etc.Thomas Graf2010-10-282-5/+26
| | | | | The alignment column/field now also takes a number, specifying the length in bytes of the field described by the location
* Packet location updatesThomas Graf2010-10-264-60/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch includes various bugfixes in the packet location parser. Namely it removes two memory leaks if parsing fails. The parser is correctly quit if an allocation error occurs and it is no longer possible to add duplicates. It removes the possibility to differ between net and host byteorder. This is better done in the actual classifiers as it makes more sense to specify this together with the value to compare against. The patch also extends the API to add new packet locations via rtnl_pktloc_add(). It introduces reference counting, therefore you now have to give back packet locations with rtnl_pktloc_put() after looking them up with rtnl_pktloc_lookup(). But you are allowed to keep using them if the packet location file has been reread. The packet location file now also understands "eth", "ip", and "tcp" for "link", "net", and "transport". A --list option has been added to nl-pktloc-lookup to list all packet location definitions A --u32=VALUE option has been added to let nl-pktloc-lookup print the definition in iproute2's u32 selector style. A manual page has been written for nl-pktloc-lookup. Finally, nl-pktloc-lookup has been made installable.
* nl-cls-* toolsThomas Graf2010-10-263-7/+101
| | | | cli based tools to add/update/list/delete classifiers
* Unified TC attributes interfaceThomas Graf2010-10-2617-445/+468
| | | | | | | | | | | | | | | | | | | | | | | | So far all common tc atttributes were accessed via specific functions, i.e. rtnl_class_set_parent(), rtnl_qdisc_set_parent(), rtnl_cls_set_parent() which implied a lot of code duplication. Since all tc objects are derived from struct rtnl_tc and these common attributes are already stored in there this patch removes all type specific functions and makes rtnl_tc_* attribute functions public. rtnl_qdisc_set_parent(qdisc, 10); becomes: rtnl_tc_set_parent((struct rtnl_tc *) qdisc, 10); This patch also adds the following new attributes to tc objects therefore removing them as tc specific attributes: - mtu - mpu - overhead This allows for the rate table calculations to be unified as well taking into account the new kernel behavior to take care of overhead automatically.
* Update include/linux header copiesThomas Graf2010-10-213-26/+13
| | | | | Adapts ratespec code taking into account that the kernel now takes care of overhead calculations.
* Remove NL_DUMP_ENV codeThomas Graf2010-10-206-344/+0
| | | | | | | 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.
* nl-class-add toolThomas Graf2010-10-204-11/+144
| | | | | | | | | | Adds a cli based tool to add/update traffic classes. This tool requires each class to be supported via the respetive qdisc module in pkglibdir/cli/qdisc/$name.so. Syntax: nl-class-add --dev eth2 --parent 1: --id 1:1 htb --rate 100mbit nl-class-add --update --dev eth2 --id 1:1 htb --rate 200mbit
* pfifo/bfifo qdisc support for cli libsThomas Graf2010-10-193-1/+160
|
* classid databaseThomas Graf2010-10-193-109/+358
| | | | | | | | | A database to resolve qdisc/class names to classid values and vice versa. The function rtnl_tc_handle2str() and rtnl_tc_str2handle() will resolve names automatically. A CLI based tool nl-classid-lookup is provided to integrate the database into existing iproute2 scripts.
* HTB: Append TCA_OPTIONS even if no options are setThomas Graf2010-10-191-7/+7
| | | | | The kernel requires the TCA_OPTIONS{TCA_HTB_INIT} attribute to be present even if the default values are to be used.
* nl-qdisc-add toolThomas Graf2010-10-193-0/+152
| | | | | | | | | | | | Adds a cli based tool to add/update/replace qdiscs. This tool requires each qdisc to be supported via a dynamic loadable module in pkglibdir/cli/qdisc/$name.so. So far HTB and blackhole have been implemented. Syntax: nl-qdisc-add --dev eth2 --parent root --id 1: htb --r2q=5 nl-qdisc-add --update-only --dev eth2 --id 1: htb --r2q=10
* - Prepare for 2.1.x treeThomas Graf2010-10-141-4/+1
| | | | - Bump interface number, we will break API in the development tree
* Generic Netlink multicast groups supportdima2010-10-144-1/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | I have a patch against commit d378220c96c3c8b6f27dca33e7d8ba03318f9c2d extending libnl with a facility to receive generic netlink messages sent to multicast groups. Essentially it add one new function genl_ctrl_resolve_grp which prototype looks like this int genl_ctrl_resolve_grp(struct nl_sock *sk, const char *family_name, const char *grp_name) It resolves the family name and the group name to group id. Then the returned id can be used in nl_socket_add_membership to subscribe to multicast messages. Besides that it adds two more functions uint32_t nl_socket_get_peer_groups(struct nl_sock *sk) void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups) allowing to modify the socket peer groups field. So it's possible to multicast messages from the user space using the legacy interface. Looks like there is no way (or I was not able to find one?) to modify the netlink socket destination group from the user space, when the group id is greater then 32.
* Don't include pktloc_syntax.h in BUILT_SOURCESlibnl2_0Thomas Graf2010-10-131-1/+0
|
* route_obj: don't add empty destination to nlmsgDavid Lamparter2010-10-131-1/+2
| | | | | | | | | | 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>
* automake: add ${top_builddir}/include to AM_CFLAGSAndreas Bießmann2010-10-131-1/+1
| | | | | | | | | | | This patch enables out-of-source builds like this $ cd builddir && src_dir/configure && make Before this patch there was an error about missing netlink/version.h which is built by automake in top_builddir rather than top_srcdir which is already in include search path. Signed-off-by: Andreas Bießmann <biessmann@corscience.de>
* Put preprocessor definitions in AM_CPPFLAGSMatthew L. Creech2010-10-131-1/+1
| | | | | | | | When an alternate kernel header include directory is added in CPPFLAGS, the libnl build fails. This is because the local copy of kernel headers is added in AM_CFLAGS, which gets included after CPPFLAGS in the automake-generated makefile. Switching to AM_CPPFLAGS fixes the problems.
* add user data to change_func_t for cachesAndreas Fett2010-10-132-11/+13
| | | | | | | | | | | the patch below adds the possibility to pass user data to callbacks of type change_func_t when using the nl_cache_mngr_* family of functions. If there is any better way to do this, without duplicating the code in cache_mngr.c please let me know.
* Trivial fix for TBF memleakDenys Fedorysychenko2010-10-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, running alloc / free cache loop will lead to huge memory leaks on machine with 3000 interfaces with tbf qdiscs. Here was valgrind output: ==5580== 18,070,728 bytes in 347,514 blocks are definitely lost in loss record 32 of 32 ==5580== at 0x4025485: calloc (in /lib/valgrind/vgpreload_memcheck-x86- linux.so) ==5580== by 0x405F410: tbf_msg_parser (tbf.c:46) ==5580== by 0x405302B: qdisc_msg_parser (qdisc.c:119) ==5580== by 0x4033DC9: nl_cache_parse (cache.c:643) ==5580== by 0x4033E7C: update_msg_parser (cache.c:460) ==5580== by 0x4038A11: nl_recvmsgs (netlink-local.h:112) ==5580== by 0x4034175: __cache_pickup (cache.c:483) ==5580== by 0x40343FF: nl_cache_pickup (cache.c:516) ==5580== by 0x403447D: nl_cache_refill (cache.c:698) ==5580== by 0x4034AB7: nl_cache_alloc_and_fill (cache.c:198) ==5580== by 0x4053216: rtnl_qdisc_alloc_cache (qdisc.c:388) ==5580== by 0x80489DB: main (in /home/root/nltest) Patch complied and tested for same test case, no more leaks anymore.
* Let git ignore generated pktloc source filesThomas Graf2010-07-031-0/+4
|
* Fix compile warning in utils.cThomas Graf2010-07-031-1/+1
|
* Fix compile warning in nl.cThomas Graf2010-07-031-1/+1
|
* Packet Location InterfaceThomas Graf2010-07-025-2/+336
|
* 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>
* addr: add NL_DUMP_ENV functionPatrick McHardy2010-04-191-0/+76
| | | | Signed-off-by: Patrick McHardy <kaber@trash.net>
* addr: restore anycast functionsPatrick McHardy2010-04-191-0/+32
| | | | | | Seems it got lost during some cleanups. Signed-off-by: Patrick McHardy <kaber@trash.net>
* neigh: fix id_attrs to include ifindexPatrick McHardy2010-04-191-1/+1
| | | | | | | Neighbour entries for the same destination may exist on multiple interfaces. Include the interface in the ID attributes. Signed-off-by: Patrick McHardy <kaber@trash.net>
* cache: properly invoke change_cb for deleted objects in nl_cache_resync()Patrick McHardy2010-04-191-2/+8
| | | | | | | When resyncing a cache, there are no delete messages, so they need to be synthesized for deleted objects. Signed-off-by: Patrick McHardy <kaber@trash.net>
* Fix a bug when calculating ticks_per_usecJose Ignacio Naranjo Hernández2010-03-101-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've noticed a wrong behavior when setting up some delays in a netem qdisc. I will try to make the things easier for the reader describing the calls path. To set up a delay (or jitter...) I use 'rtnl_netem_set_delay' which requires an int parameter that tells the delay in micro seconds. Inside this func, the delay is set up with the help of 'nl_us2ticks', which is just an arithmetic operation (us * ticks_per_usec), where us is the input parameter and ticks_per_usec is a global variable initialized in 'get_psched_settings'. And here is the problem: If this variable is going to be calculated using '/proc/net/psched', I think the file scan is not done properly. I don't understand what the meaning of the asterisk is here: int r = fscanf(fd, "%08x%08x%08x%*08x", &tick, &us, &nom); if (4 == r && nom == 1000000 && !got_tick) ticks_per_usec = (double)tick/(double)us; The execution path never gets in the if statement, because r is always 3, and if the fourth parameter is read (avoiding the asterisk), there is no variable to store it in, so it comes a segv. In my opinion we can get rid of the if statement, because I think the proc psched file has always a fixed format of 4 parameters, and 'nom' is always 1000000 (http://lxr.linux.no/#linux+v2.6.32/net/sched/sch_api.c#L1678). Find attached a patch I did, if I am correct.
* new function nfnl_queue_msg_send_verdict_payload()Karl Hiramoto2010-03-102-0/+62
| | | | | | | | | nfnl_queue_msg_send_verdict_payload() will to send the verdict, mark, and possibly changed payload through the netlink socket. Add a few docbook comments in other funcs. Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
* new feature nl_send_iovec(), nl_auto_complete() and code refactoring.Karl Hiramoto2010-03-101-24/+45
| | | | | | | | | | | | | Create new function nl_send_iovec() to be used to send multiple 'struct iovec' through the netlink socket. This will be used for NF_QUEUE, to send packet payload of a modified packet. Refactor nl_send() to use nl_send_iovec() sending a single struct iovec. Create new function nl_auto_complete() by refactoring nl_send_auto_complete(), so other functions that call nl_send may also use nl_auto_complete() Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
* one more fix, u32.cDenys Fedoryschenko2009-12-071-2/+1
| | | | | | One more segfault, also nl-tctree-list , fix Probably need reformat for better look Patch attached
* invalid comma cause segfault for nl-tctree-list, tbf.cDenys Fedoryschenko2009-12-071-1/+1
| | | | | | I notice segfault while running nl-tctree-list for tbf qdisc. Patch that fix this typo is attached.
* libnl: add ERANGE to errno translationPatrick McHardy2009-11-101-0/+1
| | | | Signed-off-by: Patrick McHardy <kaber@trash.net>
* libnl: fix automake breakagePatrick McHardy2009-11-101-1/+1
| | | | | | | | libnl-route must be handled before libnl-nf in lib_LTLIBRARIES since the later depends on the former. Additionally nf-monitor, nl-list-caches, nl-list-sockets and nl-util-addr have been dropped from the Makefile. Signed-off-by: Patrick McHardy <kaber@trash.net>
* - Compile with _GNU_SOURCEThomas Graf2009-09-021-2/+2
| | | | - Fixed classifier.c -> cls.c
* Merge branch 'master' of git://dev.medozas.de/libnlThomas Graf2009-09-023-129/+43
|\ | | | | | | | | | | Conflicts: lib/Makefile src/Makefile
| * build: make use of library dependenciesJan Engelhardt2009-07-051-0/+3
| |
| * Move to automake-based buildJan Engelhardt2009-06-223-128/+40
| | | | | | | | | | | | | | | | | | | | | | | | Issues solved: * PACKAGE_VERSION was abused for SOVERSION * unneeded DEP stage * did not support out-of-tree builds * no way to turn off silent mode * overriding CFLAGS at make time was not supported * no static libs were provided Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
* | Add support for getting and deleting queueing classes.olc2009-09-021-0/+78
| |
* | Fix rtnl_addr cachingDan Winship2009-09-021-2/+1
| | | | | | | | | | | | addr_obj.ops.oo_id_attrs included ADDR_ATTR_PEER, so any address that didn't have a peer address set would compare as unequal to itself, meaning it could never be removed from a cache after it was added, etc.
* | Patch for unexpectedly aligned messagesMarc de Kruijf2009-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | I found the following bug, where nlmsg_ok() in lib/msg.c would incorrectly return 'true' when the input argument 'remaining' was a negative number. This happens when the message is not aligned the way that libnl expects (although it is still legal). In the comparison of the signed and unsigned numbers on line 284, the signed number gets converted to an unsigned number, which is unexpected and naturally produces a bug. My patch is below. The cast is ugly, but it fixes the problem.
* | - Reworked the classifier interface.Thomas Graf2009-09-0210-187/+1046
| | | | | | | | | | | | - Added initial ematch support - Added support for the basic classifier - Added support for the cgroup classifier
* | 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.
* release_local_port: properly compute the bitmap positionInaky Perez-Gonzalez2009-05-041-1/+1
| | | | | | | | Current calculation is always off, not reflecting the right position in the bitmap, which results in failures due to conflicts (detected at the kernel level) when trying to open a new handle. Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>