Commit Graph

905 Commits

Author SHA1 Message Date
Cong Wang
e5d9b828f6 act: grab a reference when adding an action to a filter
When we add an action to a filter, its lifetime becomes
same with the filter. So in case user frees it before
us, we could just grab a reference here.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-30 11:19:42 +02:00
Cong Wang
0ba7e663ce veth: grab a reference for rtnl_link_veth_get_peer()
So that users could keep a refcount for the peer.
The capability trick is from Thomas Haller.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-30 11:08:15 +02:00
Hangbin Liu
f55ef93d1e gitignore: ignore patch files
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-16 10:08:47 +02:00
Hangbin Liu
6722853f49 doc/core: reply message should send from kernel to app
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-16 10:08:47 +02:00
Hangbin Liu
69f4a03425 gitignore: ignore ctags file
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
[thaller@redhat.com: change to ignore /tags only on top-level]
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-16 10:07:42 +02:00
Rich Fought
8ff199947f netfilter/ct: expand CT parameters that can be used in add/delete operations
This expands functionality for manipulating conntracks over netlink by
adding other attributes to nfnl_ct_build_message(). Added a command link
program to add conntracks.

https://github.com/thom311/libnl/pull/55

[thaller@redhat.com: cleaned up whitespace from original patch]
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-14 19:20:53 +02:00
Hiroaki KAWAI
cb319e22f5 python: fix wrongly passing argument to function in ObjIterator.next()
self.__next__() bound method does not take an extra argument.

https://github.com/thom311/libnl/pull/57

Signed-off-by: Hiroaki KAWAI <kawai@stratosphere.co.jp>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-09 09:22:47 +02:00
Cong Wang
65f218bcae add NLM_F_EXCL to rtnl_link_veth_add()
rtnl_link_veth_add() is a helper API we provide, it makes sense to
set NLM_F_EXCL for it since it doesn't accept flags as a parameter.

BTW, correct an indention too.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-09 09:10:19 +02:00
Cong Wang
3700bf56fa veth: use nl_object_clone() to deep copy rtnl_link object
Currently we use memcpy() to copy the peer rtnl_link for veth device,
this is wrong, we should do deep copy by calling nl_object_clone()
recursively. We should be careful and need to make sure we only call
it once.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-09 09:10:19 +02:00
Cong Wang
6c8f67b87a veth: implement ->io_free
So that veth link can be just put by rtnl_link_put()

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-09 09:10:19 +02:00
Cong Wang
12bd035b05 veth: implement ->io_alloc
Users don't have to call rtnl_link_veth_alloc(), instead
use generic rtnl_link_set_type().

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-09 09:10:19 +02:00
Cong Wang
ab55ea80a4 link: call rtnl_link_set_type() in link_msg_parser()
We need to call link-specific ->io_alloc() to alloc
addtional structures.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-09 09:10:19 +02:00
Cong Wang
690545a20e act: fix policy range check
mirred action should accept all TC_ACT* policy

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-07 15:23:26 +02:00
Thomas Haller
5206c05050 route/addr: only sent IFA_FLAGS when needed to workaround picky older kernels
Older kernels don't accept receiving unknown netlink attributes.
See net/core/rtnetlink.c, rtnetlink_rcv_msg(). This was fixed by kernel
commit 661d2967b3f1b34eeaa7e212e7b9bbe8ee072b59.

As a workaround, only set the additional attributes, when the user
provided flags that makes this necessary and useful.

https://github.com/thom311/libnl/issues/56
https://bugzilla.redhat.com/show_bug.cgi?id=1063885

Based-on-patch-by: Pavel Kankovsky <peak@argo.troja.mff.cuni.cz>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-04 16:31:36 +02:00
Thomas Graf
34bfce6215 link: Catch missing io_free() implementations
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-31 13:23:48 +02:00
Cong Wang
baa2cadd02 route: fix off-by-one in rtnl_act_parse()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-31 09:42:46 +02:00
Thomas Haller
a593803ad6 route: update copy of kernel header 'ip.h'
Take 'include/uapi/linux/ip.h' from current kernel v3.13
(commit d8ec26d7f8287f5788a494f56e8814210f0e64be).

