Commit Graph

1033 Commits

Author SHA1 Message Date
Thomas Haller
39ca54ab4d idiag: fix idiagnl_msg_clone()
For one, we did not clone all pointer values. Hence, every cloned
object was very broken and resulted in dangling pointers and
double free/unref.

Apparently nobody was really using this function up to now.

Also, fix the return cases for NLE_NOMEM, so that we did not assume
ownership of pointers in 'src'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:36:52 +01:00
Thomas Haller
f40fd71701 idiag: fix memory leak in idiagnl_msg_set_cong()
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
0e13bb44b8 idiag: reorder idiagnl.h to have deprecated functions at the top
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
6bf68e60e4 idiag: deprecate IDIAG_TIMER_* value for IDIAGNL_TIMER_*
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
94039ca48a idiag: deprecate IDIAG_SS_* socket states
These values mirror TCP_* socket states from 'netinit/tcp.h'.
There is no good reason to expose a copy of those values.
User space should use the original values (if they care).
The only value that is actually useful is IDIAGNL_SS_ALL.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
3b5226e3a2 idiag: deprecate netlink message type defines in idiagnl.h
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
22eb2569a5 idiag: deprecate IDIAG_ATTR_* enumeration
IDIAG_ATTR_* were a copy of the INET_DIAG_* extension kernel
flags. Redefining them is wrong, user space should continue
to use the values provided via the kernel headers.

Also they were misused as change flags (ce_mask), which they are not.

Deprecate the IDIAG_ATTR_* flags and redefine them to what the
originally are: INET_DIAG_*.

Also deprecated idiagnl_attrs2str() because there is already
idiagnl_exts2str(). idiagnl_attrs2str() in the sense of libnl change
flags (ce_mask) makes no sense.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
cd8cd2dae2 idiag: deprecate idiagnl_msg_obj_ops variable in public API
This internal structure should never have been exposed publically.
It as introduced as public API in v3.2.23.

For now, don't remove it as it would be an API/ABI break.

Fixes: 81d2b1d509
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
fffc7ecedd idiag: fix out of bound error parsing idiag messages
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
a3c0c04eff idiag: add copy of kernel header include/linux/inet_diag.h
Taken from upstream kernel commit bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9
(v3.17), file 'include/uapi/linux/inet_diag.h'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:30:21 +01:00
Thomas Haller
5fbd45e667 route: merge branch 'route-tc-fixes'
http://lists.infradead.org/pipermail/libnl/2014-November/001738.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:23:14 +01:00
Thomas Haller
703989eb12 route: make rtnl_tc_clone() more robust against NLE_NOMEM
When oo_clone() fails, the new object is freed. Make sure 'dst'
does not own parts of 'src'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:21:59 +01:00
Thomas Haller
24ad51518f route: set missing TCA_ATTR_XSTATS changes flags in rtnl_tc_msg_parse()
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-24 18:21:20 +01:00
Cong Wang
b54f6d8023 idiag: add a copy of linux/sock_diag.h
When we test idiag on 3.4 kernel, we always get ERANGE.
This is because libnl has its own copy for SK_MEMINFO_*,
which is actually newer than 3.4, where SK_MEMINFO_VARS
is larger than kernel's.

We add a copy from latest kernel, so on older kernel
libnl should still compile. Note, for kernel < 3.6
we don't have SK_MEMINFO_BACKLOG, we have to relax
the minlen.

'sock_diag.h' comes from v3.17 kernel sources
(bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9), file
'include/uapi/linux/sock_diag.h'.

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-11-24 13:21:15 +01:00
Cong Wang
9c066b9271 idiag: provide a hash function for idiag objects
Without ->oo_keygen, libnl will use linear search
for cache objects. This is extremely slow for idiag
when we have a lot of TCP connections. Provide a
hash function for idiag so that libnl will be able
to lookup a hashtable.

