From d6908b2c5d7068177b895e2c0d158913e9f027f1 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Fri, 25 Oct 2024 19:54:29 +0100 Subject: [PATCH] mptcpd: add package Package Multipath TCP daemon (mptcpd) and wrapper (mptcpize). Signed-off-by: Daniel Golle --- net/mptcpd/Makefile | 66 ++ net/mptcpd/files/mptcpd.init | 11 + ...tening-socket-creation-optional.-297.patch | 193 ++++++ ...-ELL-0.68-l_netlink_message-API.-303.patch | 187 ++++++ ...50-ell-only-include-ell-ell.h-header.patch | 562 ++++++++++++++++++ .../patches/100-include-byteswap-h.patch | 19 + .../110-define-bswap_constant_32.patch | 20 + .../patches/120-no-format-security.patch | 11 + .../patches/130-simplify-log-function.patch | 23 + net/mptcpd/patches/140-no-error-h.patch | 30 + 10 files changed, 1122 insertions(+) create mode 100644 net/mptcpd/Makefile create mode 100644 net/mptcpd/files/mptcpd.init create mode 100644 net/mptcpd/patches/001-Make-listening-socket-creation-optional.-297.patch create mode 100644 net/mptcpd/patches/002-Support-ELL-0.68-l_netlink_message-API.-303.patch create mode 100644 net/mptcpd/patches/050-ell-only-include-ell-ell.h-header.patch create mode 100644 net/mptcpd/patches/100-include-byteswap-h.patch create mode 100644 net/mptcpd/patches/110-define-bswap_constant_32.patch create mode 100644 net/mptcpd/patches/120-no-format-security.patch create mode 100644 net/mptcpd/patches/130-simplify-log-function.patch create mode 100644 net/mptcpd/patches/140-no-error-h.patch diff --git a/net/mptcpd/Makefile b/net/mptcpd/Makefile new file mode 100644 index 0000000000..06be10e10f --- /dev/null +++ b/net/mptcpd/Makefile @@ -0,0 +1,66 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=mptcpd +PKG_VERSION:=0.12 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://github.com/multipath-tcp/mptcpd/releases/download/v$(PKG_VERSION) +PKG_HASH:=0507d497383b773a168cd35f4680b41894fcd8d941cb6619800a8e2bed831cbe + +PKG_MAINTAINER:=Daniel Golle +PKG_LICENSE:=BSD-3-clause +PKG_LICENSE_FILES:=COPYING + +PKG_BUILD_DEPENDS:=USE_MUSL:argp-standalone +PKG_BUILD_PARALLEL:=1 +PKG_CHECK_FORMAT_SECURITY:=0 +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +CONFIGURE_ARGS += --with-kernel=upstream + +define Package/mptcpd/Default + SECTION:=net + CATEGORY:=Network + DEPENDS:=+ell + URL:=https://github.com/multipath-tcp/mptcpd +endef + +define Package/mptcpd + $(call Package/mptcpd/Default) + TITLE:=Multipath TCP Daemon +endef + +define Package/mptcpize + $(call Package/mptcpd/Default) + TITLE:=Multipath TCP wrapper +endef + +define Package/mptcpd/conffiles +/etc/mptcpd/mptcpd.conf +endef + +define Package/mptcpd/install + $(INSTALL_DIR) $(1)/etc/mptcpd + $(CP) $(PKG_INSTALL_DIR)/etc/mptcpd/mptcpd.conf $(1)/etc/mptcpd + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/mptcpd $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/lib/mptcpd + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmptcpd.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/mptcpd/*.so $(1)/usr/lib/mptcpd + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/mptcpd.init $(1)/etc/init.d/mptcpd +endef + +define Package/mptcpize/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/mptcpize $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/lib/mptcpize + $(CP) $(PKG_INSTALL_DIR)/usr/lib/mptcpize/libmptcpwrap.so* $(1)/usr/lib/mptcpize +endef + +$(eval $(call BuildPackage,mptcpd)) +$(eval $(call BuildPackage,mptcpize)) diff --git a/net/mptcpd/files/mptcpd.init b/net/mptcpd/files/mptcpd.init new file mode 100644 index 0000000000..2f39989233 --- /dev/null +++ b/net/mptcpd/files/mptcpd.init @@ -0,0 +1,11 @@ +#!/bin/sh /etc/rc.common + +USE_PROCD=1 +START=10 + +start_service() { + procd_open_instance + procd_set_param command /usr/bin/mptcpd + procd_set_param respawn + procd_close_instance +} diff --git a/net/mptcpd/patches/001-Make-listening-socket-creation-optional.-297.patch b/net/mptcpd/patches/001-Make-listening-socket-creation-optional.-297.patch new file mode 100644 index 0000000000..829532e0fa --- /dev/null +++ b/net/mptcpd/patches/001-Make-listening-socket-creation-optional.-297.patch @@ -0,0 +1,193 @@ +From 334bb9c87005d851f4f2549f95342b8d0a41a6db Mon Sep 17 00:00:00 2001 +From: marco-a-itl +Date: Fri, 23 Aug 2024 11:05:35 +0200 +Subject: [PATCH] Make listening socket creation optional. (#297) + +In some cases, it is known in advanced that external applications have +created or will create listening sockets, and mptcpd doesn't need to do +that to avoid reporting failures because the address and port are +already in use. + +This commit makes listening socket creation optional for userspace path +manager plugins by extending the API: it is now possible to call +`mptcpd_pm_add_addr_no_listener()` instead of `mptcpd_pm_add_addr()` to +announce a new address without creating a new listener socket. + +Fixes #296. +--- + include/mptcpd/path_manager.h | 18 ++++++++++++++++ + include/mptcpd/private/path_manager.h | 31 ++++++++++++++++----------- + lib/path_manager.c | 28 +++++++++++++++++++----- + src/netlink_pm_mptcp_org.c | 5 ++++- + src/netlink_pm_upstream.c | 25 ++++++++++----------- + 5 files changed, 76 insertions(+), 31 deletions(-) + +--- a/include/mptcpd/path_manager.h ++++ b/include/mptcpd/path_manager.h +@@ -127,6 +127,24 @@ MPTCPD_API int mptcpd_pm_add_addr(struct + mptcpd_token_t token); + + /** ++ * @brief Advertise new network address to peers without creating a listener. ++ * ++ * @param[in] pm The mptcpd path manager object. ++ * @param[in,out] addr Local IP address and port to be advertised ++ * through the MPTCP protocol @c ADD_ADDR ++ * option. If the port is zero no port will be ++ * specified on the underlying protocol level. ++ * @param[in] id MPTCP local address ID. ++ * @param[in] token MPTCP connection token. ++ * ++ * @return @c 0 if operation was successful. -1 or @c errno otherwise. ++ */ ++MPTCPD_API int mptcpd_pm_add_addr_no_listener(struct mptcpd_pm *pm, ++ struct sockaddr *addr, ++ mptcpd_aid_t id, ++ mptcpd_token_t token); ++ ++/** + * @brief Stop advertising network address to peers. + * + * @param[in] pm The mptcpd path manager object. +--- a/include/mptcpd/private/path_manager.h ++++ b/include/mptcpd/private/path_manager.h +@@ -138,18 +138,22 @@ struct mptcpd_pm_cmd_ops + /** + * @brief Advertise new network address to peers. + * +- * @param[in] pm The mptcpd path manager object. +- * @param[in,out] addr Local IP address and port to be +- * advertised through the MPTCP protocol +- * @c ADD_ADDR option. If the port is +- * zero an ephemeral port will be chosen, +- * and assigned to the appropriate +- * underlying address family-specific +- * port member, e.g. @c sin_port or +- * @c sin6_port. The port will be in +- * network byte order. +- * @param[in] id MPTCP local address ID. +- * @param[in] token MPTCP connection token. ++ * @param[in] pm The mptcpd path manager object. ++ * @param[in,out] addr Local IP address and port to be ++ * advertised through the MPTCP protocol ++ * @c ADD_ADDR option. If the port is ++ * zero an ephemeral port will be chosen, ++ * and assigned to the appropriate ++ * underlying address family-specific ++ * port member, e.g. @c sin_port or ++ * @c sin6_port. The port will be in ++ * network byte order. ++ * If listener is not created, port zero ++ * will cause no port specification at ++ * protocol level. ++ * @param[in] id MPTCP local address ID. ++ * @param[in] token MPTCP connection token. ++ * @param[in] listener Create listener. + * + * @return @c 0 if operation was successful. -1 or @c errno + * otherwise. +@@ -157,7 +161,8 @@ struct mptcpd_pm_cmd_ops + int (*add_addr)(struct mptcpd_pm *pm, + struct sockaddr *addr, + mptcpd_aid_t id, +- mptcpd_token_t token); ++ mptcpd_token_t token, ++ bool listener); + + /** + * @brief Stop advertising network address to peers. +--- a/lib/path_manager.c ++++ b/lib/path_manager.c +@@ -238,10 +238,11 @@ int mptcpd_kpm_set_flags(struct mptcpd_p + + // ------------------------------------------------------------------- + +-int mptcpd_pm_add_addr(struct mptcpd_pm *pm, +- struct sockaddr *addr, +- mptcpd_aid_t address_id, +- mptcpd_token_t token) ++static int do_pm_add_addr(struct mptcpd_pm *pm, ++ struct sockaddr *addr, ++ mptcpd_aid_t address_id, ++ mptcpd_token_t token, ++ bool listener) + { + if (pm == NULL || addr == NULL || address_id == 0) + return EINVAL; +@@ -258,7 +259,24 @@ int mptcpd_pm_add_addr(struct mptcpd_pm + return ops->add_addr(pm, + addr, + address_id, +- token); ++ token, ++ listener); ++} ++ ++int mptcpd_pm_add_addr(struct mptcpd_pm *pm, ++ struct sockaddr *addr, ++ mptcpd_aid_t address_id, ++ mptcpd_token_t token) ++{ ++ return do_pm_add_addr(pm, addr, address_id, token, true); ++} ++ ++int mptcpd_pm_add_addr_no_listener(struct mptcpd_pm *pm, ++ struct sockaddr *addr, ++ mptcpd_aid_t address_id, ++ mptcpd_token_t token) ++{ ++ return do_pm_add_addr(pm, addr, address_id, token, false); + } + + int mptcpd_pm_remove_addr(struct mptcpd_pm *pm, +--- a/src/netlink_pm_mptcp_org.c ++++ b/src/netlink_pm_mptcp_org.c +@@ -155,8 +155,11 @@ static bool append_remote_addr_attr(stru + static int mptcp_org_add_addr(struct mptcpd_pm *pm, + struct sockaddr *addr, + mptcpd_aid_t id, +- mptcpd_token_t token) ++ mptcpd_token_t token, ++ bool listener) + { ++ (void) listener; ++ + /* + Payload: + Token +--- a/src/netlink_pm_upstream.c ++++ b/src/netlink_pm_upstream.c +@@ -219,20 +219,21 @@ static int send_add_addr(struct mptcpd_p + static int upstream_announce(struct mptcpd_pm *pm, + struct sockaddr *addr, + mptcpd_aid_t id, +- mptcpd_token_t token) ++ mptcpd_token_t token, ++ bool listener) + { +- /** +- * Set up MPTCP listening socket. +- * +- * @note An ephemeral port will be assigned to the port in +- * @a addr if it is zero. +- * +- * @todo This should be optional. +- */ +- int const r = mptcpd_lm_listen(pm->lm, addr); ++ if (listener) { ++ /** ++ * Set up MPTCP listening socket. ++ * ++ * @note An ephemeral port will be assigned to the port in ++ * @a addr if it is zero. ++ */ ++ int const r = mptcpd_lm_listen(pm->lm, addr); + +- if (r != 0) +- return r; ++ if (r != 0) ++ return r; ++ } + + /** + * @todo Add support for the optional network interface index diff --git a/net/mptcpd/patches/002-Support-ELL-0.68-l_netlink_message-API.-303.patch b/net/mptcpd/patches/002-Support-ELL-0.68-l_netlink_message-API.-303.patch new file mode 100644 index 0000000000..0fe6a4ba7f --- /dev/null +++ b/net/mptcpd/patches/002-Support-ELL-0.68-l_netlink_message-API.-303.patch @@ -0,0 +1,187 @@ +From ffa276fc8ee18321b3c2f22deae2e254a69ae4dc Mon Sep 17 00:00:00 2001 +From: Ossama Othman +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); diff --git a/net/mptcpd/patches/050-ell-only-include-ell-ell.h-header.patch b/net/mptcpd/patches/050-ell-only-include-ell-ell.h-header.patch new file mode 100644 index 0000000000..d3b3e77b6e --- /dev/null +++ b/net/mptcpd/patches/050-ell-only-include-ell-ell.h-header.patch @@ -0,0 +1,562 @@ +From b1239f7518de8d5d59ac51e3b9e30f45c7286c80 Mon Sep 17 00:00:00 2001 +From: "Matthieu Baerts (NGI0)" +Date: Sat, 26 Oct 2024 12:41:31 +0200 +Subject: [PATCH] ell: only include 'ell/ell.h' header + +When looking at the code of other projects using ELL (IWD, BlueZ, +Ofono), it looks like only 'ell.h' should be included, not individual +header files from the 'ell' header directory. + +That looks like the way to go, because when looking at ell/genl.h, it +uses functions declared in ell/netlink.h, without including this file +before. This causes issues when compiling the code using libell-dev +installed on the system: + + libtool: compile: gcc (...) -c path_manager.c (...) + In file included from path_manager.c:21: + /usr/include/ell/genl.h: In function 'l_genl_attr_next': + /usr/include/ell/genl.h:98:16: error: implicit declaration of function 'l_netlink_attr_next'; did you mean 'l_genl_attr_next'? [-Wimplicit-function-declaration] + 98 | return l_netlink_attr_next((struct l_netlink_attr *) attr, + | ^~~~~~~~~~~~~~~~~~~ + | l_genl_attr_next + /usr/include/ell/genl.h: In function 'l_genl_attr_recurse': + /usr/include/ell/genl.h:105:16: error: implicit declaration of function 'l_netlink_attr_recurse'; did you mean 'l_genl_attr_recurse'? [-Wimplicit-function-declaration] + 105 | return l_netlink_attr_recurse((struct l_netlink_attr *) attr, + | ^~~~~~~~~~~~~~~~~~~~~~ + | l_genl_attr_recurse + make[2]: *** [Makefile:597: libmptcpd_la-path_manager.lo] Error 1 + +All .c files including ELL header files have been modified to include +only . The .cpp file in the tests has not been modified, +because it looks like that causes some issues. For the same reason, +include/mptcpd/private/plugin.h file has not been modified as well. + +Closes: #302 +Signed-off-by: Matthieu Baerts (NGI0) +--- + lib/hash_sockaddr.c | 6 +----- + lib/id_manager.c | 9 +-------- + lib/listener_manager.c | 8 +------- + lib/network_monitor.c | 10 +--------- + lib/path_manager.c | 8 +------- + lib/plugin.c | 8 +------- + lib/sockaddr.c | 5 +---- + plugins/path_managers/addr_adv.c | 7 +------ + plugins/path_managers/sspi.c | 7 +------ + src/commands.c | 7 +------ + src/configuration.c | 9 +-------- + src/mptcpd.c | 7 +------ + src/netlink_pm.c | 6 +----- + src/netlink_pm_mptcp_org.c | 4 +--- + src/netlink_pm_upstream.c | 7 +------ + src/path_manager.c | 9 +-------- + tests/plugins/noop/noop.c | 6 +----- + tests/plugins/priority/one.c | 6 +----- + tests/plugins/priority/two.c | 6 +----- + tests/plugins/security/four.c | 6 +----- + tests/plugins/security/three.c | 6 +----- + tests/test-addr-info.c | 3 +-- + tests/test-commands.c | 11 +---------- + tests/test-configuration.c | 8 +------- + tests/test-id-manager.c | 3 +-- + tests/test-listener-manager.c | 7 +------ + tests/test-murmur-hash.c | 7 +------ + tests/test-network-monitor.c | 9 +-------- + tests/test-path-manager.c | 9 +-------- + tests/test-plugin.c | 3 +-- + tests/test-sockaddr.c | 7 +------ + 31 files changed, 31 insertions(+), 183 deletions(-) + +--- a/lib/hash_sockaddr.c ++++ b/lib/hash_sockaddr.c +@@ -16,11 +16,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#pragma GCC diagnostic pop +- ++#include + + #include + +--- a/lib/id_manager.c ++++ b/lib/id_manager.c +@@ -20,14 +20,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/lib/listener_manager.c ++++ b/lib/listener_manager.c +@@ -19,13 +19,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/lib/network_monitor.c ++++ b/lib/network_monitor.c +@@ -23,15 +23,7 @@ + #include // For standard network interface flags. + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/lib/path_manager.c ++++ b/lib/path_manager.c +@@ -16,13 +16,7 @@ + + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/lib/plugin.c ++++ b/lib/plugin.c +@@ -20,13 +20,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + /** + * @todo Remove this preprocessor symbol definition once support for +--- a/lib/sockaddr.c ++++ b/lib/sockaddr.c +@@ -11,10 +11,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#pragma GCC diagnostic pop ++#include + + #include + +--- a/plugins/path_managers/addr_adv.c ++++ b/plugins/path_managers/addr_adv.c +@@ -13,12 +13,7 @@ + + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by ELL log macros. +-#include +-#pragma GCC diagnostic pop +- ++#include + + #include + #include +--- a/plugins/path_managers/sspi.c ++++ b/plugins/path_managers/sspi.c +@@ -17,12 +17,7 @@ + + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/src/commands.c ++++ b/src/commands.c +@@ -16,12 +16,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include // For L_STRINGIFY needed by l_error(), etc. +-#include +-#pragma GCC diagnostic pop ++#include + + #include "commands.h" + +--- a/src/configuration.c ++++ b/src/configuration.c +@@ -21,14 +21,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + +--- a/src/mptcpd.c ++++ b/src/mptcpd.c +@@ -15,12 +15,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + +--- a/src/netlink_pm.c ++++ b/src/netlink_pm.c +@@ -10,11 +10,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include "netlink_pm.h" + +--- a/src/netlink_pm_mptcp_org.c ++++ b/src/netlink_pm_mptcp_org.c +@@ -15,9 +15,7 @@ + #include + #include + +-#include +-#include // For L_STRINGIFY needed by l_error(), etc. +-#include ++#include + + #include "commands.h" + #include "netlink_pm.h" +--- a/src/netlink_pm_upstream.c ++++ b/src/netlink_pm_upstream.c +@@ -15,12 +15,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include // For L_STRINGIFY needed by l_error(), etc. +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/src/path_manager.c ++++ b/src/path_manager.c +@@ -21,14 +21,7 @@ + #include // For inet_ntop(). + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/tests/plugins/noop/noop.c ++++ b/tests/plugins/noop/noop.c +@@ -7,11 +7,7 @@ + * Copyright (c) 2019-2022, Intel Corporation + */ + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#pragma GCC diagnostic pop ++#include + + #ifdef HAVE_CONFIG_H + # include +--- a/tests/plugins/priority/one.c ++++ b/tests/plugins/priority/one.c +@@ -7,11 +7,7 @@ + * Copyright (c) 2019-2022, Intel Corporation + */ + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#pragma GCC diagnostic pop ++#include + + #ifdef HAVE_CONFIG_H + # include +--- a/tests/plugins/priority/two.c ++++ b/tests/plugins/priority/two.c +@@ -7,11 +7,7 @@ + * Copyright (c) 2019-2022, Intel Corporation + */ + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#pragma GCC diagnostic pop ++#include + + #ifdef HAVE_CONFIG_H + # include +--- a/tests/plugins/security/four.c ++++ b/tests/plugins/security/four.c +@@ -7,11 +7,7 @@ + * Copyright (c) 2019-2022, Intel Corporation + */ + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#pragma GCC diagnostic pop ++#include + + #ifdef HAVE_CONFIG_H + # include +--- a/tests/plugins/security/three.c ++++ b/tests/plugins/security/three.c +@@ -7,11 +7,7 @@ + * Copyright (c) 2019-2022, Intel Corporation + */ + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // For L_STRINGIFY needed by l_error(). +-#include +-#pragma GCC diagnostic pop ++#include + + #ifdef HAVE_CONFIG_H + # include +--- a/tests/test-addr-info.c ++++ b/tests/test-addr-info.c +@@ -8,8 +8,7 @@ + */ + + #include // htonl() and htons() +-#include +-#include ++#include + + #include + #include +--- a/tests/test-commands.c ++++ b/tests/test-commands.c +@@ -14,16 +14,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include // Needed by +-#include +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + // Internal Headers + // ----------------- +--- a/tests/test-configuration.c ++++ b/tests/test-configuration.c +@@ -7,13 +7,7 @@ + * Copyright (c) 2019, 2021, Intel Corporation + */ + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include // Needed by +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include // INTERNAL! + +--- a/tests/test-id-manager.c ++++ b/tests/test-id-manager.c +@@ -9,8 +9,7 @@ + + #include + +-#include +-#include ++#include + + #include + #include +--- a/tests/test-listener-manager.c ++++ b/tests/test-listener-manager.c +@@ -11,12 +11,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/tests/test-murmur-hash.c ++++ b/tests/test-murmur-hash.c +@@ -10,12 +10,7 @@ + #include + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include // Needed by . +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + +--- a/tests/test-network-monitor.c ++++ b/tests/test-network-monitor.c +@@ -15,14 +15,7 @@ + #include // For INET_ADDRSTRLEN and INET6_ADDRSTRLEN. + #include // For standard network interface flags. + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include // Needed by +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + #include +--- a/tests/test-path-manager.c ++++ b/tests/test-path-manager.c +@@ -9,14 +9,7 @@ + + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#include // Needed by +-#include +-#pragma GCC diagnostic pop ++#include + + #include "test-util.h" + +--- a/tests/test-plugin.c ++++ b/tests/test-plugin.c +@@ -14,8 +14,7 @@ + #include + #include + +-#include +-#include ++#include + + #include + #include +--- a/tests/test-sockaddr.c ++++ b/tests/test-sockaddr.c +@@ -9,12 +9,7 @@ + + #include + +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wpedantic" +-#include +-#include +-#include +-#pragma GCC diagnostic pop ++#include + + #include + diff --git a/net/mptcpd/patches/100-include-byteswap-h.patch b/net/mptcpd/patches/100-include-byteswap-h.patch new file mode 100644 index 0000000000..95ccf572e3 --- /dev/null +++ b/net/mptcpd/patches/100-include-byteswap-h.patch @@ -0,0 +1,19 @@ +From 80e5db2774a902f6a2f32741fe762888343222d9 Mon Sep 17 00:00:00 2001 +From: lifei76 +Date: Thu, 20 Jul 2023 16:33:42 +0800 +Subject: [PATCH 03/11] 1 + +--- + lib/network_monitor.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/lib/network_monitor.c ++++ b/lib/network_monitor.c +@@ -18,6 +18,7 @@ + #include + #include + ++#include + #include + #include + #include // For standard network interface flags. diff --git a/net/mptcpd/patches/110-define-bswap_constant_32.patch b/net/mptcpd/patches/110-define-bswap_constant_32.patch new file mode 100644 index 0000000000..4484ca98ac --- /dev/null +++ b/net/mptcpd/patches/110-define-bswap_constant_32.patch @@ -0,0 +1,20 @@ +--- a/include/mptcpd/private/sockaddr.h ++++ b/include/mptcpd/private/sockaddr.h +@@ -18,6 +18,17 @@ + + #include + ++#ifndef __bswap_constant_32 ++#define __bswap_constant_32(x) \ ++ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \ ++ | (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) ++#endif ++ ++#ifndef __bswap_constant_16 ++#define __bswap_constant_16(x) \ ++ ((__uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) ++#endif ++ + /** + * @name Swap host ordered bytes in an integer to network byte order. + * diff --git a/net/mptcpd/patches/120-no-format-security.patch b/net/mptcpd/patches/120-no-format-security.patch new file mode 100644 index 0000000000..3a183fb2b8 --- /dev/null +++ b/net/mptcpd/patches/120-no-format-security.patch @@ -0,0 +1,11 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -321,7 +321,7 @@ AS_IF([test "x$enable_stack_protection" + # Format string vulnerabilities + # -Wformat=2 implies: + # -Wformat -Wformat-nonliteral -Wformat-security -Wformat-y2k +-AX_APPEND_COMPILE_FLAGS([-Wformat=2]) ++# AX_APPEND_COMPILE_FLAGS([-Wformat=2]) + + # Position Independent Execution (PIE) + AX_APPEND_COMPILE_FLAGS([-fPIE], [EXECUTABLE_CFLAGS]) diff --git a/net/mptcpd/patches/130-simplify-log-function.patch b/net/mptcpd/patches/130-simplify-log-function.patch new file mode 100644 index 0000000000..076c46645d --- /dev/null +++ b/net/mptcpd/patches/130-simplify-log-function.patch @@ -0,0 +1,23 @@ +From 7e1cc2d933976c20bec932613172b56c5172b7f0 Mon Sep 17 00:00:00 2001 +From: lifei76 +Date: Thu, 20 Jul 2023 18:24:37 +0800 +Subject: [PATCH 09/11] 7 + +--- + src/configuration.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/src/configuration.c ++++ b/src/configuration.c +@@ -52,7 +52,10 @@ + # error Problem configuring default log message destination. + #endif + /// Name of the default logging function determined at compile-time. +-#define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER) ++ // #define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER) ++ ++#define MPTCPD_SET_LOG_FUNCTION l_log_set_stderr ++ + + /** + * @brief Get the function that sets the log message destination. diff --git a/net/mptcpd/patches/140-no-error-h.patch b/net/mptcpd/patches/140-no-error-h.patch new file mode 100644 index 0000000000..b057c7b43c --- /dev/null +++ b/net/mptcpd/patches/140-no-error-h.patch @@ -0,0 +1,30 @@ +--- a/src/mptcpize.c ++++ b/src/mptcpize.c +@@ -18,7 +18,7 @@ + #include + #include + #include +-#include ++//#include + #include + #include + #include +@@ -36,6 +36,18 @@ + #define PRELOAD_VAR "LD_PRELOAD=" + #define MPTCPWRAP_ENV "LD_PRELOAD="PKGLIBDIR"/libmptcpwrap.so.0.0."LIBREVISION + ++#define error(status, errnum, fmt, ...) do { \ ++ if (errnum) { \ ++ errno = errnum; \ ++ perror(fmt); \ ++ } else { \ ++ fprintf(stderr, "%s\n", fmt); \ ++ } \ ++ if (status) \ ++ exit(status); \ ++} while(0) ++ ++ + /* Program documentation. */ + static char args_doc[] = "CMD"; + -- 2.30.2