summaryrefslogtreecommitdiffstats
path: root/lib/route
Commit message (Collapse)AuthorAgeFilesLines
* route/qdisc: adjust API for 64 bit rate/ceil support for htb classThomas Haller2019-09-013-73/+138
| | | | | | | | | | | | | | | | - existing API/ABI must stay unchanged. We cannot change parameter types. Ad most we can add new variants that support 64 bit integers. - rtnl_tc_calc_txtime64() and rtnl_tc_calc_bufsize64() are trivial. We should not blow up the public API of libnl for such a thing. If the users needs it, they can just reimplement it. - getters should return an error code. Especially if the return type does not support encoding an error there. - don't add separate rs_rate64/rs_ceil64 field. Instead, extend the "rs_rate" field of "struct rtnl_ratespec" to 64 bits. It's internal API.
* Add 64bit rate/ceil support for htb classd0u92019-09-012-20/+38
| | | | | Htb class has already supported 64bit rate and ceil settings for times. Now, in this patch, we grant this ability to libnl library.
* xfrmi: return error code from getters for XFRM linksThomas Haller2019-09-011-13/+20
| | | | | | | | Returning the value directly as uint32_t does not leave room for an error code. E.g. we want to indicate to the caller whether the attribute is present or not (-NLE_NOATTR). Currenlty, the code is quite unforgiving and will just crash/assert against invalid arguments. In theory, we could also be more forgiving and return a error code if the link argument is invalid.
* xfrmi: introduce XFRM interfaces supportEyal Birger2019-09-011-0/+312
| | | | | | | XFRM interfaces were introduced in kernel 4.19. This commit adds link support for these interfaces. Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
* Sync linux headers to 4.19.66Michael Forney2019-08-263-4/+4
| | | | | | | | | | | | | | | | | | | This fixes the build with musl libc. Additionally, several changes were made to account for changes to the headers: - ip_mp_alg.h was removed, since it was removed in linux commit e06e7c61 (v2.6.23), and the last use of those constants was removed in libnl commit 535e8316. - Uses of TCF_META_ID_SK_ROUTE_CAPS were updated to __TCF_META_ID_SK_ROUTE_CAPS, since it was renamed in linux commit e20e6940 (v3.1). - Uses of IF_CARRIER_DOWN and IF_CARRIER_UP were replaced with their values, 0 and 1, since they are not in linux/if.h (they appear to be libnl-specific, added in libnl commit 3540e44b). https://github.com/thom311/libnl/pull/222
* route: Remove stray `;` at top-levelMichael Forney2019-08-162-4/+5
|
* lib: Don't omit second operand to `?` operatorMichael Forney2019-08-162-2/+6
|
* all: Avoid pointer arithmetic on `void *`Michael Forney2019-08-167-12/+12
| | | | | | | ISO C requires that the pointer operand to the binary + operator be to a complete object type[0]. [0] http://port70.net/~nsz/c/c11/n1570.html#6.5.6p2
* Add SPDX identifiersYegor Yefremov2019-08-1220-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Software Package Data Exchange identifiers help to detect source file licenses and hence simplify the FOSS compliance process. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> https://github.com/thom311/libnl/pull/219 --- FILES=( lib/addr.c lib/attr.c lib/cache.c lib/cache_mngr.c lib/cache_mngt.c lib/data.c lib/error.c lib/fib_lookup/lookup.c lib/fib_lookup/request.c lib/genl/ctrl.c lib/genl/family.c lib/genl/genl.c lib/genl/mngt.c lib/handlers.c lib/hash.c lib/hashtable.c lib/idiag/idiag.c lib/idiag/idiag_meminfo_obj.c lib/idiag/idiag_msg_obj.c lib/idiag/idiag_req_obj.c lib/idiag/idiag_vegasinfo_obj.c lib/mpls.c lib/msg.c lib/netfilter/ct.c lib/netfilter/ct_obj.c lib/netfilter/exp.c lib/netfilter/exp_obj.c lib/netfilter/log.c lib/netfilter/log_msg.c lib/netfilter/log_msg_obj.c lib/netfilter/log_obj.c lib/netfilter/netfilter.c lib/netfilter/nfnl.c lib/netfilter/queue.c lib/netfilter/queue_msg.c lib/netfilter/queue_msg_obj.c lib/netfilter/queue_obj.c lib/nl.c lib/object.c lib/route/act.c lib/route/addr.c lib/route/class.c lib/route/classid.c lib/route/cls.c lib/route/link.c lib/route/neigh.c lib/route/neightbl.c lib/route/netconf.c lib/route/nexthop.c lib/route/nexthop_encap.c lib/route/nh_encap_mpls.c lib/route/pktloc.c lib/route/qdisc.c lib/route/route.c lib/route/route_obj.c lib/route/route_utils.c lib/route/rtnl.c lib/route/rule.c lib/route/tc.c lib/socket.c lib/utils.c lib/version.c lib/xfrm/ae.c lib/xfrm/lifetime.c lib/xfrm/sa.c lib/xfrm/selector.c lib/xfrm/sp.c lib/xfrm/template.c src/genl-ctrl-list.c src/idiag-socket-details.c src/lib/addr.c src/lib/class.c src/lib/cls.c src/lib/ct.c src/lib/exp.c src/lib/link.c src/lib/neigh.c src/lib/qdisc.c src/lib/route.c src/lib/rule.c src/lib/tc.c src/lib/utils.c src/nf-ct-add.c src/nf-ct-events.c src/nf-ct-list.c src/nf-exp-add.c src/nf-exp-delete.c src/nf-exp-list.c src/nf-log.c src/nf-monitor.c src/nf-queue.c src/nl-addr-add.c src/nl-addr-delete.c src/nl-addr-list.c src/nl-class-add.c src/nl-class-delete.c src/nl-class-list.c src/nl-classid-lookup.c src/nl-cls-add.c src/nl-cls-delete.c src/nl-cls-list.c src/nl-fib-lookup.c src/nl-link-enslave.c src/nl-link-ifindex2name.c src/nl-link-list.c src/nl-link-name2ifindex.c src/nl-link-release.c src/nl-link-set.c src/nl-link-stats.c src/nl-list-caches.c src/nl-list-sockets.c src/nl-monitor.c src/nl-neigh-add.c src/nl-neigh-delete.c src/nl-neigh-list.c src/nl-neightbl-list.c src/nl-pktloc-lookup.c src/nl-qdisc-add.c src/nl-qdisc-delete.c src/nl-qdisc-list.c src/nl-route-add.c src/nl-route-delete.c src/nl-route-get.c src/nl-route-list.c src/nl-rule-list.c src/nl-tctree-list.c src/nl-util-addr.c ) sed '1s#^#/* SPDX-License-Identifier: LGPL-2.1-only */\n#' "${FILES[@]}" -i
* route/tc: ensure not string truncation in rtnl_tc_set_kind()Thomas Haller2019-08-091-1/+8
| | | | | | | | | | | | | | | | | | | | | | | The compiler warns: In function ‘rtnl_tc_set_kind’, inlined from ‘rtnl_tc_msg_parse’ at lib/route/tc.c:81:2: lib/route/tc.c:532:2: error: ‘strncpy’ output may be truncated copying 31 bytes from a string of length 31 [-Werror=stringop-truncation] 532 | strncpy(tc->tc_kind, kind, sizeof(tc->tc_kind) - 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Now, there are two choices: either accept the truncation or rejecting it. While rejecting it is a change in behavior and API, I don't think that any caller actually relied on that. That is because such "kind" name would be invalid anyway (and rejected from kernel too). So, tighten up the API and check for a suitable string length. Also, use _nl_strncpy() instead of strncpy(). Note that that doesn't suppress the warning, it merely (also) adds an _nl_assert() for something that already shouldn't happen.
* route/inet6: fix strncpy() in inet6_dump_details()Thomas Haller2019-08-091-12/+13
| | | | | | | | | | | | Compiler warnings: lib/route/link/inet6.c: In function ‘inet6_dump_details’: lib/route/link/inet6.c:383:3: error: ‘strncpy’ output may be truncated copying between 0 and 63 bytes from a string of length 63 [-Werror=stringop-truncation] 383 | strncpy(&buf[offset], buf2, strlen(buf2)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Also, passing "strlen(buf2)" as length argument to strncpy() is certainly wrong.
* link/sriov: fix memleak in rtnl_link_sriov_clone()Thomas Haller2019-08-081-6/+18
| | | | Found by Coverity.
* route: fix strncpy() warning from coverity about unterminated stringThomas Haller2019-08-081-0/+1
| | | | | | | | | | | | | | | | | | | | Coverity says: Error: BUFFER_SIZE_WARNING (CWE-120): [#def1] libnl-3.4.0/lib/route/cls/ematch/text.c:94: buffer_size_warning: Calling strncpy with a maximum size argument of 16 bytes on destination array "t->cfg.algo" of size 16 bytes might leave the destination string unterminated. # 92| struct text_data *t = rtnl_ematch_data(e); # 93| # 94|-> strncpy(t->cfg.algo, algo, sizeof(t->cfg.algo)); # 95| } # 96| Error: BUFFER_SIZE_WARNING (CWE-120): [#def11] libnl-3.4.0/lib/xfrm/sa.c:1192: buffer_size_warning: Calling strncpy with a maximum size argument of 64 bytes on destination array "auth->alg_name" of size 64 bytes might leave the destination string unterminated. # 1190| } # 1191| # 1192|-> strncpy(auth->alg_name, tmpl->auth->alg_name, sizeof(auth->alg_name)); # 1193| auth->alg_key_len = tmpl->auth->alg_key_len; # 1194| memcpy(auth->alg_key, tmpl->auth->alg_key, (tmpl->auth->alg_key_len + 7) / 8);
* route/link: avoid dangling pointer in rtnl_link_set_slave_type()Thomas Haller2019-03-071-11/+11
| | | | | | | | | - don't leave a dangling pointer, in case we unset the kind. - try first to clone the string. If that fails, return early without modifying the link. Only start modifying the link, after we know it's going to succeed.
* route/link: expose IFLA_INFO_SLAVE_KINDTobias Jungel2018-10-221-10/+76
| | | | | add rtnl_link_{get,set}_slave_type functions to expose the IFLA_INFO_SLAVE_KIND attribute.
* route/macvlan: style fixes in "lib/route/link/macvlan.c"Thomas Haller2018-10-101-56/+56
|
* link: macvlan fixesWang Jian2018-10-101-11/+12
| | | | | | | | | | | | | | | 1. While parsing flags, it overrides mode. 2. Before, dump-line and dump-details are same leading that macvlan info will be shown twice while dumpping details. So make dump-line show nothing. 3. Add some spaces to show dump-details more prettier. Signed-off-by: Wang Jian <jianjian.wang1@gmail.com> Fixes: c76393e2037d78eb60c32f95b26f5b1e5b9422a6 http://lists.infradead.org/pipermail/libnl/2018-August/002405.html http://lists.infradead.org/pipermail/libnl/2018-September/002406.html http://lists.infradead.org/pipermail/libnl/2018-September/002411.html
* route/cls: fix potential memory leakIlya Pronin2018-10-102-2/+10
| | | | | | | | | | | | | rtnl_act_append() cannot add more than TCA_ACT_MAX_PRIO actions to the same list. Because of that rtnl_basic_add_action() and rtnl_u32_add_action() should not increment the reference counter of the given action until it is successfully added to the filter's list. Signed-off-by: Ilya Pronin <ipronin@twitter.com> Fixes: e5d9b828f6ec64fd77854578fbf1c33f214f3ac4 https://github.com/thom311/libnl/pull/201
* route/act: return error code from act-vlan gettersThomas Haller2018-10-101-20/+30
| | | | | | Our API is unfortunately not consistent about this. However, in general, getters should aim to return an error code whether the attribute could be retrieved.
* route/act: style fixes in "lib/route/act/vlan.c"Thomas Haller2018-10-101-79/+79
|
* route:act: add vlan actionVolodymyr Bendiuga2018-10-101-0/+416
| | | | | | | For more information please see: http://man7.org/linux/man-pages/man8/tc-vlan.8.html Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
* route/tc: return error code from rtnl_tc_get_chain()Thomas Haller2018-10-101-6/+8
| | | | | | Our API is unfortunately not consistent about this. However, in general, getters should aim to return an error code whether the attribute could be retrieved.
* route:tc: allow to set chain index for tc objectsVolodymyr Bendiuga2018-10-101-0/+33
| | | | | | This is useful when one wants to chain filters. Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
* lib/tc: fix uninitalized err variable in rtnl_tc_msg_build()Thomas Haller2018-10-101-5/+7
| | | | Fixes: 52cd3c14ce42db53637f8f5dafaf0d5c24d724db
* lib/qdisc: avoid BUG() in "lib/route/qdisc/mqprio.c"Thomas Haller2018-10-091-18/+19
| | | | | | | | | | BUG() raises an assertion. It seems overly harsh. For example, rtnl_tc_data() can fail if we fail to allocate memory. Asserting against that, makes libnl3 not out-of-memory safe. Just return a regular error.
* lib/qdisc: style fixes in "lib/route/qdisc/mqprio.c"Thomas Haller2018-10-091-117/+117
|
* lib/tc: ensure correct error code in rtnl_tc_msg_build()Thomas Haller2018-10-081-3/+7
|
* route:qdisc: add MQPRIO QdiscVolodymyr Bendiuga2018-07-261-0/+604
| | | | | | | More about Qdisc mqprio can be found at: http://man7.org/linux/man-pages/man8/tc-mqprio.8.html Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
* ipvti: Fix wrong array size initializationThomas Winter2018-06-251-3/+3
| | | | | | | | IPv4 VTI tunnels use the VTI defines. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz> Fixes: 8f6301426a00d992d00238c7ddd666e96aa63e28
* ipgre: Fix wrong array size initializationThomas Winter2018-06-251-1/+1
| | | | | | | | IPv4 GRE tunnels use the GRE defines. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz> Fixes: 57bdc4ff4895dd91cc723d22eecadcf48945e87c
* neigh: update neighbour.h and add missing flagsTobias Jungel2018-06-251-0/+3
| | | | | | NTF_EXT_LEARNED, NTF_OFFLOADED and NTF_MASTER are added to neigh_flags. https://github.com/thom311/libnl/pull/186
* route/link/vxlan: Fix IPv4 set_local resetting ce_maskTuetuopay2018-06-251-1/+1
| | | | | | | | | | rtnl_link_vxlan_set_local() removes the bit for the other IP version in ce_mask. A missing flag inversion in the v4 part made this removal reset all bits to 0 except the v6 one, screwing all link configuration. Fixes: 2e68fb5b02304fa6a3e6429c4fdabb084e61b501 https://github.com/thom311/libnl/pull/192
* Add support for cloning cgroup filter object.d0u92018-06-252-2/+72
| | | | | | | | | | | In this commit, we implement ematch_tree_clone(), which is basis of cgroup_clone() interface. The whole ematch tree is deep-copied except the e_ops filed. Also, a new unit test is added for testing the interface, which named as check-ematch-tree-clone.c located in tests directory. https://github.com/thom311/libnl/pull/176
* neigh_dump_line: dump master as wellTobias Jungel2018-06-251-0/+8
| | | | | | | In case NEIGH_ATTR_MASTER is set this dumps as well the master interface. https://github.com/thom311/libnl/pull/190
* neigh: add get/set functions for NEIGH_ATTR_MASTERTobias Jungel2018-06-251-0/+10
| | | | | | | Beeing able to set NEIGH_ATTR_MASTER hash based lookups are possible for AF_BRIDGE neighbours. https://github.com/thom311/libnl/pull/189
* whitespace cleanupTobias Jungel2018-06-251-5/+5
|
* neigh: cache updates as well query AF_BRIDGE neighTobias Jungel2018-06-251-1/+26
| | | | | | | This commit adds the query for AF_BRIDGE neighbours. A cache refresh now includes these objects as well. The result of `./src/nl-neigh-list --family=bridge` includes now as well the same entries you would retrieve from the kernel by calling `bridge fdb show`.
* route/class: add new api rtnl_class_get_by_parent()d0u92018-04-111-0/+32
| | | | | | | | This function searches a class cache previously allocated with rtnl_class_alloc_cache() and searches for a class matching the interface index and parent qdisc. https://github.com/thom311/libnl/pull/185
* route/link: assert in rtnl_link_change() that the sequence number is set as ↵Thomas Haller2018-04-111-0/+1
| | | | expected
* route/link: fix sequence number handling in rtnl_link_change()Tuetuopay2018-04-111-0/+5
| | | | | | | | | | | | When rtnl_link_change() fails with -NLE_OPNOTSUPP, it retries with RTM_SETLINK operation. However, it also needs to re-adjust the sequence number. Otherwise, the second request might fail with NLE_SEQ_MISMATCH, although it actually succeeded. [thaller@redhat.com: changed commit message] https://github.com/thom311/libnl/issues/179 https://github.com/thom311/libnl/pull/184
* route/mall: fix deep cloning mallThomas Haller2018-04-111-6/+10
| | | | | rtnl_act_append() does not clone the object, it takes it over and thus the source object is destroyed.
* route:cls: add matchall classifierVolodymyr Bendiuga2018-04-111-0/+301
| | | | | | | This simple classifier allows any traffic pass through. Useful as an example for port mirroring. Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
* neigh: support bridge entries for vxlan interfacesTobias Jungel2018-04-061-2/+4
| | | | | | | | | bridge entries used for switching into vxlan interfaces do not include a vlan. A comparison of such entires currently always fails which leads to an invalid cache. This patch selectively adds the NEIGH_ATTR_VLAN flag based on the passed entry. https://github.com/thom311/libnl/pull/182
* neigh: set correct AF for NDA_DSTTobias Jungel2018-04-061-1/+3
| | | | | | | | | | In case using a VXLAN interface at a bridge you will set L2 bridging entries using a IP destination to tunnel the according L2 traffic. The current behavior for the dst entries for a neighbor is to use the AF of the neighbor itself thus in this case AF_BRIDGE is set. This is changed in the PR to update the family of the dst using nl_addr_guess_family. https://github.com/thom311/libnl/pull/180
* rule: Add support for protocol and port rangesDavid Ahern2018-04-061-17/+196
| | | | | | | Add support for recent fib rule features - specifying a protocol that installed a rule and an IP protocol plus port range for rules. Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
* route/vrf: initalize clone destination with NULL in vrf_clone()Jonas Johansson2018-03-121-0/+1
| | | | Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
* lib: route: rule: add rule_groups to cache opsRoopa Prabhu2018-02-151-0/+7
| | | | | Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Acked-by: David Ahern <dsa@cumulusnetworks.com>
* lib/rtnl: rename public define RTNL_GENEVE_ID_MAXThomas Haller2018-02-121-1/+1
| | | | | Public defines must have a libnl3 related prefix. Rename GENEVE_ID_MAX to RTNL_GENEVE_ID_MAX.
* link: add Geneve support.Wang Jian2018-02-121-0/+810
| | | | Signed-off-by: Wang Jian <jianjian.wang1@gmail.com>
* Fix for cgroup filter addition problem.d0u92018-01-241-1/+4
| | | | | | | | | | Currently, due to the incomplete netlink datagram sent by libnl, cgroup filter addition is not fully functional. The datagram generated by `tc` command includes an empty attribute section, which is stripped off in the libnl counterpart. In this commit, a new `interface nla_nest_end_keep_empty()` is added. This function closes attribute without stripping off empty attribute.