http://lists.infradead.org/pipermail/libnl/2014-November/001715.html

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-11-24 10:49:34 +01:00
Holger Eitzenberger
0020ba1212 cache: avoid duplicate check on initial dump
The cache pickup does a check for duplicates for some time now.

However, the pickup in nl_cache_refill() explicitely clears the
cache, so the pickup doesn't need to actually do the dupe check,
as uniqueness is already guaranteed be Netlink subsystem.

And avoiding the dup check is beneficitial for performance
reasons, as the current algorithm is O(n^2).

http://lists.infradead.org/pipermail/libnl/2014-October/001680.html

Fixes: 96bb7c9a4c
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:58:13 +01:00
Thomas Haller
15178401c2 route/cls: merge branch 'route-cls-u32-match-mark'
http://lists.infradead.org/pipermail/libnl/2014-November/001699.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:32:41 +01:00
Thomas Haller
8759c20beb route/cls: minor fixes in for match mark filters
- whitespace
- fix newline and whitespace in output of u32_dump_details()
- let rtnl_u32_del_mark() clear U32_ATTR_MARK

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:32:29 +01:00
Sagi Lowenhardt
3844b15d73 route/cls: support 'match mark' u32 filters
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-23 15:28:55 +01:00
Thomas Haller
d65c32a720 link: fix memory leaks due to repeated calls to .io_alloc()
All the io_alloc() implementation unconditionally allocated
new memory, thus leaking memory if called more then once.
Fix io_alloc() implementations not to allocate new memory
if not needed.

This happens for example in link_msg_parser() which first
calls rtnl_link_set_type():

    #0  macvlan_alloc (link=0x609d50) at route/link/macvlan.c:56
    #1  0x00007ffff7b99a78 in rtnl_link_set_type (link=link@entry=0x609d50, type=type@entry=0x609a94 "macvlan") at route/link.c:2233
    #2  0x00007ffff7b99c28 in link_msg_parser (ops=<optimized out>, who=<optimized out>, n=<optimized out>, pp=0x7fffffffd870) at route/link.c:547
    #3  0x00007ffff7dea109 in nl_cache_parse (ops=0x7ffff7dd8600 <rtnl_link_ops>, who=0x603338, nlh=0x6098a0, params=0x7fffffffd870) at cache.c:914
    #4  0x00007ffff7dea15b in update_msg_parser (msg=<optimized out>, arg=<optimized out>) at cache.c:668
    #5  0x00007ffff7def7bf in nl_cb_call (msg=<optimized out>, type=<optimized out>, cb=<optimized out>) at ../include/netlink-private/netlink.h:142
    #6  recvmsgs (cb=0x6057a0, sk=0x6034c0) at nl.c:952
    #7  nl_recvmsgs_report (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1003
    #8  0x00007ffff7defb79 in nl_recvmsgs (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1027
    #9  0x00007ffff7de9668 in __cache_pickup (sk=0x6034c0, cache=0x603510, param=param@entry=0x7fffffffd870) at cache.c:701
    #10 0x00007ffff7dea08d in nl_cache_pickup (sk=<optimized out>, cache=<optimized out>) at cache.c:753
    #11 0x0000000000400d56 in main ()

