project/libnl-tiny.git
2 years agonetlink: add NLA_F_NESTED to all nested attributes
Felix Fietkau [Tue, 17 May 2022 18:15:57 +0000 (20:15 +0200)]
netlink: add NLA_F_NESTED to all nested attributes

Newer generic netlink APIs (e.g. wireguard) require this to be able to parse
nested attributes

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agoattr.h: Add NLA_PUT_S32
Hauke Mehrtens [Sat, 20 Nov 2021 23:08:55 +0000 (00:08 +0100)]
attr.h: Add NLA_PUT_S32

This function is used by iw 5.16.

These new headers were copied from the mainline libnl.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years agounl: add support for connecting to rtnl
Felix Fietkau [Wed, 5 Aug 2020 15:11:50 +0000 (17:11 +0200)]
unl: add support for connecting to rtnl

The API is almost the same and some unl_genl_* functions are renamed to unl_*
with compat #define in place
The only thing different between genl and rtnl is the init function and the
function for allocating a message

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agolibnl-tiny: install pkgconfig file
Rosen Penev [Mon, 10 Feb 2020 05:21:09 +0000 (21:21 -0800)]
libnl-tiny: install pkgconfig file

This will allow getting rid of InstallDev in the Makefile.

It also allows compilation with CMAKE_BINARY_SUBDIR.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
5 years agoremove never used err variable assignment disliked by scan-build
Petr Štetiar [Tue, 29 Oct 2019 20:27:39 +0000 (21:27 +0100)]
remove never used err variable assignment disliked by scan-build

scan-build from clang version 9 complains about following:

 nl.c:648:3: warning: Value stored to 'err' is never read
                err = 0;
                ^     ~

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agosilence use after the free clang analyzer warning
Petr Štetiar [Tue, 29 Oct 2019 20:11:38 +0000 (21:11 +0100)]
silence use after the free clang analyzer warning

scan-build from clang version 9 complains about following:

 nl.c:507:9: warning: Use of memory after it is freed
        while (nlmsg_ok(hdr, n)) {
               ^~~~~~~~~~~~~~~~

which seems to be impossible codepath as clang analyzer doesn't somehow
account properly nl_syserr2nlerr(errno) return value:

 } else {
    free(msg.msg_control);
    free(*buf);
    return -nl_syserr2nlerr(errno);
 }

which should be always < 0, but analyzer is still checking for > 0 code
path as well for some reason. So in order to make the analyzer happy,
set the buf pointer to NULL explicitly and add assert to make it clear,
that this codepath should never happen.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agouse offsetof macro to make scan-build happy
Petr Štetiar [Tue, 29 Oct 2019 05:40:57 +0000 (06:40 +0100)]
use offsetof macro to make scan-build happy

scan-build from clang version 9 complains about following:

 cache.c:106:2: warning: Dereference of null pointer
        nl_list_for_each_entry_safe(obj, tmp, &cache->c_items, ce_list)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 include/netlink/list.h:83:20: note: expanded from macro 'nl_list_for_each_entry_safe'
             pos = n, n = nl_list_entry(n->member.next, typeof(*n), member))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 include/netlink/list.h:60:2: note: expanded from macro 'nl_list_entry'
        nl_container_of(ptr, type, member)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 include/netlink/list.h:56:55: note: expanded from macro 'nl_container_of'
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
                                                      ^~~~~

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agoadd initial GitLab CI support
Petr Štetiar [Fri, 4 Oct 2019 15:00:59 +0000 (17:00 +0200)]
add initial GitLab CI support

Uses currently proof-of-concept openwrt-ci[1] in order to:

 * improve the quality of the codebase in various areas
 * decrease code review time and help merging contributions faster
 * get automagic feedback loop on various platforms and tools
   - out of tree build with OpenWrt SDK on following targets:
     * ath79-generic
     * imx6-generic
     * malta-be
     * mvebu-cortexa53
   - out of tree native build on x86/64 with GCC (versions 7, 8, 9) and Clang 9
   - out of tree native x86/64 static code analysis with cppcheck and
     scan-build from Clang 9

1. https://gitlab.com/ynezz/openwrt-ci/

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agoiron out all extra compiler warnings
Petr Štetiar [Fri, 4 Oct 2019 14:56:12 +0000 (16:56 +0200)]
iron out all extra compiler warnings

gcc 9.1 on x86/64 has reported following:

 attr.c:403:19: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
 genl.c:154:24: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
 genl_mngt.c:157:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
 msg.c:190:20: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
 msg.c:192:18: error: comparison of integer expressions of different signedness: ‘__u32’ {aka ‘const unsigned int’} and ‘int’ [-Werror=sign-compare]
 msg.c:361:10: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
 nl.c:428:18: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
 nl.c:602:23: error: comparison of integer expressions of different signedness: ‘__u32’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agocmake: enable extra compiler checks
