]> granicus.if.org Git - libnl/log
libnl
11 years agoadd fq_codel cli module
Cong Wang [Wed, 20 Nov 2013 05:10:05 +0000 (21:10 -0800)]
add fq_codel cli module

Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd fq_codel qdisc
Cong Wang [Wed, 20 Nov 2013 05:10:04 +0000 (21:10 -0800)]
add fq_codel qdisc

Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agofix linux/pkt_act.h inclusion
Cong Wang [Mon, 11 Nov 2013 23:17:49 +0000 (15:17 -0800)]
fix linux/pkt_act.h inclusion

We should copy and use the kernel header linux/tc_act/tc_mirred.h.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agolink: Fall back to global provisioned link cache if object is not a cache resident
Thomas Graf [Sat, 9 Nov 2013 09:04:35 +0000 (10:04 +0100)]
link: Fall back to global provisioned link cache if object is not a cache resident

... if that fails, print ifindices directly.

Reported-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd veth.h into include/Makefile.am
Cong Wang [Sat, 9 Nov 2013 00:07:12 +0000 (16:07 -0800)]
add veth.h into include/Makefile.am

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agobasic: add action support
Cong Wang [Fri, 8 Nov 2013 18:47:53 +0000 (10:47 -0800)]
basic: add action support

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd u32 action test
Cong Wang [Fri, 8 Nov 2013 18:47:52 +0000 (10:47 -0800)]
add u32 action test

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd u32 action support
Cong Wang [Fri, 8 Nov 2013 18:47:51 +0000 (10:47 -0800)]
add u32 action support

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd mirred tc action
Cong Wang [Fri, 8 Nov 2013 18:47:50 +0000 (10:47 -0800)]
add mirred tc action

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd initial tc action support
Cong Wang [Fri, 8 Nov 2013 18:47:49 +0000 (10:47 -0800)]
add initial tc action support

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agodo not compile some address families when not available
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>
11 years agoMerge pull request #50 from olafhering/olh_memset__nlmsg_alloc
Thomas Graf [Fri, 8 Nov 2013 23:47:06 +0000 (15:47 -0800)]
Merge pull request #50 from olafhering/olh_memset__nlmsg_alloc

Remove extra memset from __nlmsg_alloc

11 years agoRemove extra memset from __nlmsg_alloc
Olaf Hering [Fri, 8 Nov 2013 16:15:16 +0000 (17:15 +0100)]
Remove extra memset from __nlmsg_alloc

A few lines above nm->nm_nlh is already allocated with calloc, the
allocated memory has at least sizeof(struct nlmsghdr).

Signed-off-by: Olaf Hering <olaf@aepfle.de>
11 years agopython: Include all files in distribution
Thomas Graf [Wed, 6 Nov 2013 09:28:37 +0000 (10:28 +0100)]
python: Include all files in distribution

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agofactor out rtnl_link_info_parse()
Cong Wang [Fri, 1 Nov 2013 23:58:47 +0000 (16:58 -0700)]
factor out rtnl_link_info_parse()

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd link netns support
Cong Wang [Fri, 1 Nov 2013 23:58:49 +0000 (16:58 -0700)]
add link netns support

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd veth link support
Cong Wang [Fri, 1 Nov 2013 23:58:48 +0000 (16:58 -0700)]
add veth link support

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agofactor out rtnl_link_fill_info()
Cong Wang [Fri, 1 Nov 2013 23:58:46 +0000 (16:58 -0700)]
factor out rtnl_link_fill_info()

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd ingress qdisc
Cong Wang [Fri, 25 Oct 2013 06:59:15 +0000 (23:59 -0700)]
add ingress qdisc

This patch adds ingress qdisc to libnl.

Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years ago3.2.23 release libnl3_2_23
Thomas Graf [Wed, 30 Oct 2013 23:11:18 +0000 (00:11 +0100)]
3.2.23 release

11 years agotests: fix make test-create-vxlan
Cong Wang [Fri, 25 Oct 2013 07:02:05 +0000 (00:02 -0700)]
tests: fix make test-create-vxlan

Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agolibnl-3.2.23-rc2 release libnl3_2_23rc2
Thomas Graf [Wed, 23 Oct 2013 09:06:50 +0000 (11:06 +0200)]
libnl-3.2.23-rc2 release

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoinclude: Provide <netlink/route/link/vxlan.h> in distribution
Thomas Graf [Wed, 23 Oct 2013 07:28:05 +0000 (09:28 +0200)]
include: Provide <netlink/route/link/vxlan.h> in distribution

