Commit graph

235 commits

Author SHA1 Message Date
Aaron Goodman
e5dc144968 mwan3: fix mwan3 'use'
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-22 09:41:48 -04:00
James White
14d62d6599 mwan3: Simplify default configuration, mostly use defaults
Signed-off-by: James White <james@jmwhite.co.uk>
2020-10-16 09:55:40 -04:00
Aaron Goodman
41d5f486ee mwan3: cleanup mwan3track
- reduce duplicate logging code
- simplify nping track code
- simplify ping result parsing

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:55:40 -04:00
Aaron Goodman
1990a90702 mwan3: add back support for iputils ping
With the new wrapper code, we can override the broken binding behavior of
iputils ping v20101006.

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:55:40 -04:00
Aaron Goodman
d49ca29eca mwan3: add "use" function to mwan3 utils
Use "mwan3 use" to wrap a command with interface bindings so that you can
avoid the mwan3 rules and test behavior on a specific interface.

eg "mwan3 use wan ping -c1 1.1.1.1"

Additional binding arguments to the command will have their system
calls intercepted and ignored.

eg "mwan3 use wan ping -c1 -I tun0 1.1.1.1" will use the
device associated with "wan", rather than "tun0".

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
bbbc6127ab mwan3: use helper library for mwan3track
Rather than using a special mwan3 user to manage mwan3track's tracking
packets, this commit implements a small helper library to bind to
device and to set a fwmark so that the tracking packets can be routed
out of the correct interface.

This provides a consistent method for binding to a device rather than
relying on various packages potentially buggy implementations. For
example: #8139 and #12836

This helper issue also allows for more tracking methods to be added
even if they do not have a command line option to bind to device,
such as iperf3 (eg  #13050).

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
fb4a2d99ef mwan3: give warning if ip of incorrect family specified in a rule
also use global IPv4_REGEX environment variable as consistent IPv4 regex

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
566293d228 mwan3: use procd for mwan3rtmon and mwan3track
start all mwan3mon and mwan3track instances on mwan3 start
if an interface is down when mwan3track starts, it waits
for a signal from the hotplug script to start

procd can then handle stopping all of the scripts when mwan3
is halted

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
5faa99f3b8 mwan3: fix bug when one interface is a prefix of another
correctly terminate interface status checks with new lines so that
interface status does not get confused when one interface is a prefix
of another interface.

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
189f92da4a mwan3: only update src_iface rules on ifup
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
c8deccc0e7 mwan3: improvements to route creation
handle creation of routing tables in mwan3rtmon to avoid race
conditions and potentially missing routes

handle ipv6 routes that have expiry

update directly connected ipset when routes are added or deleted

add fall through rules so that the default routing table is not
used if no rule in the interface-specific routing table matches

add option to comply with mwan3 source based routing

get default route parameters from main routing table

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
27492f64f8 mwan3: use MWAN3TRACK_STATUS_DIR variable throughout
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
b7e26dd431 mwan3: fixup some extra spaces and shellcheck warnings
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-16 09:54:48 -04:00
Aaron Goodman
c07f5230be mwan3: improve startup performance; version 2.9.0
improve startup and runtime performance by

1) moving common startup procedures out of hotplug script when called
from mwan3 start
2) reducing calls to iptables to check status of rules
3) consolidating iptables updates and updating with iptables-restore
4) do not wait for kill if nothing was killed
5) running interface hotplug scripts in parallel
6) eliminate operations in hotplug script that check status on every
single interface unnecessarily
7) consolidate how mwan3track makes hotplug calls
8) do not restart mwan3track on connected events

This is a significant refactor, but should not result in any breaking
changes or require users to update their configurations.

version bump to 2.9.0

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-08-17 22:02:36 -04:00
Aaron Goodman
39f58789e6 mwan3: use ip monitor route to detect routing changes
use only committed uci changes for updating routing table

use functions.sh functions rather than uci command line tool
to find interfaces for routing table.

consolidate rtmon_ipv4 and rtmon_ipv6 functions into a single function

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-08-15 20:19:56 -04:00
Paul Spooren
30ea917518 treewide: replace which with command -v
Fix shellcheck SC2230
> which is non-standard. Use builtin 'command -v' instead.

Once applied to everything concerning OpenWrt we can disable the busybox
feature `which` and save 3.8kB.

Signed-off-by: Paul Spooren <mail@aparcar.org>
2020-08-09 13:58:14 -10:00
Florian Eckert
85e91377cf mwan3: update version to 2.8.12
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-28 06:53:24 +02:00
Florian Eckert
981d1eb83a mwan3: unify variable check
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-28 06:53:24 +02:00
Florian Eckert
ab747fe0fb mwan3: remove lock file entirely
Removing the lock file ist not necessary

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-28 06:53:24 +02:00
Florian Eckert
b5bd6d757b mwan3: revert: also cleanup lock on mwan3 stop
This reverts commit cde2a77ed3.

Applying this change has shown that it is even quicker to provoke the
race condtition on simultan mwan3 commands execution.
By reversing the change we have the same behaviour as before.

