dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

650 Commits

Author SHA1 Message Date
Thomas Graf 18848090f9 pfifo/bfifo qdisc support for cli libs 2010-10-19 16:51:55 +02:00
Thomas Graf 23c6191726 remove obsolete nl-qdisc-add code 2010-10-19 16:35:26 +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
Thomas Graf 706ac94ed5 Use CPPFLAGS 2010-10-13 14:30:50 +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
Karl Hiramoto 018c297274 libnl: optionally disable cli tools.
compile and link time can reduced, most non-developers don't need these cli tools.

./configure --disable-cli
time make
real    0m40.485s
user    0m33.784s
sys     0m2.793s

./configure
time make
real    0m53.097s
user    0m42.077s
sys     0m4.396s

Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
2010-10-13 13:10:48 +02:00
Thomas Graf 6921b1c879 Ignore vim swap files 2010-07-03 15:56:51 +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
Karl Hiramoto d378220c96 src/nf-queue.c: cleanup and improve performance of test program for NF_QUEUE
* Fix filename in file header

* If the kernel or netlink socket becomes over loaded,
  the kernel starts printing error messages like:

nf_queue: full at 1024 entries, dropping packets(s). Dropped: 1
nf_queue: full at 1024 entries, dropping packets(s). Dropped: 2
nf_queue: full at 1024 entries, dropping packets(s). Dropped: 3

So detect out of order packet ID's and set the NF_ACCEPT verdict,
so they will be removed from the kernel queue.

* increase socket buffer to improve performance

without these changes sending more than 100 KB/s over tcp HTTP lo(localhost)
was difficult on my core2 duo machine, due to so many dropped packets.
After these changes over 150 MB/s was easy.

* improve help text

Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
2010-04-19 12:58:39 +02:00
Thomas Graf d966a3ecf7 Don't install private header files. 2010-04-19 12:56:31 +02:00
Patrick McHardy b3096c4acf object: fix attribute comparison
Currently two attributes are regarded as different if they are absent in
both objects to be compared. This is obviously incorrect, change to
regard objects as different if an attribute is only present on one of
them or if the attribute data differs.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:51:24 +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
Thomas Graf 8808743839 CLI - Command Line Interface Library
Moved common code in src/ used by CLI tools to src/lib/ for possible use
by other CLI tools. Just link to libnl-cli.{so|la}
2009-12-16 16:20: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
Pavel Roskin dec2ea357d Declare struct ucred in handlers.h and netlink.h
Both files refer to it.  The sources including those files are not
guaranteed to include sys/socket.h to ensure that struct ucred is
defined.
2009-07-20 11:47:22 +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 8ee16e6688 Separate compiling from linking
This helps users understand where possible warnings come from.
It also allows more find-grained control over the build flags.
2009-04-16 12:29:22 +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