Karl Hiramoto [Thu, 18 Mar 2010 16:50:20 +0000 (17:50 +0100)]
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.
Patrick McHardy [Wed, 7 Apr 2010 17:15:40 +0000 (19:15 +0200)]
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.
Patrick McHardy [Wed, 7 Apr 2010 17:21:47 +0000 (19:21 +0200)]
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.
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).
Karl Hiramoto [Wed, 24 Feb 2010 20:29:13 +0000 (21:29 +0100)]
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()
Patrick McHardy [Thu, 5 Nov 2009 12:38:00 +0000 (13:38 +0100)]
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.
Dan Winship [Thu, 20 Aug 2009 13:29:26 +0000 (09:29 -0400)]
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.
Marc de Kruijf [Wed, 26 Aug 2009 21:28:01 +0000 (16:28 -0500)]
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.
Jan Engelhardt [Mon, 22 Jun 2009 23:12:53 +0000 (01:12 +0200)]
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>
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.
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.
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).
Thomas Graf [Fri, 10 Oct 2008 10:13:52 +0000 (12:13 +0200)]
From: Kees Cook <kees@outflux.net>
Hello! It seems that libnl is missing an include for limits.h, which
causes it to FTBFS when glibc 2.8 is installed (currently in
experimental, so I left this bug severity at "normal").
Holger Schurig [Thu, 14 Aug 2008 09:53:38 +0000 (11:53 +0200)]
libnl: fix about 100 warnings
In file included from addr.c:28:
../include/netlink-local.h:119:1: warning: "__deprecated" redefined
In file included from /usr/include/linux/stddef.h:4,
from /usr/include/linux/posix_types.h:4,
from /usr/include/linux/types.h:8,
from ../include/netlink-local.h:37,
from addr.c:28:
/usr/include/linux/compiler.h:45:1: warning: this is the location of the previous definition
Thomas Graf [Thu, 15 May 2008 11:26:32 +0000 (13:26 +0200)]
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.
Thomas Graf [Wed, 14 May 2008 15:49:44 +0000 (17:49 +0200)]
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!
Ben Gamsa [Thu, 8 May 2008 15:42:09 +0000 (11:42 -0400)]
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.
Thomas Graf [Thu, 8 May 2008 10:47:26 +0000 (12:47 +0200)]
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.
Thomas Graf [Wed, 7 May 2008 11:18:30 +0000 (13:18 +0200)]
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.