summaryrefslogtreecommitdiffstats
path: root/src/lib
Commit message (Collapse)AuthorAgeFilesLines
* build: move "-DPGKLIBDIR" and renameThomas Haller2024-05-291-1/+1
| | | | | | | | | These defines should be defined at one place ("defines_cppflags") and they should be available the same throughout the source code. Even if PKGLIBDIR is only used by "src/lib/utils.c", there is no harm in defining it for all compilation units. The point is that it is only defined at one place and the same for all compilation units.
* include: use <linux/$file> instead of <linux-private/linux/$file>Thomas Haller2023-08-082-2/+2
| | | | | | As we now copy all linux headers, and we have include/linux-private in our include search path, just include the linux headers as we commonly do.
* include: include private linux headers with explicit pathThomas Haller2023-08-032-2/+2
| | | | | | | We have copies of the linux headers in include/linux-private. For those files, include the copies explicitly. No practice there is no difference, since we build with :-Ilinux-private".
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-0212-2/+28
|
* include: add "nl-default.h" headerThomas Haller2023-08-021-3/+3
| | | | | | | | | | | | | In an autotools project, <config.h> should be included as very first thing in almost all cases. We also want include other stuff, in particular "include/base", which contains our own extensions on top of plain C (it is thus applicable to all our C modules). Add a "nl-default.h", which can be included as first and prepares a base for each C source. Additionally, since header files are never compiled directly (only indirectly by being included), they can rely that "nl-default.h" is always available.
* build: move "lib/defs.h" to "include/config.h"Thomas Haller2023-08-021-2/+2
| | | | | | | It seems "config.h" is the more common name for the autotools generated header. In any case, it should not be under "lib", because lib is specifically about libnl-3 and similar libraries. It's awkward for modules under src to include from lib.
* include: rename "nl-hidden-route" to "nl-priv-dynamic-route"Thomas Haller2023-08-021-1/+1
| | | | | Naming is just so important to understand what this is. This name is better.
* route: move hidden symbols from "include/netlink-private/route/tc-api.h"Thomas Haller2023-08-011-1/+2
| | | | | | | | | | | To new header "include/nl-hidden-route/nl-hidden-route.h". libnl-route-3 exports some symbols that are no in public headers. They are however used by other internal users in the source tree. Such usage seems bad. We should clearly see where this is done. Move the symbols to a separate header, where it's clear who may use this header, and what's its purpose.
* cli: add nl-nh-list utilityStanislav Zaikin2023-07-311-0/+61
|
* utils: suppress coverity warning in nl_cli_load_module() about leaked handleThomas Haller2022-04-221-0/+2
| | | | | | | | | | | | | | | It's unclear to me, how to avoid this "leak". It's intentional, given the existing API. Try to suppress the warning. Error: RESOURCE_LEAK (CWE-772): libnl-3.6.0/src/lib/utils.c:232: alloc_fn: Storage is returned from allocation function "dlopen". libnl-3.6.0/src/lib/utils.c:232: var_assign: Assigning: "handle" = storage returned from "dlopen(path, 2)". libnl-3.6.0/src/lib/utils.c:236: leaked_storage: Variable "handle" going out of scope leaks the storage it points to. # 234| path, dlerror()); # 235| } # 236|-> } # 237| #else # 238| nl_cli_fatal(ENOTSUP, "Unable to load module \"%s\": built without dynamic libraries support\n",
* all: avoid coverity warnings about assigning variable but not using itThomas Haller2022-04-221-1/+2
| | | | | | | | | | | | Workaround coverity warnings like: Error: CLANG_WARNING: libnl-3.6.0/lib/netfilter/exp.c:428:7: warning[deadcode.DeadStores]: Although the value stored to 'err' is used in the enclosing expression, the value is never actually read from 'err' # 426| } # 427|··· # 428|-> if ((err = nfnl_exp_build_tuple(msg, exp, CTA_EXPECT_NAT)) < 0) # 429| goto nla_put_failure; # 430|···
* license: fix and add SPDX license identifiers and drop license commentsThomas Haller2020-04-1612-84/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also fixes a few wrong SPDX license identifiers, where the original license comment indicates GPL-2.0-only. This is not done manually, but by running the following script: --- #!/bin/bash # Tool to drop license comments, adding SPDX license identifiers, while preserving # copyright comments. The point is not to manually do this task, but perform some # hacked up string replacement. _cp() { /bin/cp "$@" } _cat() { /bin/cat "$@" } in_file() { local T=$(mktemp) _cp -f "$1" "$T" _cat "$T" rm -f "$T" } out_file() { local T=$(mktemp) _cat - > "$T" _cp -f "$T" "$1" rm -f "$T" } join() { _cat "$@" | awk '{ printf("%s#x#", $0)}' } unjoin() { _cat - | sed 's/#x#/\n/g' } files_all() { git ls-files | grep -v '\.png$' | grep -v '^include/linux-private/' } adjust() { NEWLINES='\(#x#\)\+' COPYRIGHTS='\(\( \* Copyright (c) 20..\(-20..\|, 20..\)\? [^#]\+#x#\)\+\( \*#x# \* \(Stolen[^#]*\|Based on [^#]*\)#x#\)\?\)' _cat - | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x##x#%' | \ sed '1s%^\(\)/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU General Public License as#x# \*[ ]\+published by the Free Software Foundation version 2 of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: GPL-2.0-only \*/#x#/*#x#\2 */#x##x#%' } FILES=( $(files_all) ) for f in "${FILES[@]}"; do echo "processing \"$f\"..." in_file "$f" | join | adjust | unjoin | out_file "$f" done
* Add SPDX identifiersYegor Yefremov2019-08-1212-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Software Package Data Exchange identifiers help to detect source file licenses and hence simplify the FOSS compliance process. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> https://github.com/thom311/libnl/pull/219 --- FILES=( lib/addr.c lib/attr.c lib/cache.c lib/cache_mngr.c lib/cache_mngt.c lib/data.c lib/error.c lib/fib_lookup/lookup.c lib/fib_lookup/request.c lib/genl/ctrl.c lib/genl/family.c lib/genl/genl.c lib/genl/mngt.c lib/handlers.c lib/hash.c lib/hashtable.c lib/idiag/idiag.c lib/idiag/idiag_meminfo_obj.c lib/idiag/idiag_msg_obj.c lib/idiag/idiag_req_obj.c lib/idiag/idiag_vegasinfo_obj.c lib/mpls.c lib/msg.c lib/netfilter/ct.c lib/netfilter/ct_obj.c lib/netfilter/exp.c lib/netfilter/exp_obj.c lib/netfilter/log.c lib/netfilter/log_msg.c lib/netfilter/log_msg_obj.c lib/netfilter/log_obj.c lib/netfilter/netfilter.c lib/netfilter/nfnl.c lib/netfilter/queue.c lib/netfilter/queue_msg.c lib/netfilter/queue_msg_obj.c lib/netfilter/queue_obj.c lib/nl.c lib/object.c lib/route/act.c lib/route/addr.c lib/route/class.c lib/route/classid.c lib/route/cls.c lib/route/link.c lib/route/neigh.c lib/route/neightbl.c lib/route/netconf.c lib/route/nexthop.c lib/route/nexthop_encap.c lib/route/nh_encap_mpls.c lib/route/pktloc.c lib/route/qdisc.c lib/route/route.c lib/route/route_obj.c lib/route/route_utils.c lib/route/rtnl.c lib/route/rule.c lib/route/tc.c lib/socket.c lib/utils.c lib/version.c lib/xfrm/ae.c lib/xfrm/lifetime.c lib/xfrm/sa.c lib/xfrm/selector.c lib/xfrm/sp.c lib/xfrm/template.c src/genl-ctrl-list.c src/idiag-socket-details.c src/lib/addr.c src/lib/class.c src/lib/cls.c src/lib/ct.c src/lib/exp.c src/lib/link.c src/lib/neigh.c src/lib/qdisc.c src/lib/route.c src/lib/rule.c src/lib/tc.c src/lib/utils.c src/nf-ct-add.c src/nf-ct-events.c src/nf-ct-list.c src/nf-exp-add.c src/nf-exp-delete.c src/nf-exp-list.c src/nf-log.c src/nf-monitor.c src/nf-queue.c src/nl-addr-add.c src/nl-addr-delete.c src/nl-addr-list.c src/nl-class-add.c src/nl-class-delete.c src/nl-class-list.c src/nl-classid-lookup.c src/nl-cls-add.c src/nl-cls-delete.c src/nl-cls-list.c src/nl-fib-lookup.c src/nl-link-enslave.c src/nl-link-ifindex2name.c src/nl-link-list.c src/nl-link-name2ifindex.c src/nl-link-release.c src/nl-link-set.c src/nl-link-stats.c src/nl-list-caches.c src/nl-list-sockets.c src/nl-monitor.c src/nl-neigh-add.c src/nl-neigh-delete.c src/nl-neigh-list.c src/nl-neightbl-list.c src/nl-pktloc-lookup.c src/nl-qdisc-add.c src/nl-qdisc-delete.c src/nl-qdisc-list.c src/nl-route-add.c src/nl-route-delete.c src/nl-route-get.c src/nl-route-list.c src/nl-rule-list.c src/nl-tctree-list.c src/nl-util-addr.c ) sed '1s#^#/* SPDX-License-Identifier: LGPL-2.1-only */\n#' "${FILES[@]}" -i
* Add support for label stack in nl-route commandsDavid Ahern2017-08-181-2/+16
| | | | | | | | | 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>
* all: avoid compiler warnings -Wimplicit-fallthroughThomas Haller2017-06-151-0/+1
|
* build: allow building cli without dynamic librarires supportThomas Haller2017-05-121-4/+19
| | | | | | | | | | | | | | Commit 3cb28534d34392ceec4adead0cfa97039796ccb7 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
* lib: escape usage of strerror_l() if it doesn't exist in libcAlexey Brodkin2017-03-121-0/+6
| | | | | | | | | | | | | | | | 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: 6c2d111177e91184073c44f83d4a6182aaba06d7 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>
* build: merge src/lib/Makefile.am into top-level makefileThomas Haller2017-02-271-59/+0
|
* src: switch to using strerror_l() instead of strerror_r()André Draszik2016-08-251-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* build: move -rdynamic from CPPFLAGS to LDFLAGSTobias Klauser2016-03-311-2/+2
| | | | | | | | | | 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
* link/neigh: add flags option to link and neighbor cachesDavid Ahern2015-11-192-2/+32
| | | | | | | | | | | | | 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>
* build: fix path to cli linker version script for out-of-tree buildjfarrell2015-06-191-2/+2
| | | | https://github.com/thom311/libnl/pull/78
* build: add linker scripts for libnl-cli-3.so libraryThomas Haller2015-02-021-0/+6
| | | | | | | libnl-cli-3.so was unversioned previously. This is an ABI change (but backward compatible). Signed-off-by: Thomas Haller <thaller@redhat.com>
* build: move copy of linux headers to private directoryThomas Haller2014-09-241-0/+1
| | | | | | | | | | | | | | | | | | | 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>
* build/trivial: prettify makefiles by wrapping long linesThomas Haller2014-09-241-1/+8
| | | | | Signed-off-by: Thomas Haller <thaller@redhat.com> Acked-by: Thomas Graf <tgraf@suug.ch>
* cli: Fix typo in error messageTobias Klauser2014-06-171-1/+1
| | | | | | | s/neighbout/neighbour/ Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* netfilter/ct: expand CT parameters that can be used in add/delete operationsRich Fought2014-04-141-0/+6
| | | | | | | | | | | | 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>
* build: separate compiler and linker flagsJan Engelhardt2013-11-271-4/+6
| | | | | | | | | -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>
* Use thread-safe strerror_r() instead of strerror()Thomas Graf2013-02-281-1/+2
| | | | | | | 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>
* Move private header files to <netlink-private/*>Thomas Graf2013-01-241-1/+1
| | | | | | | This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Source cleanup for upstreamRich Fought2012-10-191-29/+29
|
* Updated nfnetlink includes; removed ifdefs; added delete exp programRich Fought2012-10-161-3/+58
|
* BugfixesRich Fought2012-10-101-1/+0
|
* bugfixesRich Fought2012-10-091-0/+6
|
* Compile CLIRich Fought2012-10-092-23/+1
|
* Starting CLI workRich Fought2012-10-091-0/+127
|
* nl_cli_route_parse_table fixed typo in codeКоренберг Марк (дома)2012-08-281-1/+1
| | | | Bug introduced in 2bdcde7e8e8bb78b165f093f1a708134f417e557
* Fix types-related warnings based on clang diagnosticsКоренберг Марк2012-06-131-3/+11
| | | | | | | | | | | | | | | | | 1. Fix some places where unsigned value compared < 0 2. Fix obsolete %Z specifier to more portable %z 3. Some erroneous types substitution 4. nl_msec2str() - 64-bit msec is now properly used, Only safe changes. I mean int <--> uint32_t and signed/unsigned fixes. Some functinos require size_t argument instead of int, but changes of signatures of that functions is terrible thing. Also, I do not pretend for a full list of fixes. Just to shut up clang -Wall -Wextra One more thing. ifindex. I don't change that because changes will be too big for simple fix.
* Switch to libtool versioning systemThomas Graf2011-09-131-7/+10
| | | | | | | | | | | | | | | | | | It has been a request that multiple libnl versions should be installabe in parallel. In order to achieve this, the basename of the library was changed to libnl-3 which reflects the 3rd generation of libnl APIs. It also means that release based library versioning is left behind and libtool versioning is used instead. Projects using pkgconfig will automatically link against the new library basename and will not notice a difference. The SO versioning is based on the glib model: current := 100 * minor + micro - revision revision := revision age := age (number of backwards compatible versions)
* Make some functions and global variables staticPavel Roskin2011-08-111-1/+1
|
* 3.1 releaseThomas Graf2011-08-111-2/+0
|
* fix module parent referencesThomas Graf2011-03-211-1/+1
|
* Unified TC APIThomas Graf2011-03-214-166/+82
| | | | | | | | Finally got rid of all the qdisc/class/cls code duplication in the tc module API. The API takes care of allocation/freeing the tc object specific data. I hope I got it right this time.
* Extend rtnl_link_alloc_cache() to support address familiesThomas Graf2010-11-111-1/+20
| | | | | | | Adds a family argument which allows to request link dumps for a certain address family. This allows to f.e. dump ipv6 specific statistics and data. nl-link-list --family inet6
* link: Support IFLA_IFALIAS attributeThomas Graf2010-11-111-1/+12
| | | | | | | | - parse IFLA_IFALIAS if available - provides API to access/change ifalias rtnl_link_get_ifalias(link) rtnl_link_set_ifalias(link, alias) - extends nl-link-set to test functionality
* classid auto generation if provided tc name does not existThomas Graf2010-11-011-5/+12
| | | | | | | | | | | | | | | | Manually editing etc/libnl/classid before adding tc objects is a pain. This patch adds code to attempt auto generating a unique tc id which will then be assigned to the provided name and added to the classid file. This will make the following commands work with prior definitions of the names "top" and "test" sudo sbin/nl-qdisc-add --dev eth0 --parent root --id top htb sudo sbin/nl-class-add --dev eth0 --parent top --id test htb --rate 100mbit It will generate the following ids automatically: 4001: top 4001:1 test
* Tons of ematch workThomas Graf2010-10-281-0/+17
| | | | | | | | | | - Fixes a bunch of bugs related to ematches - Adds support for the nbyte ematch - Adds a bison/flex parser for ematch expressions, expressions may look like this: ip.length > 256 && pattern(ip6.src = 3ffe::/16) documenation on syntax follows - adds ematch support to the basic classifier (--ematch EXPR)
* nl-cls-* toolsThomas Graf2010-10-262-1/+117
| | | | cli based tools to add/update/list/delete classifiers
* Unified TC attributes interfaceThomas Graf2010-10-264-69/+84
| | | | | | | | | | | | | | | | | | | | | | | | So far all common tc atttributes were accessed via specific functions, i.e. rtnl_class_set_parent(), rtnl_qdisc_set_parent(), rtnl_cls_set_parent() which implied a lot of code duplication. Since all tc objects are derived from struct rtnl_tc and these common attributes are already stored in there this patch removes all type specific functions and makes rtnl_tc_* attribute functions public. rtnl_qdisc_set_parent(qdisc, 10); becomes: rtnl_tc_set_parent((struct rtnl_tc *) qdisc, 10); This patch also adds the following new attributes to tc objects therefore removing them as tc specific attributes: - mtu - mpu - overhead This allows for the rate table calculations to be unified as well taking into account the new kernel behavior to take care of overhead automatically.
* nl-class-delete toolThomas Graf2010-10-201-0/+14
| | | | Tool based on nl-qdisc-delete to delete traffic classes.