dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

35 Commits

Author SHA1 Message Date
Thomas Graf d3cf89ea94 addr: only translate more recent address family names and ARP types if defined
Helps making libnl compilable with older kernel headers

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-05 10:37:55 +02:00
Thomas Graf ff567100d6 nl: Print file:line:func in debugging messages and provide --disable-debug to disable debugging
Compiling libnl with --disable-debug will result in the ignorance
of the 'NLDBG' environment variable.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-04-02 11:39:30 +02: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
Thomas Jarosch 6971932254 Fix file descriptor leak on error
Detected by cppcheck

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-12-27 13:20:18 +01:00
Thomas Graf 23c4ef67c7 Use NL_DBG() instead of printing warnings and errors to stderr
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-16 00:42:34 +01:00
Коренберг Марк (дома) a2b23ffe45 Fix warning "not checking return value of fscanf" in lib/utils.c: get_psched_settings
Also, change internal variables type from uint32_t to unsigned int.
Correct scanf format string should contain "SCNx32" instead of just "x",
but I decide not to fix that and just changed variable type.
2012-08-30 03:19:04 +06:00
Thomas Graf 376a0e29c7 Fix build warning after const char ** convert
Commit 25d640da4a caused the following build warning:
../include/netlink/utils.h:47:15: note: expected 'const char **' but argument is of type 'char **'
route/link/inet6.c:300:11: warning: passing argument 2 of 'nl_cancel_down_bytes' from incompatible pointer type [enabled by default]

Revert the const char ** change.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-08-29 12:05:51 +02:00
Коренберг Марк 25d640da4a lib/utils.c: One kilobit now is a 1000bits (instead of 1024)
http://en.wikipedia.org/wiki/Kilobit

Also, convert "char*" to "const char*" in output value,
as returned values can not be modified.
2012-08-28 18:59:59 +06:00
Коренберг Марк 2bdcde7e8e Fix types-related warnings based on clang diagnostics
1. Fix some places where unsigned value compared < 0
2. Fix obsolete %Z specifier to more portable %z
3. Some erroneous types substitution
4. nl_msec2str() - 64-bit msec is now properly used,

Only safe changes. I mean int <--> uint32_t and signed/unsigned fixes.
Some functinos require size_t argument instead of int, but changes of
signatures of that functions is terrible thing.

Also, I do not pretend for a full list of fixes.
Just to shut up clang -Wall -Wextra

One more thing. ifindex. I don't change that because changes will
be too big for simple fix.
2012-06-13 13:30:26 +02:00
Andrew Collins 970f5d0221 correct HTB rtable/HZ calculations
The HTB implementation in libnl uses units of microseconds in a number
of places where it seems TC is expecting time in units of ticks, which
causes actual rates much higher than requested.  Additionally, libnl
uses USER_HZ for calculating buffer and cbuffer sizes, which can
result in much larger buffers than necessary on systems with high
resolution timers.

Note that the TBF qdisc uses microseconds incorrectly in two spots as
well, I fixed this but did not test.
2012-05-29 11:42:48 +02:00
Bushman, Jeff ca883b61bc Fix for dumping objects to a buffer instead of file descriptor
Attached is a patch to fix two problems with dumping objects to a buffer in=
stead of a file descriptor.
One was a problem in detecting the end of the buffer in the newline code.
The other was a problem with clearing the whole buffer before printing each=
 object.
2012-05-18 15:03:46 +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
Justin Mayfield 32057bc154 __str2flags fix
I found a minor bug in __str2flags where empty strings or short strings
will match all or many flags respectively.  Basically the test needs to
ensure the test string is the same length as the table entry before
doing a strncasecmp to avoid doing just a prefix test.
2012-05-10 09:12:18 +02:00
Thomas Graf 30d3f8c199 utils: Initialize list head after freeing translation list
Problem found and fix proposed by Andrew Kraslavsky <andykras@hotmail.com>
2011-10-10 12:02:33 +02:00
Thomas Graf b5d081d1c9 Avoid freeing memory if vasprintf() failed
Founds this bugfix in Fedora's SOURCES for libnl. Not sure who the
original author is but the bug should be fixed upstream as well.
2011-08-11 15:06:29 +02:00
Thomas Graf 053c93fa8a Update local copies of include/linux 2011-06-09 12:56:52 +02:00
Thomas Graf 58e0e1eda9 Add nl_rate2str() 2011-06-09 12:29:21 +02:00
Thomas Graf 3d70697e4c Add support for ARPHRD_NONE 2011-04-19 09:57:14 +02:00
Thomas Graf 2dbe7d7cfc Initialize dump buffer in case caller missed it
(Set an end to all the bug reports of applications failing
to do so.)
2011-04-10 10:18:04 +02:00
Thomas Graf cf5577d280 constify struct trans_tbl 2010-11-17 16:09:08 +01:00
Thomas Graf d8eeb0a26f New function nl_size2str() 2010-11-17 15:13:33 +01:00
Thomas Graf 10424b20c1 Rename nl_get_hz() to nl_get_user_hz() to indicate it's not the in-kernel HZ value 2010-11-17 11:55:42 +01:00
Thomas Graf 6d434415ad Updated arp and ethernet codes 2010-10-29 01:48:13 +02:00
Thomas Graf 0fa04772ab Fix compile warning in utils.c 2010-07-03 15:17:04 +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
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 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 d844307024 Remove old line counting while dumping 2008-05-23 23:45:14 +02:00
Thomas Graf 00466b0f95 Return libnl error codes in translation routines 2008-05-20 12:13:48 +02:00
Thomas Graf 8cd39c9f4c Uninline various functions to save 7K code 2008-05-15 13:56:13 +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 662887c052 Export nl_dump_line() and automatically count lines while dumping 2008-04-29 23:08:12 +02:00
Thomas Graf 3c56ed5787 Read debugging environment variable when initializing the library 2007-12-18 12:42:06 +01: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