Petr Štetiar [Fri, 4 Oct 2019 14:43:05 +0000 (16:43 +0200)]
cmake: enable extra compiler checks

Let's enforce additional automatic checks enforced by the compiler in
order to catch possible errors during compilation.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agoconvert into CMake project
Petr Štetiar [Fri, 4 Oct 2019 14:06:01 +0000 (16:06 +0200)]
convert into CMake project

Aligning it with other C based projects.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years agorefactor into separate Git project
Petr Štetiar [Fri, 4 Oct 2019 13:47:25 +0000 (15:47 +0200)]
refactor into separate Git project

For improved reusability, testing etc.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
7 years agolibnl-tiny: use fixed message size instead of using the page size
Felix Fietkau [Thu, 9 Nov 2017 13:39:48 +0000 (14:39 +0100)]
libnl-tiny: use fixed message size instead of using the page size

Simplifies the code and reduces size

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agolibnl-tiny: define _GNU_SOURCE if not defined
Alexandru Ardelean [Mon, 19 Dec 2016 15:18:18 +0000 (17:18 +0200)]
libnl-tiny: define _GNU_SOURCE if not defined

If _GNU_SOURCE was added as part of a package's TARGET_CFLAGS,
then compilation would fail for that module (especially if
warnings get treated as errors).

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years agolibnl-tiny: Remove GENL_ID_GENERATE
Florian Fainelli [Wed, 23 Nov 2016 23:13:18 +0000 (15:13 -0800)]
libnl-tiny: Remove GENL_ID_GENERATE

This constant was always defined to 0, and recently got removed in
upstream commit a07ea4d9941af5a0c6f0be2a71b51ac9c083c5e5 ("genetlink: no
longer support using static family IDs")

Fixes libnl-tiny builds with latest upstream kernels.

Fixes: d723f2573af3 ("libnl-tiny: remove include/linux overrides to fix various build issues")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
8 years agolibnl-tiny: remove include/linux overrides to fix various build issues
Felix Fietkau [Mon, 14 Nov 2016 08:35:03 +0000 (09:35 +0100)]
libnl-tiny: remove include/linux overrides to fix various build issues

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agolibs/libnl-tiny: drop Build/Prepare rule in favor of default one
Alexandru Ardelean [Thu, 6 Oct 2016 06:14:34 +0000 (09:14 +0300)]
libs/libnl-tiny: drop Build/Prepare rule in favor of default one

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years agolibnl-tiny: Generic Netlink multicast groups support
Hauke Mehrtens [Wed, 29 Jun 2016 21:13:58 +0000 (23:13 +0200)]
libnl-tiny: Generic Netlink multicast groups support

This adds this commit from normal libnl to libnl-tiny:
https://github.com/tgraf/libnl/commit/2dbc1ca76c5b82c40749e609eb83877418abb006

commit 2dbc1ca76c5b82c40749e609eb83877418abb006
Author: dima <dima.ky@gmail.com>
Date:   Wed Oct 13 17:53:34 2010 +0300

    Generic Netlink multicast groups support

    I have a patch against commit d378220c96c3c8b6f27dca33e7d8ba03318f9c2d
    extending libnl with a facility to receive generic netlink messages sent
    to multicast groups.

    Essentially it add one new function genl_ctrl_resolve_grp which
    prototype looks like this
    int genl_ctrl_resolve_grp(struct nl_sock *sk, const char *family_name,
            const char *grp_name)
    It resolves  the family name and the group name to group id. Then
    the returned id can be used in nl_socket_add_membership to subscribe
    to multicast messages.

    Besides that it adds two more functions

    uint32_t nl_socket_get_peer_groups(struct nl_sock *sk)
    void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups)

    allowing to modify the socket peer groups field. So it's possible to
    multicast messages from the user space using the legacy interface.
    Looks like there is no way (or I was not able to find one?) to modify
    the netlink socket destination group from the user space, when the
    group id is greater then 32.

Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [cosmetic style fix]
8 years agotreewide: replace nbd@openwrt.org with nbd@nbd.name
Felix Fietkau [Tue, 7 Jun 2016 06:58:31 +0000 (08:58 +0200)]
treewide: replace nbd@openwrt.org with nbd@nbd.name

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agolibnl-tiny: backport 'gnet_stats_rate_est64' support
Hauke Mehrtens [Sun, 17 Apr 2016 12:53:11 +0000 (12:53 +0000)]
libnl-tiny: backport 'gnet_stats_rate_est64' support

