summaryrefslogtreecommitdiffstats
path: root/lib/route
Commit message (Collapse)AuthorAgeFilesLines
...
* license: use SPDX license identifiers and drop license commentsThomas Haller2022-03-111-8/+1
|
* ip6vti: Add fwmark APIThomas Winter2022-03-111-0/+55
| | | | | | This is a new option that was added in Linux v4.12. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* ip6gre: Add fwmark APIThomas Winter2022-03-111-0/+55
| | | | | | This is a new option that was added in Linux v4.12. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* sit: Add fwmark APIThomas Winter2022-03-111-0/+52
| | | | | | This is a new option that was added in Linux v4.12. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* ipip: Add fwmark APIThomas Winter2022-03-111-0/+56
| | | | | | This is a new option that was added in Linux v4.12. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* ip6_tnl: Add fwmark APIThomas Winter2022-03-111-0/+56
| | | | | | This is a new option that was added in Linux v4.12. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* ipvti: Add fwmark APIThomas Winter2022-03-111-0/+56
| | | | | | This is a new option that was added in Linux v4.12. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* ipgre: Add fwmark APIThomas Winter2022-03-111-0/+56
| | | | | | This is a new option that was added in Linux v4.12. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* ip6vti: Add IPv6 VTI supportThomas Winter2022-03-111-0/+509
| | | | | | | This patch adds support for IPv6 VTI tunneling that uses the vti6 kernel module. Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
* license: use SPDX license identifiers and drop license commentsThomas Haller2022-03-112-15/+2
|
* route/route: don't report failure when we receive a route in rtnl_route_lookup()Thomas Haller2022-03-111-6/+6
| | | | | | | | | - when we received a route and set `*result`, we should not return an error. That means, ignore the result of wait_for_ack(). - use _nl_auto* cleanup macros. - move new symbols to linker version for the upcoming release.
* route/route: support FIB lookups using rtnlTobias Waldekranz2022-03-111-0/+27
| | | | | | | Using the flnl_* family of functions to perform FIB lookups is rather limited. In particular, there seems to be no way of resolving the nexthop. By hooking into RTM_GETROUTE, a regular rtnl route object is returned instead.
* route/link: add support for team deviceJonas Johansson2022-03-101-0/+109
| | | | Signed-off-by: Jonas Johansson <jonas.johansson@westermo.se>
* route/link: Move LINK_ATTR_IFNAME to a proper locationGreger Wrang2022-03-101-2/+2
| | | | | | | | It should be set right where link name is set. Signed-off-by: Greger Wrang <greger.wrang@westermo.se> https://github.com/thom311/libnl/pull/237
* route/qdisc: allow fetching qdiscs by their kindVolodymyr Bendiuga2022-03-101-0/+32
| | | | | | | | | | | | API: rtnl_qdisc_get_by_kind() This function allows getting qdisc based on its kind, i.e. tbf, htb, cbq, etc. Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se> https://github.com/thom311/libnl/pull/244
* route/link: Add IPv6 GRE supportScott Parlane2022-03-091-0/+841
| | | | | | | This patch adds support for IPv6 GRE tunneling that uses the ip6_gre kernel module. https://github.com/thom311/libnl/pull/255
* neigh: support to add fdb entrywangli092022-03-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | rtnl_neigh.n_family should be set as AF_BRIDGE when we want to add a fdb entry, but the func build_neigh_msg does not allow dst addr to be put at that time. Here is the example: struct rtnl_neigh *neigh = rtnl_neigh_alloc(); struct nl_addr *mac = nl_addr_build(AF_LLC, eth, ETH_ALEN); struct nl_addr *dst = nl_addr_build(AF_INET, addr, 4); rtnl_neigh_set_ifindex(neigh, rtnl_link_get_ifindex(vxlan_link)); rtnl_neigh_set_state(neigh, NUD_NOARP | NUD_PERMANENT); rtnl_neigh_set_lladdr(neigh, mac); rtnl_neigh_set_flags(neigh, NTF_SELF); rtnl_neigh_set_dst(neigh, dst); rtnl_neigh_set_family(neigh, AF_BRIDGE); rtnl_neigh_add(sk, neigh, NLM_F_CREATE); Then command "bridge fdb show" will print out the fdb entry: 02:68:60:19:6b:a4 dev flannel.1 dst 10.40.252.12 self permanent Signed-off-by: huangxuesen <huangxuesen@kuaishou.com> Signed-off-by: wangli09 <wangli09@kuaishou.com> https://github.com/thom311/libnl/pull/260
* cls:u32: fix u32_clone() functionMagnus Öberg2022-03-041-12/+77
| | | | | | | | | | | | | | | | Spit the function into 2 parts: - where first being responsible for memory allocation/cloning - and second for populating the destination object Make proper cloning of 'action' attribute. For now, only the first action in chain is included in the clone. Signed-off-by: Magnus Öberg <magnus.oberg@westermo.se> Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se> [thaller@redhat.com: fix using the correct cleanup macros] https://github.com/thom311/libnl/pull/245
* route:tc: fix rtnl_tc_clone() calling to_clone() and add commentThomas Haller2022-03-041-10/+8
| | | | | | | | | | | | | | | | | | | | | rtnl_tc_data() allocates a data if necessary (or ENOMEM). So the code void *a = rtnl_tc_data(dst), *b = rtnl_tc_data(src); if (!a) return 0; else if (!b) return -NLE_NOMEM; is not right. It also means, rtnl_tc_clone() will always add the data pointers if the previously doesn't exist. In particular, it means that clone modifies "src", and that "dst" will always have an allocated pointer afterwards. Fix that. Also, add a comment about the subtleties for how to_clone() must fix the aliased pointers. Otherwise, we will crash. All implementations actually got this wrong earlier, and it only worked if they didn't encounter ENOMEM.
* route:cls: fix dangling pointers in to_clone() implementationsThomas Haller2022-03-044-1/+14
| | | | | | | | | | | rtnl_tc_clone() first does a shallow-copy (nl_data_clone()), and then calls the to_clone() implementation. We need the shallow-copy, because we want that by default all simple fields get cloned automatically. But it means, we *must* take care of all pointers in the to_clone() implementation, and must never return without fixing them. Otherwise we will do a double free. An early "return -NLE_NOMEM;" leaves the pointer unchanged, and two objects own the same data (double free and use-after-free says hello).
* route:act: drop unnecessary implementations for to_clone()Thomas Haller2022-03-044-36/+4
| | | | | Of the struct has no pointers that require a deep copy, there is no need to implement to_clone().
* route: fix memory leak of l_info_ops in link_msg_parser()Finikssky2022-03-041-0/+3
| | | | | | [thaller@redhat.com: whitespace fix] https://github.com/thom311/libnl/pull/254
* route: add accessors for setting/getting ENCAP_MPLS attributesAnn Pokora2022-03-041-0/+28
| | | | | [thaller@redhat.com: split original patch, reword commit message and fix symbols in "libnl-route-3.sym"]
* route: remove incorrect nl_addr_valid() from rtnl_route_nh_set_newdst(), etc.Ann Pokora2022-03-042-12/+0
| | | | | | | | | | | | | | | | | | nl_addr_valid() expects an address family as argument, not the length. It also expects an address in string form, not in binary. Those checks were wrong. Also, it seems not necessary to validate the argument, purely based on some criteria of the argument alone. Just set the provided address. Drop those checks. This is relevant for NEWDST and ENCAP_MPLS DST processing. Fixes: 760d74f99c88 ('route: Add support for MPLS encap') Fixes: 0a6d27ce90a1 ('route: Add support for MPLS address family') [thaller@redhat.com: split original patch and rewrite commit message].
* route: don't use internal bit mask constants in NLA_PUT in can_put_attrs()Anders Piniesjö2022-03-041-7/+7
| | | | | | | | [thaller@redhat.com: split original patch and rewrite commit message] Fixes: 5251188673e4 ('link: basic socket-CAN support') https://github.com/thom311/libnl/pull/274
* route: fix duplicate check for next hop for IPv6 multipath routesThomas Haller2022-03-041-1/+2
| | | | | | The check is right, that we skip adding the next hop if it already exists. However, we must not return a failure. Instead, we need to return success, that the old object is already good.
* route: check if nh exists while updating routet0mmmy902022-03-041-0/+9
|
* yyerror: update to POSIX standardheitbaum2022-03-032-0/+2
| | | | | | | | | | | | | | | | | | To comply with the latest POSIX standard, in Yacc compatibility mode (options `-y`/`--yacc`) Bison now generates prototypes for yyerror and yylex. In some situations, this is breaking compatibility: if the user has already declared these functions but with some differences (e.g., to declare them as static, or to use specific attributes), the generated parser will fail to compile. To disable these prototypes, #define yyerror (to `yyerror`), and likewise for yylex. refer: https://git.savannah.gnu.org/cgit/bison.git/tree/NEWS GNU Bison 3.8 https://github.com/thom311/libnl/issues/294 https://github.com/thom311/libnl/pull/295
* Supporting Hardware offload capability for MACsecJohan Alexis Duque Cadena2022-03-031-1/+41
| | | | | | [thaller@redhat.com: adjust libnl-route-3.sym file] https://github.com/thom311/libnl/pull/300
* route/link: check calloc() return valueBeniamino Galvani2022-03-031-0/+4
| | | | https://github.com/thom311/libnl/pull/292
* route/qdisc: handle error of calloc()Beniamino Galvani2021-06-161-3/+6
|
* route/qdisc: fix memory leak in netem.cBeniamino Galvani2021-06-161-6/+4
| | | | | 'data' was leaked when returning -NLE_INVAL. Fix this by using the cleanup attribute.
* route/link: fix copy-paste error in geneve.cBeniamino Galvani2021-06-161-1/+1
|
* route/cls: fix cgroup's clone() functionBeniamino Galvani2021-06-161-10/+5
| | | | | | The destination object doesn't have to be allocated because it's passed as _dst argument. Also, the function doesn't have to copy plain fields.
* route: let route/link join RTNLGRP_IPV6_IFINFO mcast groupReto Buerki2020-12-251-0/+1
| | | | | | | | Required to be notified about inet6 managed/otherconf flag changes, see occurrences of inet6_ifinfo_notify in net/ipv6/ndisc.c of the Linux kernel. https://github.com/thom311/libnl/pull/264
* addr: Add address flag `dadfailed`Leonard Crestez2020-12-031-0/+1
| | | | | | | This has been defined in linux for a long time but libnl does not show it. Signed-off-by: Leonard Crestez <cdleonard@gmail.com>
* route/link: avoid cloning link policy in link_msg_parser()Thomas Haller2020-04-171-4/+6
| | | | | Most families don't have a "link->l_af_ops", and those that do, mostly don't define ao_protinfo_policy. Only clone the policy if necessary.
* route/link: fix link_msg_parser() for using the af_ops of the link familyThomas Haller2020-04-171-5/+8
| | | | | | | | Often, the link itself has family unset, and thus no af_ops_family is set. However, we would fallback to set the family via IFLA_INFO_KIND. That af_ops must not be used for parsing the IFLA_AF_SPEC. Fixes: 17e09aaa1b70 ('rtnl/route: use cleanup attribute in "lib/route/link.c"')
* route: add test for valid content of map_stat_id_from_IPSTATS_MIB_v2 arrayThomas Haller2020-04-161-0/+6
| | | | | When updating the linux header, it's easy to miss updating the type mapping. Add a test to avoid that.
* route/link: add RTNL_LINK_REASM_OVERLAPS statIlya Pronin2020-04-162-0/+2
| | | | | | | | | | | | | | | | | | The new stat exposes IPSTATS_MIB_REASM_OVERLAPS link stat. However, the original motivation for this change was fixing the issue with missing RX packets link stat. The regression was introduced in version 3.5.0 with commit 73c1d047, that added a new enum constant IPSTATS_MIB_REASM_OVERLAPS. Without this patch, IPSTATS_MIB_REASM_OVERLAPS is missing from map_stat_id_from_IPSTATS_MIB_v2 and is mapped by it to 0. This tricks inet6_parse_protinfo() into erroneously overwriting RTNL_LINK_RX_PACKETS stat, which happens to have value 0, when it tries to set IPSTATS_MIB_REASM_OVERLAPS. Fixes: 73c1d0479643 ('Sync linux headers to 4.19.66') https://github.com/thom311/libnl/pull/235
* gitignore: merge all gitignore files in top level directoryThomas Haller2020-04-162-6/+0
| | | | | | | The source tree of libnl3 is fairly simple. We can afford thinking and reasoning about it as one. Don't spread out the .gitignore files, instead ignore all files consistently via the ignore file in the top level directory.
* license: fix and add SPDX license identifiers and drop license commentsThomas Haller2020-04-1675-525/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also fixes a few wrong SPDX license identifiers, where the original license comment indicates GPL-2.0-only. This is not done manually, but by running the following script: --- #!/bin/bash # Tool to drop license comments, adding SPDX license identifiers, while preserving # copyright comments. The point is not to manually do this task, but perform some # hacked up string replacement. _cp() { /bin/cp "$@" } _cat() { /bin/cat "$@" } in_file() { local T=$(mktemp) _cp -f "$1" "$T" _cat "$T" rm -f "$T" } out_file() { local T=$(mktemp) _cat - > "$T" _cp -f "$T" "$1" rm -f "$T" } join() { _cat "$@" | awk '{ printf("%s#x#", $0)}' } unjoin() { _cat - | sed 's/#x#/\n/g' } files_all() { git ls-files | grep -v '\.png$' | grep -v '^include/linux-private/' } adjust() { NEWLINES='\(#x#\)\+' COPYRIGHTS='\(\( \* Copyright (c) 20..\(-20..\|, 20..\)\? [^#]\+#x#\)\+\( \*#x# \* \(Stolen[^#]*\|Based on [^#]*\)#x#\)\?\)' _cat - | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x##x#%' | \ sed '1s%^\(\)/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU General Public License as#x# \*[ ]\+published by the Free Software Foundation version 2 of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: GPL-2.0-only \*/#x#/*#x#\2 */#x##x#%' } FILES=( $(files_all) ) for f in "${FILES[@]}"; do echo "processing \"$f\"..." in_file "$f" | join | adjust | unjoin | out_file "$f" done
* license: cleanup copyright commentsThomas Haller2020-04-162-2/+3
| | | | Manually make copyright comments in a consistent format.
* rtnl/route: use cleanup attribute in "lib/route/link.c"Thomas Haller2020-04-151-149/+98
|
* rtnl/route: use cleanup attribute in "lib/route/route_obj.c"Thomas Haller2020-04-152-92/+61
|
* rtnl/route: fix NLE_NOMEM handling in parse_multipath()Thomas Haller2020-04-151-2/+6
|
* rtnl/link: fix leaking rtnl_link_af_ops in link_msg_parser()Thomas Haller2020-04-151-0/+2
|
* rtnl/route: only consider negative error codes as errorThomas Haller2020-04-158-22/+27
| | | | | | The convention is that negative values are errors. Positive values are undefined, but when in doubt, they are not errors. In these cases it makes no difference. The code won't return positive values.
* lib: use _nl_strncpy*() instead of plain strncpy()Thomas Haller2020-04-153-6/+7
| | | | | | | | | | | | | | | | There wasn't really a bug previously, but it's ugly and raises questions about the correct use of strncpy(). For example, void genl_family_set_name(struct genl_family *family, const char *name) { strncpy(family->gf_name, name, GENL_NAMSIZ-1); was in fact correct, because family->gf_name will (presumably) always have a NUL character as last position. Still use _nl_strncpy*() wrappers, to avoid raising such questions.
* lib: rename _nl_strncpy() to _nl_strncpy_assert()Thomas Haller2020-04-151-1/+1
| | | | It makes it clearer how this function differs from _nl_strncpy_trunc().