summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* xfrm: fix leaking usertemplate in xfrmnl_sp_parse()Thomas Haller2023-12-042-2/+9
| | | | Fixes: 49c20efaa783 ('xfrm: fix crashes in case of ENOMEM')
* socket: workaround coverity warning about time_t handlingThomas Haller2023-12-041-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | Coverity really wants to warn if a time_t is cast to 32 bits. We use time() here to get (some very bad) randomness. The loss of the upper bits is the least of the problems. Work around the coverity warning by also the higher bits. Error: Y2K38_SAFETY (CWE-197): [#def12] libnl-3.8.0/lib/socket.c:76: store_truncates_time_t: A "time_t" value is stored in an integer with too few bits to accommodate it. The expression "time(NULL)" is cast to "uint32_t". # 74| # 75| if (idx_state == 0) { # 76|-> uint32_t t = (uint32_t) time(NULL); # 77| # 78| /* from time to time (on average each 2^15 calls), the idx_state will Error: Y2K38_SAFETY (CWE-197): [#def13] libnl-3.8.0/lib/socket.c:193: store_truncates_time_t: A "time_t" value is stored in an integer with too few bits to accommodate it. The expression "time(NULL)" is cast to "unsigned int". # 191| sk->s_local.nl_family = AF_NETLINK; # 192| sk->s_peer.nl_family = AF_NETLINK; # 193|-> sk->s_seq_next = (unsigned int) time(NULL); # 194| sk->s_seq_expect = sk->s_seq_next; # 195|
* github: update Fedora image and version for clang-formatThomas Haller2023-12-041-1/+1
| | | | | Update the Fedora container for github. In particular, this updates the used version of clang-format for formatting the C sources.
* clang-format: rework container scriptThomas Haller2023-12-022-31/+31
| | | | Build a container image for the code formatting, and run that.
* lib: fix signed overflow warning in nl_object_diff()Thomas Haller2023-12-011-1/+1
| | | | Coverity warns "Signed integer overflow for expression '1<<31'".
* socket: explicitly cast time() to uint32_tThomas Haller2023-12-011-2/+3
| | | | | | Coverity warns about this. Try to avoid the warning by casting. We only use time() to get some (very little) entropy. The cast is fine.
* src: fix leak in "nl-cls-add"Thomas Haller2023-12-011-1/+1
| | | | Not important, but coverity flags this. Avoid it.
* route/cls: add get/take wrappers for rtnl_act_append()Thomas Haller2023-12-016-24/+40
| | | | | | | | | | | | rtnl_act_append() either takes ownership of the argument, or does nothing (on error). This pattern is hard to get right. In the past, there were various bugs at this place. Add two wrappers _rtnl_act_append_get() and _rtnl_act_append_take() which consistently don't take ownership of the pointer or take it. Also, in functions like rtnl_flower_append_action() only set the mask after successfully modifying the data.
* route/cls: fix leak in error handling of rtnl_flower_append_action()Thomas Haller2023-12-011-1/+5
| | | | | | Using rtnl_act_append() correctly is hard. Fixes: ef46de143206 ('route/cls: add flower classifier')
* route: fix just introduced use-after-free in rtnl_act_parse()Thomas Haller2023-12-011-0/+2
| | | | Fixes: 105a6be10a5f ('route: use cleanup macro in rtnl_act_parse()')
* route: use cleanup macro in rtnl_act_parse()Thomas Haller2023-12-011-28/+19
|
* nl-aux-route: add cleanup macro for rtnl_act_put_all()Thomas Haller2023-12-011-0/+5
|
* base: add _NL_AUTO_DEFINE_FCN_INDIRECT0() macroThomas Haller2023-12-011-0/+8
| | | | | | | This is useful for a very special case. For a cleanup macro that calls rtnl_act_put_all(). In that case, we have a auto variable `struct rtnl_act *head`, but the cleanup function expects as argument `&head`.
* route: fix memleak in rtnl_act_parse()Thomas Haller2023-12-011-1/+1
| | | | | | | | | | | | | | | | | | | Coverity warns: Error: RESOURCE_LEAK (CWE-772): [#def2] libnl-3.8.0/lib/route/act.c:421: alloc_fn: Storage is returned from allocation function "rtnl_act_alloc". libnl-3.8.0/lib/route/act.c:421: var_assign: Assigning: "act" = storage returned from "rtnl_act_alloc()". libnl-3.8.0/lib/route/act.c:426: var_assign: Assigning: "tc" = "act". libnl-3.8.0/lib/route/act.c:438: noescape: Resource "tc" is not freed or pointed-to in "rtnl_tc_set_kind". libnl-3.8.0/lib/route/act.c:455: leaked_storage: Variable "tc" going out of scope leaks the storage it points to. libnl-3.8.0/lib/route/act.c:455: leaked_storage: Variable "act" going out of scope leaks the storage it points to. # 453| tc_act_stats_policy); # 454| if (err < 0) # 455|-> return err; # 456| # 457| if (tb3[TCA_STATS_BASIC]) { Fixes: 05bd6366387c ('add support for TC action statistics')
* base: don't use static array indices for buffer argument of _nl_inet_ntop()Thomas Haller2023-12-011-2/+1
| | | | | | | | | | | | Seems the static array indices can confuse coverity. I think coverity is wrong here, regardless, change it. libnl-3.8.0/include/base/nl-base-utils.h:683: overrun-buffer-arg: Overrunning buffer pointed to by "buf" of 16 bytes by passing it to a function which accesses it at byte offset 45 using argument "(addr_family == 2) ? 16 : 46" (which evaluates to 46). # 681| * and a suitably large buffer, it cannot. Assert for that. */ # 682| # 683|-> r = (char *)inet_ntop(addr_family, addr, buf, # 684| (addr_family == AF_INET) ? INET_ADDRSTRLEN : # 685| INET6_ADDRSTRLEN);
* route/can: implement can_device_statsJob Feikens2023-12-013-5/+58
| | | | | | | Adds the rtnl_link_can_get_device_stats function to get xstats of a CAN-bus link as a can_device_stats struct. https://github.com/thom311/libnl/pull/368
* github: build with "-fexceptions" CFLAGSThomas Haller2023-11-291-3/+3
| | | | | | | | | | | This seems good for our test builds. This can result in additional uninitialized variable warnings about autovariables with cleanup attribute. This flag is also enabled by default on Fedora package build ([1]). [1] https://src.fedoraproject.org/rpms/redhat-rpm-config//blob/rawhide/f/buildflags.md
* xfrm: erge branch 'th/xfrm-addr-cleanup'Thomas Haller2023-11-298-164/+155
|\ | | | | | | https://github.com/thom311/libnl/pull/367
| * xfrm: refactor error handling in XFRM parsingThomas Haller2023-11-293-140/+70
| | | | | | | | Use cleanup attribute and return-early.
| * include: add "nl-aux-xfrm" helpersThomas Haller2023-11-293-0/+45
| |
| * xfrm: fix crashes in case of ENOMEMThomas Haller2023-11-293-14/+51
| |
| * xfrm: refactor nl_addr_build() calls in XFRM codeThomas Haller2023-11-292-46/+12
| | | | | | | | Use _nl_addr_build() helper. No need for all this redundant code.
| * xfrm: use cleanup attribute for nl_addr in XFRM parsingThomas Haller2023-11-292-37/+31
| |
| * xfrm: fix error code for NLE_ENOMEM in xfrmnl_ae_parse()Thomas Haller2023-11-291-1/+1
| | | | | | | | | | | | | | These internal error codes are probably a bad idea. However, at least be consistent about it. Fixes: 77bbf2270ce7 ('xfrm: fix an unintialized return value on memory allocation error in xfrmnl_ae_parse()')
| * xfrm: fix parsing address in xfrmnl_ae_parse()Thomas Haller2023-11-291-2/+3
| | | | | | | | | | | | | | Passing a size of (sizeof (ae_id->saddr)) is wrong for IPv4. The size depends on the address family. Fixes: 917154470895 ('xfrm: add xfrm support')
| * nl-aux-core: add _nl_addr_build() helperThomas Haller2023-11-291-0/+7
| |
| * nl-base-utils: add _nl_addr_family_to_size() helperThomas Haller2023-11-291-0/+11
|/
* xfrm: merge branch 'spellingmistake:main'Thomas Haller2023-11-271-0/+10
|\ | | | | | | https://github.com/thom311/libnl/pull/366
| * xfrm: clear XFRM_SP_ATTR_TMPL when removing the last template from a policyThomas Egerer2023-11-271-0/+2
| | | | | | | | | | | | | | | | Leaving XFRM_SP_ATTR_TMPL active in the mask may not impose a problem but, when removing the last template from a policy, the value signifying attached templates should be cleared. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
| * xfrm/sp: fix reference counters of sa selector/tmpl addressesThomas Egerer2023-11-271-0/+8
|/ | | | | | | | | | | | | | It's a similar issue as in commit 3f4f1dda, when calling xfrmnl_sp_parse, the refcount of the addresses for selectors and templates increases to two, as xfrmnl_sel_set_[s|d]addr and xfrmnl_user_tmpl_set_[s|d]addr add another reference to the address object. As only one of those refs is dropped in sel_destroy or xfrmnl_user_tmpl_free respectively the address objects' refcount will never drop to zero, causing a leak. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Fixes: 917154470895 ('xfrm: add xfrm support')
* route/link: add bonding interface options set rtnl apisLokesh Dhoundiyal2023-10-303-0/+80
| | | | | | | [thaller@redhat.com: fixed wrong variable name in code and reworded commit message.] https://github.com/thom311/libnl/pull/363
* build: fix declaring special targets as ".PHONY"Thomas Haller2023-08-311-2/+6
|
* Makefile.am: avoid use of non-portable echo argumentsmainSam James2023-08-311-1/+1
| | | | | | | | | | | This fixes tests with a non-bash shell as /bin/sh (in this case, dash) which does not support `echo -e`. echo itself is portable, but not echo with any arguments. Use `printf` instead. Fixes: d9a1e0ce9c95 ('build: add "check-local-build-headers" test target to build public headers') https://github.com/thom311/libnl/pull/360
* python: Use correct decorator syntax in HTBQdiscDavid Ward2023-08-301-1/+1
| | | | | | Fixes: 87d370912ca8 ("netlink.nlattr re-implemented in more pythonic way") https://github.com/thom311/libnl/pull/359
* libnl-3.8.0 releaselibnl3_8_0Thomas Haller2023-08-294-3/+9
|
* build: merge branch 'th/configure-fixes'Thomas Haller2023-08-292-27/+14
|\
| * build: replace old "NOTE" in configure output and add summaryth/tmpThomas Haller2023-08-291-23/+10
| | | | | | | | | | | | | | The NOTE refers to an ancient libnl3 version. It is not relevant anymore. Drop it. Instead, print some summary overview from the configuration.
| * build: avoid aclocal warning about missing "m4" directoryThomas Haller2023-08-291-1/+1
| | | | | | | | | | | | | | | | | | We get this warning: aclocal: warning: couldn't open directory 'm4': No such file or directory Avoid it, by letting "doc/configure.ac" use the top-level m4 directory too.
| * build: run `autoupdate` for AM_PROG_LIBTOOLThomas Haller2023-08-291-2/+2
| | | | | | | | | | configure.ac:67: warning: The macro `AM_PROG_LIBTOOL' is obsolete. configure.ac:67: You should run autoupdate.
| * build: add "-Wno-portability" to AC_INIT_AUTOMAKE()Thomas Haller2023-08-291-1/+1
|/ | | | | | | | | | | | | | | | | | | Silence warnings with "-Wno-portability". Makefile.am:1130: warning: '%'-style pattern rules are a GNU make extension Makefile.am:1131: warning: dir $@: non-POSIX variable name Makefile.am:1131: (probably a GNU make extension) Makefile.am:1134: warning: '%'-style pattern rules are a GNU make extension Makefile.am:1137: warning: patsubst %,%.build-headers-test.o,$(public_headers: non-POSIX variable name Makefile.am:1137: (probably a GNU make extension) We care about portability, but only to the extend that we test configurations via CI. As all our current CI passes, the warning is bogus and not something we will fix. If you come up in a situation where this is a problem, then we have a real scenario at hand and something to fix. Unless that happens, we target a real implementation and not the make specification.
* license: merge branch 'th/fix-gpl-license'Thomas Haller2023-08-214-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the license for a few files from GPL-2.0-only to LGPL-2.1-only. All relevant contributions seems to have been made by Thomas Graf. I presume, this was just a mistake in the license header, as the project as a whole is LGPL licensed. Thomas as working for Red Hat at the time, maybe the copyright for the code is with Red Hat. In any case, the wrong licensing needs to be fixed. If there are any objections to this, the offending code needs to be removed. Please reach out in that case. https://github.com/thom311/libnl/pull/357
| * license: fix/adjust license for "src/nl-cls-add.c"Thomas Haller2023-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit ef858fb492df ('- Reworked the classifier interface. - Added initial ematch support - Added support for the basic classifier - Added support for the cgroup classifier'), the license headers were added as GPL-2.0-only. That is in conflict with the licences of the project and a problem. We would either have to delete the code, or "change" the license. The file only had (relevant) contributions by Thomas Graf. There are some trivial modifications by myself (Thomas Haller), and I agree with this change. There is also a small change by another contributor, which does seem trivial enough to not prevent changing the license: - 4ff512b05456 [Cong Wang] ('correct --protocol option for nl-cls-* utilities') - c52087601198 [Peter Wu] ('trivial: whitespace-only fixes for src and lib') - cee0b1b50c2e [Yegor Yefremov] ('Add SPDX identifiers') See `gitk src/nl-cls-add.c`.
| * license: fix/adjust license for "src/nl-addr-{add,delete,list}.c"Thomas Haller2023-08-213-3/+3
|/ | | | | | | | | | | | | | | | | | | In commit 5e732ad075e5 ('New set of address management tools'), the license headers were added/changed as GPL-2.0-only. That is in conflict with the licences of the project and a problem. We would either have to delete the code, or "change" the license. The files only had (relevant) contributions by Thomas Graf. There are some trivial modifications by myself (Thomas Haller), and I agree with this change. There are also small changes by another contributors, which seem trivial enough to not prevent changing the license: - 7701c8572fa4 [Pavel Roskin] ('Make some functions and global variables static') - c52087601198 [Peter Wu] ('trivial: whitespace-only fixes for src and lib') - cee0b1b50c2e [Yegor Yefremov] ('Add SPDX identifiers') See `gitk src/nl-addr-{add,delete,list}.c`.
* all: merge 'th/avoid-mt-unsafe-libc'Thomas Haller2023-08-189-23/+89
|\
| * tests: use thread-safe localtime_r() instead of localtime()Thomas Haller2023-08-181-1/+2
| |
| * lib/xfrm: use thread-safe gmtime_r() instead of gmtime()Thomas Haller2023-08-183-6/+9
| |
| * tests: avoid srandom()/random() in favor of _nltst_rand_u32()Thomas Haller2023-08-181-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | srandom() and random() are a code smell, because they are not thread safe. Avoid its usage, even if this was only for testing. Even in testing code, we don't want to find those functions and have to reason why they are fine for testing. Just don't. Arguably, _nltst_rand_u32() calls jrand48(), which (in glibc) is possibly not thread-safe either. But that is only one place for investigation, instead of 3. Also, _nltst_rand_u32() honors NLTST_SEED_RAND to generate a reproducible sequence of random numbers.
| * lib: use getprotobyname_r(), getprotobynumber_r() if availableThomas Haller2023-08-183-8/+67
| | | | | | | | Avoid non-threadsafe libc API.
| * lib: fix error handling in nl_str2ip_proto()Thomas Haller2023-08-182-3/+3
| |
| * tests: check nl_str2ip_proto()Thomas Haller2023-08-181-0/+9
|/