import mptcpd-0.8-2.el9

This commit is contained in:
CentOS Sources 2022-01-11 11:47:09 -05:00 committed by Stepan Oksanichenko
parent 1ea8f561c0
commit 386c601f10
3 changed files with 114 additions and 1 deletions

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

@ -1,7 +1,7 @@
Summary: Multipath TCP daemon
Name: mptcpd
Version: 0.8
Release: 1%{?dist}
Release: 2%{?dist}
License: BSD
URL: https://multipath-tcp.org
Requires(post): systemd
@ -20,6 +20,8 @@ BuildRequires: systemd-rpm-macros
Source0: https://github.com/intel/mptcpd/archive/v%{version}/%{name}-%{version}.tar.gz
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
@ -86,6 +88,11 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%{_libdir}/pkgconfig/mptcpd.pc
%changelog
* 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