Commit Graph

1019 Commits

Author SHA1 Message Date
Thomas Haller
0fd510b367 lib/socket: use proper typed constant UINT32_MAX for uint32_t typed port
This was a bug on architectures with native int type less then 32 bit.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-06 14:33:38 +02:00
Thomas Haller
657e257ec5 gitignore: ignore test binaries and artifacts in "tests/"
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-06 12:48:47 +02:00
Susant Sahani
8f6301426a ipvti: introduce vti tunnel support
Signed-off-by: Susant Sahani <susant@redhat.com>
[thaller@redhat.com: some whitespace fixes]
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-06 12:04:02 +02:00
Susant Sahani
adb9f5d8fa ipgre: rename new public API to avoid confusion
Signed-off-by: Susant Sahani <susant@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-06 11:57:40 +02:00
Susant Sahani
737d5f0247 ipgre: fix attribute IPGRE_ATTR_OKEY in ipgre_put_attrs()
Signed-off-by: Susant Sahani <susant@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-06 11:57:32 +02:00
Susant Sahani
d715b8a5f6 introduce sit tunnel support
This patch introduces sit tunnel support

Signed-off-by: Susant Sahani <susant@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
[thaller@redhat.com: change WS to TAB, fix code doc]
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-05 19:08:29 +02:00
Susant Sahani
57bdc4ff48 introduce gre tunnel support
This patch introduces gre tunnel support

Signed-off-by: Susant Sahani <susant@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
[thaller@redhat.com: change WS to TAB, fix code doc]
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-05 19:08:23 +02:00
Susant Sahani
3a95fad5c9 introduce ipip tunnel support
This patch introduces ipip tunnel support. This
works with kernel module ipip.

Signed-off-by: Susant Sahani <susant@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
[thaller@redhat.com: change WS to TAB, fix code doc]
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-05 18:08:47 +02:00
Thomas Haller
0482cdcddb gitignore: ignore test binaries and artifacts in "tests/"
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-05 14:38:08 +02:00
Thomas Haller
a1c9915022 doc: fix wrong name in documentation for rtnl_link_bridge_alloc()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-01 20:50:26 +02:00
Thomas Haller
35f44734bc act: fix memory leak in rtnl_act_parse()
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-01 16:59:06 +02:00
Cong Wang
b8d90d9bb1 act: fix a pointer in rtnl_act_msg_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-05-01 16:55:31 +02:00
Thomas Haller
6d70d83947 docs: add code comment to explain the meaning of the fields in rtnl_addr_cacheinfo
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-30 14:34:14 +02:00
Thomas Haller
a5917da51e gitignore: ignore 'nf-ct-add' (netfilter/ct)
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-30 13:06:50 +02:00
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