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>
This commit is contained in:
parent
1335e4f3dd
commit
dcb7ad17ba
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue