1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-13 19:03:52 +02:00
Commit Graph

18 Commits

Author SHA1 Message Date
Tim Nordell
b1f831aa9f
Merge 320262a7f0 into f788525078 2024-04-17 07:29:11 +08:00
Jonas Lochmann
fc3cc2fe5c mwan3: use network_get_preferred_ipaddr6
This updates mwan3 to use network_get_preferred_ipaddr6 instead of
network_get_ipaddr6 if possible to determine a source ip for the
connectivity checks. This avoids issues where the first ip address
that is returned from network_get_ipaddr6 does not work anymore while
the preferred one returned from network_get_preferred_ipaddr6 works.

Signed-off-by: Jonas Lochmann <git@inkompetenz.org>
2024-02-04 16:39:13 -08:00
Florian Eckert
28e058e92f mwan3: rename tracking state from 'not enabled' to 'disabled'
The expression 'disabled' is more meaningful than 'not enabled' and can
therefore be better processed in the ubus output, since it is only one
word.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2023-09-20 16:05:13 +02:00
Tim Nordell
320262a7f0
mwan3: Fix packet routing when WAN interface is partially up
This introduces a new concept of "unknown_wan" to mwan3.  The action for
this can be configured in the globals section the default of which is
'none'.  This can be set to 'none', 'default', 'unreachable' or 'blacklist'
switching out the matching ip rule for this match.  This assignment for
a connection is temporary and is re-resolved for each additional
original direction packet through the firewall allowing the unknown WAN
to start resolving once the ifup has finished for the given interface.

An example configuration:

	config globals 'globals'
			option unknown_wan_action 'unreachable'

Prior to this commit, mwan3 had multiple hit spots for packets in the
following order:

 1. Packets are checked to see if they originate from known WAN interfaces
 2. Packets are checked to see if they destined for ipsets defined
 3. Packets are checked against default WAN policies

The WAN list is maintained via hotplug 'ifup'/'ifdown' events and the local
route ipset list is maintained via monitoring the routing table.  This
means that while a WAN interface is brought up, the list for 2 is
updated before the list for 1, since an interface is fully brought up
before the ifup event is fired off.  Additionally, we want to make sure we
don't apply a WAN policy for incoming packets from a WAN interface that
is in the process of being brought up.

We can identify packets that are presumably coming from a WAN interface
we don't recognize yet by eliminating all packets that the source comes
from networks we don't know about in the ipsets that mwan3 manages.  We
have to be careful here to only match the original direction of the
packet flow (e.g. for instance with ICMP, the ping request is in the
ORIGINAL direction, and the response is in the REPLY direction) or else
we might match something we didn't intend to.

By modifying the rule set to the following:

 1. Packets are checked to see if they are in a REPLY direction of flow
 2. Packets are checked to see if they originate from known WAN interfaces
 3. Packets are checked to see if they not sourced from ipsets defined
 4. Packets are checked to see if they destined for ipsets defined
 5. Packets are checked against default WAN policies

If a packet is in the REPLY direction of flow, we definitely don't want
to do any routing table assignments - we only want to do this for the
original direction of traffic flow.  This reduces the amount of rules
parsed within mwan3.

If a packet is not sourced from a defined ipset, this should match any
packet originating from a "default route" upstream.  We do this post the
known WAN interface check since we don't know what mask to apply to this
packet at this time until the 'ifup' has completed.  It's also setup to
reevaluate this decision by clearing this specific mark when a new
packet comes in in the REPLY direction of flow before any subsequent
evaluations.  This allows additional packets for the same connection to
eventually be assigned the appropriate mask once the 'ifup' has
finished.

One easy way to test this out before and after this change is to:

 - Bring down wan (e.g. ifdown wan)
 - Manually bring up WAN
    - This mitigates the firewall rules being added for 1 above, but 2
      is still added since this is monitoring the routing interface
 - Ping the device from a non-local subnet via the WAN interface; leave
   running
 - Observe mark set to ICMP session via conntrack
 - Bring up wan (e.g. ifup wan)
 - Observe mark set to ICMP session from above

Signed-off-by: Tim Nordell <tnordell@airgain.com>
2023-07-03 10:20:06 -05:00
Denys Yarkovyi
675ecfba89 mwan3: support offload routing modifier
Signed-off-by: Denys Yarkovyi <dyarkovoy@gmail.com>
2022-10-05 05:20:05 -07:00
Florian Eckert
0b5f09162b mwan3: dump iptables and ipset command for debugging
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2022-03-14 09:34:49 +01:00
Florian Eckert
a49d0953dc mwan3: move command definitions to common.sh
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2022-03-14 09:34:49 +01:00
Aaron Goodman
267b65ad9f mwan3: fix regression in ipv6 routing tables
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2021-01-02 21:37:37 -05:00
Aaron Goodman
5691ff247f mwan3: fix linkdown routes not being added
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-12-16 09:32:02 +01:00
Aaron Goodman
a5f3e6bb6b mwan3: don't call rpcd on 'mwan3 interfaces'
Allow `mwan3 interfaces` to get uptime via an internal function and
thus remove the dependency on rpcd for `mwan3 interface` calls.

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-11-16 11:19:55 -05:00
Aaron Goodman
13d22445e4 mwan3: fix rpcd with for routers with no IPv6 support
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-10-29 23:06:25 -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
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
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
Florian Eckert
267c0eeaed net/mwan3: use uptime for ubus age info
If the date is changed by ntp the age value of mwan3 on ubus could jitter.
Use instead the uptime value from /proc/uptime which will not change during
system run.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-11-16 09:15:04 +01:00