Reported-by: Jeroen Roovers <jer@gentoo.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoFix up -rc1 versioning to not be included in libnl_micro_version
Thomas Graf [Tue, 22 Oct 2013 14:45:21 +0000 (16:45 +0200)]
Fix up -rc1 versioning to not be included in libnl_micro_version

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agodoc: Add instructions on how to build docs
Thomas Graf [Tue, 22 Oct 2013 14:33:27 +0000 (16:33 +0200)]
doc: Add instructions on how to build docs

Reported-by: Teto <mattator@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agodoxygen-link: Be python3 compatible
Thomas Graf [Tue, 22 Oct 2013 14:32:23 +0000 (16:32 +0200)]
doxygen-link: Be python3 compatible

Reported-by: Teto <mattator@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agolibnl-3.2.23-rc1 release libnl3_2_23rc1
Thomas Graf [Tue, 22 Oct 2013 13:26:12 +0000 (15:26 +0200)]
libnl-3.2.23-rc1 release

11 years agortnl-addr: set ifa_flags when creating/updating address
Thomas Haller [Tue, 22 Oct 2013 08:38:14 +0000 (10:38 +0200)]
rtnl-addr: set ifa_flags when creating/updating address

Set the address flags when creating/updating an address with
rtnl_addr_add/rtnl_addr_build_add_request. Before, the flags
were not passed on.

As of now, the flags except IFA_F_NODAD|IFA_F_HOMEADDRESS are ignored by
the kernel. Still pass them on without filtering.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoobj: Check for NULL pointer in nl_object_clone()
Thomas Graf [Tue, 22 Oct 2013 12:16:43 +0000 (14:16 +0200)]
obj: Check for NULL pointer in nl_object_clone()

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agopython: add bridge flags API
Nicolas PLANEL [Fri, 11 Oct 2013 15:52:22 +0000 (15:52 +0000)]
python: add bridge flags API

Add flags set/get methods aim to change bridge flags :
 o hairpin_mode
 o bpdu_guard
 o root_block
 o fast_leave

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agotest: add python bridge testing sample
Nicolas PLANEL [Thu, 10 Oct 2013 22:34:18 +0000 (22:34 +0000)]
test: add python bridge testing sample

New test sample file, test-create-bridge.py
Create an bridge (testbrige) and attach an already setup interface (testtap1) to it.

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agopython: add basic netlink protocol bridge interface support
Nicolas PLANEL [Thu, 10 Oct 2013 22:27:44 +0000 (22:27 +0000)]
python: add basic netlink protocol bridge interface support

Implements basic bridge interface support using netlink protocol

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agotest: add bridge creation sample
Nicolas PLANEL [Thu, 10 Oct 2013 21:43:12 +0000 (21:43 +0000)]
test: add bridge creation sample

New test sample file, test-create-bridge.c
Create an bridge (testbrige) and attach an already setup interface (testtap1) to it.

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoroute/link: fixup link->l_af_ops must be set for some kind of links
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>
11 years agonl-link-set: Add --state option
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.

--
Julien BERNARD

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoMerge branch 'recvmsgs-comment-typo' of git://github.com/olafhering/libnl into olafhe...
Thomas Graf [Mon, 7 Oct 2013 09:40:13 +0000 (11:40 +0200)]
Merge branch 'recvmsgs-comment-typo' of git://github.com/olafhering/libnl into olafhering-recvmsgs-comment-typo

11 years agoFixed ObjIterator for python3, fixed output of _color and added missing parameter...
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

Example:
cache = nlrta.AddressCache()
cache.resync()

for i in cache:
    print ("item", i ) # then you can filter here

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agopython: fixup VLANLink() initialization
Nicolas PLANEL [Tue, 1 Oct 2013 19:58:36 +0000 (15:58 -0400)]
python: fixup VLANLink() initialization

The varialble name should be link._rtnl_link
instead of link._link to get rid of the AttributeError.

Traceback (most recent call last):
File "examples/test.py", line 11, in <module>
 eth0 = link.resolve('eth0.800')
...
File
"/home/ubuntu/libnl/python/build/lib.linux-x86_64-2.7/netlink/route/link.py",
line 151, in __init__
 self._module_lookup('netlink.route.links.' + self.type)
