dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

367 Commits

Author SHA1 Message Date
Thomas Graf 4e48d90e71 Correctly parse and generate classids
Make sure to parse strings starting with a hex represention letter
but not representing a valid number as tc names.

Fix typo while generating classid.
2010-11-01 13:17:19 +01:00
Thomas Graf 4267d8f336 classid auto generation if provided tc name does not exist
Manually editing etc/libnl/classid before adding tc objects is a pain.
This patch adds code to attempt auto generating a unique tc id which
will then be assigned to the provided name and added to the classid
file.

This will make the following commands work with prior definitions of
the names "top" and "test"
	sudo sbin/nl-qdisc-add --dev eth0 --parent root --id top htb
	sudo sbin/nl-class-add --dev eth0 --parent top --id test htb --rate 100mbit

It will generate the following ids automatically:
4001:			top
4001:1			test
2010-11-01 08:17:40 +01:00
Thomas Graf 7903d6ab4b Support for meta match
Syntax:
	meta(pktlen > 768)
2010-10-31 23:13:01 +01:00
Thomas Graf c7a673787b text ematch support 2010-10-29 21:10:02 +02:00
Thomas Graf 93f992eac5 attr: Add padding if nested data does not end at an alignment boundry
This could happen if a user put an unaligned amount of data inside
an attribute with nlmsg_append().
2010-10-29 18:40:48 +02:00
Thomas Graf cc22992d0c Improved debugging messages while constructing messages/attributes 2010-10-29 18:34:27 +02:00
Thomas Graf f703192a4f routing rules: adapt to unified routing rules
- Use FRA_ definitions
- Removed obsoleted fields
- Added fwmask and goto support
2010-10-29 12:48:46 +02:00
Thomas Graf 1eccb7b99c Revert "routing rules: mark support"
This reverts commit ee88c71d16.
2010-10-29 11:52:22 +02:00
Thomas Graf 858527622a Revert "Include RTA_MARK in routing rule messages"
This reverts commit 6862c6592a.
2010-10-29 11:52:08 +02:00
Thomas Graf 48cdb1fe66 Support RT_TABLE_COMPAT 2010-10-29 02:06:14 +02:00
Thomas Graf 2e6d49784b Support neighbour flag NTF_USE 2010-10-29 02:00:53 +02:00
Thomas Graf 873a64e2c1 Support for 64bit link counters IFLA_STATS64 2010-10-29 01:58:27 +02:00
Thomas Graf 6d434415ad Updated arp and ethernet codes 2010-10-29 01:48:13 +02:00
Thomas Graf 6862c6592a Include RTA_MARK in routing rule messages 2010-10-29 01:38:10 +02:00
Thomas Graf ee88c71d16 routing rules: mark support
Obsolete RTA_PROTOINFO code and parse RTA_MARK

rtnl_rule_set_mark(rule, mark)
rtnl_rule_get_mark(rule)

now access the mark as in firewall mark
2010-10-29 01:34:15 +02:00
Thomas Graf 691905bc56 cgroup classifier improvements
- 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
2010-10-29 00:51:11 +02:00
Thomas Graf 2f867686ac basic: Only add ematches to message if available 2010-10-29 00:45:45 +02:00
Thomas Graf d7a561a137 Tons of ematch work
- 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)
2010-10-29 00:20:42 +02:00
Thomas Graf e1eacd6b16 Fix use of uninitialized data at the end of netlink message
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.
2010-10-29 00:17:07 +02:00
Thomas Graf d0e564548f Avoid memcpy()/memset() when reserving space for nested attributes 2010-10-29 00:16:40 +02:00
Thomas Graf 0fe5b29423 Extended pktloc to support nbyte locations for ipv6, etc.
The alignment column/field now also takes a number, specifying
the length in bytes of the field described by the location
2010-10-29 00:14:34 +02:00
Thomas Graf 65e386c8ba Packet location updates
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.
2010-10-27 01:21:50 +02:00
Thomas Graf b57a697ef1 nl-cls-* tools
cli based tools to add/update/list/delete classifiers
2010-10-26 22:30:02 +02:00
Thomas Graf 4c6d1c5dfb Unified TC attributes interface
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.
2010-10-26 12:54:33 +02:00
Thomas Graf b9d965b01b Update include/linux header copies
Adapts ratespec code taking into account that the kernel now takes
care of overhead calculations.
2010-10-21 19:47:14 +02: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
Thomas Graf 27883b0f9b nl-class-add tool
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
2010-10-20 14:57:39 +02:00
Thomas Graf 18848090f9 pfifo/bfifo qdisc support for cli libs 2010-10-19 16:51:55 +02:00
Thomas Graf 757592ec1b classid database
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.
2010-10-19 16:31:23 +02:00
Thomas Graf fa89403149 HTB: Append TCA_OPTIONS even if no options are set
The kernel requires the TCA_OPTIONS{TCA_HTB_INIT} attribute to be
present even if the default values are to be used.
2010-10-19 13:10:26 +02:00
Thomas Graf c0cd587dfc nl-qdisc-add tool
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
2010-10-19 13:06:42 +02:00
Thomas Graf 3229b32e39 - Prepare for 2.1.x tree
- Bump interface number, we will break API in the development tree
2010-10-14 13:56:46 +02:00
dima 2dbc1ca76c Generic Netlink multicast groups support
I have a patch against commit d378220c96
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.
2010-10-14 13:46:02 +02:00
Thomas Graf 513e45ccce Don't include pktloc_syntax.h in BUILT_SOURCES 2010-10-13 16:50:33 +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
Andreas Bießmann cb05bbb0e2 automake: add ${top_builddir}/include to AM_CFLAGS
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>
2010-10-13 14:36:09 +02:00
Matthew L. Creech a172e3ccf0 Put preprocessor definitions in AM_CPPFLAGS
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.
2010-10-13 14:29:34 +02:00
Andreas Fett 4ab22ccd47 add user data to change_func_t for caches
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.
2010-10-13 13:41:57 +02:00
Denys Fedorysychenko 86b6f6f629 Trivial fix for TBF memleak
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.
2010-10-13 13:24:25 +02:00
Thomas Graf 7cf52dd94b Let git ignore generated pktloc source files 2010-07-03 15:56:07 +02:00
Thomas Graf 0fa04772ab Fix compile warning in utils.c 2010-07-03 15:17:04 +02:00
Thomas Graf 256d7e723c Fix compile warning in nl.c 2010-07-03 15:15:12 +02:00
Thomas Graf db5bd57899 Packet Location Interface 2010-07-02 14:06:59 +02:00
Patrick McHardy 3c28aa5dca Fix rule attribute comparison
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>
2010-04-19 12:43:18 +02:00
Patrick McHardy 0e4f54d288 addr: add NL_DUMP_ENV function
Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:43:01 +02:00
Patrick McHardy f5f49c2248 addr: restore anycast functions
Seems it got lost during some cleanups.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:42:53 +02:00
Patrick McHardy 8290725718 neigh: fix id_attrs to include ifindex
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>
2010-04-19 12:42:40 +02:00
Patrick McHardy ba1bd9050d cache: properly invoke change_cb for deleted objects in nl_cache_resync()
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>
2010-04-19 12:42:27 +02:00
Jose Ignacio Naranjo Hernández 52d6b8b9ee Fix a bug when calculating ticks_per_usec
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.
2010-03-10 16:18:54 +01:00
Karl Hiramoto cafdaa4e06 new function nfnl_queue_msg_send_verdict_payload()
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>
2010-03-10 16:02:01 +01:00
Karl Hiramoto 27c505eb89 new feature nl_send_iovec(), nl_auto_complete() and code refactoring.
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>
2010-03-10 16:01:46 +01:00
Denys Fedoryschenko ff76549013 one more fix, u32.c
One more segfault, also nl-tctree-list , fix
Probably need reformat for better look
Patch attached
2009-12-07 16:27:59 +01:00
Denys Fedoryschenko 52510e7d39 invalid comma cause segfault for nl-tctree-list, tbf.c
I notice segfault while running nl-tctree-list for tbf qdisc.

