[packages/mtr] - fix source address binding for IPv4 - rel 2
adwol
adwol at pld-linux.org
Tue Apr 3 00:22:57 CEST 2018
commit c96b0a7dd7762b2bc937cdb020d45377a37e4e0f
Author: Adam Osuchowski <adwol at pld-linux.org>
Date: Mon Apr 2 23:53:08 2018 +0200
- fix source address binding for IPv4
- rel 2
mtr-sourceaddr_ipv4.patch | 45 +++++++++++++++++++++++++++++++++++++++++++++
mtr.spec | 4 +++-
2 files changed, 48 insertions(+), 1 deletion(-)
---
diff --git a/mtr.spec b/mtr.spec
index 615c837..7a45780 100644
--- a/mtr.spec
+++ b/mtr.spec
@@ -10,7 +10,7 @@ Summary(ru.UTF-8): Matt's Traceroute - утилита для диагности
Summary(uk.UTF-8): Matt's Traceroute - утиліта для діагностики мережі
Name: mtr
Version: 0.92
-Release: 1
+Release: 2
Epoch: 1
License: GPL v2
Group: Networking/Utilities
@@ -23,6 +23,7 @@ Patch0: %{name}-Makefile.patch
Patch2: %{name}-mtr6.patch
Patch3: %{name}-display.patch
Patch4: %{name}-curses-clear_colors.patch
+Patch5: %{name}-sourceaddr_ipv4.patch
URL: http://www.bitwizard.nl/mtr/
BuildRequires: autoconf >= 2.50
BuildRequires: automake
@@ -141,6 +142,7 @@ процесу mtr виводить поточну статистику по к
%patch2 -p1
%patch3 -p1
%patch4 -p1
+%patch5 -p1
#echo 'AC_DEFUN([AM_PATH_GTK],[$3])' >> acinclude.m4
%{!?with_x:echo 'AC_DEFUN([AM_PATH_GTK_2_0],[$3])' >> acinclude.m4}
diff --git a/mtr-sourceaddr_ipv4.patch b/mtr-sourceaddr_ipv4.patch
new file mode 100644
index 0000000..7cf1cdd
--- /dev/null
+++ b/mtr-sourceaddr_ipv4.patch
@@ -0,0 +1,45 @@
+diff -ruNp mtr-0.92.orig/packet/construct_unix.c mtr-0.92/packet/construct_unix.c
+--- mtr-0.92.orig/packet/construct_unix.c 2017-06-02 10:54:58.000000000 +0200
++++ mtr-0.92/packet/construct_unix.c 2018-04-02 23:40:33.993584361 +0200
+@@ -491,6 +491,9 @@ int construct_ip4_packet(
+ {
+ int send_socket = net_state->platform.ip4_send_socket;
+ bool is_stream_protocol = false;
++ bool bind_send_socket = true;
++ struct sockaddr_storage current_sockaddr;
++ int current_sockaddr_len;
+
+ if (param->protocol == IPPROTO_TCP) {
+ is_stream_protocol = true;
+@@ -528,6 +531,31 @@ int construct_ip4_packet(
+ }
+
+ /*
++ Check the current socket address, and if it is the same
++ as the source address we intend, we will skip the bind.
++ This is to accomodate Solaris, which, as of Solaris 11.3,
++ will return an EINVAL error on bind if the socket is already
++ bound, even if the same address is used.
++ */
++ current_sockaddr_len = sizeof(struct sockaddr_in);
++ if (getsockname(send_socket, (struct sockaddr *) ¤t_sockaddr,
++ ¤t_sockaddr_len) == 0) {
++
++ if (memcmp(¤t_sockaddr,
++ src_sockaddr, sizeof(struct sockaddr_in)) == 0) {
++ bind_send_socket = false;
++ }
++ }
++
++ /* Bind to our local address */
++ if (bind_send_socket) {
++ if (bind(send_socket, (struct sockaddr *) src_sockaddr,
++ sizeof(struct sockaddr_in))) {
++ return -1;
++ }
++ }
++
++ /*
+ The routing mark requires CAP_NET_ADMIN, as opposed to the
+ CAP_NET_RAW which we are sometimes explicitly given.
+ If we don't have CAP_NET_ADMIN, this will fail, so we'll
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/mtr.git/commitdiff/1d63a650b6e6e9dd8a76758fba0d8ba520fa8497
More information about the pld-cvs-commit
mailing list