1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-18 13:23:57 +02:00
Commit Graph

109 Commits

Author SHA1 Message Date
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
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
Aaron Goodman
aafdd0730c mwan3: don't add ipv6 link local address to routing tables
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-05-20 05:37:40 -04:00
Aaron Goodman
02ebd831c1 mwan3: reduce calls to `ip route list'
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-05-20 05:37:39 -04:00
Florian Eckert
581d7df844 mwan3: fix variable naming
The variable IPT is not valid at this point. Set the variable usage to IPT4
fixes this issue.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2019-11-14 07:57:11 +01:00
Florian Eckert
171cb17694 mwan3: change flush_conntrack handling to use uci list element
With this change it is now possible to combine interface action events.
If an interface action is generated by netifd or mwan3 for example ifup,
ifdown, connectd or disconnected and this action is configured in the inteface
uci section, then the conntrack table is flushed by mwan3.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2019-06-03 14:16:05 +02:00
Chen Minqiang
a004d07632 mwan3: fix logical/typo bug in mwan3rtmon
This bug was introduced since dd206b7d0b
mwan3_remon_ipv4 and mwan3_remon_ipv6 is command to run not a variable
I add some comments on them hopefully people will notice it

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
2019-03-22 18:11:07 +08:00
Florian Eckert
2ff9c8ecb7 mwan3: add locking debug possibility
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2019-01-22 14:29:04 +01:00
Florian Eckert
10cadcb2af mwan3: set interface unknown to offline
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2019-01-14 08:28:53 +01:00
Florian Eckert
a974558cfa mwan3: add syslog debug possibility to rules
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2019-01-14 08:28:50 +01:00
Florian Eckert
85a6d89b8e mwan3: revert add online_metric for local_source none
This is not necessary.

This reverts commit be91e71805.
2018-11-08 12:29:12 +01:00
Florian Eckert
be91e71805 net/mwan3: add online_metric for local_source none
If we set the option "local_source" in the globals mwan3 section to "none",
traffic generated by the router it self will always use the default route from
the wan interface with the lowest metric. If this interface is down
the router traffic still uses the connection with the lowest metric but
this is disconnected. Load balancing and failover from the lan site is
still possible. Only router generated traffic is not load balanced and
could not use failover.

To solve this issue with router initiated traffic add the additional
option "online_metric" to the mwan3 interface section.

If the interface is connected then this lower "online metric" is set in the
default routing table.

With this change we have at least a failover with router initiated
traffic.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-23 15:00:11 +02:00
Florian Eckert
181174b64b net/mwan3: add dynamic ipsets to mwan3_connected ipsets
During runntime of mwan3 we could add dynamicly networks to this ipset
which would then treated as connected networks by mwan3.

This is also usefull for ipsec.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-23 14:57:33 +02:00
Florian Eckert
dcb7ad17ba net/mwan3: add custom address from ip tables to connected ipset
With the list param "rt_table_lookup" in the mwan3 section globals,
it is now possible to add a additional routing table numbers which would get
also parsed and will be added to the connected network.
So mwan3 will treat them as they are directly connected to this device.

This could be usefull if we use ipsec.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-23 14:49:34 +02:00
Florian Eckert
1335e4f3dd net/mwan3: cleanup egrep ipv6 regex
The IPv6 egrep regex is confusing and hard to maintain.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-23 14:47:50 +02:00
Florian Eckert
84007a2723 net/mwan3: enhance ipset status generation
This change should optimize and speed up the status output generation.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-23 14:47:10 +02:00
Florian Eckert
ac8c4512d1 net/mwan3: reduce duplicate code
The generation for reporting the policies uses the same code add a
common function to reduce duplication.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-23 14:44:29 +02:00
Florian Eckert
952f3e1361 net/mwan3: cleanup/prettify 80 characters code boundary
Prettify and cleanup source

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-23 14:43:37 +02:00
Florian Eckert
3a5c3e03e2 net/mwan3: also add the metric to the default interface routing table
This is now the same route as in the main table.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-10-12 08:13:46 +02:00
Chen Minqiang
8ae2889674 mwan3: rtmon: filter out linkdown routing table
Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
2018-10-10 07:30:47 +08:00
Chen Minqiang
6a5836db32 mwan3: optimize the process of copying routing tables
- The original copy process is to delete all routing tables first,
   then add new routing table. This process is too slow and very dirty.
 - We use grep to identify the changes and apply them.
 - ignore ipv6 unreachable routes
 - update version number

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
2018-09-21 15:35:39 +08:00
Chen Minqiang
9e75edcf2c mwan3: fix missing device in mwan3_set_policy()
Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
2018-08-29 22:54:42 +08:00
Chen Minqiang
46ed09408e mwan3: refine link selection
- globals src_ip to none
 - ip route back to source
 - add mwan3rtmon
 - update version to 2.7

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
2018-08-09 05:06:17 +08:00
Florian Eckert
b6249f1781 net/mwan3: fix NDP on ipv6 for ra services
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-06-06 10:41:38 +02:00
Florian Eckert
215708a415 net/mwan3: remove logging mwan3track pid is not found
Remove unnecessary logging if mwan3track pid is not found

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-05-16 11:20:32 +02:00
Florian Eckert
704ec2b064 net/mwan3: set default mask to 0x3F00
The IPsec ip route table has the default number 220.
If mwan3 has more then 7 bits set (124 interfaces) then if mwan3 down is
executed the table is also cleared. To solve this set default max 7
bits in the mmx_mask for mwan3.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-03-29 14:51:36 +02:00
Florian Eckert
270245e6d4 net/mwan3: deviate max interface value from mmx_mask value
We need always three of the firewall mask value for
* default routing table
* blackhole
* unreachable
the other will be used for the interfaces.

* If we have set the mmx_mask to max 0xFF00 (8 bit set) we could use max 252
  interfaces.
* If we have set the mmx_mask to min 0x0E00 (3 bit set) we could use max 4
  interfaces.

Only the ones are counting from the firewall mask value.
Minimal three firewall mask bit vaules must be set.
Maximal eight firewall mask bit vaules could be set.

Table overview mmx_mask value bits vs. max interfaces

mmx_mask value bits set 1 -> not usefull
mmx_mask value bits set 2 -> not usefull
mmx_mask value bits set 3 ->   4 Interfaces (mask example 0x0E)
mmx_mask value bits set 4 ->  12 Interfaces
mmx_mask value bits set 5 ->  28 Interfaces
mmx_mask value bits set 6 ->  60 Interfaces
mmx_mask value bits set 7 -> 124 Interfaces
mmx_mask value bits set 8 -> 252 Interfaces (mask example 0xFF)

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-03-16 14:45:29 +01:00
Florian Eckert
7c178353f0 net/mwan3: remove unused local variables
Remove unused local variables

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-03-16 14:45:29 +01:00
Florian Eckert
8fa2101ea3 net/mwan3: add mwan3_init function
Move all shell commands which are executed during /lib/mwan3/mwan3.sh
sourceing into a seperate init function which must be called at first.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-02-05 10:29:28 +01:00
Florian Eckert
7cf9d9ec20 net/mwan3: send SIGKILL to mwan3track
In some situation it is not enough to send a SIGTERM to mwan3track to
ask service to stop accurate. If this does not work send him a SIGKILL
to prevent mwan3track running more then once per interface.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-02-05 10:29:25 +01:00
Jakub Janco
349b90cc24 mwan3: Improve logs when member metric is too big
If metric of member interface is bigger then 256, it is not
appended to policy, now at least warn message is printed into
syslog

Signed-off-by: Jakub Janco <kubco2@gmail.com>
2017-12-07 15:41:59 +01:00
David Yang
e094212b17 mwan3: reduce dependency on src_ip
Interfaces may be managed by 3rd-party scripts, thus src_ip may not be
always available in uci.

Signed-off-by: David Yang <mmyangfl@gmail.com>
2017-11-08 16:14:52 +08:00
David Yang
6f38affd0c mwan3: fix empty gateway when creating routing table
Interfaces of some PtP protocols do not have a real gateway. In that
case ubus may fill them with '0.0.0.0' or even leave it blank. This
will cause error when adding new routing rule.

Signed-off-by: David Yang <mmyangfl@gmail.com>
2017-11-08 16:14:50 +08:00
David Yang
5688f3e65a mwan3: reduce unnecessary comparisons
Signed-off-by: David Yang <mmyangfl@gmail.com>
2017-11-08 16:14:46 +08:00
Florian Eckert
2cf984c69e net/mwan3: fix track_ips order
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-09-12 16:14:32 +02:00
Marcin Jurkowski
66406f98db mwan3: fix interface-bound traffic when interface is offline
This commit fixed what 6d99b602 was supposed to fix without affecting
interface-bound traffic.

Before 6d99b602 interface-bound traffic was working normally as long
as at least one interface was online. However when the last interface
went offline, it was impossible to ping and such state was
unrecoverable.

Commit 6d99b602 fixed unrecoverable offline state problem (it was
possible to ping -I iface) but messed inteface-bound traffic. Traffic
with interface source address was not working if the interface was in
"offline" state, even if another interface was online.
The problem was caused by an inconsistent "offline" interface state:
iptables-related rules were kept while routing table and policy were
deleted.

The idea behind this commit is to:
 1. Keep all the rules for each interface (iptables, routing table,
    policy) regardless of its state. This ensures consistency,
 2. Make interface state hotplug events affect only iptables'
    mwan3_policy_* rules. Interface-related iptables, routing table
    and policy is removed only when mwan3 is manually stopped.

To make such changes possible, it's necessary to change the way
mwan3_policy_* rule generator keeps track of interface state hotplug
events.
Until now, it checked for the existence of custom interface-related
routing table (table id 1, 2, 3, ...). Clearly we can no longer rely
on that so each interface state is stored explicitly in file.

Signed-off-by: Marcin Jurkowski <marcin1j@gmail.com>
2017-09-12 11:18:52 +02:00
Florian Eckert
3607bac3af net/mwan3: make mwan3 mask configurable over uci
Add new global config option mmx_mask.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-08-16 14:35:06 +02:00
Florian Eckert
815e83d461 net/mwan3: on startup mark interface online only if track_ip are reachable
Add new interface config option "inital_state".

If interface comeing up the first time(mwan3 start, boot),
there are now two option for interface behaviour:

- online (default as is now)
  Set up interface regardless wether tracking ip are reachable or not.

- offline
  Set up interface first to ping tracking ip and if they are reachable set up
  the interface completely.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-08-10 11:30:47 +02:00
Florian Eckert
5e123852bc net/mwan3: move mwan3track clean up to mwan3 cmd
This is usefull to see the last state of the interface with ubus.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-08-10 10:48:27 +02:00
Florian Eckert
0b44ca505b net/mwan3: fix mwan3track kill execution
If two interface have the same prefix "wan" for example "wan" and "wan1"
pgrep returns the PID for wan1 also "pgrep -f mwan3track wan".

Before this fix "wan1" was also killed! This is not what we want.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-08-10 10:48:18 +02:00
Florian Eckert
f942701b1a net/mwan3: add process PID to LOG output
Update log output macro to show PID during logging

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-08-10 09:06:48 +02:00
Lars Schumann
78b6789475 mwan3: allow to change mwan3's MARKing mask
Signed-off-by: Lars Schumann <larsi.org@gmail.com>
2017-08-04 14:21:50 -04:00
Marcin Jurkowski
de4fc2b5de mwan3: support various interface tracking methods
Adds support for interface tracking using either ping, arping or
httping. This allows to track interface status on networks with filtered
ICMP traffic or simply to monitor data link layer etc.

To facilitate binding to a specified interface its IP address is passed
as a new mwan3track parameter. It's currently required by httping
and possibly by other tools that may be added in the future.

Signed-off-by: Marcin Jurkowski <marcin1j@gmail.com>
2017-08-02 17:44:07 +02:00
Florian Eckert
99229475b7 net/mwan3: simplify tracking status statement command
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-06-22 13:42:14 +02:00
Florian Eckert
b6e9debc1b net/mwan3: add lock for mwan3 hotplug script
If more then one interface get up/down at once mwan3 could be in a
undefined state, because more then one mwan3 hotplug script are running
and editing the iptables.

Lock the critical section should solve this issue.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-06-22 13:42:12 +02:00
Florian Eckert
ef3261d0b4 net/mwan3: remove absolute path for bin files
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-05-12 15:28:12 +02:00
Florian Eckert
1fd3f85d4f net/mwan3: remove pid file use pgrep to get pid
If mwan3track will not stop immediately after sending the kill signal,
the clean_up handler will delete the pid file later while the new mwan3track is
already running.

This could result in a situation that mwan3track is running
more then once because the old mwan3track service could not be killed,
because the pid file is missing.

Using pgrep to kill all mwan3track for the tracked interface and not using
pid file should fix this issue.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-05-12 15:28:12 +02:00
Florian Eckert
b216fd3642 net/mwan3: registrate SIGUSR1 trap on interface down event
If interface is getting down by netifd (unplug ethernet cable)
mwan3track will not recognize this change. It will also generate an
additional down event when he notice does his tracking interface is offline.

Mwan3track will now be informed by a signal (trap) USR1 during down event
that the interface is already down. An additional down event will not be
generated.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-04-11 09:46:20 +02:00
Florian Eckert
6bb84f69e7 net/mwan3: decrease parameter invocation of mwan3track
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-04-05 07:29:45 +02:00
Florian Eckert
5b55223d80 net/mwan3: add clean_up trap function for SIGINT SIGTERM
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-04-04 16:00:06 +02:00
Florian Eckert
ae335e7384 net/mwan3: add failure and recovery interval
If mwan3track detects a failure the interval check will change to
"failure_interval" value until this interface is declared "offline".
After interface gets "offline" normal "interval" value is used again.
If interface ping is successful again "recovery_interval" value is used until
interface is declared "online" again.

Using the different intervals will accelerate the wan line detections on
failure and recovery.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-03-27 08:45:13 +02:00
Florian Eckert
5cacfd34a6 net/mwan3: add ubus interface check
On interfaces with interface proto "qmi|ncm" and option dhcp
enabled the interface will be changed to $iface_4 | $iface_6. The
interface mapping in mwan3 will not recognize this interface. To fix
this issue an ubus call will check if an upper interface exists.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-03-21 08:59:31 +01:00
Florian Eckert
6d44a7679a net/mwan3: add ping size option to mwan3track
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-03-16 10:01:07 +01:00
Florian Eckert
3231736cab net/mwan3: reset conntrack table on iface up/down event
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2017-03-16 10:01:06 +01:00
Jo-Philipp Wich
a67e66c280 mwan3: remove bad local shell variable declarations
Local variable declarations outside of functions are illegal since the Busybox
update to v1.25.0, therfore remove them from the appropriate places.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-09-24 14:47:38 +02:00
Jeroen Louwes
05eaec986b mwan3: update to version 2.0-2
Fix iptables issue where a needed ipset was not created if first wan that came online was not a member of policy.

Signed-off-by: Jeroen Louwes <jeroen.louwes@gmail.com>
2015-12-21 16:50:59 +01:00
Jeroen Louwes
725cfe6b8e mwan3: update to version 2.0-1
Fix issue with sticky sessions not working correctly
Fix issue where user created ipsets were not applied

Signed-off-by: Jeroen Louwes <jeroen.louwes@gmail.com>
2015-12-17 12:11:50 +01:00
Jeroen Louwes
8ff00a6273 mwan3: update to version 2.0-0
IPv6 support! :D
Big code overhaul; expect bugs..

Signed-off-by: Jeroen Louwes <jeroen.louwes@gmail.com>
2015-11-19 09:37:30 +01:00