Compare commits

...

10 Commits

Author SHA1 Message Date
Davide Caratti 81ea308588 workaround for broken uAPI headers in upstream kernels 2023-05-18 15:52:53 +00:00
Davide Caratti 2bb0fc0142 fix mptcpize failures in some common scenarios
Resolves: #2015623

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2021-11-30 14:23:15 +01:00
Davide Caratti 004d212168 fix selftests
- fix typo in do_cleanup
- remove comments (no more need to mention the problem with link-locals)
- remove implicit dependency on procps-ng
- sleep 5 seconds before checking mptcp service, to allow settling of
  the endpoint list also on slow systems

Related: #2008796

Signed-off-by:Davide Caratti <dcaratti@redhat.com>
2021-10-12 11:43:32 +02:00
Davide Caratti e34899e7c8 fix default addr_adv plugin configuration
Related: #2008796

Signed-off-by:Davide Caratti <dcaratti@redhat.com>
2021-09-30 16:50:16 +02:00
Davide Caratti d63d197fa3 Update to release 0.8
Related: #2008796

Signed-off-by:Davide Caratti <dcaratti@redhat.com>
2021-09-30 09:12:49 +02:00
Mohan Boddu bf3b3b5642 Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
Signed-off-by: Mohan Boddu <mboddu@redhat.com>
2021-08-09 22:23:35 +00:00
Davide Caratti 0aee7ca3f6 fix 'check_conflicts' on multilib
Related: #1967697

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2021-06-23 18:22:07 +02:00
Davide Caratti f0e9a8533e backport for upstream issue #125
Related: #1967697

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2021-06-22 19:27:28 +02:00
Davide Caratti 4247433232 add mptcpd simple sanity test and enable gating
Resolves: #1962741
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2021-06-22 16:37:06 +02:00
Davide Caratti 351ab7ce12 update to release 0.7
Related: #1954118
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2021-05-06 11:15:46 +02:00
11 changed files with 333 additions and 3 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
/mptcpd-0.5.1.tar.gz
/mptcpd-0.6.tar.gz
/mptcpd-0.7.tar.gz
/mptcpd-0.8.tar.gz

1
.mptcpd.metadata Normal file
View File

@ -0,0 +1 @@
a75235d98b7d2ab1ed71e0bd9d1683e6da462bfb mptcpd-0.8.tar.gz

View File

