summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRubens Figueiredo <rubens.figueiredo@bisdn.de>2020-07-20 08:44:39 (GMT)
committerThomas Haller <thaller@redhat.com>2022-03-14 07:49:11 (GMT)
commit0ec6c6c2f0238f12c9088d454a83433cfdf9792c (patch)
tree85e970f3f405824629c5f0e43236960a39d46ddb /include
parentc980034d9fc3e23b9ef7c5431307c3ad574841b0 (diff)
downloadlibnl-0ec6c6c2f0238f12c9088d454a83433cfdf9792c.zip
libnl-0ec6c6c2f0238f12c9088d454a83433cfdf9792c.tar.gz
libnl-0ec6c6c2f0238f12c9088d454a83433cfdf9792c.tar.bz2
mdb: support bridge multicast database notification
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.
Diffstat (limited to 'include')
-rw-r--r--include/netlink-private/types.h18
-rw-r--r--include/netlink/cli/mdb.h11
-rw-r--r--include/netlink/route/mdb.h43
3 files changed, 72 insertions, 0 deletions
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
index 0bfaae0..5cd2b95 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -1346,4 +1346,22 @@ struct rtnl_vlan
uint32_t v_flags;
};
+struct rtnl_mdb {
+ NLHDR_COMMON
+ uint32_t ifindex;
+
+ struct nl_list_head mdb_entry_list;
+};
+
+struct rtnl_mdb_entry {
+ uint32_t ce_mask; /* HACK to support attr macros */
+
+ uint32_t ifindex;
+ uint8_t state;
+ uint16_t vid;
+ struct nl_addr *addr;
+ uint16_t proto;
+
+ struct nl_list_head mdb_list;
+};
#endif
diff --git a/include/netlink/cli/mdb.h b/include/netlink/cli/mdb.h
new file mode 100644
index 0000000..cd37604
--- /dev/null
+++ b/include/netlink/cli/mdb.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: LGPL-2.1-only */
+
+#ifndef __NETLINK_CLI_MDB_H_
+#define __NETLINK_CLI_MDB_H_
+
+#include <netlink/route/mdb.h>
+
+#define nl_cli_mdb_alloc_cache(sk) \
+ nl_cli_alloc_cache_flags((sk), "mdb", NL_CACHE_AF_ITER, rtnl_mdb_alloc_cache)
+
+#endif
diff --git a/include/netlink/route/mdb.h b/include/netlink/route/mdb.h
new file mode 100644
index 0000000..fc518bb
--- /dev/null
+++ b/include/netlink/route/mdb.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: LGPL-2.1-only */
+
+#ifndef NETLINK_MDB_H_
+#define NETLINK_MDB_H_
+
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/route/link.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ struct rtnl_mdb_entry;
+ struct rtnl_mdb *rtnl_mdb_alloc(void);
+ void rtnl_mdb_put(struct rtnl_mdb *mdb);
+
+ int rtnl_mdb_alloc_cache(struct nl_sock *sk, struct nl_cache **result);
+ int rtnl_mdb_alloc_cache_flags(struct nl_sock *sock,
+ struct nl_cache **result,
+ unsigned int flags);
+
+ int rtnl_mdb_add();
+ struct rtnl_mdb_entry *rtnl_mdb_entry_alloc(void);
+
+ uint32_t rtnl_mdb_get_ifindex(struct rtnl_mdb *mdb);
+ void rtnl_mdb_add_entry(struct rtnl_mdb *mdb,
+ struct rtnl_mdb_entry *_entry);
+
+ void rtnl_mdb_foreach_entry(struct rtnl_mdb *mdb,
+ void (*cb)(struct rtnl_mdb_entry *, void *),
+ void *arg);
+
+ int rtnl_mdb_entry_get_ifindex(struct rtnl_mdb_entry *mdb_entry);
+ int rtnl_mdb_entry_get_vid(struct rtnl_mdb_entry *mdb_entry);
+ int rtnl_mdb_entry_get_state(struct rtnl_mdb_entry *mdb_entry);
+ struct nl_addr *rtnl_mdb_entry_get_addr(struct rtnl_mdb_entry
+ *mdb_entry);
+ uint16_t rtnl_mdb_entry_get_proto(struct rtnl_mdb_entry *mdb_entry);
+#ifdef __cplusplus
+}
+#endif
+#endif