Go to file
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
.circleci CircleCI: Add 22.03 public keys, 18.06 v2 gpg key, 18.06 usign key 2022-05-11 16:40:55 +08:00
.github CI: update build architectures 2023-06-16 12:30:32 +08:00
.keys build: move gpg keys into .keys directory 2018-04-30 13:14:25 -07:00
admin zabbix: Add "oldstable" source URL 2023-06-02 21:51:57 +08:00
devel gitlab-runner: Update to 16.0.2 2023-06-22 21:38:36 +03:00
fonts/dejavu-fonts-ttf [dejavu-fonts] add license info and myself as maintainer 2017-02-22 18:39:54 +01:00
ipv6 treewide: remove AUTORELEASE 2023-04-21 22:46:58 +02:00
kernel treewide: remove AUTORELEASE 2023-04-21 22:46:58 +02:00
lang Merge pull request #21405 from jefferyto/selinux-update 2023-06-25 17:04:14 +08:00
libs libpfring: update to 8.4.0 2023-06-25 07:05:37 +03:00
mail alpine: disable parallel build 2023-06-19 16:05:00 +03:00
multimedia tvheadend: add dependency on gettext (host) 2023-06-22 21:35:11 +03:00
net mwan3: Fix packet routing when WAN interface is partially up 2023-07-03 10:20:06 -05:00
sound squeezelite: restructure package variants 2023-05-26 06:29:12 +03:00
utils Merge pull request #21405 from jefferyto/selinux-update 2023-06-25 17:04:14 +08:00
CONTRIBUTING.md CONTRIBUTING: add CI information 2020-09-30 10:47:12 -10:00
LICENSE Add GPLv2 pro-forma license 2014-06-16 08:14:04 +02:00
README.md Update the SDK URL in the README. 2020-05-24 14:50:30 -07:00

README.md

OpenWrt packages feed

Description

This is the OpenWrt "packages"-feed containing community-maintained build scripts, options and patches for applications, modules and libraries used within OpenWrt.

Installation of pre-built packages is handled directly by the opkg utility within your running OpenWrt system or by using the OpenWrt SDK on a build system.

Usage

This repository is intended to be layered on-top of an OpenWrt buildroot. If you do not have an OpenWrt buildroot installed, see the documentation at: OpenWrt Buildroot Installation on the OpenWrt support site.

This feed is enabled by default. To install all its package definitions, run:

./scripts/feeds update packages
./scripts/feeds install -a -p packages

License

See LICENSE file.

Package Guidelines

See CONTRIBUTING.md file.