flu0r1ne [Mon, 2 Oct 2023 08:53:16 +0000 (03:53 -0500)]
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.
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.
Sami Kerola [Tue, 6 Sep 2022 13:16:04 +0000 (14:16 +0100)]
ui: make interactive and non-interactive exit code the same
Before this change the report gave successful exit value when destination
hostname could not be found.
$ ./mtr --report nxdomain. ; echo $?
./mtr: Failed to resolve host: nxdomain.: Name or service not known
0
Quickly looking 'git grep ---after-context if.*Interactive' there does not
appear to be more than the two instances in main() where exit is called
depending on interactive, so this change should cover all these cases.
Reported-by: Marek Kroemeke <mkroemeke@cloudflare.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Brandon Ewing [Fri, 13 May 2022 16:18:38 +0000 (11:18 -0500)]
add --max-display-paths option
It is not unknown to have datacenters with over 8 ECMP paths between two
hops. Expand the maximum number of ECMP hosts stored in addrs to 128,
and add a new option to control the number to display, defaulting to the
old MAX_PATHS of 8
Brandon Ewing [Fri, 13 May 2022 15:27:55 +0000 (10:27 -0500)]
use addrs for static host ordering in curses
Change d2552ca has the side effect of moving hosts around in the
multipath view, as the last host to reply to a packet was set as
addr. Using addrs[0] istead of addr to draw the first host keeps
the ordering deterministic, in order of first reply.
Andrew Marshall [Wed, 23 Mar 2022 15:36:48 +0000 (11:36 -0400)]
Adjust MIN_PORT to match other implementations
Port 33434 is the IANA-reserved port for traceroute. It also seems to be
the most common start port. The following implementations, and
likely others, use it as their start port:
- Apple macOS traceroute
- FreeBSD traceroute
- GNU inetutils-traceroute
- Modern traceroute for Linux
- OpenBSD traceroute
The benefit to using a standard starting port is that some firewalls may
have these ports allowed, whereas other ports may be blocked, so there
is a greater probability the probe will succeed.
hiro [Tue, 9 Nov 2021 17:50:12 +0000 (17:50 +0000)]
ipv6 udp checksums like ipv4 but with ipv6 pseudoheader
this fixes a problem where both source and destination port are supplied on the commandline,
this lead to packets not showing up any more due to checksum being different.
this was mentioned first on https://github.com/traviscross/mtr/issues/351
ui/curses: always use "%s"-style format for printf()-style functions
`ncuses-6.3` added printf-style function attributes and now makes
it easier to catch cases when user input is used in palce of format
string when built with CFLAGS=-Werror=format-security:
ui/curses.c:765:42:
error: format not a string literal and no format arguments [-Werror=format-security]
765 | mvprintw(rowstat - 1, startstat, msg);
| ^~~
Let's wrap all the missing places with "%s" format.
This is not really elegant and I didn't try to display with vertical
bars like it should be done when no additional IP info is requested,
but the code already has many branches with very similar code and I
didn't want to add even more complexity to it.
Vincent Bernat [Tue, 9 Mar 2021 21:46:47 +0000 (22:46 +0100)]
net: fix MPLS display for curses and report
After #364, MPLS labels were not displayed anymore due to a logic
invertion. Previously, the addr/mpls fields were populated first and
addrs[i]/mplss[i] copied from these values. After the patch, the
reverse is happening but populating addrs[i] and mpls[i] was still
done by copying the value from addr/mpls. This was not a problem for
displaying addresses as addr was used however for mpls labels, this is
mplss which is used exclusively (net_mpls() is not using mpls field,
but mplss field).
After #364, hosts position is changing depending on the most recent
paths. I didn't fix that as it may be seen as a feature but this can
be a bit disturbing.
Also, unrelated, but the unnecessary/unsafe casts to void pointer are
removed for net_addr(), net_addrs(), net_mpls() and net_mplss(). Also,
net_mpls() is using mpls field instead of mplss as this seems more
correct.
This has been tested with curses and report. Also, raw is still
working.
Vincent Bernat [Mon, 8 Mar 2021 07:29:53 +0000 (08:29 +0100)]
ui: don't cast to void* when calling display_rawhost()
The provided types are compatible with the function signature.
Moreover, this seems to hide a bug where `display_rawhost()` is called
with an address instead of an MPLS struct.