Commit Graph

152 Commits

Author SHA1 Message Date
Tobias Jungel
250a7c9ae9 nl-neigh-list: free allocated items 2018-06-25 13:57:34 +02:00
Thomas Haller
b7504b8b64 build: sort entries in Makefile.am and .gitignore by name 2018-04-06 19:44:57 +02:00
Lukáš Karas
3bbbe347d7 nf-ct-add typo 2018-04-06 19:27:33 +02:00
Lukáš Karas
6c6c74a788 add demo program for listen conntrack events 2018-04-06 19:27:33 +02:00
David Ahern
3500e25fd2 Add support for label stack in nl-route commands
Add support for MPLS labels in nexthop specification. Specifically, the
'as' keyword specifies the MPLS label stack and if the route address
family is MPLS then the nexthop via is added as a route via instead of
a gateway (subtle differences introduced for MPLS).

Signed-off-by: David Ahern <dsahern@gmail.com>
2017-08-18 15:01:04 +02:00
Thomas Haller
cda0d805aa all: avoid compiler warnings -Wimplicit-fallthrough 2017-06-15 18:52:53 +02:00
Thomas Haller
c881a27fbd build: allow building cli without dynamic librarires support
Commit 3cb28534d3 enables building
of cli always as part of `make check`. As cli previously always
included <dlfcn.h>, this broke tests for building with toolchains
that don't support dynamic library loading.

Add a configure check and disable dlopen() based on whether
<dlfcn.h> is available.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://github.com/thom311/libnl/pull/141
2017-05-12 12:57:34 +02:00
David Ahern
37fda66735 route: Add support for MPLS to netconf
Add support to netconf for MPLS address family.

v2
- change get method to return 0/error and take 'int *val'
  which is set to the value requested
- added rtnl_netconf_get_input to libnl-route-3.sym

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2017-05-12 10:09:15 +02:00
David Ahern
a66511d7ed nl-monitor: Add support for netconf caches
Allow user to monitor netconf changes.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2017-05-12 10:09:15 +02:00
David Ahern
92b96a48ec nl-monitor: All user to specify line format
nl-monitor defaults to stats. Allow user to select brief and details.

The known_groups is moved up to a global to allow a proper print_usage
function.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2017-05-12 10:09:15 +02:00
Alexey Brodkin
e15966ac7f lib: escape usage of strerror_l() if it doesn't exist in libc
uClibc doesn't implement strerror_l() and thus libnl starting from
3.2.29 couldn't be compiled with it any longer.

To work-around that problem we'll just do a check on strerror_l()
availability during configuration and if it's not there just fall back
to locale-less strerror().

See-also: 6c2d111177

http://lists.infradead.org/pipermail/libnl/2017-March/002301.html

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2017-03-12 14:42:42 +01:00
Thomas Haller
45cbfb9d11 include: don't include kernel headers in public libnl3 headers
It would be desirable not to include kernel headers in our public
libnl3 headers. As a test, remove all those includes, and fix
compilation by explicitly including the kernel headers where needed.
In some cases, that requires forward declaration for kernel
structures, as we use them as part of our own headers.

Realistically, we cannot drop those includes as it probalby breaks
compilation for users that expect to get a certain kernel header
when including a libnl3 header. So, this will not be done and the
includes will be restored in the next commit.

Do this step to show how it would be and to verify that we could
build with such a change. The reason not to do this is backward
compatibility (at compile-time).
2017-03-02 01:33:25 +01:00
Thomas Haller
cf2ccbd5cc build: merge src/Makefile.am into top-level makefile 2017-02-27 13:36:03 +01:00
Thomas Haller
061d4fd8b8 build: merge src/lib/Makefile.am into top-level makefile 2017-02-27 13:36:03 +01:00
Nick Kralevich
64b12a065a fopen: add O_CLOEXEC
Add O_CLOEXEC to various fopen() calls. This avoids file descriptors
leaking across an exec() boundary in a multi-threaded program. Please
see "man 2 open" for additional information about O_CLOEXEC.

Signed-off-by: Nick Kralevich <nnk@google.com>

https://github.com/thom311/libnl/pull/128
2017-01-17 23:00:18 +01:00
Thomas Haller
a078e364fb nl-link-stats: prefer RTNL_LINK_STATS_MAX over __RTNL_LINK_STATS_MAX
The result is basically the same, but I feel that __RTNL_LINK_STATS_MAX
is an internal variable that shouldn't be used. Thus, let's iterate
instead until <= MAX.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-29 12:37:00 +01:00
Tobias Klauser
4618b88dca src: nl-link-stats: use correct rtnl link stats maximum
Use __RTNL_LINK_STATS_MAX instead of RTNL_LINK_STATS_MAX when iterating
over all rtnl link stat counters. Otherwise, the last stat counter will
always be missing, as RTNL_LINK_STATS_MAX is the value of the last valid
index.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-11-29 09:15:15 +01:00
André Draszik
6c2d111177 src: switch to using strerror_l() instead of strerror_r()
glibc provides two versions of strerror_r(), which
can be chosen between using feature test macros
_GNU_SOURCE and _POSIX_C_SOURCE. libnl is built using
the former, hence we get the glibc special version,
and all code so far has been written for this.

Other C libraries like musl on the other hand only try
to be posix compliant, and only ever provide the posix
version of strerror_r(), which has a different signature.

Uses in libnl hence generally cause printf() of an *int*
with a *string format* specifier for that reason.

Additionally, strerror_r() has been deprecated:
  http://austingroupbugs.net/view.php?id=655