But the race condition on mwan3 execute at the same time still exists.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-28 06:53:24 +02:00
Florian Eckert
2dac1bcdc9 mwan3: fix race condition on mwan3 restart
This adjustment of the locks fixes the race condition when a mwan3
hotplug script and a mwan3 command are running at the same time.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-28 06:53:24 +02:00
Florian Eckert
f601e6cfa4 mwan3: update version to 2.8.11
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-20 08:15:50 +02:00
Florian Eckert
b0acbf057e mwan3: add online and uptime to detail output
Add also online time value and uptime time value from netifd to the
detail output view.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-20 08:13:34 +02:00
Florian Eckert
058a2b6f30 mwan3: add workaround for procd change
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-20 08:12:48 +02:00
Florian Eckert
cde2a77ed3 mwan3: also cleanup lock on mwan3 stop
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-20 08:12:31 +02:00
Florian Eckert
bcd13ba95c mwan3: fix rtmon routing table function generation
If the uci option family is not set in the interface section, then there
is no default value set as in the `config_load / config_get` API.
The problem here is that if the family is not set, the default value ipv4
is normaly assumed. But the comparison fails here because the value is empty
and therefore the dedicated routing table for this interface is not compared
with the other routes from the main table and so not updated.

To fix this set the default value for this config option which is`false`
for enabled and `ipv4` for family.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-20 08:11:20 +02:00
Florian Eckert
8e3e6f8dde mwan3: fix IPv6 routing add handling
This fixes routing handling. Introduced with the last version update.
The following message disappears on the shell
when mwan3 is called with 'mwna3 restart`.

`Error: Invalid gateway address.`

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
[aaronjg@stanford.edu: fully unset variable and handle ipv4 as well]
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-19 23:24:13 -04:00
Florian Eckert
a796b7a84e mwan3: fix idx calculation
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
[aaronjg@stanford.edu: fix syntax error]
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-19 23:24:13 -04:00
Aaron Goodman
ca8bc3d115 mwan3: version bump
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-19 23:24:13 -04:00
Aaron Goodman
30a46bdc9e mwan3: cleanup duplicate ipv4 and ipv6 logic
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-19 23:24:13 -04:00
Aaron Goodman
702a104f9c mwan3: don't send iptable setup failures to /dev/null
silencing failing rules makes debugging more difficult

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-19 23:18:22 -04:00
Aaron Goodman
2a5e9be83e mwan3: add default rule for ipv6 in example config
default rule only applied to ipv4 with dest_ip 0.0.0.0/0
and error was hidden when trying to apply it in ip6table

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-19 23:18:21 -04:00
Aaron Goodman
a0d66d4eeb mwan3: don't try to use ipv6 if not installed
fix issue  #11826

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-19 23:18:18 -04:00
Aaron Goodman
84a53b7c79 mwan3: be more efficient with sleep after killing trackers
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-16 02:03:21 -04:00
Aaron Goodman
da9a626f78 mwan3: don't add single ipv4 to connected list if already covered by a cidr
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-16 02:03:21 -04:00
Florian Eckert
2594258c4b mwan3: update version to 2.8.9
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-15 10:23:47 +02:00
Florian Eckert
d0c248a7da mwan3: cleanup function mwan3_create_iface_route
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-15 10:23:47 +02:00
Florian Eckert
feae9e5742 mwan3: fix shellcheck warning SC2086
Add double quote to prevent globbing and word splitting where there is
no regression.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-15 10:22:26 +02:00
Florian Eckert
c0fdfaa174 mwan3: fix shellcheck warning SC2166
Replace -o boolean check with ||.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-15 10:21:54 +02:00
Florian Eckert
644d9a25df mwan3: remove unused variable complained by shellcheck
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-15 10:21:54 +02:00
Florian Eckert
0ed7524f81 mwan3: fix shellcheck warning SC2039
Replace all `==` with `=`.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-15 10:21:54 +02:00
Florian Eckert
facf8ea299 mwan3: move redirect error output to trash
This suppress the following output on `mwan3 restart`:
> Dump terminated

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-07-15 10:21:54 +02:00
Michiel Blokzijl
acfbd98ce0 mwan3: Fix mwan3 start not doing anything
Due to a missing config load function call, mwan3 start runs ifup for an empty
list of interfaces, thus not calling ifup at all.

This commit introduces the missing config_load call.

Signed-off-by: Michiel Blokzijl <code@m01.eu>
2020-07-03 20:03:42 +01:00
Florian Eckert
8030814267 mwan3: update version to 2.8.7
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-06-17 13:04:38 +02:00
Florian Eckert
e30f16beef mwan3: set status to unknown in rpcd if status file not found
If the status file is not found then set then return the value unknown.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-06-17 13:01:49 +02:00
Florian Eckert
a6dc75428c mwan3: switch to procd init script
This enables the procd handling for mwan3 on config change.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-06-17 13:00:48 +02:00
Aaron Goodman
38be40843b mwan3: address reviewer comments on 5147dfc7
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-06-13 15:29:32 -04:00
Aaron Goodman
4efaa44b21 mwan3: Use /128 for ipv6 if no other source address was found
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-05-29 09:44:20 -04:00
Aaron Goodman
5147dfc73a mwan3: Allow user to specify rules based on source interface
Add an option for adding rules based on source interface.
The default 0.0.0.0/0 src and destination ip addresses has been removed. It is unclear
how the 'any' family of rules would have worked, as it appears each rule always required an
ipv4 or ipv6 address src and destination address.  With this change, the any family will work
again.

I also cleaned up a bunch of repeated code around adding the iptables rules for
ipv4/ipv6/any in making the change.

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-05-29 09:42:29 -04:00
Aaron Goodman
cf38136b00 mwan3: Do not mangle outgoing ipv6 pings
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-05-29 01:24:57 -04:00