summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* route/mdb: drop extra MDB attributes and rework mdb_compare()Thomas Haller2022-03-141-26/+25
| | | | | | | | | | | | | | | | | | - a `struct rtnl_mdb` has a list of `struct rtnl_mdb_entry`. An attribute like MDB_ATTR_PORT is not really an attribute of the MDB struct, but rather of one entry. It makes no sense to mangle these. Having MDB_ATTR_PORT set in the change flags would mean that at least one entry has the port set. Instead, add MDB_ATTR_ENTRIES which is about the list of entries. - drop unused `ce_mask` in `struct rtnl_mdb_entry`. - rework mdb_compare(). When we compare the two lists of entries, it's not right to have two nested loops. You can either iterate both lists in step, and compare each element to do a comparison that honors the order of the elements. Or, you can compare the two lists accepting any order. The latter is more complicated, and does not seem right. So do the former.
* route/mdb: hide rtnl_mdb_entry_alloc() from public APIThomas Haller2022-03-141-1/+3
| | | | | | | | | | | "struct rtnl_mdb_entry" is a relatively simple object that keeps a few data fields. But there are no public setters in the API, so it's not useful to be able to allocate such an entry. Hide from public API. Also, it was already not listed in libnl-route-3.sym, and thus the symbol was hidden anyway.
* route/mdb: use nl_list_for_each_entry_safe() for destroying list in ↵Thomas Haller2022-03-141-8/+6
| | | | | | | | | mdb_free_data() I think this was wrong before. We cannot use mdb_free_data() and free the current element. Use nl_list_for_each_entry_safe() and properly unlink the element.
* mdb: support bridge multicast database notificationRubens Figueiredo2022-03-141-0/+451
| | | | | | | | | | | The Linux kernel has a notification system via Netlink that reports the changes in the multicast database over the RTNLGRP_MDB multicast socket. As such notifications such as RTM_NEWMDB, RTM_GETMDB can be processed in userspace. libnl must support the capability of processing these messages, e.g. RTM_GETMDB. This commit adds a new rtnl_mdb object as well as a route/mdb cache, in order to expose the contents of the multicast database.
* route/cls: rename rtnl_cls_get{,_by_prio}() API to ↵Thomas Haller2022-03-141-4/+4
| | | | | | | rtnl_cls_find_by{handle,prio}() The functions return the first matching object (of potentially several). Rename them to "find", so that this is a bit clearer.
* route/cls: allow fetching of classifiers from cacheVolodymyr Bendiuga2022-03-141-0/+72
| | | | | | | | API: rtnl_cls_get() rtnl_cls_get_by_prio() These functions search for classifiers in classifier cache.
* 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
* nflog:add conntrack flag and enable flags for nflogMichael Braun2022-03-092-0/+11
| | | | Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
* nflog: add CT supportMichael Braun2022-03-094-24/+132
| | | | Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
* nflog: add mac_header supportMichael Braun2022-03-092-2/+103
| | | | Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
* nflog: add vlan attributeMichael Braun2022-03-092-0/+91
| | | | | | | Signed-off-by: Michael Braun <michael-dev@fami-braun.de> -- v2: use new kernel api like for nfqueue
* 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().
* log: fix typo in dumping msgMichael Braun2022-03-041-1/+1
| | | | | | | | This fixes an incorrect output. Signed-off-by: Michael Braun <michael-dev@fami-braun.de> https://github.com/thom311/libnl/pull/250
* 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].
* netfilter/ct: fix use of reply/orig for conntrack requestsAnisse Astier2022-03-041-6/+10
| | | | | | https://github.com/thom311/libnl/issues/281 https://github.com/thom311/libnl/pull/282
* 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
* lib: fix descriptions for nl_cache_pickup()/nl_cache_pickup_checkdup()t0mmmy902022-03-041-5/+5
| | | | | | [thaller@redhat.com: picked partial patch and rewrite commit message] https://github.com/thom311/libnl/pull/277
* 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
|
* xfrm: fix naming consistency in xfrmnl_sp_get_curlifetime()Balaji Marisetti2022-03-031-6/+6
| | | | | | Trivial name change for consistency. https://github.com/thom311/libnl/pull/276
* 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
* xfrm: ensure minlen in policy for XFRMA_OFFLOAD_DEVThomas Haller2022-03-031-0/+1
| | | | | | Otherwise, we cannot just access the netlink attribute and be sure it has the right size. Add the length to the policy, so it gets validated.
* xfrm: Add support for xfrm user offloadingThomas Egerer2022-03-031-0/+86
| | | | Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
* 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
* zero stack allocated memory in xfrmnl_build_sa_delete_requestNeil Horman2022-03-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running valgrind on an application that uses xfrmnl_build_sa_delete_request, it reports the following error: ==783216== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) ==783216== at 0x4DF771D: sendmsg (in /usr/lib64/libpthread-2.33.so) ==783216== by 0x48627D9: nl_sendmsg (nl.c:336) ==783216== by 0x4862993: nl_send_iovec (nl.c:401) ==783216== by 0x48629F9: nl_send (nl.c:453) ==783216== by 0x48629F9: nl_send (nl.c:441) ==783216== by 0x4931B89: xfrmnl_sa_delete (sa.c:1379) ==783216== by 0x40A390: delete_associated_state (net-api.c:88) ==783216== by 0x40C191: del_tunnel (net-api.c:883) ==783216== by 0x414EB0: net_api_test_tunnel (net-api_test.c:181) ==783216== by 0x4DD763A: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD79C0: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD8966: CU_run_all_tests (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x422E13: RunAllTests (test.c:87) ==783216== by 0x422FA9: main (test.c:150) ==783216== Address 0x5217394 is 20 bytes inside a block of size 4,096 alloc'd ==783216== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==783216== by 0x4860CF5: __nlmsg_alloc (msg.c:269) ==783216== by 0x4860FFE: nlmsg_inherit (msg.c:321) ==783216== by 0x4861091: nlmsg_alloc_simple (msg.c:352) ==783216== by 0x4931AA5: build_xfrm_sa_delete_message (sa.c:1340) ==783216== by 0x4931AA5: xfrmnl_sa_build_delete_request (sa.c:1367) ==783216== by 0x4931B58: xfrmnl_sa_delete (sa.c:1375) ==783216== by 0x40A390: delete_associated_state (net-api.c:88) ==783216== by 0x40C191: del_tunnel (net-api.c:883) ==783216== by 0x414EB0: net_api_test_tunnel (net-api_test.c:181) ==783216== by 0x4DD763A: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD79C0: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD8966: CU_run_all_tests (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x422E13: RunAllTests (test.c:87) ==783216== by 0x422FA9: main (test.c:150) ==783216== Uninitialised value was created by a stack allocation ==783216== at 0x492DA10: ??? (in /home/nhorman/git/privafy/microedge-c/external_libs/install/lib/libnl-xfrm-3.so.200.26.0) It occurs because the sa_id value thats allocated on the stack isn't completely initalized (if you're using ipv4, the daddr winds up with garbage in the extra bytes). Its not critical, but it would be nice to avoid sending that garbage into the kernel, and it would silence the valgrind error. Easy fix, just memset the sa_id before copying it into the nlmsg. Signed-off-by: Neil Horman <nhorman@gmail.com> https://github.com/thom311/libnl/pull/297
* 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
|