51 Commits

Author SHA1 Message Date
George Sapkin
40493a655d formal: fix workflow permissions
Fix formality check permissions that are needed to post optional
summaries back to the PR.

Link: openwrt/actions-shared-workflows#64
Signed-off-by: George Sapkin <george@sapk.in>
Link: https://github.com/openwrt/libnl-tiny/pull/5
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-12-02 14:43:13 +01:00
Álvaro Fernández Rojas
567be11015 github: ci: add MIPS64, PowerPC64 and RISCV64
MIPS64, PowerPC64 and RISCV64 are popular OpenWrt archs.
Refactor the sizes build step to generate the table programatically.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-11-18 09:10:24 +01:00
Álvaro Fernández Rojas
2871f3f26a github: ci: add powerpc arch
PowerPC is another popular OpenWrt arch.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-11-14 15:09:27 +01:00
Álvaro Fernández Rojas
087d4ce8c0 github: ci: add cmake build and source directories
Add cmake build and source directories to suppress the following warning:
CMake Warning:
  No source or binary directory provided. Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-11-14 15:08:07 +01:00
Álvaro Fernández Rojas
532ac744de github: fix CI apt dependencies
We need to run 'apt update' before installing the APT packages.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-11-03 08:07:46 +01:00
Álvaro Fernández Rojas
c69fb5ef80 github: improve CI
- Remove unneeded CMAKE_SYSTEM_PROCESSOR.
- Add summary table with sizes (in bytes) for each arch/variant.
- Upload generated binaries as artifacts.
- Add OpenWrt formalities.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-10-20 07:55:47 +02:00
Álvaro Fernández Rojas
fa6a52b037 github: add CI build
Add Github CI supporting different architectures.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-10-12 22:09:00 +02:00
Christian Marangi
feca1d341d CMakeLists: update cmake minimum required version to 3.10
New cmake version 4.0 requires at least 3.5 version as the minimum
required version with it increased to 3.10 in to-be-released cmake
versions.

Set the minimum required version to 3.10 to future-proof for future
cmake version.

Suggested-by: Hannu Nyman <hannu.nyman@iki.fi>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2025-10-03 23:42:30 +02:00
Felix Fietkau
c0df580adb attr.c: fix nla_reserve size check
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-03-19 13:17:08 +01:00
Felix Fietkau
965c4bf496 socket: change debug callbacks to pass struct nl_msg
This allows checking the netlink protocol in the callback

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-12-05 12:52:43 +01:00
Felix Fietkau
785e11aee7 socket: call rx debug callback once per packet instead of per batch
When receiving a batch, split up calls

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-12-05 12:46:26 +01:00
Felix Fietkau
af57bb123f socket: add debug callbacks for rx/tx
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-12-04 20:20:45 +01:00
Jo-Philipp Wich
bc92a28018 build: allow passing SOVERSION value for dynamic library
In order to prepare for proper ABI handling in the OpenWrt package of
libnl-tiny, add an option to specify the library SOVERSION value when
invoking CMake.

Let the library SOVERSION default to `1` as first ABI version as the
library is stable and there's been no incompatible changes since it's
inception in 2009.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-07-27 11:59:13 +02:00
Hauke Mehrtens
d433990c00 Make struct nla_policy and struct nlattr const
Make the struct nla_policy and the struct nlattr const in many places
like it is done in full libnl. This brings our libnl-tiny closer to the
upstream version.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2023-07-01 12:03:05 +02:00
Nick Hainke
11b7c5f074 attr: add NLA_S* definitions
NLA_S8 is used by newer hostapd versions. Directly add all NLA_S*
definitions.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2023-04-02 02:19:37 +02:00
Jesus Fernandez Manzano
f5d9b7e4f5 libnl-tiny: fix duplicated branch in family.h
Duplicated branch in function genl_family_get_maxattr().
Detected by gcc with -Werror=duplicated-branches.

libnl-tiny/netlink/genl/family.h:118:5: error: this condition has
identical branches [-Werror=duplicated-branches]
  if (family->ce_mask & FAMILY_ATTR_MAXATTR)

Signed-off-by: Jesus Fernandez Manzano <jesus.manzano@galgus.net>
2023-01-06 19:55:57 +01:00
Joerg Vehlow
db3b2cdbca libnl-tiny: set SOCK_CLOEXEC if available
If CLOEXEC is not set on the netlink socket, restarting netifd using ubus
fails with "Failed to initialize system control", because the bind call
in nl_connect fails with EADDRINUSE, due to the inherited socket handle.

Also it does not make sense, to leak the handle to child processes.

See libnl3: ca0fc7558 ("socket: Set SOCK_CLOEXEC if available")