...
File
"/home/ubuntu/libnl/python/build/lib.linux-x86_64-2.7/netlink/route/links/vlan.py",
line 70, in init
 link.vlan = VLANLink(link._link)
AttributeError: 'Link' object has no attribute '_link'

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agopython: remove use of PyArg_ParseTuple() for callback result
Arend van Spriel [Mon, 30 Sep 2013 08:21:46 +0000 (10:21 +0200)]
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.

refs:
[1] http://stackoverflow.com/questions/13636711/what-is-the-proper-usage-of-pyarg-parsetuple

Reported-by: Teto <mattator@gmail.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agonl: Fix comment typo on recvmsgs
Olaf Hering [Tue, 1 Oct 2013 16:23:54 +0000 (18:23 +0200)]
nl: Fix comment typo on recvmsgs

Signed-off-by: Olaf Hering <olaf@aepfle.de>
11 years agopython: add send and receive functions to Socket class
Arend van Spriel [Thu, 5 Sep 2013 12:11:32 +0000 (14:11 +0200)]
python: add send and receive functions to Socket class

Adding class methods send_auto_complete() and recvmsgs()
that call their swig capi equivalent function.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agopython: fix typo in Socket::__str__() function
Arend van Spriel [Thu, 5 Sep 2013 12:11:25 +0000 (14:11 +0200)]
python: fix typo in Socket::__str__() function

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>
11 years agopython: remove unnecessary callback type definitions
Arend van Spriel [Thu, 5 Sep 2013 12:11:28 +0000 (14:11 +0200)]
python: remove unnecessary callback type definitions

Copied the typedefs when adding callback support, but they serve
no actual use in the swig input file.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agopython: allow callback function to be a class method
Arend van Spriel [Thu, 5 Sep 2013 12:11:27 +0000 (14:11 +0200)]
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))

s = netlink.core.Socket()
testobj = test_class()
netlink.capi.py_nl_cb_set(cb, netlink.capi.NL_CB_VALID,
  netlink.capi.NL_CB_CUSTOM,
  test_class.my_callback, testobj)
netlink.capi.py_nl_cb_err(cb, netlink.capi.NL_CB_CUSTOM,
                          test_class.my_callback, s)

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agouse Callback object constructing Socket
Arend van Spriel [Thu, 5 Sep 2013 12:11:31 +0000 (14:11 +0200)]
use Callback object constructing Socket

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agopython: rework netlink callback handling
Arend van Spriel [Thu, 5 Sep 2013 12:11:26 +0000 (14:11 +0200)]
python: rework netlink callback handling

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>
11 years agonl_cb: store nl_cb_type in struct nl_cb
Arend van Spriel [Thu, 5 Sep 2013 12:11:29 +0000 (14:11 +0200)]
nl_cb: store nl_cb_type in struct nl_cb

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>
11 years agoadd python examples using swig provided api
Arend van Spriel [Thu, 5 Sep 2013 12:11:30 +0000 (14:11 +0200)]
add python examples using swig provided api

using the nl80211 family to show use of generic netlink api and
attribute parsing.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agonetfilter/ct: support optional CTA_ZONE attribute
Holger Eitzenberger [Fri, 30 Aug 2013 08:50:23 +0000 (10:50 +0200)]
netfilter/ct: support optional CTA_ZONE attribute

Newer kernels support conntrack zones, which help to partition the
conntrack table into virtual conntrack tables.

This patch is for adding support for the optional attribute, adds
setters and getters, and adds support for the zone ID in the conntrack
dumper.

An example entry in NL_DUMP_LINE format looks like:

  tcp SYN_SENT 10.128.128.99:43354 <-> 10.128.129.20:22 zone 1

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agonetfilter/ct: support optional CTA_TIMESTAMP attribute
Holger Eitzenberger [Fri, 30 Aug 2013 08:50:22 +0000 (10:50 +0200)]
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:

  udp 10.128.128.28:56836 <-> 10.128.129.255:8612 delta-time 30

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoCall to_msg_fill_raw when defined to_msg_fill is NULL
chantra [Mon, 19 Aug 2013 07:16:45 +0000 (00:16 -0700)]
Call to_msg_fill_raw when defined to_msg_fill is NULL

netem qdisc uses to_msg_fill_raw to build netlink packet. So far, this
was not called from anywhere.

Example creating a netem qdisc before and after the change:

