Commit Graph

794 Commits

Author SHA1 Message Date
Roger Wolff
c68adc104f
Merge pull request #515 from msekletar/icmp-socket-leak
Prevent icmp_socket leak on error
2024-08-27 19:12:57 +02:00
Michal Sekletar
7b4eda3369 Prevent icmp_socket leak on error 2024-08-27 18:01:23 +02:00
Roger Wolff
aad45da277
Merge pull request #513 from arekm/master
Handle EHOSTDOWN and refine error handling better granularity
2024-08-21 13:16:32 +02:00
Arkadiusz Miśkiewicz
95d5f8b833 Handle EHOSTDOWN and refine error handling better granularity 2024-08-21 10:03:55 +02:00
Roger Wolff
49662a9655
Merge pull request #512 from infrastation/fix_man_mtr
mtr.8.in: spell --mark argument type properly
2024-08-15 16:08:04 +02:00
Denis Ovsienko
83fc8e2b25 mtr.8.in: spell --mark argument type properly
[skip ci]
2024-08-15 14:39:27 +01:00
Roger Wolff
e14581c5f2
Merge pull request #511 from verrens/compact-layout
Add a compact mode in curses
2024-08-03 18:57:28 +02:00
verrens
748de4b546
Merge branch 'master' into compact-layout 2024-08-03 19:29:29 +03:00
Denis Afonin
e130318d8a Add a compact mode in curses 2024-08-03 19:16:57 +03:00
Roger Wolff
469e1bca74
Merge pull request #509 from nuclearcat/tiny-typo
Fix tiny typo in target
2024-07-08 08:23:52 +02:00
Denys Fedoryshchenko
b4c47a1e82 Fix tiny typo in target
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
2024-07-08 01:00:46 +03:00
Roger Wolff
e137a71a3c
Merge pull request #495 from matt-kimball/cygwin-async-pipe
Update Cygwin ICMP service thread for asynchronous pipes
2023-10-24 09:22:58 +02:00
Matt Kimball
dffd81b656 Update Cygwin ICMP service thread for asynchronous pipes
Recent versions of Cygwin implement pipe() using Windows' named
pipes, and put the read end of the pipe in FILE_PIPE_COMPLETE_OPERATION
mode, which doesn't allow overlapped I/O operations.

For the relevant commit in the Cygwin repository, see
9e4d308cd592fe383dec58ea6523c1b436888ef8

The solution here is to maintain a Windows event object which is
set only when any ICMP requests are pending.  We can do an alertable
wait on that event object, which will allow us to complete ICMP
requests.

Thanks to Adam Schultz for research into this issue and a first
attempt at a fix.
2023-10-24 03:02:43 +01:00
Roger Wolff
adfa754a45
Merge pull request #493 from slord399/master
Recommend WSL as a way to run MTR on Windows.
2023-10-14 23:00:54 +02:00
Tony Lewis Hiroaki URAHAMA
0845501b34
Update section title 2023-10-07 21:20:42 +01:00
Tony Lewis Hiroaki URAHAMA
2579026dd8
Add Ubuntu as specific distribution 2023-10-07 21:05:19 +01:00
Tony Lewis Hiroaki URAHAMA
9c9bc71977
Add WSL method to Windows Install
It would be much simpler and not experience IPv6 related build fail at all.
2023-10-07 20:58:59 +01:00
Roger Wolff
6e659b821a
Merge pull request #489 from flu0r1ne/set-mark-during-address-selection
Set mark during address selection
2023-10-04 11:28:08 +02:00
flu0r1ne
7d8b704e8d Support Hexadecimal Arguments for Packet Marking
Packet marks are often specified in hexadecimal format. Update the
`strtonum_or_err` function to parse both hexadecimal and decimal
values.
2023-10-03 23:19:04 -05:00
flu0r1ne
23486b312c Use Packet Marking for IP Address Selection
In certain scenarios, the routing policy database may affect packet
routing. When selecting an address in `mtr`, assign a packet mark if
`SO_MARK` is defined and a mark has been supplied.
2023-10-03 23:19:01 -05:00
flu0r1ne
47dd026ce3 Use a uint32 for the type of a Linux mark
It is typical to store and manipulate Linux packet marks using unsigned values.
2023-10-03 22:13:00 -05:00
Roger Wolff
62bd718e83
Merge pull request #478 from esimest/master
Add error code ETIMEOUT(110) handle logic
2023-10-03 14:00:59 +02:00
Roger Wolff
4b111829c5
Merge pull request #488 from flu0r1ne/linux-tests
Linux-Only Interface, Marking, and IP Unit Tests
2023-10-03 14:00:11 +02:00
Roger Wolff
4a1939ace9
Merge pull request #487 from flu0r1ne/adjust-capability-handling
Adjust capability handling
2023-10-03 09:19:23 +02:00
flu0r1ne
6ef2b495ab Change B101->S101 to reflect flake8 2023-10-02 21:21:53 -05:00
flu0r1ne
4264e97e17 Fix flake8 linting
- Remove unused imports
- Search for ip executables in known locations
- Fix f-string
- Ignore assert warnings
2023-10-02 20:57:51 -05:00
flu0r1ne
54abd964b7 Drop capabilities when setsockopt errors
Ensure that `set_privileged_socket_opt` drops capabilities even in the event
that `setsockopt` returns an error.
2023-10-02 20:16:28 -05:00
flu0r1ne
74645e05ec Annotate set_privileged_socket_opt with UNUSED
The `set_privileged_socket_opt` function is currently called only when
`SO_MARK` or `SO_BINDTODEVICE` are defined. On systems that do not support
either feature, `set_privileged_socket_opt` is expected to be unused. Adding
an annotation suppresses compiler warnings.
2023-10-02 18:10:43 -05:00
flu0r1ne
42f5dcc46a Linux-Only Interface, Marking, and IP Unit Tests
This commit introduces three unit tests focused on interface binding,
packet marking, and IP source address spoofing/selection. Each of these
tests builds upon the original `MtrPacketTest` base class. To evaluate
these network-dependent features, the tests utilize an emulated network
environment. To enable this, a small network emulation library, `netem`,
has been developed specifically for this purpose. `Netem` allows for the
creation of arbitrary network configurations for testing and can reliably
set up and clean up virtual network environments on Linux systems. The only
dependencies are `iproute2` and `libc`, which are generally pre-installed
on most Linux hosts.

