summaryrefslogtreecommitdiff
path: root/net-misc/mptcpd
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-04-06 22:33:41 +0100
committerV3n3RiX <venerix@koprulu.sector>2022-04-06 22:33:41 +0100
commite68d405c5d712af4387159df07e226217bdda049 (patch)
tree009ab0f3d427f0813e62930d71802cb054c07e30 /net-misc/mptcpd
parent401101f9c8077911929d3f2b60a37098460a5d89 (diff)
gentoo resync : 06.04.2022
Diffstat (limited to 'net-misc/mptcpd')
-rw-r--r--net-misc/mptcpd/Manifest3
-rw-r--r--net-misc/mptcpd/files/mptcpd-0.9-loopback-monitoring.patch197
-rw-r--r--net-misc/mptcpd/mptcpd-0.9.ebuild3
3 files changed, 202 insertions, 1 deletions
diff --git a/net-misc/mptcpd/Manifest b/net-misc/mptcpd/Manifest
index 95dba01578c8..616c95796f1a 100644
--- a/net-misc/mptcpd/Manifest
+++ b/net-misc/mptcpd/Manifest
@@ -1,4 +1,5 @@
+AUX mptcpd-0.9-loopback-monitoring.patch 6941 BLAKE2B f3798b5da940266cad94093e0ab16c93546ac62923b94f947ffdefea89b864776ef668d6359c6a7b7f5f675b05dd4d55f73ea55f632fb209eb12b99c8f585975 SHA512 cf3cc223d46ad568b25c5bb9c583ad388d558242956692328c9582d11c73e69d2acc58661607b9ec44b71abc5265f6171529d34b21cabf5f16c313bf05d2a7a6
DIST mptcpd-0.9.tar.gz 654063 BLAKE2B fd9e8bf5cec517c934b9d38a736a128d087b54b5e4db90816a8cf8c242195fec8e3c4cd28d2f6e5a93326cac311a6b29048313c722004cea39e19448dc467976 SHA512 4fd292304d6270351b865e86cc401c1f5cc9043606b171e852bd37b2472c5f80061d760be68e5cd965caccb2f25c03d9ceea6232a5a587016c81f85e68ca8882
-EBUILD mptcpd-0.9.ebuild 1103 BLAKE2B 629897a77071480b8516bc646df0852838a88fe8122581ba13ff178691e3311dc9927d78502d7bb415fd506eb435887ff4b348f8a53d24b04966e9812eb381f8 SHA512 f9c005fbad040d994458e7c8cd9b64f929368de5f7d2ee7abc5f2d84deb944228d04966820c71bb01c42940001e8dc5e5110b268b9be8f9eefa9d33ed80403b0
+EBUILD mptcpd-0.9.ebuild 1161 BLAKE2B 1cbefb7a16d7bcfb267e5c40ca708fd5908e6a9e214671419950b63f2012a80617c537a4d5eb4f4d2d4c82f5b53cfaf2d5c595f4a6aadb566fad0bb11da4c736 SHA512 d7449fcd0eb50db970a7174624250c8f4b743a967c8a9f058063a01e6915d56586991228204445f630edce0743a1879576734e782ad73d971cafd7590ff0b40a
EBUILD mptcpd-9999.ebuild 1103 BLAKE2B 629897a77071480b8516bc646df0852838a88fe8122581ba13ff178691e3311dc9927d78502d7bb415fd506eb435887ff4b348f8a53d24b04966e9812eb381f8 SHA512 f9c005fbad040d994458e7c8cd9b64f929368de5f7d2ee7abc5f2d84deb944228d04966820c71bb01c42940001e8dc5e5110b268b9be8f9eefa9d33ed80403b0
MISC metadata.xml 326 BLAKE2B 77d6f17ab473dfbdd5d156b8c6020ba80cf49d95fc9693c88b6f6a5f2a9449cc0caa53ba000183a4fba747d7e298b77528346c680049ea28fa86b9c308da0a34 SHA512 1150bc86b2b12c042e0de7eab7701808a703bd0a42e5a38eac94e07131f3138ee6c010644fd1837ef6240e1c83cf51553f8f99fd03970a2f84252aeee7e76f06
diff --git a/net-misc/mptcpd/files/mptcpd-0.9-loopback-monitoring.patch b/net-misc/mptcpd/files/mptcpd-0.9-loopback-monitoring.patch
new file mode 100644
index 000000000000..38061a754a4d
--- /dev/null
+++ b/net-misc/mptcpd/files/mptcpd-0.9-loopback-monitoring.patch
@@ -0,0 +1,197 @@
+From a200ef26e4daf0347dd8f1bd35d49dd66fba7a7e Mon Sep 17 00:00:00 2001
+From: Ossama Othman <ossama.othman@intel.com>
+Date: Thu, 17 Feb 2022 16:39:59 -0800
+Subject: [PATCH] Allow loopback network interface monitoring. (#220)
+
+* network_monitor: Allow loopback monitoring.
+
+Add a new mptcpd_nm_monitor_loopback() function that allows the user
+to enable monitoring of loopback network interfaces. Monitoring of
+loopback network interfaces is meant primarily for testing purposes.
+Mptcpd will retain the previous behavior of only monitoring
+non-loopback network interfaces by default.
+
+* tests: Enable loopback interface monitoring.
+
+Enable loopback network interface monitoring to allow the
+test-network-monitor unit test to succeed in cases where non-loopback
+interfaces are unavailable, such as in a sandboxed environment.
+
+Fixes #208.
+
+Co-authored-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
+---
+ include/mptcpd/network_monitor.h | 21 ++++++++++++++++++
+ lib/network_monitor.c | 38 +++++++++++++++++++++-----------
+ tests/test-network-monitor.c | 15 +++++++++----
+ 3 files changed, 57 insertions(+), 17 deletions(-)
+
+diff --git a/include/mptcpd/network_monitor.h b/include/mptcpd/network_monitor.h
+index dc35e3d..ea1a95b 100644
+--- a/include/mptcpd/network_monitor.h
++++ b/include/mptcpd/network_monitor.h
+@@ -213,6 +213,27 @@ MPTCPD_API bool mptcpd_nm_register_ops(struct mptcpd_nm *nm,
+ struct mptcpd_nm_ops const *ops,
+ void *user_data);
+
++/**
++ * @brief Enable monitoring of the loopback network interface.
++ *
++ * Mptcpd normally only monitors non-loopback network interfaces.
++ * Call this function to enable monitoring of loopback network
++ * interfaces.
++ *
++ * @note Mptcpd monitoring of loopback network interfaces is meant
++ * primarily for testing purposes.
++ *
++ * @param[in,out] nm Pointer to the mptcpd network monitor
++ * object.
++ * @param[in] enable Enable or disable monitoring of loopback
++ * network interfaces.
++ *
++ * @retval true Successfully enable or disabled.
++ * @retval false Invalid @a nm argument.
++ */
++MPTCPD_API bool mptcpd_nm_monitor_loopback(struct mptcpd_nm *nm,
++ bool enable);
++
+ #ifdef __cplusplus
+ }
+ #endif
+diff --git a/lib/network_monitor.c b/lib/network_monitor.c
+index 2ae275b..7a3927e 100644
+--- a/lib/network_monitor.c
++++ b/lib/network_monitor.c
+@@ -4,7 +4,7 @@
+ *
+ * @brief mptcpd network device monitoring.
+ *
+- * Copyright (c) 2017-2021, Intel Corporation
++ * Copyright (c) 2017-2022, Intel Corporation
+ */
+
+ #ifdef HAVE_CONFIG_H
+@@ -78,6 +78,9 @@ struct mptcpd_nm
+
+ /// Flags controlling address notification.
+ uint32_t notify_flags;
++
++ /// Enable/disable loopback network interface monitoring.
++ bool monitor_loopback;
+ };
+
+ // -------------------------------------------------------------------
+@@ -525,16 +528,15 @@ static void mptcpd_interface_callback(void *data, void *user_data)
+ *
+ * @return @c true if network interface is ready, and @c false other.
+ */
+-static bool is_interface_ready(struct ifinfomsg const *ifi)
++static bool is_interface_ready(struct mptcpd_nm const *nm,
++ struct ifinfomsg const *ifi)
+ {
+- /*
+- Only accept non-loopback network interfaces that are
+- up and running.
+- */
+- static unsigned int const iff_ready = IFF_UP | IFF_RUNNING;
++ // Only accept network interfaces that are up and running.
++ static unsigned int iff_ready = IFF_UP | IFF_RUNNING;
+
+ return (ifi->ifi_flags & iff_ready) == iff_ready
+- && (ifi->ifi_flags & IFF_LOOPBACK) == 0;
++ && ((ifi->ifi_flags & IFF_LOOPBACK) == 0
++ || nm->monitor_loopback);
+ }
+
+ /**
+@@ -708,7 +710,7 @@ static void handle_link(uint16_t type,
+
+ switch (type) {
+ case RTM_NEWLINK:
+- if (is_interface_ready(ifi))
++ if (is_interface_ready(nm, ifi))
+ update_link(ifi, len, nm);
+ else
+ remove_link(ifi, nm); // Interface disabled.
+@@ -1301,7 +1303,7 @@ static void handle_rtm_getlink(int error,
+ struct ifinfomsg const *const ifi = data;
+ struct mptcpd_nm *const nm = user_data;
+
+- if (is_interface_ready(ifi)) {
++ if (is_interface_ready(nm, ifi)) {
+ (void) insert_link(ifi, len, nm);
+ }
+ }
+@@ -1442,9 +1444,10 @@ struct mptcpd_nm *mptcpd_nm_create(uint32_t flags)
+ return NULL;
+ }
+
+- nm->notify_flags = flags;
+- nm->interfaces = l_queue_new();
+- nm->ops = l_queue_new();
++ nm->notify_flags = flags;
++ nm->interfaces = l_queue_new();
++ nm->ops = l_queue_new();
++ nm->monitor_loopback = false;
+
+ /**
+ * Get network interface information.
+@@ -1555,6 +1558,15 @@ bool mptcpd_nm_register_ops(struct mptcpd_nm *nm,
+ return registered;
+ }
+
++bool mptcpd_nm_monitor_loopback(struct mptcpd_nm *nm, bool enable)
++{
++ if (nm == NULL)
++ return false;
++
++ nm->monitor_loopback = enable;
++
++ return true;
++}
+
+ /*
+ Local Variables:
+diff --git a/tests/test-network-monitor.c b/tests/test-network-monitor.c
+index d7c6b87..d22f6be 100644
+--- a/tests/test-network-monitor.c
++++ b/tests/test-network-monitor.c
+@@ -4,7 +4,7 @@
+ *
+ * @brief mptcpd network monitor test.
+ *
+- * Copyright (c) 2018-2020, Intel Corporation
++ * Copyright (c) 2018-2020, 2022, Intel Corporation
+ */
+
+ #define _DEFAULT_SOURCE // Enable IFF_... interface flags in <net/if.h>.
+@@ -115,12 +115,11 @@ static void check_interface(struct mptcpd_interface const *i, void *data)
+ l_queue_foreach(i->addrs, dump_addr, NULL);
+
+ /*
+- Only non-loopback interfaces that are up and running should
+- be monitored.
++ Only network interfaces that are up and running should be
++ monitored.
+ */
+ static unsigned int const ready = IFF_UP | IFF_RUNNING;
+ assert(ready == (i->flags & ready));
+- assert(!(i->flags & IFF_LOOPBACK));
+
+ if (data) {
+ struct foreach_data *const fdata = data;
+@@ -249,6 +248,14 @@ int main(void)
+ struct mptcpd_nm *const nm = mptcpd_nm_create(0);
+ assert(nm);
+
++ assert(!mptcpd_nm_monitor_loopback(NULL, true)); // Bad arg
++
++ /*
++ Enable loopback network interface monitoring for this unit
++ test in case non-loopback network interfaces are unavailable.
++ */
++ assert(mptcpd_nm_monitor_loopback(nm, true));
++
+ struct mptcpd_nm_ops const nm_events[] = {
+ {
+ .new_interface = handle_new_interface,
diff --git a/net-misc/mptcpd/mptcpd-0.9.ebuild b/net-misc/mptcpd/mptcpd-0.9.ebuild
index 8f307676ab46..a35610eb41ad 100644
--- a/net-misc/mptcpd/mptcpd-0.9.ebuild
+++ b/net-misc/mptcpd/mptcpd-0.9.ebuild
@@ -27,6 +27,9 @@ BDEPEND="
)
virtual/pkgconfig
"
+PATCHES=(
+ "${FILESDIR}/${P}-loopback-monitoring.patch"
+)
if [[ ${PV} == 9999* ]]; then
inherit git-r3