[root@testbox libnl]# NLCB=debug ./netem
-- Debug: Sent Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 48
    .type = 36 <route/qdisc::new>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376894544
    .port = 17877
  [PAYLOAD] 20 octets
    00 00 00 00 02 00 00 00 00 00 01 80 01 00 01 00 ................
    00 00 00 00                                     ....
  [ATTR 01] 6 octets
    6e 65 74 65 6d 00                               netem.
  [PADDING] 2 octets
    00 00                                           ..
---------------------------  END NETLINK MESSAGE ---------------------------
-- Debug: Received Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 68
    .type = 2 <ERROR>
    .flags = 0 <>
    .seq = 1376894544
    .port = 17877
  [ERRORMSG] 20 octets
    .error = -22 "Invalid argument"
  [ORIGINAL MESSAGE] 16 octets
    .nlmsg_len = 16
    .type = 36 <0x24>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376894544
    .port = 17877
---------------------------  END NETLINK MESSAGE ---------------------------
-- Error received: Invalid argument
-- Original message: type=0x24 length=48 flags=<REQUEST,ACK,ATOMIC>
sequence-nr=1376894544 pid=17877
RC -7
[root@testbox libnl]# NLCB=debug ./netem
-- Debug: Sent Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 76
    .type = 36 <route/qdisc::new>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376895147
    .port = 26541
  [PAYLOAD] 20 octets
    00 00 00 00 02 00 00 00 00 00 01 80 01 00 01 00 ................
    00 00 00 00                                     ....
  [ATTR 01] 6 octets
    6e 65 74 65 6d 00                               netem.
  [PADDING] 2 octets
    00 00                                           ..
  [ATTR 02] 24 octets
    00 00 00 00 a0 86 01 00 00 00 00 80 00 00 00 00 ................
    00 00 00 00 00 00 00 00                         ........
---------------------------  END NETLINK MESSAGE ---------------------------
-- Debug: Received Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 36
    .type = 2 <ERROR>
    .flags = 0 <>
    .seq = 1376895147
    .port = 26541
  [ERRORMSG] 20 octets
    .error = 0 "Success"
  [ORIGINAL MESSAGE] 16 octets
    .nlmsg_len = 16
    .type = 36 <0x24>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376895147
    .port = 26541
---------------------------  END NETLINK MESSAGE  ---------------------------
RC 0
[root@testbox libnl]# tc qdisc show
qdisc htb 1: dev eth0 root refcnt 2 r2q 10 default 0 direct_packets_stat 21115
qdisc netem 8001: dev eth0 parent 1:1 limit 100000 loss 50%
qdisc htb 1: dev eth1 root refcnt 2 r2q 10 default 0 direct_packets_stat 0

Signed-off-by: chantra <chantra@fb.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoPriority of the '<' operator is higher than that of the '=' operator
maksqwe [Fri, 23 Aug 2013 10:39:03 +0000 (13:39 +0300)]
Priority of the '<' operator is higher than that of the '=' operator

Signed-off-by: maksqwe <maksqwe1@ukr.net>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agofix double free caused by freeing link af_data in rtnl_link_set_family()
Jiri Pirko [Wed, 21 Aug 2013 12:40:34 +0000 (14:40 +0200)]
fix double free caused by freeing link af_data in rtnl_link_set_family()