Patch that fix this typo is attached.
2009-12-07 16:23:48 +01:00
Patrick McHardy 8d2bb90726 libnl: add ERANGE to errno translation
Signed-off-by: Patrick McHardy <kaber@trash.net>
2009-11-10 11:29:07 +01:00
Patrick McHardy fed168212e libnl: fix automake breakage
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>
2009-11-10 11:28:51 +01:00
Thomas Graf dc273a12da - Compile with _GNU_SOURCE
- Fixed classifier.c -> cls.c
2009-09-03 00:01:33 +02:00
Thomas Graf f946cfaa3a Merge branch 'master' of git://dev.medozas.de/libnl
Conflicts:
	lib/Makefile
	src/Makefile
2009-09-02 23:41:03 +02:00
olc 2ead49f0d5 Add support for getting and deleting queueing classes. 2009-09-02 21:10:48 +02:00
Dan Winship e0af9e1802 Fix rtnl_addr caching
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.
2009-09-02 18:45:12 +02:00
Marc de Kruijf 1ed227d3a9 Patch for unexpectedly aligned messages
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.
2009-09-02 18:43:03 +02:00
Thomas Graf ef858fb492 - Reworked the classifier interface.
- Added initial ematch support
- Added support for the basic classifier
- Added support for the cgroup classifier
2009-09-02 18:31:14 +02:00
Alexander Sack 7d249fc2e1 nl_object_clone: properly clone ce_mask field
based on my finding, ce_mask needs to be identical on clones; otherwise
some functions (like "dump") will treat clones differently.
2009-07-20 11:58:57 +02:00
Jan Engelhardt a73e5f92c3 build: make use of library dependencies 2009-07-05 18:00:41 +02:00
Jan Engelhardt bf4fd3acee Move to automake-based build
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>
2009-06-23 01:24:51 +02:00
Inaky Perez-Gonzalez ef8ba32e0c release_local_port: properly compute the bitmap position
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>
2009-05-04 14:56:24 +02:00
Pavel Roskin a8cd7b62c8 nl_object_priv() is inline, so define it in the header 2009-04-16 12:29:13 +02:00
Pavel Roskin becae5f37a Remove all versioned libraries on "make clean" 2009-04-16 12:28:58 +02:00
Pavel Roskin 1276256a72 Fix parallel build
When linking against libnl, require libnl.so to exist.  When linking
against libnl-route, require libnl-route.so to exist.
2009-04-16 12:28:48 +02:00
Thomas Graf 664e1deaeb Fix up naming changes 2008-12-10 18:16:31 +01:00
Thomas Graf 6782b6f709 restructure module documentation order
split hiearchy into one top level module per library
2008-12-10 18:12:30 +01:00
Thomas Graf 724dfa6d70 Consistent naming of socket functions 2008-12-10 18:00:11 +01:00
Thomas Graf 4fd5f7cb66 Documentation update 2008-12-03 19:58:41 +01:00
Holger Eitzenberger 72aa861c48 Allow to pass multiple group values to membership functions
Instead of calling the membership functions several times it is
helpfull to extend the API and make the single group functions a
special case.

The value 0 (NFNLGRP_NONE) terminates this list.

Example use:

  nl_socket_add_memberships(sock, group_1, group_2, 0);
  nl_socket_drop_memberships(sock, group_1, group_2, 0);

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
2008-12-03 19:54:21 +01:00
Patrick McHardy 37f9855f4c libnl: add some errno codes to nl_syserr2nlerr
Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-10-30 12:29:37 +01:00
Patrick McHardy 334f551c59 libnl: nfqueue: add nfqueue specific socket allocation function
commit e92539843a0c7e5116254382626cce226bf2135e
Author: Patrick McHardy <kaber@trash.net>
Date:   Thu Oct 23 13:46:16 2008 +0200

    libnl: nfqueue: add nfqueue specific socket allocation function

    nfqueue users usually send verdict messages from the receive callback.
    When waiting for ACKs, the receive callback might be called again
    recursively until the stack blows up.

    Add a nfqueue specific socket allocation function that automatically
    disables ACKing for the socket.

    Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-10-23 13:59:40 +02:00