Also add three new IPV4_DEVCONF_* names.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-21 12:38:45 +01:00
Thomas Haller
1048a610fb route: rename internal copy of kernel header file 'inetdevice.h' to 'ip.h'
libnl used 'inetdevice.h' for the IPV4_DEVCONF_* names, which the kernel
in the meantime moved to public user space API and are now defined in 'ip.h'.

As a first step, rename the file 'inetdevice.h'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-21 12:38:45 +01:00
Thomas Haller
5981a39583 route: update kernel header snmp.h and fix inet6_parse_protinfo() after kernel API breakage
Take 'include/uapi/linux/snmp.h' from current kernel v3.13
(commit d8ec26d7f8287f5788a494f56e8814210f0e64be).

The header file added new values for IPSTATS_MIB_* and ICMP6_MIB_*, but
more importantly, the kernel broke user space API by reordering enum values in
IPSTATS_MIB_*. Add a workaround when parsing IFLA_PROTINFO trying to
be compatible with both older and newer kernels.

Note that this workaround might fail for some specific kernel versions by
assuming the old enum value mapping, although the kernel version already
contains the API change. In this case rtnl_link_get_stat() mixes up
values.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-21 12:38:45 +01:00
Thomas Haller
3584a7ab55 route: detect missing cfgid in rtnl_link_inet_get_conf()
If the netlink message for IFLA_INET_CONF contains less then
IPV4_DEVCONF_MAX entires, the last entries in i_conf are unset.
Modify rtnl_link_inet_get_conf() to return -EINVAL when accessing
an unset cfgid.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-21 12:27:23 +01:00
Thomas Haller
dfd0a80ec8 route: don't enforce minlen in inet6_parse_protinfo() (IFLA_PROTINFO) and inet_parse_af() (IFLA_AF_SPEC)
Older kernel version might have fewer values defined, so they would send
netlink messages that got rejected. Only check that at least one value
got sent.

This is especially grave as libnl uses an internal copy of the
kernel header files. Thus not only it is bound to the installed kernel
headers but to the libnl internal header copies that might easily be out
of sync with the kernel.

This affects IFLA_PROTINFO, inet6_parse_protinfo():
  - tb[IFLA_INET6_CONF], expecting DEVCONF_MAX
  - tb[IFLA_INET6_STATS], expecting __IPSTATS_MIB_MAX
  - tb[IFLA_INET6_ICMP6STATS], expecting __ICMP6_MIB_MAX
and IFLA_AF_SPEC, inet_parse_af():
  - tb[IFLA_INET_CONF], expecting IPV4_DEVCONF_MAX

https://bugzilla.redhat.com/show_bug.cgi?id=1062533

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-21 12:27:18 +01:00
Cong Wang
c0a5b39308 u32: add const to rtnl_u32_add_key_in*_addr()
Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-21 12:23:09 +01:00
Cong Wang
67a704676c link: document sk == NULL case for rtnl_link_alloc_cache()
When sk == NULL, rtnl_link_alloc_cache() returns 0 but the cache
is still empty. We should document this behavior, otherwise it is confusing.