Introduced by commit 8026fe2e3a9089eff3f5a06ee6e3cc78d96334ed ("link:
Free and realloc af specific data upon rtnl_link_set_family()")

link->l_af_data[link->l_af_ops->ao_family] is freed here but not set to
zero. That leads to double free made by link_free_data->do_foreach_af.

Fix this by setting link->l_af_data[link->l_af_ops->ao_family] to zero
rigth after free.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoEnable linker versioning
Thomas Graf [Wed, 7 Aug 2013 12:51:03 +0000 (14:51 +0200)]
Enable linker versioning

Reported-by: Ian Stakenvicius
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoMerge pull request #44 from sassanosystems/idiag
Thomas Graf [Mon, 5 Aug 2013 06:10:42 +0000 (23:10 -0700)]
Merge pull request #44 from sassanosystems/idiag

Idiag

11 years agolink: add support for IFLA_PHYS_PORT_ID
Jiri Pirko [Thu, 1 Aug 2013 11:57:08 +0000 (13:57 +0200)]
link: add support for IFLA_PHYS_PORT_ID

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoMerge pull request #45 from chibacchie/vxlan
Thomas Graf [Mon, 5 Aug 2013 06:06:19 +0000 (23:06 -0700)]
Merge pull request #45 from chibacchie/vxlan

Add VXLAN support

11 years agoAdd VXLAN support.
Yasunobu Chiba [Sun, 4 Aug 2013 06:43:54 +0000 (15:43 +0900)]
Add VXLAN support.

11 years agoMore safely parse vegas info and mem info.
Joe Damato [Fri, 26 Jul 2013 00:07:12 +0000 (17:07 -0700)]
More safely parse vegas info and mem info.

11 years agoAdd idiag-socket-details
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.

11 years agoHandle the case where nl_msec2str is passed 0 msecs
Joe Damato [Fri, 19 Jul 2013 05:35:45 +0000 (22:35 -0700)]
Handle the case where nl_msec2str is passed 0 msecs

11 years agoAdd support for inet diag Netlink protocol.
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.

11 years agoadd generic netlink functions to swig
Arend van Spriel [Mon, 15 Jul 2013 10:09:13 +0000 (12:09 +0200)]
add generic netlink functions to swig

Provide wrapper function for generic netlink library functions. The
genlmsg_parse() function is handled similar to nla_parse_nested() so
it returns tuple with error code and dictionary of parsed attributes.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd python module for generic netlink library
Arend van Spriel [Mon, 15 Jul 2013 10:09:12 +0000 (12:09 +0200)]
add python module for generic netlink library

This commit adds creation of the netlink.genl package. The actual
capi.i will be filled in upcoming commits so the module is rather
dumb for now.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoadd support functions for attributes and callback handlers
Arend van Spriel [Mon, 15 Jul 2013 10:09:11 +0000 (12:09 +0200)]
add support functions for attributes and callback handlers

added support functions to access the netlink attributes and use
custom callback handlers. Most is wrapped as is, but there are
a couple of special cases handled.

1) void *nla_data(struct nlattr *);
The return value is changed to a Python byte array so it includes
the lenght of the data stream.

2) int nla_parse_nested(...);
This returns a tuple (err, dict). 'err' is the error code and 'dict'
is a dictionary with attribute identifier as key and value represents
a struct nlattr object.

3) macro nla_for_each_nested()
Provide nla_get_nested() which returns a Python list of struct nlattr
objects that is iterable.

4) allocate struct nla_policy array
Provide nla_policy_array() function that allocates consecutive space
in memory for struct nla_policy array entries. Each entry is put in
a Python list so the entry fields can be modified in Python. This
array object can be passed to the nla_parse_nested() function.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agohandle the case where 0 is passed to nl_size2str
Joe Damato [Sun, 7 Jul 2013 19:12:27 +0000 (12:12 -0700)]
handle the case where 0 is passed to nl_size2str

(cherry picked from commit 968ccbe97d476e3a8485b04dbaf469e8d01b8811)
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agocache: Return -NLE_PROTO_MISMATCH if socket provided mismatches cache protocol
Thomas Graf [Sat, 29 Jun 2013 20:29:43 +0000 (22:29 +0200)]
cache: Return -NLE_PROTO_MISMATCH if socket provided mismatches cache protocol

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agosocket: Warn via debug message if local port namespace is exhausted
Thomas Graf [Fri, 28 Jun 2013 16:53:16 +0000 (18:53 +0200)]
socket: Warn via debug message if local port namespace is exhausted

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agotests: use AM_CFLAGS instead of CFLAGS directly
Thomas Graf [Fri, 28 Jun 2013 16:49:51 +0000 (18:49 +0200)]
tests: use AM_CFLAGS instead of CFLAGS directly

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agomsg: Avoid returning a negative value for nlmsg_attrlen()
Thomas Graf [Thu, 27 Jun 2013 16:29:17 +0000 (18:29 +0200)]
msg: Avoid returning a negative value for nlmsg_attrlen()

If a hdrlen was provided that was greather than the actual
message length, a negative attributes length would result.

This was typically happening for RTM_GETLINK requests where
we can get a away with a 4 bytes header on the request side
but the response would use a 16 bytes header.

This resulted in strange -8 bytes leftover debug messages.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agonetfilter/queue: introduce nfnl_queue_msg_send_verdict_batch()
Holger Eitzenberger [Wed, 19 Jun 2013 13:23:15 +0000 (15:23 +0200)]
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>
11 years agonetfilter/queue: generalize nfnl_queue_msg_build_verdict()
Holger Eitzenberger [Wed, 19 Jun 2013 13:23:14 +0000 (15:23 +0200)]
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>
11 years agoHandle -NLE_AGAIN in nl_cache_mngr_data_ready
Andrew Collins [Mon, 17 Jun 2013 21:58:43 +0000 (15:58 -0600)]
Handle -NLE_AGAIN in nl_cache_mngr_data_ready