and later ops->io_parse():

    #0  macvlan_alloc (link=0x609d50) at route/link/macvlan.c:56
    #1  0x00007ffff7baae9d in macvlan_parse (link=0x609d50, data=<optimized out>, xstats=<optimized out>) at route/link/macvlan.c:79
    #2  0x00007ffff7b99c80 in link_msg_parser (ops=<optimized out>, who=<optimized out>, n=<optimized out>, pp=0x7fffffffd870) at route/link.c:567
    #3  0x00007ffff7dea109 in nl_cache_parse (ops=0x7ffff7dd8600 <rtnl_link_ops>, who=0x603338, nlh=0x6098a0, params=0x7fffffffd870) at cache.c:914
    #4  0x00007ffff7dea15b in update_msg_parser (msg=<optimized out>, arg=<optimized out>) at cache.c:668
    #5  0x00007ffff7def7bf in nl_cb_call (msg=<optimized out>, type=<optimized out>, cb=<optimized out>) at ../include/netlink-private/netlink.h:142
    #6  recvmsgs (cb=0x6057a0, sk=0x6034c0) at nl.c:952
    #7  nl_recvmsgs_report (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1003
    #8  0x00007ffff7defb79 in nl_recvmsgs (sk=sk@entry=0x6034c0, cb=cb@entry=0x6057a0) at nl.c:1027
    #9  0x00007ffff7de9668 in __cache_pickup (sk=0x6034c0, cache=0x603510, param=param@entry=0x7fffffffd870) at cache.c:701
    #10 0x00007ffff7dea08d in nl_cache_pickup (sk=<optimized out>, cache=<optimized out>) at cache.c:753
    #11 0x0000000000400d56 in main ()

https://github.com/thom311/libnl/issues/59

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 19:35:46 +02:00
Lubomir Rintel
b0d0d339cd link/inet6: add support for tokenized interface identifiers
http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

[thaller@redhat.com: Add OOM handling, fix whitespace issues]

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

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-08 16:47:43 +02:00
Jörg Krause
e003951945 netlink/netlink.h: fix build including <poll.h> with the musl C library
https://github.com/thom311/libnl/pull/64

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-30 09:33:46 +02:00
Thomas Haller
d6f761bc4e build: move copy of linux headers to private directory
libnl3 contains a private copy of some kernel header files.

Normally, users are expected to install libnl and specify
-I$PREFIX/include/libnl3 as include path. As the private kernel
header files are not installed, this works fine.

However, it can be convenient to build against the libnl source
directory, without installing libnl. In this case, the private kernel
header files shaddow the system provided ones. This is undesired.

Move these files to a different directory to avoid this clash.

http://lists.infradead.org/pipermail/libnl/2014-September/001645.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
2014-09-24 16:00:31 +02:00
Thomas Haller
1e3f316081 build/trivial: prettify makefiles by wrapping long lines
Signed-off-by: Thomas Haller <thaller@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
2014-09-24 16:00:26 +02:00
Cong Wang
a2b9f33fd4 idiag: fix a typo in idiagnl_req_set_ifindex()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 07:50:25 +02:00
Sébastien Barré
1578095b8a build: generate libnl-idiag-3.0.pc
That file was not generated due to a missing line in Makefile.am
and configure.ac

http://lists.infradead.org/pipermail/libnl/2014-September/001649.html

Signed-off-by: Sébastien Barré <sebastien.barre@uclouvain.be>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-22 11:06:05 +02:00
Thomas Haller
cea532d296 Merge branch 'enovance-sa_fixup'
https://github.com/thom311/libnl/pull/62

[thaller@redhat.com: I changed the original patches
 to indent with tabs (vs. spaces) and reworded the
 commit messages.]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 13:27:33 +02:00
Nicolas PLANEL
592d665fbc cls: check data before memcpy() it
[thaller@redhat.com: I modified the condition "if (data && len)"
 in the original patch to just check "len > 0".
 Note that all call sites of meta_alloc() make sure to pass a
 valid data pointer with a non-zero length (anything else would
 be a bug). But indeed, calling memcpy with invalid src pointer
 is undefined behavior, even if len is zero.]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 13:22:22 +02:00