Cc: Thomas Haller <thaller@redhat.com>
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-20 19:37:37 +01:00
Thomas Haller
015c4ee59b utils: indicate capability NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE
This capability indicates that libnl does no longer overwrites
the route scope in rtnl_route_build_msg(), as fixed by commit
85ec9c7ad8.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 13:16:51 +01:00
Thomas Haller
68d6bd7f37 utils: add nl_has_capability() function
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 13:16:05 +01:00
Cong Wang
a126d66b58 fill prio and protocol attr bits when parsing cls message
Otherwise, the filter we get from a cls cache can't be used
for removal.

Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 09:58:47 +01:00
Cong Wang
cdfdfb16d0 remove some useless code in lib/route/cls/u32.c
Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-27 11:32:16 +01:00
Cong Wang
59547d2d45 fix comments for rtnl_act_add()
Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-27 11:32:16 +01:00
Cong Wang
20aa7320d8 basic: make BASIC_ATTR_TARGET optional
At least in kernel TCA_BASIC_CLASSID is optional.

Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-27 11:32:16 +01:00
Thomas Haller
85ec9c7ad8 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>
2014-02-20 16:49:46 +01:00
Thomas Haller
3fb0aae0bc utils: fix nl_msec2str() which always returned '0msec' for whole second durations
If the duration was without subsecond part, the function always returned
'0msec', instead of giving the time in days, hours, minutes or seconds.

Regression introduced by commit b3fb89f445.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
2014-02-20 16:28:47 +01:00
Cong Wang
b3b8d72416 remove nl_cache_lookup() from cache.h
It is never defined.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-31 15:52:17 +01:00
Cong Wang
7dbf4d5903 remove the obsolete src/cls directory
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-31 15:52:06 +01:00
Thomas Haller
b70174668b route: fix return value of nl_rtgen_request()
According to documentation, nl_rtgen_request() returns 0 on success,
but before it returned the number of bytes sent.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-31 14:46:13 +01:00
Thomas Haller
4c7a3074bb build: fix error when running configure --disable-doc
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-29 18:13:35 +01:00
Thomas Haller
1a510c57e9 libnl-3.2.24 release
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-21 19:48:41 +01:00
Thomas Haller
894acf798d doc: fix typo in documentation
Also fix typo in source code comment.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-21 19:16:55 +01:00
Thomas Haller
815e192db6 python: fix build error for missing library_path in setup.py
Patch obtained from gentoo package.

https://bugs.gentoo.org/show_bug.cgi?id=477110
https://bugs.gentoo.org/show_bug.cgi?id=490584

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-21 19:11:16 +01:00
Thomas Haller
b203c89d86 addr: add address flag IFA_F_NOPREFIXROUTE
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-16 11:09:32 +01:00
Cong Wang
aa8877d5c1 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>
2014-01-15 14:16:46 +01:00
HongweiBi
8dabf9fb1a bridge: add rtnl_link_add_bridge() function
Signed-off-by: HongweiBi <hwbi2008@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-14 14:37:58 +01:00
Thomas Haller
dcc0baac02 addr: add address flag IFA_F_MANAGETEMPADDR
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-03 13:38:08 +01:00
Jiri Pirko
42c4133600 add support for IFA_FLAGS nl attribute
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-03 13:37:56 +01:00
Thomas Haller
2cf635b06a route: add libnl name prefix to global variable link_policy
Public names should be prefixed with a libnl specific
prefix to avoid name collisions. Rename link_policy to
rtln_link_policy.

Related bugs:
  https://github.com/thom311/libnl/issues/52
  https://bugzilla.gnome.org/show_bug.cgi?id=720902
  https://bugs.gentoo.org/show_bug.cgi?id=494986
  https://bugs.gentoo.org/show_bug.cgi?id=494890

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-02 11:56:56 +01:00
Thomas Haller
62c37faa3f libnl-3.2.24-rc1 release
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-17 18:31:42 +02:00
Thomas Haller
02c9c2518f 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).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-17 18:26:31 +02:00
Cong Wang
d7aca17701 u32: add rtnl_u32_get_key()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-17 18:14:10 +02:00
Thomas Graf
bc717a9bfc cache: Add missing declaration for nl_cache_find()
Reported-by: Andrej.Gantvorg@wago.com
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-13 15:57:43 +01:00
Cong Wang
c855e4fef5 add declaration for rtnl_basic_add_action()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-11 09:11:23 +01:00
Thomas Graf
85c0192455 Revert "basic: Add missing declaration for rtnl_basic_add_action()"
This reverts commit 4b84836085.
2013-12-11 09:10:32 +01:00