summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* libnl-3.9.0 releaselibnl3_9_0Thomas Haller2023-12-041-1/+1
|
* lib: remove unused assignment in nl_addr_parse()Thomas Haller2023-12-041-2/+0
| | | | | | | | | | | | Coverity warns about this. Avoid it. Error: CLANG_WARNING: [#def3] libnl-3.8.0/lib/addr.c:324:3: warning[deadcode.DeadStores]: Value stored to 'len' is never read # 322| !strcasecmp(str, "any")) { # 323| # 324|-> len = 0; # 325| # 326| switch (hint) {
* route/tc: avoid integer overflow in rtnl_tc_calc_cell_log()Thomas Haller2023-12-041-2/+2
| | | | | | | | | | | | Coverity doesn't like this. Workaround. Error: CPPCHECK_WARNING (CWE-190): [#def97] libnl-3.8.0/lib/route/tc.c:681: error[integerOverflow]: Signed integer overflow for expression '1<<i'. # 679| # 680| for (i = 0; i < 32; i++) # 681|-> if ((1 << i) == cell_size) # 682| return i; # 683|
* xfrm: return -NLE_MISSING_ATTR from xfrmnl_sa_get_auth_params()Thomas Haller2023-12-041-13/+10
| | | | | | Don't return -1, that is not an error code. Also, return early from function.
* xfrm: fix leaking usertemplate in xfrmnl_sp_parse()Thomas Haller2023-12-041-2/+2
| | | | 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|
* 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.
* route/cls: add get/take wrappers for rtnl_act_append()Thomas Haller2023-12-015-21/+14
| | | | | | | | | | | | 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
|
* 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')
* route/can: implement can_device_statsJob Feikens2023-12-011-5/+54
| | | | | | | 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
* xfrm: refactor error handling in XFRM parsingThomas Haller2023-11-293-140/+70
| | | | Use cleanup attribute and return-early.
* 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')
* 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-301-0/+70
| | | | | | | [thaller@redhat.com: fixed wrong variable name in code and reworded commit message.] https://github.com/thom311/libnl/pull/363
* libnl-3.8.0 releaselibnl3_8_0Thomas Haller2023-08-291-1/+1
|
* lib/xfrm: use thread-safe gmtime_r() instead of gmtime()Thomas Haller2023-08-183-6/+9
|
* lib: use getprotobyname_r(), getprotobynumber_r() if availableThomas Haller2023-08-181-8/+59
| | | | Avoid non-threadsafe libc API.
* lib: fix error handling in nl_str2ip_proto()Thomas Haller2023-08-181-1/+1
|
* clang-format: reformat files with new formatThomas Haller2023-08-173-25/+25
| | | | $ ./tools/clang-format.sh
* include: use <linux/$file> instead of <linux-private/linux/$file>Thomas Haller2023-08-0854-64/+64
| | | | | | 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/linux: update all linux headersThomas Haller2023-08-081-2/+3
| | | | Taken from v6.4 (6995e2de6891c724bfeb2db33d7b87775f913ad1).
* all: drop "extern "C"" from internal codeThomas Haller2023-08-073-24/+0
| | | | | libnl3 itself needs to be build with a C compiler. Drop the unnecessary "extern "C"" parts from internal code.
* include: don't explicitly include headers from "nl-default.h"Thomas Haller2023-08-038-13/+0
|
* include: include private linux headers with explicit pathThomas Haller2023-08-0352-63/+68
| | | | | | | 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".
* include: drop "netlink-private/netlink.h" and move declarationsThomas Haller2023-08-02136-253/+179
|
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-02141-189/+571
|
* include: add "nl-default.h" headerThomas Haller2023-08-021-1/+1
| | | | | | | | | | | | | 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-1/+1
| | | | | | | 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: split and drop "netlink-private/types.h"Thomas Haller2023-08-02111-37/+1491
| | | | | Move all the declarations from "netlink-private/types.h" to places closer to where they are used.
* 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.
* include: rename "nl-intern-route" to "nl-priv-static-route"Thomas Haller2023-08-021-1/+1
| | | | | Naming is just so important to understand what this is. This name is better.
* genl: rename private header "nl-priv-genl.h" to "nl-genl.h"Thomas Haller2023-08-025-4/+4
| | | | | | The filename is still unique (which is the important part). Otherwise, the "priv" is redundant, since the header being inside "lib/genl" is clearly private.
* route/tc: avoid unalinged access in rtnl_tc_msg_parse()Thomas Haller2023-08-021-14/+15
|
* add support for TC action statisticsDavide Caratti2023-08-021-0/+46
| | | | | | | | https://github.com/thom311/libnl/issues/343 Signed-off-by: Davide Caratti <dcaratti@redhat.com> https://github.com/thom311/libnl/pull/346
* route: move "include/netlink-private/route/link/sriov.h" to ↵Thomas Haller2023-08-013-2/+30
| | | | lib/route/link-sriov.h
* lib: move "include/netlink-private/socket.h" to lib/nl-core.hThomas Haller2023-08-013-2/+21
|
* route: move "include/netlink-private/route/nexthop-encap.h" to lib/routeThomas Haller2023-08-015-4/+42
|
* route: merge "include/netlink-private/tc.h" to lib/route/tc-api.hThomas Haller2023-08-0144-45/+33
| | | | | It's a private header only for lib/route (libnl-route-3). We already have a similar header. Move the content to "lib/route/tc-api.h".
* route: move rtnl_tc_build_rate_table() to "tc-api.h"Thomas Haller2023-08-011-0/+4
| | | | | | This symbols is (wronly) exposed on the ABI of libnl-route-3. Move the declaration to "tc-api.h", where there are similar symbols of this kind.
* route: move "include/netlink-private/route/tc-api.h" to lib/routeThomas Haller2023-08-0133-32/+121
| | | | | | | | This header is entirely private to lib/route (libnl-route-3). Move the header there, it should not be used by anybody else. Note that libnl-route-3 exports symbols from this private header. That is ugly, make that clearer by adding comments.
* include: move "include/netlink-private/route/link/api.h" to lib/routeThomas Haller2023-07-3130-29/+251
| | | | | This header is entirely private to compiling libnl-route-3 under lib/route. Move the header there.