Nicolas PLANEL
06140c3ec9 xfrm: fix xfrm_sa_msg_parser() to return the value from the callback
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 13:00:46 +02:00
Nicolas PLANEL
77bbf2270c xfrm: fix an unintialized return value on memory allocation error in xfrmnl_ae_parse()
fix : err = -ENOMEM if calloc() failed

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 12:59:39 +02:00
Nicolas PLANEL
a640e97a22 qdisc: avoid calling strstr() with a NULL haystack
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 12:56:34 +02:00
Nicolas PLANEL
54ae1d95a4 xfrm: fix calling free() with a bad pointer
sp->sec_ctx->ctx is a zero-length member, so it's already allocated

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 16:52:17 +02:00
Thomas Haller
8cd946a683 travis-ci: run make check in travis build
Test programs are only compiled when running `make check`.
Also, fix passing $CFLAGS argument to make.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 14:15:36 +02:00
Thomas Graf
7c775184c1 Remove pointless N < 0 checks
route/tc.c:553:9: warning: comparison of unsigned enum expression < 0 is
always false [-Wtautological-compare]
              if (id < 0 || id > RTNL_TC_STATS_MAX)

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 14:12:52 +02:00
Thomas Haller
54f6d7d1b3 Merge branch 'tgraf/trivial-fixes'
http://lists.infradead.org/pipermail/libnl/2014-August/001614.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 13:14:32 +02:00
Thomas Graf
340d5d69c4 src: Silence all warnings
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 13:09:20 +02:00
Thomas Graf
c231aa4159 xfrm: Remove unused variable sp_id and sa_id
Cc: Sruthi Yellamraju <ysruthi@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 13:09:20 +02:00
Thomas Graf
485cefd665 nf: Remove unused function htonll()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 13:09:20 +02:00
Thomas Graf
a45fca9a58 xfrm: Remove unused function __assign_addr()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 13:09:20 +02:00
Thomas Graf
da80033c2f nf: nfnl_*_str2copy_mode() should return int
... to be able to return a negative error code for unknown modes.

[thaller@redhat.com: This is potentially an ABI break, but since
the size of the enum is implementation defined, it seems
anyway unstable to have them as function arguments/return values.]

http://lists.infradead.org/pipermail/libnl/2014-August/001616.html

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 13:03:30 +02:00
Thomas Graf
03f3f3c4c0 build: Add continuous integration support via travis-ci
This allows any libnl github repo to link to travis-ci which
will result in new commits and pull requests to be automatically
built with both gcc and clang. Any build failures including the
addition of warnings are reported to the author and committer.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 12:41:38 +02:00
Thomas Haller
16e3d61689 tests: build test-create-macvlan as part of make check
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-18 15:17:43 +02:00
Thomas Haller
76237f6d63 Merge branch 'hfsc-qdisc-support'
http://lists.infradead.org/pipermail/libnl/2014-July/001566.html
http://lists.infradead.org/pipermail/libnl/2014-July/001594.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 19:06:03 +02:00
Cong Wang
cacc24ea66 qdisc: add hfsc qdisc support
Cc: Thomas Graf <tgraf@suug.ch>
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-07-30 19:03:56 +02:00
Cong Wang
f904fabcb4 tc: save error code for rtnl_tc_data_check()
Cc: Thomas Graf <tgraf@suug.ch>
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-07-30 19:03:50 +02:00
Thomas Haller
000dd945b6 Merge branch 'dcbw/inet6_addr_gen'
http://lists.infradead.org/pipermail/libnl/2014-July/001561.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 18:55:32 +02:00
Dan Williams
558f966782 link/inet6: add link IPv6 address generation mode support
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 18:45:51 +02:00
Dan Williams
b51815a9db link: update copy of kernel header include/linux/if_link.h
The next patch will use some of these defines, so update.

Taken from upstream kernel commit bc91b0f07ada5535427373a4e2050877bcc12218,
file 'include/uapi/linux/if_link.h'.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-30 00:39:24 +02:00
Thomas Haller
2605538632 Merge branch 'declaration-fixes'
Assorted declaration fixes

http://lists.infradead.org/pipermail/libnl/2014-July/001570.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 11:10:15 +02:00
Thomas Graf
5329f6a6c7 cache_mngt: Make __nl_cache_ops_lookup() static, it was never declared
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 11:04:07 +02:00