This has been added to the kernel uapi for a while, and makes
sense to have it here too.
At the moment we're using it for query-ing qdisc via netlink
using libnl-tiny.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
SVN-Revision: 49188

9 years agolibnl-tiny: include <sys/socket.h>
Felix Fietkau [Wed, 11 Nov 2015 11:39:21 +0000 (11:39 +0000)]
libnl-tiny: include <sys/socket.h>

Currently some libnl headers require application code to include
dependencies on its own. E.g. a simple include of <linux/netlink.h>
will trigger an error:
/usr/include/libnl-tiny/linux/netlink.h:32:2: error: unknown type name 'sa_family_t'

Similarly including <netlink/handlers.h> causes:
/usr/include/libnl-tiny/netlink/handlers.h:133:19: warning: 'struct ucred' declared inside parameter list [enabled by default]

Fix it by including <sys/socket.h> where needed in libnl headers.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
SVN-Revision: 47456

9 years agolibnl-tiny: honor CFLAGS when linking
Steven Barth [Thu, 18 Jun 2015 08:13:04 +0000 (08:13 +0000)]
libnl-tiny: honor CFLAGS when linking

Signed-off-by: Steven Barth <steven@midlink.org>
SVN-Revision: 46029

9 years agolibnl-tiny: link library with -Bsymbolic-functions
Felix Fietkau [Sun, 19 Apr 2015 18:33:19 +0000 (18:33 +0000)]
libnl-tiny: link library with -Bsymbolic-functions

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 45510

10 years agolibnl-tiny: fix receiving netlink messages larger than 4K
Jonas Gorski [Thu, 11 Dec 2014 19:35:48 +0000 (19:35 +0000)]
libnl-tiny: fix receiving netlink messages larger than 4K

Apply libnl commit 807fddc4cd9ecb12ba64e1b7fa26d86b6c2f19b0 ("nl:
Increase receive buffer size to 4 pages") also to libnl-tiny to ensure
netlink messages larger than 4KiB can be received, as the restart logic
seems to be broken.

This fixes iwinfo accessing info on dual band b43 cards, as they can
support a lot of channels, breaking the 4K default limit (seen was >5k).

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
SVN-Revision: 43633

10 years agolibnl-tiny: remove dead code
Felix Fietkau [Wed, 10 Dec 2014 16:02:49 +0000 (16:02 +0000)]
libnl-tiny: remove dead code

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 43599

10 years agoAdd a few SPDX tags
Steven Barth [Sun, 2 Nov 2014 12:20:54 +0000 (12:20 +0000)]
Add a few SPDX tags

Signed-off-by: Steven Barth <steven@midlink.org>
SVN-Revision: 43151

10 years agolibnl-tiny: ensure compatibility to libnl version 3 and higher
Felix Fietkau [Fri, 21 Mar 2014 15:54:48 +0000 (15:54 +0000)]
libnl-tiny: ensure compatibility to libnl version 3 and higher

To be prepared to support keepalived 1.2.10 and higher we need libnl3 or
higher. The attached patch
add some defines so that it can be build be libnl-tiny.
Patch by Thomas Heil

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 39991

10 years agolibnl-tiny: fix include path to poll.h
Felix Fietkau [Mon, 24 Feb 2014 21:08:28 +0000 (21:08 +0000)]
libnl-tiny: fix include path to poll.h

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 39747

11 years agolibnl-tiny: add includedir to pkg-config cflags
Felix Fietkau [Sat, 22 Dec 2012 18:56:01 +0000 (18:56 +0000)]
libnl-tiny: add includedir to pkg-config cflags

SVN-Revision: 34864

12 years agolicensing: Add licensing metadata to many packages Two new variables are introduces...
Hamish Guthrie [Fri, 19 Oct 2012 15:34:28 +0000 (15:34 +0000)]
licensing: Add licensing metadata to many packages Two new variables are introduces to many packages, namely PKG_LICENSE and PKG_LICENSE_FILES - there may be more than one license applied to packages, and these are listed in the PKG_LICENSE variable and separated by spaces. All relevant license files are also added to the PKG_LICENSE_FILES variable, also space separated.

The licensing metadata is put into the bin/<platform>/packages/Packages file
for later parsing. A script for that is on it's way!

SVN-Revision: 33861

12 years agoadd myself as a maintainer for various packages
Felix Fietkau [Mon, 8 Oct 2012 11:41:02 +0000 (11:41 +0000)]
add myself as a maintainer for various packages

SVN-Revision: 33660

12 years agomove library packages to package/libs/
Felix Fietkau [Mon, 8 Oct 2012 11:24:12 +0000 (11:24 +0000)]
move library packages to package/libs/

SVN-Revision: 33657