Switch to using strerror_l().

Signed-off-by: André Draszik <adraszik@tycoint.com>
Reviewed-by: Stephane Ayotte <sayotte@tycoint.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-08-25 17:32:57 +02:00
Peter Wu
c520876011 trivial: whitespace-only fixes for src and lib
Fixes alignment, lines with just whitespace and mixed tab/space
indentation. Searched, reviewed and optionally fixed in vim using
regex ^\t* [\t ]*\([^*us ]\|$\)\|\t\+$

http://lists.infradead.org/pipermail/libnl/2016-August/002183.html

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-08-12 23:06:27 +02:00
Tobias Klauser
4dd3ca4840 build: move -rdynamic from CPPFLAGS to LDFLAGS
The -rdynamic flag is a linker flag, not a compiler/preprocessor flag,
so move it to LDFLAGS.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>

http://lists.infradead.org/pipermail/libnl/2016-March/002100.html
2016-03-31 15:31:00 +02:00
David Ahern
18d60cb9d7 link/neigh: add flags option to link and neighbor caches
Both link and neighbor cache support specify multiple groups (nl_af_group),
but the alloc_cache functions for both do not set the NL_CACHE_AF_ITER
flag before populating the cache so only the first group is used by
default. This patch adds an API to pass in flags to make that happen
and updates the nl-neigh-list command to make use of it.

http://lists.infradead.org/pipermail/libnl/2015-October/001996.html

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-11-19 16:48:21 +01:00
jfarrell
d754cb4543 build: fix path to cli linker version script for out-of-tree build
https://github.com/thom311/libnl/pull/78
2015-06-19 17:42:51 +02:00
Thomas Haller
ff19c781d3 build: extend configure option --enable-cli and install all cli programs
Previously, some cli programs were installed to sbin/
and most were not installed at all.

Now, by default install all of them to bin/ directory.
But extend the configure option to allow specifying
'no-inst', 'bin', or 'sbin'.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-18 15:36:02 +01:00
Thomas Haller
0c97b088f1 build/trivial: sort PROGRAMS list in src/Makefile.am
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-18 09:49:36 +01:00
David Chappelle
50a76998ac route: remove unnecessary include of private linux/if.h
Including linux/if.h in netlink/route/link.h causes issues
in cases where libnl is used in conjuntion with other third
party libraries that include net/if.h. Seems to be a long
checkered history of symbol collisions between these two
files. As it turns out, including linux/if.h from within
netlink/route/link.h is actually unecessary. I resurrected
a forgotten path from this thread:

    http://lists.infradead.org/pipermail/libnl/2012-April/000525.html

By removing the include as the patch suggests we can get
around the nuissance of the symbol collisions.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-03-17 10:07:49 +01:00
Cong Wang
4ff512b054 correct --protocol option for nl-cls-* utilities
Just in the help message.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-25 10:08:07 +01:00
Thomas Haller
541b249358 build: add linker scripts for libnl-cli-3.so library
libnl-cli-3.so was unversioned previously. This is an
ABI change (but backward compatible).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2015-02-02 17:28:06 +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
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
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
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
Tobias Klauser
feda705426 cli: Fix typo in error message
s/neighbout/neighbour/

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-17 17:24:42 +02:00
Thomas Haller
87682a093a cli: add error checking to nl-route-get about out-of-memory
This is mainly to appease coverity which warned about this.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-10 21:45:52 +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
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
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
Jan Engelhardt
bda0f668b6 build: separate compiler and linker flags
-Wall is a compiler flag, and thus should be in CFLAGS,
not CPPFLAGS. Similarly, -l belongs into LDADD/LIBADD because of
ordering constraints.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-27 23:38:50 +01:00
Julien BERNARD
27019c5671 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>
2013-10-22 14:20:41 +02:00
maksqwe
c31467e0a4 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>
2013-08-26 10:06:30 +02:00
Joe Damato
c97c8c2bfd 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.
2013-07-25 16:36:16 -07:00
Joe Damato
81d2b1d509 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.
2013-07-19 02:06:21 -07:00
roopa
6c9be5a316 nl-route-add: Add NLM_F_EXCL flag to route add
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-03-24 10:58:18 +01:00
Thomas Graf
4d7680c19c Use thread-safe strerror_r() instead of strerror()
We have only ever fed well known error codes into strerror()
so it should never have been a problem though.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-02-28 13:07:04 +01:00
Thomas Graf
4cb375a812 Merge pull request #29 from rmfought/natdir32
netfilter: expectation NAT direction is 32 bit attribute
2013-01-24 08:32:35 -08:00
Thomas Graf
c4f803366e Fix build warnings of nl-(qdisc|class|cls)-add
Reported-by: Jeroen Roovers <jer@gentoo.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-01-24 14:10:33 +01:00
Thomas Graf
9680f910f4 Move private header files to <netlink-private/*>
This clarifies the seperation between public and private
header files.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-01-24 13:51:24 +01:00
Rich Fought
56352ab9f6 netfilter: expectation NAT direction is 32 bit attribute 2013-01-23 13:59:27 -08:00
Thomas Graf
00132b4696 cache: provide safe variant of nl_cache_mngt_require() and use it
This makes runtime removal of cache operations possible if non-safe
API is not in use by application. The non-safe API will be removed
in the next major version.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2012-11-16 01:11:55 +01:00
Thomas Graf
609b47961b Merge branch 'master' of https://github.com/rmfought/libnl 2012-10-26 12:48:22 +02:00