The commit adds three tests that are expected to fail:

1. Interface Binding: Evaluates the capability of `mtr-packet` to bind to
   a specific interface.
2. Packet Marking: Assesses the ability of `mtr-packet` to apply a Linux
   networking mark (fwmark).
3. Source Address Selection: Tests `mtr-packet`'s ability to spoof or bind
   to a specified source address.
2023-10-02 04:08:09 -05:00
flu0r1ne
04d5abe3b5 Fix interface binding by retaining CAP_NET_RAW
This commit addresses an issue where mtr would fail with EPERM because setting the
SO_BINDTODEVICE socket option requires the CAP_NET_RAW capability.

Changes:

- Refactor the code to abstract setting privileged socket options. This
  includes a common interface for setting capabilities depending on the
  platform (with or without LIBCAP).

- Replace direct setsockopt calls with the new abstracted function for
  setting both SO_MARK and SO_BINDTODEVICE.

- Update capability management in `drop_excess_capabilities` to retain
  CAP_NET_RAW when needed.
2023-09-29 18:42:16 -05:00
flu0r1ne
1b519cde3e Fix Capability Management, Retain CAP_NET_ADMIN
Modify the capability-dropping logic to specifically retain CAP_NET_ADMIN if it
is initially provided, in adherence to least-privilege principles.

Details:
1. Update the `drop_excess_capabilities` function to only drop capabilities that
   are unnecessary, retaining CAP_NET_ADMIN when needed for setting the socket
   mark.
2. Introduce logic in `set_socket_mark` to temporarily elevate CAP_NET_ADMIN
   into the effective set for the duration of the packet mark setting
   operation.
2023-09-29 18:36:37 -05:00
Roger Wolff
74d312d7e6
Merge pull request #484 from alarig/master
Change UDP and ICMP sockets binding to accept a source IP from the -a…
2023-09-11 14:09:17 +02:00
Alarig Le Lay
d529dbeefc
Change UDP and ICMP sockets binding to accept a source IP from the -a CLI option
Issue: #232

Signed-off-by: Alarig Le Lay <alarig@swordarmor.fr>
2023-09-11 11:48:53 +02:00
Roger Wolff
ad48183ff9
Merge pull request #481 from darless/github-workflows
Github actions added to perform lint and compile
2023-08-10 16:31:35 +02:00
darless
4fc3361930 Github actions added to perform lint and compile
In the test folder, there was lint.sh, but I think flake8 is a better
tool.

Added a compile job for linux, this runs compilation as defined in
the README, runs a sample mtr and runs cmdparse.py test. Need
documentation on what other tests to run and whether to include the
testing in tox instead of running them individually.

Not adding in this PR support for cygwin or freebsd, as that will need
investigation on how to run.

Minor:
- Fixed a typo in configure.ac that used ---- vs -- for a flag option.
2023-07-12 12:48:34 -05:00
Jian Cheng
dc076a6c15 Add error code ETIMEOUT(110) handle logic 2023-06-08 20:38:18 +08:00
Roger Wolff
ab6f80fc8d
Merge pull request #476 from ewpratten/nat64_asns
Implement ASN lookups in well-known nat64 prefix
2023-05-31 11:39:00 +02:00
Evan Pratten
91035185dd Implement ASN lookups in well-known nat64 prefix 2023-05-30 20:22:48 -04:00
R.E. Wolff
7ad8ef6951 Fixed typo noted by @szczot3k 2023-05-16 14:03:37 +02:00
R.E. Wolff
d5732b02a7 Merge branch 'master' of github.com:traviscross/mtr 2023-05-16 13:58:23 +02:00
Roger Wolff
ca7058feba
Merge pull request #473 from famfo/master
Add option to use custom ipinfo provider
2023-05-16 13:13:54 +02:00
famfo
3a69802ceb Add option to use custom ipinfo provider 2023-05-16 12:41:58 +02:00
Roger Wolff
fb5e300f1c
Merge pull request #472 from the-eater/fix-cap
configure.ac: fix broken cap check
2023-05-16 09:33:32 +02:00
eater
3d1f85d073
configure.ac: fix broken cap check 2023-05-16 04:40:24 +00:00
R.E. Wolff
5646356950 merged 2023-04-22 19:14:02 +02:00
Roger Wolff
a1548b40c0
Merge pull request #468 from msmeissn/master
fixed the sizes passed into snprintf
2023-04-11 17:17:13 +02:00
Marcus Meissner
5908af4c19 fixed the sizes passed into snprintf 2023-04-11 16:05:36 +02:00
Roger Wolff
56fe6c435f
Merge pull request #462 from uniontech-lilinjie/master
fix typo
2023-01-10 11:11:49 +01:00
lilinjie
b7a6df88fd fix typo
Signed-off-by: lilinjie <lilinjie@uniontech.com>
2023-01-10 14:20:12 +08:00
R.E. Wolff
4f6d0e7c35 Markus pointed out useless statement. 2022-09-30 09:42:20 +02:00