]> git.ipfire.org Git - thirdparty/mtr.git/commit
mtr-packet: use ICMP and UDP without privilege on linux
authorChonggang Li <chonggangli@google.com>
Thu, 13 Jul 2017 23:17:08 +0000 (16:17 -0700)
committerChonggang Li <chonggangli@google.com>
Sun, 13 Aug 2017 22:32:28 +0000 (15:32 -0700)
commit34b97a370e633c0df029ca754e72be2fe795dd3e
tree3252ff096b0a94a52fce8f6982f5473ba5441ec3
parenteca60b8feefd2b1a0bcbd7898e2ec5bc645f3e89
mtr-packet: use ICMP and UDP without privilege on linux

This commit enables non-privileged users to use mtr on linux without
setuid. Currently ICMP and UDP protocols are supported in this commit.
Previously, to use mtr on linux with protocol ICMP and UDP, RAW sockets
have to be opened to send out packets and receive ICMP errors, so users
must have RAW socket permission to use this program. The goal of this
commit is to make mtr usable for normal users without RAW socket
permission. The changes include:
(1) The origianl logic is not changed, but instead, when the program
fails to open RAW sockets, it will fallback to opening DGRAM scoekts.
(2) A new flag is created to indicate whether RAW socket is used for
IPv4 and IPv6 respectively.
(3) When using DGRAM sockets to send out packets, receive sockets are
not required. Instead, IP_RECVERR is enabled to receive ICMP errors.
(4) Packet receiving function is changed from recvfrom() to recvmsg() to
retrieve more information.
(5) When error is indicated, the program will check the error type and
read from the error queue of the socket. Original payload causing the
error will be read out from the error queue to match for probe, and
additional data (e.g. source ip of ICMP error packets) will be retrieved
from CMSG.
(6) Use a separate socket to probe byter order if raw socket creation
fails, to avoid double bind issue.
(7) Also a few tweaks are added to make non-RAW socket working.

Change-Id: Idb08ff0847adbabd23cdc031907de3bde08a6afc
packet/command.c
packet/construct_unix.c
packet/deconstruct_unix.c
packet/deconstruct_unix.h
packet/probe.c
packet/probe.h
packet/probe_cygwin.c
packet/probe_unix.c
packet/probe_unix.h
packet/wait_unix.c