summaryrefslogtreecommitdiffstats
path: root/lib/route/mdb.c
Commit message (Collapse)AuthorAgeFilesLines
* include: use <linux/$file> instead of <linux-private/linux/$file>Thomas Haller2023-08-081-1/+1
| | | | | | 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: include private linux headers with explicit pathThomas Haller2023-08-031-1/+1
| | | | | | | 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-021-2/+2
|
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-021-0/+2
|
* include: split and drop "netlink-private/types.h"Thomas Haller2023-08-021-1/+21
| | | | | Move all the declarations from "netlink-private/types.h" to places closer to where they are used.
* nl-aux: add "include/nl-aux-{core,route}" headersThomas Haller2023-07-311-1/+4
| | | | | | | | | | | | | | | | | | | We have "include/netlink-private/netlink.h", which is private API used internally. However, it's confusing where "include/netlink-private/netlink.h" can be used. For example, it contains some "libnl-route-3.so" specific extensions like "link_lookup()", hence you would think that it can only be used with libraries that also use "libnl-route-3.so". Well, since it's a header, you actually can also use it for example under "lib/xfrm/", you couldn't just use those declarations because they are implemented and accessible only under "lib/route/" In a first step to clean this up, and move helper to separate headers, add "include/nl-aux-{core,route}" headers with certain clear usage. Clear in the sense who may use those headers, and what the implementation of those headers may use.
* lib: use _nl_{init,exit} instead of __{init,exit}Thomas Haller2023-07-281-2/+2
| | | | | We should have things with "nl" prefix in our headers. Also, netlink-private/netlink.h is not header-only, preferably header-only stuff is in netlink-private/utils.h
* all: rework ATTR_DIFF() macros to not generate attribute namesThomas Haller2023-07-281-3/+3
| | | | | | | | | | I find macros that stitch together names like "FAMILY_ATTR_##ATTR" very confusing, because we no longer see where a certain name is used. It breaks grepping for symbols, and it breaks cscope. Yes, it's more verbose to not do that. If you really think that those names are too verbose, then maybe they should get a shorter name. And not use macros to make them palatable.
* route/mdb: check parser error in mdb_msg_parser() for nested MDBA_MDB attributeThomas Haller2022-04-221-2/+4
| | | | | | Coverity says: libnl-3.6.0/lib/route/mdb.c:198: check_return: Calling "nla_parse_nested" without checking return value (as is done elsewhere 43 out of 44 times).
* route/mdb: add and use rtnl_mdb_entry_free() internal helper methodThomas Haller2022-04-221-6/+12
|
* route/mdb: fix leak in mdb_msg_parser()Thomas Haller2022-04-221-32/+28
| | | | | | Found by coverity: libnl-3.6.0/lib/route/mdb.c:242: leaked_storage: Variable "entry" going out of scope leaks the storage it points to.
* route/mdb: fix buffer overflow in mdb_msg_parser()Thomas Haller2022-04-221-1/+1
| | | | | | | | Found by coverity: 4. libnl-3.6.0/lib/route/mdb.c:198: overrun-buffer-arg: Overrunning array "db_attr" of 1 8-byte elements by passing it to a function which accesses it at element index 1 (byte offset 15) using argument "1". Fixes: 0ec6c6c2f023 ('mdb: support bridge multicast database notification')
* route/mdb: add support for MAC multicast entriesJoachim Wiberg2022-03-301-0/+5
| | | | | | | | | | | | | | | | The kernel bridge now support (permanent) forwarding of MAC multicast using the MDB. Internally the kernel use AF_UNSPEC, but we remap this here to AF_LLC for the benefit for nl_addrs. To test, put `nl-monitor mdb` in the background. Then, with a bridge and at least one port, run the following command: # nl-monitor mdb & # bridge mdb add dev br0 port eth0 grp 01:02:03:c0:ff:ee vid 1 permanent dev 9 port 3 vid 1 proto 0x0000 address 01:02:03:c0:ff:ee Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* route/mdb: add missing detils and stats dump callbacksJoachim Wiberg2022-03-301-2/+14
| | | | | | | | When using, e.g., nl-monitor to debug the bridge mdb the nl-monitor tool did not dump anything. This change adds the missing stats dump callback to rectify this issue, and also the details callback for completeness. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* lib: make nl_object_clone() out-of-memory safeThomas Haller2022-03-161-0/+1
| | | | | | | | | | | | | | | | | nl_object_clone() first does a shallow copy using memcpy(). That is useful, because it can correctly copy simple fields (like numbers). For pointer values, we need to implement oo_clone() to fixup the pointers and get the deep-copy correct. Now, oo_clone() must always follow through, to un-alias the copied pointer. In particular also in the error case. The oo_clone() implementations sometimes fail (with ENOMEM) and just return. In those cases, we must make sure that we don't leave the wrong pointers there. The pointers must be cleared first. Otherwise, any failure (which basically are ENOMEM) leave the object in an inconsistent state, and we double-free/use-after-free the pointers.
* route/mdb: drop setting ifindex in mdb_clone()Thomas Haller2022-03-141-3/+0
| | | | | | | The default implementation of oo_clone() already clones the object using memcpy(). So simple fields (like ifindex) are correct. What is not correct (and for what we need the oo_clone() implementation) are pointer values which require a deep clone.
* route/mdb: minor cleanup in "mdb.c"Thomas Haller2022-03-141-34/+31
|
* 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.