Thomas Graf cfcfca0703 Add internal wait_for_ack() which only waits for ACK if !NL_NO_AUTO_ACK
This changeset ensures that internal code properly synchronizes to
ACKs if ACKs are enabled and otherwise return immediately.
2008-10-20 13:12:13 +02:00
Thomas Graf 2bdee95a76 Add socket flag NL_NO_AUTO_ACK to allow disabling auto ACKS 2008-10-20 13:02:38 +02:00
Thomas Graf f42f195a80 Error handling for rtnl_cls_set_kind() & addition of rtnl_cls_get_ops() 2008-10-15 13:01:46 +02:00
Thomas Graf 5d92f9c03d Use 16bit ints for classifier prio/protocol 2008-10-15 12:25:26 +02:00
Thomas Graf 23ee46ef71 Replace NL_KEEP code with proper message reference counting
Adds reference counting to netlink messages so callbacks
can hold on to a message without using the broken keep
message flag.
2008-10-14 19:26:44 +02:00
Wolfgang Steudel 5702d4c1b9 Only include local addr as peer addr if provided
we're using libnl-1.1 for a project. When trying to delete all
addresses of an interface by only setting interface index and
address family of an rtnl_addr and executing rtnl_addr_delete()
we received some error (I don't remember what it was).

The bug(?) is in build_addr_msg() in lib/route/addr.c:
IFA_ADDRESS is set to a_local when a_peer is not set,
without checking if a_local was set. We just added
   if (tmpl->ce_mask & ADDR_ATTR_LOCAL)
after the "else" (line 496 in the current git).
2008-10-10 12:32:23 +02:00
Patrick McHardy b12918df16 fix lib symlinks 2008-10-10 12:17:22 +02:00
Thomas Graf 13ab2441ce Remove XML dumping
Bloats the library, not frequently used
2008-06-17 03:04:19 +02:00
Thomas Graf ab578b9ca0 Improvements to address utilities
- Moved env var dumping to nl-addr-list.c
- support for ipv6 lifetimes
- correct and complete help texts
2008-06-17 02:52:18 +02:00
Thomas Graf 7072675b40 Improved printing of route cache entries 2008-06-16 23:59:09 +02:00
Thomas Graf c48a17694b Extend nl_time2int() and rename it to nl_str2msec()
Support parsing of more complex time duration input.
2008-06-16 13:54:57 +02:00
Thomas Graf d49018fd78 Introduce nla_strdup() to help parse strings attributes 2008-06-13 16:40:41 +02:00
Thomas Graf 5ab9421111 Properly handle addr=NULL in nl_addr2str 2008-06-13 16:39:35 +02:00
Thomas Graf d844307024 Remove old line counting while dumping 2008-05-23 23:45:14 +02:00
Thomas Graf 337fbd24ca Present port and icmp values in host byte order and beautify printing
This changes make nfnl_ct_get_src_port() and others return the value
in host byte order rather than in network byte order.

Also splits printing into details and statistical section and
improves readability.
2008-05-22 23:55:52 +02:00
Thomas Graf 531029c130 Remove change routine, works flawlessly via add() with NLM_F_REPLACE
This breaks the API but is the right thing to do.
2008-05-22 23:52:53 +02:00
Thomas Graf 18efaacc16 Improve printing of routing rules 2008-05-22 23:51:02 +02:00
Thomas Graf 566a09ecbd Family specific libraries can link to the core directly 2008-05-22 23:50:01 +02:00
Thomas Graf 304746f8d0 Fix error code of nl_addr_resolve() 2008-05-22 23:49:11 +02:00
Thomas Graf 5d82806b48 Add rtnl_neigh_get_family() 2008-05-20 12:14:21 +02:00
Thomas Graf 00466b0f95 Return libnl error codes in translation routines 2008-05-20 12:13:48 +02:00
Thomas Graf b5fa6c8b74 Fix library install target 2008-05-15 20:26:37 +02:00
Thomas Graf 0d925c5806 Remove references to unused attribute anycast 2008-05-15 20:25:15 +02:00
Thomas Graf ad2a7bd1e4 Build separate libraries for each netilnk family
This reduces the footprint on systems which only require a small
subset of the library.
2008-05-15 18:01:50 +02:00
Thomas Graf 28233246cd Allow parser callbacks to return NL_OK, NL_SKIP, NL_EXIT
Obsoletes internal P_ACCEPT/P_IGNORE
2008-05-15 14:01:57 +02:00
Thomas Graf 8cd39c9f4c Uninline various functions to save 7K code 2008-05-15 13:56:13 +02:00
Thomas Graf ef50a38fbd Fix memory leaks when sending of message failed
Various callers of nl_send_auto_complete() failed to
free the allocated message when an error was reported.
2008-05-15 13:45:41 +02:00
Thomas Graf 1155370f52 Rename struct nl_handle to struct nl_sock
The idea of a common handle is long revised and only misleading,
nl_handle really represents a socket with some additional
action handlers assigned to it.

Alias for nl_handle is kept for backwards compatibility.
2008-05-15 13:26:32 +02:00
Thomas Graf 0cf780859c Check length of provided address label 2008-05-14 23:08:06 +02:00
Thomas Graf b4fbe1d34d Replace RTNL_LINK_NOT_FOUND with just 0
The interface index 0 is reserved and can be safely used to
signal that the device does not exist.
2008-05-14 18:34:39 +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 107dc162c5 patch: fixed up support for tables in rules 2008-05-08 17:56:11 +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 b7c5bf98c4 Improve performance by using malloc() over calloc() in critical places
As pointed out by Regis Hanna, a considerable performance gain can be
achieved by using malloc() over calloc() when allocating netlink message
buffers. This is likely due to the fact that we use a complete page for
each message.
2008-05-07 13:18:30 +02:00
Thomas Graf d6cd72555d Fix dumping of iif route attribute 2008-05-05 17:09:56 +02:00
Thomas Graf 85808860b6 Route cache support
This changesets adds the possibility to fill a nl_cache with
the contents of the route cache. It also adds the possibility
to limit route caches to certain address families.
2008-05-05 17:09:25 +02:00
Tad Kollar 861901c55b Fixed netem_build_msg() delay distribution table existence test. 2008-05-01 00:06:06 +02:00
Tad Kollar 241b2b83ba New netem funtionality and TBF fix
New netem-related functionality:
Added ability to save new settings to the kernel. In netem.c, the
netem_get_opts() stub has been replaced with netem_build_msg() which
manipulates the nl_msg data directly and returns an error code instead
of a new nl_msg. Modifications to qdisc_build() in qdisc.c and struct
rtnl_qdisc_ops were necessary for this.
Added support for getting/setting corruption probability/correlation.
Added support for setting a delay distribution.

Fixed tbf_msg_parser() to call tbf_alloc() instead of tbf_qdisc() to
prevent a seg fault.
2008-04-30 19:59:06 +02:00
Thomas Graf 5c92c656cc Remove leftover definition of verbose errors 2008-04-30 18:53:01 +02:00
Inaky Perez-Gonzalez 32000e8e9c libnl: recvmsgs doesn't necessarily free the message data
I stepped over libnl always freeing the messages and it
kind of made it awkward to reuse the message data without
reallocating.

The basic idea is: if a callback return value has a bit set,
don't free that message. The calling application owns it.
By default, things stay as before (messages are freed).

Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
2008-04-29 23:46:47 +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 662887c052 Export nl_dump_line() and automatically count lines while dumping 2008-04-29 23:08:12 +02:00
Thomas Graf 5ab64d5173 Define datarootdir to silent autoconf 2008-04-29 23:01:39 +02:00
Thomas Graf f4f7704b0d Ignore NULL pointers passed to nl_cache_free() 2008-04-29 22:58:07 +02:00
Thomas Graf 0ca291d9e4 Fix 64bit alignment issue on x86_64. 2008-03-31 22:43:04 +02:00
Thomas Graf 0c2cb97924 libnl: fix policy check for NFQA_HWADDR
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
2008-03-10 14:59:32 +01:00
Thomas Graf 358e44efa4 Optimize nl_cache_ops_associate by checking protocol early 2008-03-05 14:11:05 +01:00
Thomas Graf 6a7606fa29 Initialize message type list to avoid overrun 2008-03-05 14:10:09 +01:00
Thomas Graf 4be02ace48 Be liberal when receiving an empty nested attribute
No longer enforce at least one attribute in a container of nested
attributes. The application may do so itself by setting minlen
to NLA_HDRLEN.
2008-02-22 15:20:58 +01:00
Patrick McHardy ca0988a2a7 Fix nfnl_queue_msg_get_packetid() return type
[LIBNL]: Fix nfnl_queue_msg_get_packetid() return type

The packet-ID is a 32 bit value, but nfnl_queue_msg_get_packetid() returns
an uint16_t. Makes queueing fail after 2^16 packets.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 13:18:34 +01:00
Patrick McHardy 596d3bc2e9 [LIBNL]: Support conntrack add/delete/query requests
Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 13:13:03 +01:00
Patrick McHardy 2f4f8a5094 [LIBNL]: Split up nfnetlink_log into log and msg objects
Split the nfnetlink_log code into two seperate objects, "netfilter/log"
to represent logging instances and "netfilter/log_msg" to represent
log messages. Also perform some function name unification for consistency
with other libnl object types, mainly renaming nfnl_log_build_*_msg
to nfnl_log_build_*_request.

This changes the API in an incompatible way, but since this feature is
new and the libnl netfilter headers haven't been installed so far,
there shouldn't be any users affected by this.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 13:09:17 +01:00
Patrick McHardy 3f48e49102 [LIBNL]: nfnetlink_log: support NUFLA_GID attribute
The NUFLA_GID attribute (currently only in net-2.6.25) contains the
gid of the sending process for locally generated packets.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 13:02:41 +01:00
Patrick McHardy 5618ea8f5a [LIBNL]: nfnetlink_log: only set hwproto if not zero
The hwproto doesn't have its own attribute and is also present when
not set. Don't set the attribute if its value is zero.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 13:01:12 +01:00
Patrick McHardy e72cb033f2 [LIBNL]: Add nfnetlink_queue support
Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 12:57:53 +01:00
Patrick McHardy 665b757809 [LIBNL]: Generic netfilter stuff
Add some generic helper functions for netfilter.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 12:53:03 +01:00
Patrick McHardy b64f15d6f9 [LIBNL]: Fix minor memleaks on exit
Make valgrind happy ...

Signed-off-by: Patrick McHardy <kaber@trash.net>
2008-02-07 12:51:28 +01:00
Thomas Graf 7f6b7a8eea Improve readability of link statistics output 2008-02-07 12:42:07 +01:00
Thomas Graf 080727d90b Free associated caches when freeing cache manager
Caches allocated by the cache manager must be freed again when the cache
manager itself is freed. However, the netlink socket is allocated
indepdently so it should not be freed.
2008-02-05 12:35:41 +01:00
Thomas Graf dbcdf91a99 Detailed attribute documentation
This patch extends and reorganizes the existing attribute documentation
and includes various verbose examples.
2008-01-30 13:16:48 +01:00
Thomas Graf 0fa6756cca Abstract address allocation based on netlink attribute 2008-01-30 13:14:58 +01:00
Thomas Graf 3607dbfa54 Abstract data allocation based on netlink attribute 2008-01-30 13:14:38 +01:00
Thomas Graf 75a26f3fc5 Improve message/attribute construction documentation and add nlmsg_expand() 2008-01-14 16:46:17 +01:00
Thomas Graf dbefb734d3 Fix documentation of cache manager. 2008-01-14 16:38:37 +01:00
Thomas Graf 6de17f3308 Fix stale data pointers when constructing messages
Patrick McHardy reported a problem where pointers to the
payload of a netlink message as returned by f.e. the
nesting helpers become stale when the payload data
chunk is reallocated.

In order to avoid further problems, the payload chunk is
no longer extended on the fly. Instead the allocation is
made during netlink message object allocation time with
a default size of a page which should be fine for the
majority of all users. Additionally the functions
nlmsg_alloc_size() and nlmsg_set_default_size() have been
added to allocate messages of a particular length and to
modify the default message size.
2008-01-14 16:17:56 +01:00
Thomas Graf 13c85b6633 Add missing @{ for doxygen to build genl documentation 2008-01-10 17:03:34 +01:00
Thomas Graf aa00f82a7b Remove lib/defs.h from repository 2008-01-10 12:45:02 +01:00
Patrick McHardy c6609efc0f [PATCH] libnl cache management leak 2008-01-10 12:44:22 +01:00
Thomas Graf c8a0a5cdfb Added additional parsing and validation functions for generic netlink
Also adds better example documentation for generic netlink
2008-01-10 12:35:38 +01:00
Thomas Graf 373bc78545 Tell git to ignore temporary files and push to pre9 2008-01-09 12:28:17 +01:00
Thomas Graf ddbe8f6c41 Make vlan_put_attrs() available 2008-01-08 15:18:23 +01:00
Thomas Graf a7469ce758 Link info interface and vlan support
Adds an external interface to implement link info types and
implements the type vlan.
2008-01-08 15:00:46 +01:00
Thomas Graf 1952414737 Add support for the IFF_ECHO flag 2007-12-19 22:06:47 +01:00
Thomas Graf 3ad4665be2 Support link operstate and linkmode 2007-12-19 22:03:44 +01: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 680c54fd46 Support defining the default callback handler with an environment variable 2007-12-18 13:06:48 +01:00
Thomas Graf 3c56ed5787 Read debugging environment variable when initializing the library 2007-12-18 12:42:06 +01:00
Thomas Graf 3f0f32bf79 Fix nl_msg_parse() to not give back a reference it does not own 2007-12-17 23:07:22 +01:00
Thomas Graf 12ed4a03d3 Fix cache manager to not give back a reference it does not own 2007-12-17 23:01:06 +01:00
Thomas Graf 155ad439a4 Fix memory leak when parsing netlink messages into caches
The reference created by the parsers was never given back.
2007-12-17 16:52:41 +01:00
Thomas Graf 91c330aae5 Fix creation and destruction of sockets
Fixes an off-by-one when releasing local ports. Fixes nl_connect()
to properly close the socket upon failure. Return EBADFD if
operations are performed on unconnected sockets where appropriate.
Makes nl_handle_alloc() return an error if all local ports are
used up.
2007-12-17 16:26:49 +01:00
Patrick McHardy 936c9844b0 [LIBNL]: Fix format strings
Use %td for ptrdiff_t and %zu for size_t.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2007-12-13 12:09:45 +01:00
Thomas Graf e166565121 Pushed to pre8 due to wrong version string in pre7 2007-11-21 18:24:11 +01:00
Thomas Graf d36d396fd0 Cache message type association interface cleanups 2007-10-11 23:09:49 +02:00
Philip Craig cbe8902265 Allow filtering by name for conntrack status flags 2007-09-18 12:37:49 +02:00
Philip Craig 104e158bd5 Fix typo in conntrack object compare 2007-09-18 12:37:49 +02:00
Thomas Graf 3040a1d625 Export interface to define caches
This interface was internal so far which required all code defining
caches to be compiled with the sources available.

In order to simplify the interface, the co_msg_parser prototype was
changed to take the struct nl_parser_param directly instead of a
void *. It used to be void * because the co_msg_parser was directly
passed as the NL_CB_VALID callback function.
2007-09-17 13:36:16 +02:00
Thomas Graf 3d8efba917 Check for availability of request_update()
The implementation of this function is optional if a cache wishes to
be updated by notifications only.
2007-09-17 12:35:19 +02:00
Thomas Graf 508685c269 Export interface to define objects
This interface was internal so far which required all code defining
objects to be compiled with the sources available.

This change exposes struct nl_object_ops which seems safe as it
is not supposed to be embedded in other structures.

Patch contains extensive documentation to help with the creation
of own object implementations.
2007-09-15 19:55:38 +02:00
Thomas Graf 44d362409d Initial import 2007-09-15 01:28:01 +02:00