Thomas Haller [Thu, 13 Feb 2014 20:31:37 +0000 (21:31 +0100)]
route: rtnl_route_build_msg() should not overwrite the route scope
rtnl_route_build_msg() should allow the user to set the route scope
explicitly to RT_SCOPE_NOWHERE.
This is useful for IPv4 routes, because when deleting a route,
the kernel requires the scope to match, unless the scope is set to
RT_SCOPE_NOWHERE. Thus by setting the scope to RT_SCOPE_NOWHERE,
the user can delete a route, even without knowing its scope.
rtnl_route_build_msg() should only try to guess the scope, if it was
not explicitly specified.
Signed-off-by: Thomas Haller <thaller@redhat.com> Acked-by: Thomas Graf <tgraf@suug.ch>
Cong Wang [Wed, 15 Jan 2014 01:37:42 +0000 (17:37 -0800)]
act: remove rtnl_act_alloc_cache()
It is complicated to cache tc actions, they are different
from tc qdisc's and filters by design. So, it is simple
if we just don't cache them.
This patch only removes the tc action cache allocation API.
We still need to bypass the libnl cache layer from scratch,
but that would not break ABI any more, therefore we can do
it later.
Cc: Thomas Graf <tgraf@suug.ch> Cc: Thomas Haller <thaller@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
Thomas Haller [Mon, 16 Dec 2013 20:19:14 +0000 (21:19 +0100)]
build: fix build failure when using different build dir (make distcheck)
`make distcheck` builds outside the source directory using
`../configure --srcdir=..`. This was broken because libnl.sym was
expected in the $(top_srcdir) instead of $(top_builddir).
Samuel Gauthier [Fri, 29 Nov 2013 08:28:44 +0000 (09:28 +0100)]
The commit 6a8d90f5fec4 "attr: Allow attribute type 0" intended to
allow the parsing of {netlink,packet,unix}_diag, even if they are
using type 0 for valid attributes.
It lacked this part in nla_parse.
Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Thomas Graf [Thu, 28 Nov 2013 22:14:38 +0000 (23:14 +0100)]
attr: Allow attribute type 0
{netlink,packet,unix}_diag use attribute type 0 for valid
attributes. The value was reserved and usage was prohibited
by the protocol but we can't undo the breakge.
Make libnl accept attribute type 0 to allow parsing these
attributes.
Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Cong Wang [Fri, 8 Nov 2013 19:32:13 +0000 (11:32 -0800)]
do not compile some address families when not available
This fixes the following error while compiling libnl3 on CentOS5:
addr.c:1027: error: 'AF_RDS' undeclared here (not in a function)
addr.c:1033: error: 'AF_CAN' undeclared here (not in a function)
addr.c:1034: error: 'AF_TIPC' undeclared here (not in a function)
addr.c:1036: error: 'AF_IUCV' undeclared here (not in a function)
addr.c:1037: error: 'AF_RXRPC' undeclared here (not in a function)
addr.c:1038: error: 'AF_ISDN' undeclared here (not in a function)
addr.c:1039: error: 'AF_PHONET' undeclared here (not in a function)
make[2]: *** [addr.lo] Error 1
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Nicolas PLANEL [Thu, 10 Oct 2013 20:51:38 +0000 (20:51 +0000)]
route/link: fixup link->l_af_ops must be set for some kind of links
Lookup on IFLA_INFO_KIND information to setup the right link->l_af_ops callbacks
For example, if you setup a bridge this is avoid to trig IS_BRIDGE_LINK_ASSERT() on rtnl_link_bridge_get_flags() call.
line=<optimized out>, function=<optimized out>) at assert.c:94
0x7ffff5dc39a0 "rtnl_link_bridge_get_flags") at assert.c:103
Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Julien BERNARD [Tue, 8 Oct 2013 11:04:30 +0000 (13:04 +0200)]
nl-link-set: Add --state option
I modified the nl-link-set.c file to be able to set the interface up or
down. I joined the patch.
With the new nl-link-set binary I can set the tap interface down.
I am working with Ubuntu 12.04 LTS 64bits and the libnl and libnl-route
packages built from libnl3-3.2.3 from ubuntu reprositories.
Teto [Wed, 2 Oct 2013 20:18:31 +0000 (22:18 +0200)]
Fixed ObjIterator for python3, fixed output of _color and added missing parameter to nl_cache_resync
Here are a few things I fixed and that provoked a python error.
I canno't answer to this thread but one solution I found while using
the python binding is to iterate over all and filter via python
http://list-archives.org/2013/09/09/libnl-lists-infradead-org/missing-feature-for-retrieving-cached-
address-objects/f/5031600704
python: remove use of PyArg_ParseTuple() for callback result
The message receive callback handler in the netlink api processes
the result object from the python callback. It used PyArg_ParseTuple()
to get the value, but this does not work as intended (see ref [1]).
Instead check the type and convert it accordingly.
The property name used in __str__ should be local_port
instead of localPort to get rid of the AttributeError.
>>> str(s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../netlink/core.py", line 172, in __str__
return 'nlsock<{0}>'.format(self.localPort)
AttributeError: 'Socket' object has no attribute 'localPort'
Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
python: allow callback function to be a class method
The callback functionality only worked for regular Python
functions. With this patch it also allows the callback
to be a class method (bounded or unbounded) as show in
example below.
class test_class(object):
def my_callback(self, msg, arg):
print('handling %s' % str(msg))
The initial commit adding netlink callback handling also introduced
memory leak issue. The python callback info was stored in an allocated
structure, but that was never freed.
Only exposing nl_cb_alloc() as is. nl_cb_get() is removed as it is
not very useful to use reference counting mechanism. Python uses
that itself internally. To deal properly with Python callback info
the function nl_cb_put() and nl_cb_clone() have a custom wrapper
taking care of Python reference counting.
This commit also adds a Callback python class using the netlink
callback functions.
Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
The application could use the same handler for multiple
nl_cb_type events. This patch stores the nl_cb_type in
the nl_cb struct during the callback. This allows the
application to obtain that information using the new
nl_cb_active_type() function. This way the callback
signature remains as is so existing applications are
not affected.
Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
netfilter/ct: support optional CTA_TIMESTAMP attribute
Recent kernels support conntrack time stamping, which is a helpful
feature to determine the duration of a flow without building a flow
cache in your user space application, just to keep the 'start' time of
your flow.
Timestamps are recorded with nanosecond resolution once this feature
is enabled.
This patch adds optional support for the CTA_TIMESTAMP, then
modifies the dump routine to write that info in a format similar
to /proc/net/nf_conntrack. This is an example output when using
NL_DUMP_LINE:
Joe Damato [Thu, 25 Jul 2013 23:36:16 +0000 (16:36 -0700)]
Add idiag-socket-details
This small program lists all sockets on the system seen by netlink and serves
as a simple example showing how to alloc an idiag msg cache and dump the
objects in it.
Joe Damato [Thu, 4 Jul 2013 01:40:58 +0000 (18:40 -0700)]
Add support for inet diag Netlink protocol.
- Inet diag allows users to gather low-level socket information.
- This library provides a higher-level API for creating inetdiag requests (via
idiagnl_connect and idiagnl_send_simple) and parsing the replies (via
idiagnl_msg_parse). A cache is also provided (via idiagnl_msg_alloc_cache).
- Request and message objects provide APIs for accessing and setting the
various properties of each.
- This library also allows the user to parse the inetdiag response attributes
which contain information about traffic class, TOS, congestion, socket
memory info, and more depending on the kernel version used.
- Includes doxygen documentation.