@ -0,0 +1,31 @@
From 5633f08e35552295b2f9414ff32ca4e8e081b2f2 Mon Sep 17 00:00:00 2001
Message-Id: <5633f08e35552295b2f9414ff32ca4e8e081b2f2.1638196305.git.dcaratti@redhat.com>
From: Paolo Abeni <paolo.abeni@gmail.com>
Date: Tue, 12 Oct 2021 19:24:33 +0200
Subject: [PATCH] mptcpize: force MPTCP usage for IPPROTO_IP, too (#159)
The current ignores calls alike:
socket(AF_INET, SOCK_STREAM, IPPROTO_IP)
We should hijack them, too.
---
src/mptcpwrap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mptcpwrap.c b/src/mptcpwrap.c
index 37b0545..1aaf00f 100644
--- a/src/mptcpwrap.c
+++ b/src/mptcpwrap.c
@@ -27,7 +27,7 @@ int __attribute__((visibility("default"))) socket(int family, int type, int prot
goto do_socket;
// socket(AF_INET, SOCK_STREM, 0) maps to TCP, too
- if (protocol == 0 && protocol != IPPROTO_TCP)
+ if (protocol != 0 && protocol != IPPROTO_TCP)
goto do_socket;
protocol = IPPROTO_TCP + 256;
--
2.31.1

View File

@ -0,0 +1,75 @@
From 591b3b168d949c45d5b5994332a3007767845434 Mon Sep 17 00:00:00 2001
Message-Id: <591b3b168d949c45d5b5994332a3007767845434.1638277575.git.dcaratti@redhat.com>
From: Paolo Abeni <paolo.abeni@gmail.com>
Date: Thu, 14 Oct 2021 05:05:54 +0200
Subject: [PATCH] mptcpize: use explicit file copy instead of rename() (#161)
The mentioned syscall fails if the involved files belong to
different fs, which is pretty much expected in the relevant
scenario (tmp file, in tmpfs, and unit file usually under the
root partition)
Instead use sendfile() to explicitly copy all the contents. Note
that we need to close and re-open the unit file, as sendfile()
expect a O_WRITE fd as the target.
---
src/mptcpize.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/mptcpize.c b/src/mptcpize.c
index cb79e09..b502d75 100644
--- a/src/mptcpize.c
+++ b/src/mptcpize.c
@@ -13,6 +13,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/sendfile.h>
#include <argp.h>
#include <dlfcn.h>
@@ -163,10 +164,12 @@ static int unit_update(int argc, char *argv[], int enable)
char *unit, *line = NULL;
int append_env = enable;
char dst_path[PATH_MAX];
+ off_t bytes_copied = 0;
+ struct stat fileinfo;
+ int dst, unit_fd;
size_t len = 0;
ssize_t read;
FILE *src;
- int dst;
if (argc < 1) {
fprintf(stderr, "missing unit argument\n");
@@ -210,11 +213,24 @@ static int unit_update(int argc, char *argv[], int enable)
error(1, errno, "can't read from %s", unit);
free(line);
fclose(src);
- close(dst);
- if (rename(dst_path, unit) < 0)
- error(1, errno, "can't rename %s to %s", dst_path, unit);
+ // copy back the modified file into the original unit
+ // note: avoid using rename, as it fails across filesystems
+ if (fstat(dst, &fileinfo) < 0)
+ error(1, errno, "can't stat %s", dst_path);
+
+ // re-open the unit file for writing
+ // mkstemp already opened the temporary file for R/W so we don't need
+ // to touch that file descriptor.
+ unit_fd = open(unit, O_TRUNC | O_RDWR);
+ if (unit_fd < 0)
+ error(1, errno, "can't open %s for writing", unit);
+ while (bytes_copied < fileinfo.st_size)
+ if (sendfile(unit_fd, dst, &bytes_copied, fileinfo.st_size - bytes_copied) < 0)
+ error(1, errno, "can't copy from %s to %s", dst_path, unit);
+
+ close(dst);
if (system("systemctl daemon-reload") != 0)
error(1, errno, "can't reload unit, manual 'systemctl daemon-reload' is required");
--
2.31.1

View File

@ -0,0 +1,24 @@
diff --git a/etc/mptcpd.conf.in b/etc/mptcpd.conf.in
index 615c63b..c6b31ac 100644
--- a/etc/mptcpd.conf.in
+++ b/etc/mptcpd.conf.in
@@ -19,7 +19,6 @@ log=@mptcpd_logger@
# ----------------
# Plugin directory
# ----------------
-plugin-dir=@pkglibdir@
# -------------------
# Path manager plugin
diff --git a/src/mptcp.service.in b/src/mptcp.service.in
index 89dfe04..738f59f 100644
--- a/src/mptcp.service.in
+++ b/src/mptcp.service.in
@@ -9,7 +9,6 @@ Documentation=man:mptcpd(8)
[Service]
Type=simple
DynamicUser=yes
-Environment=LD_LIBRARY_PATH=@libdir@
ExecStart=@libexecdir@/mptcpd --log=journal
CapabilityBoundingSet=CAP_NET_ADMIN
AmbientCapabilities=CAP_NET_ADMIN

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -1,7 +1,7 @@
Summary: Multipath TCP daemon
Name: mptcpd
Version: 0.6
Release: 2%{?dist}
Version: 0.8
Release: 3%{?dist}
License: BSD
URL: https://multipath-tcp.org
Requires(post): systemd
@ -19,6 +19,11 @@ BuildRequires: systemd-rpm-macros
Source0: https://github.com/intel/mptcpd/archive/v%{version}/%{name}-%{version}.tar.gz
Patch2: workaround-build-issues-uapi.patch
Patch3: 0003-fix-multilib-install.patch
Patch4: 0001-mptcpize-force-MPTCP-usage-for-IPPROTO_IP-too-159.patch
Patch5: 0001-mptcpize-use-explicit-file-copy-instead-of-rename-16.patch
%description
The Multipath TCP Daemon is a daemon for Linux based operating systems that
performs multipath TCP path management related operations in user space. It
@ -52,6 +57,8 @@ install -d %{buildroot}/%{_unitdir}
install -d %{buildroot}/%{_libdir}/%{name}
install -d %{buildroot}/%{_includedir}/%{name}
%make_install
sed -i '/^# addr-flags=subflow/s/^# //g' %{buildroot}/%{_sysconfdir}/%{name}/%{name}.conf
sed -i '/^# notify-flags=existing,skip_link_local,skip_loopback/s/^# //g' %{buildroot}/%{_sysconfdir}/%{name}/%{name}.conf
find %{buildroot} -name '*.la' -exec rm -f {} ';'
%post -p /sbin/ldconfig
@ -65,9 +72,12 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%dir %{_libdir}/%{name}
%{_libdir}/libmptcpd.so.*
%{_libdir}/%{name}/*.so
%{_libdir}/%{name}/libmptcpwrap.so*
%{_libexecdir}/%{name}
%{_bindir}/mptcpize
%{_unitdir}/mptcp.service
%{_mandir}/man8/%{name}.8.gz
%{_mandir}/man8/mptcpize.8.gz
# todo add %doc
%license COPYING
@ -79,6 +89,29 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%{_libdir}/pkgconfig/mptcpd.pc
%changelog
* Wed Jul 6 2022 Davide Caratti <dcaratti@redhat.com> - 0.8-3
- workaround for uAPI header build issue
* Tue Nov 30 2021 Davide Caratti <dcaratti@redhat.com> - 0.8-2
- fix mptcpize to work also when protocol number is 0 (upstream issue #159)
and when command resides in another file system (upstream issue #161)
Related: rhbz#2015623
* Wed Sep 29 2021 Davide Caratti <dcaratti@redhat.com> - 0.8-1
- update to version 0.8
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 0.7-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Jun 23 2021 Davide Caratti <dcaratti@redhat.com> - 0.7-2
- add a simple sanity test and enable gating. Related: rhbz#1962741
- don't overwrite global build options. Related: rhbz#1967697
- fix 'check_conflicts' on multilib. Related: rhbz#1967697
* Wed Apr 28 2021 Davide Caratti <dcaratti@redhat.com> - 0.7-1
- update to version 0.7
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.6-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937

View File

@ -1 +1 @@
SHA512 (mptcpd-0.6.tar.gz) = b7ecd2f3959b28b1d1fd1b66f9a5815e9da2a861694b97bcdf90e57fc07947988e989145dc653f5e4f7a7cce3b9745c8fc8d7152081f28341830dc5041439c39
SHA512 (mptcpd-0.8.tar.gz) = acbbc9d42f8d233ea62276f20034a602395945a95b189c123a222d0312840693872b450233e254b3f2a32dae9265c32f5cd5a1de8c2093755f670aba4d267936

44
tests/sanity/mptcpd.sh Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash
set -e
exec 3>&1
export LANG=C
pretty() { echo -e "\x1b[32m\x1b[1m[+] ${1:+NS$1: }${2}\x1b[0m" >&3; }
pp() { pretty "" "$*"; "$@"; }
slp() { read -t "$1" -N 1 || true; }
do_cleanup() {
set +e
exec 2>/dev/null
pp systemctl stop mptcp
pp ip link del dev mptcp-dummy0 || true
# note: endpoints are still present after interface removal
pp ip mptcp endpoint flush || true
}
trap do_cleanup EXIT
do_setup() {
ip mptcp endpoint flush || true
ip link del dev mptcp-dummy0 2>/dev/null || true
pp modprobe dummy
pp systemctl restart mptcp
# settle to allow addition of all endpoints
sleep 5
pp systemctl is-active --quiet mptcp
pp ip mptcp limits set add_addr_accepted 8 subflows 8
pp ip link add name mptcp-dummy0 type dummy
pp ip link set dev mptcp-dummy0 up
pp ip address add dev mptcp-dummy0 192.0.2.10/24
}
do_check0() {
# settle to allow addition of all endpoints
sleep 5
pp ip mptcp endpoint show | grep "192\.0\.2\.10.*dev mptcp-dummy0"
pp echo done
}
do_setup
do_check0

12
tests/tests.yml Normal file
View File

@ -0,0 +1,12 @@
# Tests for mptcpd
- hosts: localhost
roles:
- role: standard-test-basic
required_packages:
- iproute
tags:
- classic
tests:
- sanity-tests:
dir: ./sanity
run: mptcpd.sh

View File

@ -0,0 +1,102 @@
--- a/configure.ac
+++ b/configure.ac
@@ -207,8 +207,7 @@ AC_CHECK_HEADERS([linux/mptcp.h],
AX_CHECK_DEFINE(
[linux/mptcp.h],
[MPTCP_PM_NAME],
- [AC_DEFINE([HAVE_LINUX_MPTCP_H_UPSTREAM], [1])
- AX_CHECK_DEFINE([linux/mptcp.h],
+ [AX_CHECK_DEFINE([linux/mptcp.h],
[MPTCP_PM_EV_GRP_NAME],
[AC_DEFINE([HAVE_LINUX_MPTCP_H_UPSTREAM_EVENTS],
[1])
--- a/include/linux/mptcp_upstream.h
+++ b/include/linux/mptcp_upstream.h
@@ -2,8 +2,16 @@
#ifndef _UAPI_MPTCP_H
#define _UAPI_MPTCP_H
+#ifndef __KERNEL__
+#include <netinet/in.h> /* for sockaddr_in and sockaddr_in6 */
+#include <sys/socket.h> /* for struct sockaddr */
+#endif
+
#include <linux/const.h>
#include <linux/types.h>
+#include <linux/in.h> /* for sockaddr_in */
+#include <linux/in6.h> /* for sockaddr_in6 */
+#include <linux/socket.h> /* for sockaddr_storage and sa_family */
#define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0)
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
@@ -48,6 +56,9 @@ enum {
MPTCP_PM_ATTR_ADDR, /* nested address */
MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */
MPTCP_PM_ATTR_SUBFLOWS, /* u32 */
+ MPTCP_PM_ATTR_TOKEN, /* u32 */
+ MPTCP_PM_ATTR_LOC_ID, /* u8 */
+ MPTCP_PM_ATTR_ADDR_REMOTE, /* nested address */
__MPTCP_PM_ATTR_MAX
};
@@ -73,6 +84,8 @@ enum {
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
+#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
+#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4)
enum {
MPTCP_PM_CMD_UNSPEC,
@@ -84,6 +97,10 @@ enum {
MPTCP_PM_CMD_SET_LIMITS,
MPTCP_PM_CMD_GET_LIMITS,
MPTCP_PM_CMD_SET_FLAGS,
+ MPTCP_PM_CMD_ANNOUNCE,
+ MPTCP_PM_CMD_REMOVE,
+ MPTCP_PM_CMD_SUBFLOW_CREATE,
+ MPTCP_PM_CMD_SUBFLOW_DESTROY,
__MPTCP_PM_CMD_AFTER_LAST
};
@@ -177,6 +194,7 @@ enum mptcp_event_attr {
MPTCP_ATTR_IF_IDX, /* s32 */
MPTCP_ATTR_RESET_REASON,/* u32 */
MPTCP_ATTR_RESET_FLAGS, /* u32 */
+ MPTCP_ATTR_SERVER_SIDE, /* u8 */
__MPTCP_ATTR_AFTER_LAST
};
@@ -192,4 +210,32 @@ enum mptcp_event_attr {
#define MPTCP_RST_EBADPERF 5
#define MPTCP_RST_EMIDDLEBOX 6
+struct mptcp_subflow_data {
+ __u32 size_subflow_data; /* size of this structure in userspace */
+ __u32 num_subflows; /* must be 0, set by kernel */
+ __u32 size_kernel; /* must be 0, set by kernel */
+ __u32 size_user; /* size of one element in data[] */
+} __attribute__((aligned(8)));
+
+struct mptcp_subflow_addrs {
+ union {
+ __kernel_sa_family_t sa_family;
+ struct sockaddr sa_local;
+ struct sockaddr_in sin_local;
+ struct sockaddr_in6 sin6_local;
+ struct __kernel_sockaddr_storage ss_local;
+ };
+ union {
+ struct sockaddr sa_remote;
+ struct sockaddr_in sin_remote;
+ struct sockaddr_in6 sin6_remote;
+ struct __kernel_sockaddr_storage ss_remote;
+ };
+};
+
+/* MPTCP socket options */
+#define MPTCP_INFO 1
+#define MPTCP_TCPINFO 2
+#define MPTCP_SUBFLOW_ADDRS 3
+
#endif /* _UAPI_MPTCP_H */