summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * bridge: don't normalize the u8 argument in ↵Thomas Haller2022-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rtnl_link_bridge_set_vlan_filtering() to boolean In bridge-info, we have two u8 attributes (vlan-filtering and stats-enabled). In both cases, kernel only expects there a boolean value (either zero or one). In case of vlan-filtering, I think kernel actually doesn't care, and would treat any non-zero value as true. In case of stats-enabled, kernel would reject values outside the values zero or one. Previously, libnl3 would normalize the boolean value for vlan-filtering, but not for stats-enabled. That is at least inconsistent, in particular considering that kernel requires a normalized value for stats-enabled, but not for vlan-filtering. Our public API has uint8_t parameters (and not bool). That makes sense, as it follows the netlink API. It's not clear how to handle these boolean u8 attributes best. Should the API be bool or uint8_t? Should we normalize the boolean values? In any case, do something consistently. For no particular reason, choose to not add additional logic. The user can set any value, whether that value makes sense, it's up to them.
| * bridge: expose rtnl_link_bridge_get_vlan_protocol() in host byte orderThomas Haller2022-08-241-4/+7
| | | | | | | | | | On netlink, IFLA_BR_VLAN_PROTOCOL attribute is be16. In the libnl3 API, expose the number in native endianness.
| * bridge: fix parsing vlan-protocol in bridge_info_parse()Thomas Haller2022-08-241-1/+1
| |
| * bridge: minor cleanups in "bridge_info.c"Thomas Haller2022-08-241-8/+7
| |
| * bridge: use SPDX license identifiers in bridge_info filesThomas Haller2022-08-242-14/+2
| |
| * bridge: reformat bridge_info file with clang-formatThomas Haller2022-08-242-50/+54
| |
| * bridge: extend libnl with options needed for VLAN aware forwardingRobert Dabrowski2022-08-244-1/+238
| | | | | | | | | | | | Signed-off-by: Robert Dabrowski <rdabrowski@maxlinear.com> Co-Authored-By: Kacper Ludwinski <kludwinski@maxlinear.com>
| * bridge: Add support for link_info of a bridgeLanger, Thomas2022-08-242-0/+120
|/ | | | | | | | And functions to access some new bridge attributes. Signed-off-by: Langer Thomas <tlanger@maxlinear.com> Co-Authored-By: Kacper Ludwinski <kludwinski@maxlinear.com>
* route/vlan: drop unnecessary "else" in vlan_put_attrs()Thomas Haller2022-08-241-10/+8
|
* route/vlan: fix error handling in 'lib/route/link/vlan.c'Thomas Langer2022-08-241-3/+16
| | | | | | | | related to goto label nla_put_failure Signed-off-by: Langer Thomas <tlanger@maxlinear.com> Co-Authored-By: Kacper Ludwinski <kludwinski@maxlinear.com>
* build: add comments to linker version scripts about the version tagsThomas Haller2022-08-247-0/+42
|
* all: merge branch 'yogo1212:typo'Thomas Haller2022-08-248-13/+13
|\ | | | | | | https://github.com/thom311/libnl/pull/330
| * doc: fix typoThomas Haller2022-08-241-2/+2
| |
| * doc: fix typoLeon M. George2022-08-247-11/+11
|/
* route: merge branch 'bisdn:jogo_lib_attr_handle_default_routes'Thomas Haller2022-07-073-5/+28
|\ | | | | | | https://github.com/thom311/libnl/pull/320
| * attr: reject zero length addressesJonas Gorski2022-07-071-0/+3
| | | | | | | | | | | | | | A zero length address is not a valid address in netlink, so we should not try to send them to the kernel. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
| * route: construct all-zero addresses for default route destinationJonas Gorski2022-07-071-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A default route is equivalent to a 0.0.0.0/0 or ::/0 route, so we should construct the dst as such with a all-zero address. Since this breaks the assumption that a dst with a 0 address length is a default route, switch to checking the prefix length being 0, and make sure that there is an address part that is all-zero. This ensures we will print the actual dst in case the address is not zero, or does not exist. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
| * addr: allow constructing all-zero addressesJonas Gorski2022-07-061-1/+1
| | | | | | | | | | | | | | | | Allow easy contruction of all-zero addresses by not passing a buf to copy. Since the object is allocated with calloc, the address data will default to all-zero, and only the length needs to be set. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
| * addr: create an all-zero addresses when parsing "any" or "default"Jonas Gorski2022-07-061-1/+6
|/ | | | | | | | | | | | | When calling nl_addr_parse() is called with "any" or "default", the constructed address will have zero-length address data. This has the side effect that a comparison with e.g. an address contructed from "0.0.0.0/0" will fail, since their address has different lengths, even if they should be equal. Fix this by allocating an appropriate zeroed address for "any" and "default", but do not for "none", since "none" implies no address. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
* libnl-3.7.0 releaselibnl3_7_0Thomas Haller2022-07-064-2/+17
|
* route: act: Allow full set of actions on gact,skbedit,mirredVolodymyr Bendiuga2022-07-063-28/+3
| | | | | | Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.com> https://github.com/thom311/libnl/pull/319
* Use print() function in both Python 2 and Python 3Christian Clauss2022-07-069-48/+59
| | | | https://github.com/thom311/libnl/pull/327
* sriov: fix setting ce_mask when parsing VF stat counterkyolee2022-07-061-1/+1
| | | | | | https://github.com/thom311/libnl/pull/324 Fixes: 5d6e43ebef12 ('lib/route: SRIOV Parse and Read support')
* Fix typos and errorsAntonio Prcela2022-07-062-77/+75
| | | | https://github.com/thom311/libnl/pull/325
* changelog: update URL to git historyThomas Haller2022-07-061-1/+1
|
* changelog: fix typos in ChangeLogChristian Clauss2022-07-061-6/+6
| | | | https://github.com/thom311/libnl/pull/326
* route: format recently added code with clang-formatThomas Haller2022-05-273-15/+15
|
* route/act: add NAT actionMagnus Öberg2022-05-275-0/+363
| | | | | | | Signed-off-by: Magnus Öberg <magnus.oberg@westermo.se> Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@gmail.com> https://github.com/thom311/libnl/pull/317
* route: format recently added code with clang-formatThomas Haller2022-05-273-13/+17
|
* cls: flower: extend flower APIVolodymyr Bendiuga2022-05-274-0/+197
| | | | | | | | | | | | | The following API has been added: rtnl_flower_set_ipv4_src rtnl_flower_get_ipv4_src rtnl_flower_set_ipv4_dst rtnl_flower_get_ipv4_dst Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.com> https://github.com/thom311/libnl/pull/309
* flower: use correct attribute when filling out flagsVolodymyr Bendiuga2022-05-191-1/+1
| | | | | | | | Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.com> Fixes: ef46de143206 ('route/cls: add flower classifier') https://github.com/thom311/libnl/pull/316
* tests: merge branch 'th/test-link'Thomas Haller2022-05-0910-107/+1133
|\ | | | | | | https://github.com/thom311/libnl/pull/314
| * tests: add unit tests for creating linksThomas Haller2022-05-091-0/+213
| | | | | | | | | | | | Based-on-patch-by: Susant Sahani <susant@redhat.com> https://src.fedoraproject.org/rpms/libnl3/pull-request/4
| * github: run unit tests several times and directlyThomas Haller2022-05-091-1/+6
| | | | | | | | | | | | | | | | | | `make check` swallows the output, which is kinda important to debug a problem. I guess, I could print the log file, but it seems simpler to just run the test directly. While at it, run it a few times. It's fast enough, and with the randomization, it might actually hit a faulty code path.
| * github: export NLTST_SEED_RAND= to randomize unit testsThomas Haller2022-05-091-1/+5
| |
| * tests: add test utilsThomas Haller2022-05-094-6/+777
| |
| * tests: reformat unit test files with clang-formatThomas Haller2022-05-064-100/+108
| |
| * utils: add _NL_AUTO_DEFINE_FCN_STRUCT() macroThomas Haller2022-05-061-0/+8
| |
| * utils: add _nl_thread_local macroThomas Haller2022-05-061-0/+17
|/
* route: fix crash caused by parse_multipath() by wrong free()Thomas Haller2022-05-031-1/+1
| | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=2081279 Fixes: b50be8fa869b ('rtnl/route: use cleanup attribute in "lib/route/route_obj.c"')
* route/link: Set the cache ops when cloning a linkJacques de Laval2022-04-261-0/+3
| | | | | | | | | The cache ops needs to be included in a cloned link for link methods to work as expected. Signed-off-by: Jacques de Laval <Jacques.De.Laval@westermo.com> https://github.com/thom311/libnl/pull/311
* route/link: add lock around rtnl_link_af_ops_put()Thomas Haller2022-04-261-1/+4
|
* route/link: avoid accessing af_ops after af_free() in rtnl_link_set_family()Thomas Haller2022-04-261-3/+4
|
* xfrm/sa: fix reference counters of sa selector addressesNeil Horman2022-04-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | valgrind reported this memory leak to me in testing an application that I'm building: ==1807969== 24 bytes in 1 blocks are definitely lost in loss record 2 of 12 ==1807969== at 0x4849464: calloc (vg_replace_malloc.c:1328) ==1807969== by 0x160F2F: nl_addr_alloc (addr.c:184) ==1807969== by 0x160F2F: nl_addr_build (addr.c:215) ==1807969== by 0x15CEF1: xfrmnl_sa_parse (sa.c:693) ==1807969== by 0x18F95D: parse_sa (xfrm_monitor.c:82) ==1807969== by 0x18FC5A: parse_nlmsg (xfrm_monitor.c:170) ==1807969== by 0x18FC5A: xfrm_cb (xfrm_monitor.c:181) ==1807969== by 0x169D21: nl_cb_call (netlink.h:138) ==1807969== by 0x169D21: recvmsgs (nl.c:868) ==1807969== by 0x16A42C: nl_recvmsgs_report (nl.c:1051) ==1807969== by 0x16A42C: nl_recvmsgs (nl.c:1075) ==1807969== by 0x16A42C: nl_recvmsgs_default (nl.c:1089) ==1807969== by 0x18FD6F: monitor_xfrm (xfrm_monitor.c:233) ==1807969== by 0x49D8B19: start_thread (pthread_create.c:443) ==1807969== by 0x4A5C8F3: clone (clone.S:100) when calling xfrmnl_sa_parse, we accidentally get a refcount of 2 on the selector source and destination addresses. The nl_addr_build calls for these addresses set the count to one, and the subsequent calls to xfrmnl_sel_set_[s|d]addr increase the reference count to two. One of the references is dropped when we call xfrmnl_sa_put, which calls down through xfrmnl_sa_free_data->xfrmnl_sel_put->nl_addr_put(), but the other reference count is leaked, leading to the above leak of both the saddr and daddr pointers. Not sure if this is the ideal fix, but it works for me, we just drop the refrence count incremented by the call to set_[s|d]addr. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> https://github.com/thom311/libnl/pull/312
* all: merge branch 'th/coverity-fixes'Thomas Haller2022-04-2643-382/+463
|\ | | | | | | https://github.com/thom311/libnl/pull/310
| * xfrm: fix uninitalized variables in build_xfrm_ae_message()Thomas Haller2022-04-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Error: UNINIT (CWE-457): libnl-3.6.0/lib/xfrm/ae.c:377: var_decl: Declaring variable "ae_id" without initializer. libnl-3.6.0/lib/xfrm/ae.c:402: uninit_use_in_call: Using uninitialized value "ae_id". Field "ae_id.flags" is uninitialized when calling "nlmsg_append". # 400| return -NLE_NOMEM; # 401|··· # 402|-> if (nlmsg_append(msg, &ae_id, sizeof(ae_id), NLMSG_ALIGNTO) < 0) # 403| goto nla_put_failure; # 404|··· Error: UNINIT (CWE-457): libnl-3.6.0/lib/xfrm/ae.c:377: var_decl: Declaring variable "ae_id" without initializer. libnl-3.6.0/lib/xfrm/ae.c:402: uninit_use_in_call: Using uninitialized value "ae_id". Field "ae_id.reqid" is uninitialized when calling "nlmsg_append". # 400| return -NLE_NOMEM; # 401|··· # 402|-> if (nlmsg_append(msg, &ae_id, sizeof(ae_id), NLMSG_ALIGNTO) < 0) # 403| goto nla_put_failure; # 404|··· Error: UNINIT (CWE-457): libnl-3.6.0/lib/xfrm/ae.c:377: var_decl: Declaring variable "ae_id" without initializer. libnl-3.6.0/lib/xfrm/ae.c:402: uninit_use_in_call: Using uninitialized value "ae_id". Field "ae_id.saddr" is uninitialized when calling "nlmsg_append". # 400| return -NLE_NOMEM; # 401|··· # 402|-> if (nlmsg_append(msg, &ae_id, sizeof(ae_id), NLMSG_ALIGNTO) < 0) # 403| goto nla_put_failure; # 404|···
| * route: fix check for NULL in nh_encap_dump()Thomas Haller2022-04-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | Error: REVERSE_INULL (CWE-476): libnl-3.6.0/lib/route/nexthop_encap.c:35: deref_ptr: Directly dereferencing pointer "rtnh_encap->ops". libnl-3.6.0/lib/route/nexthop_encap.c:37: check_after_deref: Null-checking "rtnh_encap->ops" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. # 35| nh_encap_type2str(rtnh_encap->ops->encap_type)); # 36|··· # 37|-> if (rtnh_encap->ops && rtnh_encap->ops->dump) # 38| rtnh_encap->ops->dump(rtnh_encap->priv, dp); # 39| }
| * route/qdisc/mqprio: fix bufferoverflow and argument checking in ↵Thomas Haller2022-04-221-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rtnl_qdisc_mqprio_set_*() rtnl_qdisc_mqprio_set_priomap() would access the input array prio after len. Also these setters did the wrong argument checking (arguably, the caller is not supposed to provide an invalid argument, so that part is less severe). Coverity: Error: OVERRUN (CWE-119): libnl-3.6.0/lib/route/qdisc/mqprio.c:363: cond_at_most: Checking "len / 2UL > 16UL" implies that "len" may be up to 33 on the false branch. libnl-3.6.0/lib/route/qdisc/mqprio.c:366: overrun-buffer-arg: Overrunning array "mqprio->qm_count" of 32 bytes by passing it to a function which accesses it at byte offset 65 using argument "len * 2UL" (which evaluates to 66). [Note: The source code implementation of the function has been overridden by a builtin model.] # 364| return -NLE_RANGE; # 365|··· # 366|-> memcpy(mqprio->qm_count, count, len * sizeof(uint16_t)); # 367| memcpy(mqprio->qm_offset, offset, len * sizeof(uint16_t)); # 368| mqprio->qm_mask |= SCH_MQPRIO_ATTR_QUEUE; Error: OVERRUN (CWE-119): libnl-3.6.0/lib/route/qdisc/mqprio.c:363: cond_at_most: Checking "len / 2UL > 16UL" implies that "len" may be up to 33 on the false branch. libnl-3.6.0/lib/route/qdisc/mqprio.c:367: overrun-buffer-arg: Overrunning array "mqprio->qm_offset" of 32 bytes by passing it to a function which accesses it at byte offset 65 using argument "len * 2UL" (which evaluates to 66). [Note: The source code implementation of the function has been overridden by a builtin model.] # 365|··· # 366| memcpy(mqprio->qm_count, count, len * sizeof(uint16_t)); # 367|-> memcpy(mqprio->qm_offset, offset, len * sizeof(uint16_t)); # 368| mqprio->qm_mask |= SCH_MQPRIO_ATTR_QUEUE; # 369|··· Error: OVERRUN (CWE-119): libnl-3.6.0/lib/route/qdisc/mqprio.c:496: cond_at_most: Checking "len / 8UL > 16UL" implies that "len" may be up to 135 on the false branch. libnl-3.6.0/lib/route/qdisc/mqprio.c:499: overrun-buffer-arg: Overrunning array "mqprio->qm_min_rate" of 128 bytes by passing it to a function which accesses it at byte offset 1079 using argument "len * 8UL" (which evaluates to 1080). [Note: The source code implementation of the function has been overridden by a builtin model.] # 497| return -NLE_RANGE; # 498|··· # 499|-> memcpy(mqprio->qm_min_rate, min, len * sizeof(uint64_t)); # 500| mqprio->qm_mask |= SCH_MQPRIO_ATTR_MIN_RATE; # 501|··· Error: OVERRUN (CWE-119): libnl-3.6.0/lib/route/qdisc/mqprio.c:545: cond_at_most: Checking "len / 8UL > 16UL" implies that "len" may be up to 135 on the false branch. libnl-3.6.0/lib/route/qdisc/mqprio.c:548: overrun-buffer-arg: Overrunning array "mqprio->qm_max_rate" of 128 bytes by passing it to a function which accesses it at byte offset 1079 using argument "len * 8UL" (which evaluates to 1080). [Note: The source code implementation of the function has been overridden by a builtin model.] # 546| return -NLE_RANGE; # 547|··· # 548|-> memcpy(mqprio->qm_max_rate, max, len * sizeof(uint64_t)); # 549| mqprio->qm_mask |= SCH_MQPRIO_ATTR_MAX_RATE; # 550|··· Fixes: 25cf1d39eded ('route:qdisc: add MQPRIO Qdisc'
| * route/sriov: fix buffer overflow in rtnl_link_sriov_parse_vflist()Thomas Haller2022-04-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Coverity: Error: OVERRUN (CWE-119): libnl-3.6.0/lib/route/link/sriov.c:653: overrun-buffer-arg: Overrunning array "stb" of 6 8-byte elements by passing it to a function which accesses it at element index 8 (byte offset 71) u # 651|··· # 652| if (t[IFLA_VF_STATS]) { # 653|-> err = nla_parse_nested(stb, IFLA_VF_STATS_MAX, # 654| t[IFLA_VF_STATS], # 655| sriov_stats_policy); Fixes: 5d6e43ebef12 ('lib/route: SRIOV Parse and Read support')
| * all: fix "-Wformat" warnings for nl_dump*()Thomas Haller2022-04-2217-220/+220
| |