Since commit "nl: Return -NLE_AGAIN if non-blocking socket would block",
nl_cache_mngr_data_ready returns -NLE_AGAIN to callers on non-blocking sockets.
Change it to consider -NLE_AGAIN as a non-error case as it is expected behavior
with the nl_recv changes.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoDefault to comparing all attributes if no oo_id_attrs defined
Andrew Collins [Mon, 17 Jun 2013 21:24:05 +0000 (15:24 -0600)]
Default to comparing all attributes if no oo_id_attrs defined

Since commit: "cache pickup: Avoid duplicates during cache pickup",
nfnl_ct_alloc_cache no longer properly fills the cache, as it doesn't
define oo_id_attrs so all items are considered duplicates.

Instead of adding a ~0 oo_id_attrs to ct_obj, this changes
nl_object_identical to default to comparing all attributes if
neither oo_id_attrs_get or oo_id_attrs are provided.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoMerge branch 'master' of https://github.com/michael-dev/libnl
Thomas Graf [Fri, 24 May 2013 12:37:02 +0000 (14:37 +0200)]
Merge branch 'master' of https://github.com/michael-dev/libnl

11 years agoAdd macvlan support
Michael Braun [Thu, 16 May 2013 14:54:13 +0000 (16:54 +0200)]
Add macvlan support

This patch add support for kernel macvlan interfaces.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
11 years ago3.2.22 release libnl3_2_22
Thomas Graf [Tue, 14 May 2013 12:09:07 +0000 (14:09 +0200)]
3.2.22 release

11 years agonl: Increase receive buffer size to 4 pages
Thomas Graf [Wed, 8 May 2013 11:52:27 +0000 (13:52 +0200)]
nl: Increase receive buffer size to 4 pages

Assuming that the kernel does not send more than a page is no longer valid,
and enabling MSG_PEEK'ing by default to figure out the exact message buffer
requirements can have a negative influence on the performance of existing
applications. Bumping the default receive buffer space to 4 pages seems
a sane default.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agortnl_link_af_unregister: fix locking
Nathan Lynch [Mon, 29 Apr 2013 21:29:46 +0000 (16:29 -0500)]
rtnl_link_af_unregister: fix locking

rtnl_link_af_unregister() attempts to write-lock info_lock twice
instead of releasing it before returning.  It also will return with
info_lock write-locked if passed a NULL ops.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoPrepare for 3.2.22-rc1 release libnl3_2_22rc1
Thomas Graf [Sun, 28 Apr 2013 10:52:26 +0000 (12:52 +0200)]
Prepare for 3.2.22-rc1 release

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agotests: Include util.h in dist
Thomas Graf [Sun, 28 Apr 2013 10:51:58 +0000 (12:51 +0200)]
tests: Include util.h in dist

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agotests: Add basic attribute unit tests
Thomas Graf [Sun, 28 Apr 2013 10:31:52 +0000 (12:31 +0200)]
tests: Add basic attribute unit tests

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoconfigure: Convert ENABLE_UNIT_TESTS to a mere AM conditional
Thomas Graf [Sun, 28 Apr 2013 09:41:15 +0000 (11:41 +0200)]
configure: Convert ENABLE_UNIT_TESTS to a mere AM conditional

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoWrong calcultation in nla_reserve
Emmanuel Thierry [Wed, 24 Apr 2013 16:39:19 +0000 (18:39 +0200)]
Wrong calcultation in nla_reserve

There seams to be an error in the calculation of needed space for the message in nla_reserve. The current size of the message is counted twice: Once in NLMSG_ALIGN, once in the condition below.
This causes nla_put_* calls to be rejected if the allocation size of the message has been strictly calculated by the caller.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoattr: Fix typo in nla_is_nested()
Thomas Graf [Sun, 28 Apr 2013 08:33:52 +0000 (10:33 +0200)]
attr: Fix typo in nla_is_nested()

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoMerge branch 'fixes' of https://github.com/socketpair/libnl
Thomas Graf [Sun, 28 Apr 2013 08:25:47 +0000 (10:25 +0200)]
Merge branch 'fixes' of https://github.com/socketpair/libnl

