]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Also try SOCK_RAW/IPPROTO_ICMP when other fail. 261/head
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Tue, 5 Jun 2018 13:54:44 +0000 (15:54 +0200)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Tue, 5 Jun 2018 13:54:44 +0000 (15:54 +0200)
Under Linux Vserver SOCK_RAW is quite limited. Only IPPROTO_ICMP works,
so try to use it.

check_length_order() also doesn't work because sendto is also limited.
Fortunately under linux check_length_order is not needed as described
in comment around check_length_order.

packet/probe_unix.c

index 56b670e6773fa615f95381e3bf05f47bb38e44ee..2804ecbfc5ae1907a8d32d222d3b49b9749936ac 100644 (file)
@@ -128,6 +128,12 @@ void check_length_order(
     ssize_t bytes_sent;
     int packet_size;
 
+#ifdef __linux__
+    /*  Linux will accept either byte order and check below fails to work
+     *  in some cases due to sendto() returning EPERM. */
+    return;
+#endif
+
     memset(&param, 0, sizeof(struct probe_param_t));
     param.ip_version = 4;
     param.protocol = IPPROTO_ICMP;
@@ -230,7 +236,10 @@ int open_ip4_sockets_raw(
 
     send_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
     if (send_socket == -1) {
-        return -1;
+        send_socket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+        if (send_socket == -1) {
+            return -1;
+        }
     }
 
     /*