mirror of
https://github.com/openwrt/packages.git
synced 2025-12-21 17:04:32 +04:00
Package Multipath TCP daemon (mptcpd) and wrapper (mptcpize). Signed-off-by: Daniel Golle <daniel@makrotopia.org>
188 lines
6.8 KiB
Diff
188 lines
6.8 KiB
Diff
From ffa276fc8ee18321b3c2f22deae2e254a69ae4dc Mon Sep 17 00:00:00 2001
|
|
From: Ossama Othman <ossama.othman@intel.com>
|
|
Date: Sat, 14 Sep 2024 17:50:13 +0900
|
|
Subject: [PATCH] Support ELL 0.68 l_netlink_message API. (#303)
|
|
|
|
* configure: Check for l_netlink_message_new_sized()
|
|
|
|
ELL 0.68 introduced a non-backward compatible change to its API by
|
|
introducing a new l_netlink_message API to simplify use of the
|
|
l_netlink_send() function. Check for the existence of the new API in
|
|
the mptcpd configure script.
|
|
|
|
* network_monitor: Support ELL l_netlink_message API
|
|
|
|
Support both the pre- and post- ELL 0.68 versions of l_netlink_send()
|
|
function.
|
|
|
|
* network_monitor: Refactor l_netlink_send() calls.
|
|
|
|
Refactor #ifdef blocks containing calls to the pre- and post-0.68
|
|
ELL l_netlink_send() calls to a separate helper functions. This
|
|
simplifies the code, and obviates the need to have an #ifdef block
|
|
each time l_netlink_send() is called. Many thanks to Matthieu Baerts
|
|
for making this suggestion.
|
|
|
|
* configure: Bump copyright year.
|
|
---
|
|
configure.ac | 8 +++-
|
|
lib/network_monitor.c | 95 +++++++++++++++++++++++++++++++------------
|
|
2 files changed, 77 insertions(+), 26 deletions(-)
|
|
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -2,7 +2,7 @@
|
|
# -*- Autoconf -*-
|
|
# Process this file with autoconf to produce a configure script.
|
|
#
|
|
-# Copyright (c) 2017-2023, Intel Corporation
|
|
+# Copyright (c) 2017-2024, Intel Corporation
|
|
|
|
AC_PREREQ([2.69])
|
|
AC_INIT([mptcpd],
|
|
@@ -265,6 +265,12 @@ AC_CHECK_FUNC([l_hashmap_replace],
|
|
[AC_DEFINE([HAVE_L_HASHMAP_REPLACE],
|
|
[],
|
|
[ELL has l_hashmap_replace()])])
|
|
+
|
|
+dnl l_netlink_message_new_sized() was introduced in ELL v0.68.
|
|
+AC_CHECK_FUNC([l_netlink_message_new_sized],
|
|
+ [AC_DEFINE([HAVE_L_NETLINK_MESSAGE_NEW_SIZED],
|
|
+ [],
|
|
+ [ELL has l_netlink_message_new_sized()])])
|
|
LIBS=$mptcpd_save_libs
|
|
|
|
# ---------------------------------------------------------------
|
|
--- a/lib/network_monitor.c
|
|
+++ b/lib/network_monitor.c
|
|
@@ -4,7 +4,7 @@
|
|
*
|
|
* @brief mptcpd network device monitoring.
|
|
*
|
|
- * Copyright (c) 2017-2022, Intel Corporation
|
|
+ * Copyright (c) 2017-2022, 2024, Intel Corporation
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
@@ -96,6 +96,51 @@ struct mptcpd_nm
|
|
};
|
|
|
|
// -------------------------------------------------------------------
|
|
+// Helper Functions
|
|
+// -------------------------------------------------------------------
|
|
+
|
|
+/**
|
|
+ * @brief Wrap different versions of ELL @c l_netlink_send().
|
|
+ *
|
|
+ * ELL 0.68 changed the API for @c l_netlink_send(). This helper
|
|
+ * function wraps the two different function calls so that mptcpd will
|
|
+ * work with both pre- and post-0.68 @c l_netlink_send() APIs.
|
|
+ */
|
|
+static unsigned int netlink_send(struct l_netlink *netlink,
|
|
+ uint16_t type,
|
|
+ uint16_t flags,
|
|
+ void const *data,
|
|
+ uint32_t len,
|
|
+ l_netlink_command_func_t function,
|
|
+ void *user_data,
|
|
+ l_netlink_destroy_func_t destroy)
|
|
+{
|
|
+#ifdef HAVE_L_NETLINK_MESSAGE_NEW_SIZED
|
|
+ // ELL >= 0.68
|
|
+ struct l_netlink_message *const message =
|
|
+ l_netlink_message_new_sized(type, flags, len);
|
|
+
|
|
+ l_netlink_message_add_header(message, data, len);
|
|
+
|
|
+ return l_netlink_send(netlink,
|
|
+ message,
|
|
+ function,
|
|
+ user_data,
|
|
+ destroy);
|
|
+#else
|
|
+ // ELL < 0.68
|
|
+ return l_netlink_send(netlink,
|
|
+ type,
|
|
+ flags,
|
|
+ data,
|
|
+ len,
|
|
+ function,
|
|
+ user_data,
|
|
+ destroy);
|
|
+#endif
|
|
+}
|
|
+
|
|
+// -------------------------------------------------------------------
|
|
// Network Address Information Handling
|
|
// -------------------------------------------------------------------
|
|
|
|
@@ -1015,14 +1060,14 @@ static void check_default_route(struct n
|
|
*/
|
|
mptcpd_addr_get(ai);
|
|
|
|
- if (l_netlink_send(ai->nm->rtnl,
|
|
- RTM_GETROUTE,
|
|
- 0,
|
|
- &store,
|
|
- buf - (char *) &store,
|
|
- handle_rtm_getroute,
|
|
- ai,
|
|
- NULL) == 0) {
|
|
+ if (netlink_send(ai->nm->rtnl,
|
|
+ RTM_GETROUTE,
|
|
+ 0,
|
|
+ &store,
|
|
+ buf - (char *) &store,
|
|
+ handle_rtm_getroute,
|
|
+ ai,
|
|
+ NULL) == 0) {
|
|
l_debug("Route lookup failed");
|
|
mptcpd_addr_put(ai);
|
|
}
|
|
@@ -1388,14 +1433,14 @@ static void send_getaddr_command(void *u
|
|
|
|
// Get IP addresses.
|
|
struct ifaddrmsg addr_msg = { .ifa_family = AF_UNSPEC };
|
|
- if (l_netlink_send(nm->rtnl,
|
|
- RTM_GETADDR,
|
|
- NLM_F_DUMP,
|
|
- &addr_msg,
|
|
- sizeof(addr_msg),
|
|
- handle_rtm_getaddr,
|
|
- nm,
|
|
- NULL) == 0) {
|
|
+ if (netlink_send(nm->rtnl,
|
|
+ RTM_GETADDR,
|
|
+ NLM_F_DUMP,
|
|
+ &addr_msg,
|
|
+ sizeof(addr_msg),
|
|
+ handle_rtm_getaddr,
|
|
+ nm,
|
|
+ NULL) == 0) {
|
|
l_error("Unable to obtain IP addresses.");
|
|
|
|
/*
|
|
@@ -1481,14 +1526,14 @@ struct mptcpd_nm *mptcpd_nm_create(uint3
|
|
* resulted in an EBUSY error.
|
|
*/
|
|
struct ifinfomsg link_msg = { .ifi_family = AF_UNSPEC };
|
|
- if (l_netlink_send(nm->rtnl,
|
|
- RTM_GETLINK,
|
|
- NLM_F_DUMP,
|
|
- &link_msg,
|
|
- sizeof(link_msg),
|
|
- handle_rtm_getlink,
|
|
- nm,
|
|
- send_getaddr_command)
|
|
+ if (netlink_send(nm->rtnl,
|
|
+ RTM_GETLINK,
|
|
+ NLM_F_DUMP,
|
|
+ &link_msg,
|
|
+ sizeof(link_msg),
|
|
+ handle_rtm_getlink,
|
|
+ nm,
|
|
+ send_getaddr_command)
|
|
== 0) {
|
|
l_error("Unable to obtain network devices.");
|
|
mptcpd_nm_destroy(nm);
|