11 years agoattr: nla_is_nested() must access nla_type directly
Thomas Graf [Sun, 28 Apr 2013 08:23:28 +0000 (10:23 +0200)]
attr: nla_is_nested() must access nla_type directly

Can't used nla_type() as it applies NLA_TYPE_MASK first

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoFix leak of cb if nl_socket_alloc_cb() failed to allocate socket
Коренберг Марк (дома) [Sat, 27 Apr 2013 18:35:37 +0000 (00:35 +0600)]
Fix leak of cb if nl_socket_alloc_cb() failed to allocate socket

- each *_get() should have corresponding *_put(). That rule was broken in nl_socket_alloc()
- Also, check if cb is NULL in nl_socket_set_cb (calls BUG())

11 years agotests: Make unit test building optional
Thomas Graf [Sat, 27 Apr 2013 12:27:10 +0000 (14:27 +0200)]
tests: Make unit test building optional

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agodump_attrs: "NLA_F_NESTED" => nla_is_nested(nla)
Коренберг Марк (дома) [Fri, 26 Apr 2013 17:50:54 +0000 (23:50 +0600)]
dump_attrs: "NLA_F_NESTED"  => nla_is_nested(nla)

11 years agoautoconf: Use PKG_CHECK_MODULES() instead of AM_PATH_CHECK()
Thomas Graf [Fri, 5 Apr 2013 08:44:06 +0000 (10:44 +0200)]
autoconf: Use PKG_CHECK_MODULES() instead of AM_PATH_CHECK()

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoaddr: only translate more recent address family names and ARP types if defined
Thomas Graf [Fri, 5 Apr 2013 08:37:55 +0000 (10:37 +0200)]
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>
11 years agoPerform no operation on nl_object_free(NULL).
Emmanuel Roullit [Wed, 3 Apr 2013 19:07:32 +0000 (21:07 +0200)]
Perform no operation on nl_object_free(NULL).

Passing a NULL pointer would cause a NULL pointer dereference within
nl_object_free().
Returning early on NULL pointer is the behavior free(3) and other
nl*_free() functions.

Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
11 years agomsg: Pretty print generic netlink header in nl_msg_dump()
Thomas Graf [Tue, 2 Apr 2013 21:13:15 +0000 (23:13 +0200)]
msg: Pretty print generic netlink header in nl_msg_dump()

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agonl: Return -NLE_AGAIN if non-blocking socket would block
Thomas Graf [Tue, 2 Apr 2013 09:58:18 +0000 (11:58 +0200)]
nl: Return -NLE_AGAIN if non-blocking socket would block

Previously 0 was returned which gave the caller no chance of detecting
when a non-blocking socket would block. If a caller intends to never
see an error message it should utilize poll()/select() to only read
when the socket has pending data or information.

Reported-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agogenl: Fix cb reference leak in genl_ctrl_probe_by_name()
Thomas Graf [Tue, 2 Apr 2013 09:51:53 +0000 (11:51 +0200)]
genl: Fix cb reference leak in genl_ctrl_probe_by_name()

nl_socket_get_cb() bumps the cb reference counter

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agoct: add ICMPv6 type,code and ID
Holger Eitzenberger [Sun, 31 Mar 2013 19:16:21 +0000 (21:16 +0200)]
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>
11 years agonl: Print file:line:func in debugging messages and provide --disable-debug to disable...
Thomas Graf [Tue, 2 Apr 2013 09:39:30 +0000 (11:39 +0200)]
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>
11 years agocache: Improve debugging messages of cache operations
Thomas Graf [Mon, 1 Apr 2013 09:46:30 +0000 (11:46 +0200)]
cache: Improve debugging messages of cache operations

Signed-off-by: Thomas Graf <tgraf@suug.ch>
11 years agogenl: Update mt_id of cache ops when resolving genl id
Thomas Graf [Mon, 1 Apr 2013 09:16:34 +0000 (11:16 +0200)]
genl: Update mt_id of cache ops when resolving genl id

The cache layer uses the message type array stored in the cache
ops to lookup which cache a message belongs to. Update to the
the message array with the resolved generic netlink id to make
it compatible with the caching API.

Allows to use nl_cache_refill() and others for generic netlink
based caches with dynamic generic netlink ids.

Signed-off-by: Thomas Graf <tgraf@suug.ch>