dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

52 Commits

Author SHA1 Message Date
Holger Eitzenberger d612180cda netfilter/queue: introduce nfnl_queue_msg_send_verdict_batch()
The batched verdict implicitely ACKs all queue packet IDs up to the
one send back, which reduces the number of verdict messages send
to the kernel.

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-06-27 01:16:15 +02:00
Holger Eitzenberger 34a96ba5c2 netfilter/queue: generalize nfnl_queue_msg_build_verdict()
Generalize netfilter/queue to allow sending batched verdicts
later.

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-06-27 01:15:34 +02:00
Holger Eitzenberger 18152ca916 ct: add ICMPv6 type,code and ID
Add ICMPv6 type, code and ID (if set) by using the already available
conntrack atttributes.

Currently the ICMPv6 conntrack objects in libnl are without type, code
and ID.  This e. g. is the output of nl_object_dump() without the patch:

  ipv6-icmp ::1 <-> ::1
  id 0xdd0871f0 family inet6 timeout 30s <NOREPLY,SNAT_INIT,DNAT_INIT>

The attached patch tries to solve that.  It then looks like

  ipv6-icmp ::1 <-> ::1 icmp type 128 code 0 id 28253
  id 0xdf3a11f0 family inet6 timeout 30s <SNAT_INIT,DNAT_INIT>

It is the 'small' approach, because it reuses the existing ICMP
attributes of the conntrack object (currently only used for IPv4).
This way I can avoid to add new _icmp6_get_, _icmp6_set_ and
_icmp6_test_ functions.

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-02 11:42:59 +02:00
Rich Fought 4f088d38ae netfilter: correct error in construction of NAT tuple 2013-01-29 15:10:01 -08:00
Thomas Graf 4cb375a812 Merge pull request #29 from rmfought/natdir32
netfilter: expectation NAT direction is 32 bit attribute
2013-01-24 08:32:35 -08:00
Rich Fought 87244f739c netfilter: keep 8-bit API for 32-bit NAT dir attribute 2013-01-24 08:18:35 -08:00
Thomas Graf 9680f910f4 Move private header files to <netlink-private/*>
This clarifies the seperation between public and private
header files.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-01-24 13:51:24 +01:00
Rich Fought 56352ab9f6 netfilter: expectation NAT direction is 32 bit attribute 2013-01-23 13:59:27 -08:00
Thomas Graf 00132b4696 cache: provide safe variant of nl_cache_mngt_require() and use it
This makes runtime removal of cache operations possible if non-safe
API is not in use by application. The non-safe API will be removed
in the next major version.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-16 01:11:55 +01:00
Rich Fought d2fff93cce Source cleanup for upstream 2012-10-19 11:18:52 -07:00
Rich Fought 2d707513c6 Updated nfnetlink includes; removed ifdefs; added delete exp program 2012-10-16 12:13:33 -07:00
Rich Fought 07418658a6 define advanced attributes out 2012-10-12 17:44:27 -07:00
Rich Fought 416459570f Bugfixes 2012-10-10 13:08:23 -07:00
Rich Fought 547c8f6d50 reinit port numers on tuple dump 2012-10-09 15:22:16 -07:00
Rich Fought d3bec59eb9 bugfixes 2012-10-09 15:16:00 -07:00
Rich Fought f111efd894 Successful compilation of libnl-nf with expectation 2012-10-08 16:49:06 -07:00
Rich Fought c675bf0486 Checkpoint before compilation attempt 2012-10-08 15:26:55 -07:00
Rich Fought e8b3356dd2 "checkpoint" 2012-10-05 17:32:20 -07:00
Rich Fought 20035ce021 Checkpoint: compare function 2012-10-05 11:09:45 -07:00
Rich Fought 40457db1f4 Exp checkpoint 2012-10-05 06:55:04 -07:00
Коренберг Марк (дома) 8cd2f5728a Fix typo in textual description in ct_dump_stats()
Bug introduced in a0f1c0e281
2012-08-30 03:19:04 +06:00
Коренберг Марк (дома) ab15d06d13 "%llu" replaced with "%" PRIu64
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.
2012-08-30 03:19:04 +06:00
Коренберг Марк (дома) a0f1c0e281 ct_dump_stats: detect when stats are not available
Since about 2.6.27 kernel, stats are not enabled by default.
Stats can be enabled using sysctl named

net.netfilter.nf_conntrack_acct

So, do not print zeroes in stats if it's not available.
When not checked, trash may appear in output
2012-08-28 18:53:33 +06:00
Isaac 996b502961 FTBFS with musl libc: Missing includes
Hello,
libnl 3.2.9 does not build with musl libc, without patching.
I' using a current musl libc (http://www.etalabs.net/musl/)
with linux 2.6.32 headers.
At first there were a couple problems on the musl side, but those are
resolved.
However, I found some other issues:
First, two files were missing
#include <byteswap.h>:
lib/netfilter/log_msg.c
lib/netfilter/queue_msg.c
These files used __bswap_64 (which should be bswap_64), a macro
declared in byteswap.h

Second, I got this error after fixing that:

In file included from nf-queue.c:16:
./include/linux/netfilter.h:53: error: field in has incomplete type
./include/linux/netfilter.h:54: error: field in6 has incomplete type

I found that src/nf-queue.c is missing an
#include <netinet/in.h>

Attached is a patch which resolves these issues.  I've tested with both
musl and glibc, and it builds cleanly on both.
2012-05-13 11:18:28 +02:00
Thomas Graf fec10a2823 doc: documentation restructuring
- 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
2012-05-10 12:03:59 +02:00
Thomas Graf 8a365dbd49 rename nl_send_auto_complete() -> nl_send_auto(), nl_auto_complete -> nl_complete_msg()
Old symbols left to maintain backwards compatibility
2010-11-18 14:13:49 +01:00
Thomas Graf cf5577d280 constify struct trans_tbl 2010-11-17 16:09:08 +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
Thomas Graf 6782b6f709 restructure module documentation order
split hiearchy into one top level module per library
2008-12-10 18:12:30 +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 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 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 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 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
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 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 6a7606fa29 Initialize message type list to avoid overrun 2008-03-05 14:10:09 +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
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
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