aboutsummaryrefslogtreecommitdiff
path: root/net/mwan3
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2018-10-15 11:22:35 +0200
committerFlorian Eckert <fe@dev.tdt.de>2018-10-23 14:49:34 +0200
commitdcb7ad17ba1ee17f0db71073327a909cdd1db55b (patch)
tree8c5225fe060fe85c252156a41343b214fd961817 /net/mwan3
parent1335e4f3dde65192ae0376792f3d18711439d24f (diff)
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>
Diffstat (limited to 'net/mwan3')
2 files changed, 41 insertions, 0 deletions
diff --git a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3
index a02f88baa..897872e68 100644
--- a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3
+++ b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3
@@ -19,6 +19,7 @@ config_get_bool enabled globals 'enabled' '0'
mwan3_lock
mwan3_init
mwan3_set_connected_iptables
+mwan3_set_custom_ipset
mwan3_unlock
config_get enabled $INTERFACE enabled 0
diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh
index eff51892b..712abe07c 100644
--- a/net/mwan3/files/lib/mwan3/mwan3.sh
+++ b/net/mwan3/files/lib/mwan3/mwan3.sh
@@ -188,6 +188,46 @@ mwan3_get_iface_id()
export "$1=$_tmp"
}
+mwan3_set_custom_ipset_v4()
+{
+ local custom_network_v4
+
+ for custom_network_v4 in $($IP4 route list table "$1" | awk '{print $1}' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}'); do
+ $LOG notice "Adding network $custom_network_v4 from table $1 to mwan3_custom_v4 ipset"
+ $IPS -! add mwan3_custom_v4_temp $custom_network_v4
+ done
+}
+
+mwan3_set_custom_ipset_v6()
+{
+ local custom_network_v6
+
+ for custom_network_v6 in $($IP6 route list table "$1" | awk '{print $1}' | egrep "$IPv6_REGEX"); do
+ $LOG notice "Adding network $custom_network_v6 from table $1 to mwan3_custom_v6 ipset"
+ $IPS -! add mwan3_custom_v6_temp $custom_network_v6
+ done
+}
+
+mwan3_set_custom_ipset()
+{
+ $IPS -! create mwan3_custom_v4 hash:net
+ $IPS create mwan3_custom_v4_temp hash:net
+ config_list_foreach "globals" "rt_table_lookup" mwan3_set_custom_ipset_v4
+ $IPS swap mwan3_custom_v4_temp mwan3_custom_v4
+ $IPS destroy mwan3_custom_v4_temp
+
+
+ $IPS -! create mwan3_custom_v6 hash:net family inet6
+ $IPS create mwan3_custom_v6_temp hash:net family inet6
+ config_list_foreach "globals" "rt_table_lookup" mwan3_set_custom_ipset_v6
+ $IPS swap mwan3_custom_v6_temp mwan3_custom_v6
+ $IPS destroy mwan3_custom_v6_temp
+
+ $IPS -! create mwan3_connected list:set
+ $IPS -! add mwan3_connected mwan3_custom_v4
+ $IPS -! add mwan3_connected mwan3_custom_v6
+}
+
mwan3_set_connected_iptables()
{
local connected_network_v4 connected_network_v6