Signed-off-by: Joerg Vehlow <joerg.vehlow@aox.de>
2022-11-01 17:00:30 +01:00
Petr Štetiar
28c44ca97c genl_family: explicitly null terminate strncpy destination buffer
The strncpy() function doesn't null terminate the destination string if
the source string is at least as long as the destination. (This behavior
is defined by the C99 specification.) As a result, the destination
string must be null terminated after calling strncpy().

And clang11 static analyzer thus reports following:

 genl_family.c:148:2: error: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 15 [-Werror=stringop-truncation]
   148 |  strncpy(grp->name, name, GENL_NAMSIZ - 1);
       |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

References: https://gitlab.com/openwrt/project/libnl-tiny/-/jobs/2495301251#L197
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2022-05-23 21:02:38 +02:00
Felix Fietkau
c42d890625 build static library
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-05-23 19:56:27 +02:00
Felix Fietkau
b5b2ba09c4 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>
2022-05-17 20:15:59 +02:00
Hauke Mehrtens
8e0555fb39 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>
2021-12-14 22:11:05 +01:00
Felix Fietkau
c291088f63 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>
2020-08-05 17:45:17 +02:00
Rosen Penev
2584ebc642 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>
2020-07-11 13:42:34 +02:00
Petr Štetiar
0219008cc8 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>
2019-10-29 22:16:00 +01:00
Petr Štetiar
7ce813fcd6 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>
2019-10-29 22:16:00 +01:00
Petr Štetiar
1f73b6a8e6 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>
2019-10-29 22:16:00 +01:00
Petr Štetiar
0230d0698e 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>
2019-10-29 22:16:00 +01:00
Petr Štetiar
5e13b797a9 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>
2019-10-29 22:16:00 +01:00
Petr Štetiar
802fbd4d6f 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>
2019-10-29 22:16:00 +01:00
Petr Štetiar
050bb5c443 convert into CMake project
Aligning it with other C based projects.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-10-29 22:14:03 +01:00
Petr Štetiar
5b350e42d1 refactor into separate Git project
For improved reusability, testing etc.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-10-04 16:02:05 +02:00
Felix Fietkau
8ee5f3a402 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>
2017-11-16 12:54:15 +01:00
Alexandru Ardelean
c8de248db0 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>
2016-12-20 09:35:36 +01:00
Florian Fainelli
8b994b0bba 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>
2016-11-24 12:53:19 +01:00
Felix Fietkau
30bf9f3889 libnl-tiny: remove include/linux overrides to fix various build issues
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-11-17 13:36:09 +01:00
Alexandru Ardelean
bec5016ac4 libs/libnl-tiny: drop Build/Prepare rule in favor of default one
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-10-15 11:36:51 +02:00
Hauke Mehrtens
6700d2e02a libnl-tiny: Generic Netlink multicast groups support
This adds this commit from normal libnl to libnl-tiny:
2dbc1ca76c

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]
2016-07-02 10:12:04 +02:00
Felix Fietkau
c3aba2c1ff treewide: replace nbd@openwrt.org with nbd@nbd.name
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-06-07 08:58:42 +02:00
Hauke Mehrtens
bf7cab92bb 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
2016-04-17 12:53:11 +00:00
Felix Fietkau
95282adbcb 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
2015-11-11 11:39:21 +00:00
Steven Barth
50ae486cf4 libnl-tiny: honor CFLAGS when linking
Signed-off-by: Steven Barth <steven@midlink.org>

SVN-Revision: 46029
2015-06-18 08:13:04 +00:00
Felix Fietkau
2b68d0ba9a libnl-tiny: link library with -Bsymbolic-functions
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 45510
2015-04-19 18:33:19 +00:00
Jonas Gorski
92745c280a 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
2014-12-11 19:35:48 +00:00
Felix Fietkau
833b26660e libnl-tiny: remove dead code
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 43599
2014-12-10 16:02:49 +00:00
Steven Barth
c092f05a4c Add a few SPDX tags
Signed-off-by: Steven Barth <steven@midlink.org>

SVN-Revision: 43151
2014-11-02 12:20:54 +00:00
Felix Fietkau
11d52adecb 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
2014-03-21 15:54:48 +00:00
Felix Fietkau
b74e41338f libnl-tiny: fix include path to poll.h
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 39747
2014-02-24 21:08:28 +00:00
Felix Fietkau
f5b0d743dc libnl-tiny: add includedir to pkg-config cflags
SVN-Revision: 34864
2012-12-22 18:56:01 +00:00
Hamish Guthrie
5d835abe92 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
2012-10-19 15:34:28 +00:00
Felix Fietkau
e584fa1b7b add myself as a maintainer for various packages
SVN-Revision: 33660
2012-10-08 11:41:02 +00:00