1
0
mirror of https://git.openwrt.org/feed/routing.git synced 2024-06-18 13:13:56 +02:00
openwrt-routing/batman-adv/files/etc/uci-defaults/99-migrate-batadv_hardif

98 lines
3.9 KiB
Plaintext
Raw Normal View History

batman-adv: Split batadv proto in meshif and hardif part batman-adv allows to configure three different objects: * batadv hardif - network interface used by batadv meshif to transport the batman-adv packets - its master interface is set to the batadv meshif * batadv (meshif/softif) - virtual interface that emulates a normal 802.3 interface on top - encapsulates traffic and forwards it via the batadv hardifs * batadv vlan - potential VLAN ID on top of batadv meshif - allows filtering of traffic from specific VIDs While batadv vlan objects were already represented as an own proto "batadv_vlan", the batadv meshif could never be fully configured using /etc/config/network. Instead, parts of its configuration were stored in /etc/config/batman_adv and some in the interfaces with the "batadv" proto. To increase the confusion, the "batadv" proto wasn't used to define the batadv meshif but to identify batadv (slave) hardifs. The batman-adv meshifs were also never created directly but only when a hardif was configured. The actual modification of the configuration settings was then applied using a hotplug script hack. The batadv meshif network interface could therefore only be created when an hardif was available and not manipulated with ifup/ifdown. Also `/etc/init.d/network reload` didn't modify the batadv meshif interface configuration correctly. The "batadv" is now renamed to "batadv_hardif" and a new "batadv" proto is used to configure the main (meshif) network interface with all its configuration. A simple network configuration with WiFi & ethernet interfaces and static IP on top of bat0 would look like: # batadv meshif bat0 config interface 'bat0' option proto 'batadv' option routing_algo 'BATMAN_IV' option aggregated_ogms 1 option ap_isolation 0 option bonding 0 option fragmentation 1 #option gw_bandwidth '10000/2000' option gw_mode 'off' #option gw_sel_class 20 option log_level 0 option orig_interval 1000 option bridge_loop_avoidance 1 option distributed_arp_table 1 option multicast_mode 1 option network_coding 0 option hop_penalty 30 option isolation_mark '0x00000000/0x00000000' # add *single* wifi-iface with network bat0_hardif_wlan as hardif to bat0 config interface 'bat0_hardif_wlan' option mtu '1536' option proto 'batadv_hardif' option master 'bat0' # option ifname is filled out by the wifi-iface # add eth0 as hardif to bat0 config interface 'bat0_hardif_eth0' option proto 'batadv_hardif' option master 'bat0' option ifname 'eth0' option mtu '1536' # configure IP on bat0 config interface 'bat0_lan' option ifname 'bat0' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' option ip6assign '60' Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-02-24 17:51:13 +01:00
#!/bin/sh
# This UCI-Defaults script will split the batadv proto network interfaces
# in batadv_hardif and batadv proto. The configuration options from
# /etc/config/batman-adv will be moved to the latter.
. /lib/functions.sh
proto_batadv_to_batadv_hardif() {
local section="$1"
local proto
local mesh
local routing_algo
config_get proto "${section}" proto
config_get mesh "${section}" mesh
config_get routing_algo "${section}" routing_algo
if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
continue
fi
uci set network."${section}".proto="batadv_hardif"
uci rename network."${section}".mesh="master"
uci delete network."${section}".routing_algo
# create new section or adjust existing one
uci set network."${mesh}"=interface
uci set network."${mesh}".proto=batadv
[ -n "${routing_algo}" ] && uci set network."${mesh}".routing_algo="${routing_algo}"
}
mv_batadv_config_section() {
local section="$1"
local aggregated_ogms
local ap_isolation
local bonding
local bridge_loop_avoidance
local distributed_arp_table
local fragmentation
local gw_bandwidth
local gw_mode
local gw_sel_class
local hop_penalty
local isolation_mark
local log_level
local multicast_mode
local network_coding
local orig_interval
config_get aggregated_ogms "${section}" aggregated_ogms
config_get ap_isolation "${section}" ap_isolation
config_get bonding "${section}" bonding
config_get bridge_loop_avoidance "${section}" bridge_loop_avoidance
config_get distributed_arp_table "${section}" distributed_arp_table
config_get fragmentation "${section}" fragmentation
config_get gw_bandwidth "${section}" gw_bandwidth
config_get gw_mode "${section}" gw_mode
config_get gw_sel_class "${section}" gw_sel_class
config_get hop_penalty "${section}" hop_penalty
config_get isolation_mark "${section}" isolation_mark
config_get log_level "${section}" log_level
config_get multicast_mode "${section}" multicast_mode
config_get network_coding "${section}" network_coding
config_get orig_interval "${section}" orig_interval
# update section in case it exists
[ -n "${aggregated_ogms}" ] && uci set network."${section}".aggregated_ogms="${aggregated_ogms}"
[ -n "${ap_isolation}" ] && uci set network."${section}".ap_isolation="${ap_isolation}"
[ -n "${bonding}" ] && uci set network."${section}".bonding="${bonding}"
[ -n "${bridge_loop_avoidance}" ] && uci set network."${section}".bridge_loop_avoidance="${bridge_loop_avoidance}"
[ -n "${distributed_arp_table}" ] && uci set network."${section}".distributed_arp_table="${distributed_arp_table}"
[ -n "${fragmentation}" ] && uci set network."${section}".fragmentation="${fragmentation}"
[ -n "${gw_bandwidth}" ] && uci set network."${section}".gw_bandwidth="${gw_bandwidth}"
[ -n "${gw_mode}" ] && uci set network."${section}".gw_mode="${gw_mode}"
[ -n "${gw_sel_class}" ] && uci set network."${section}".gw_sel_class="${gw_sel_class}"
[ -n "${hop_penalty}" ] && uci set network."${section}".hop_penalty="${hop_penalty}"
[ -n "${isolation_mark}" ] && uci set network."${section}".isolation_mark="${isolation_mark}"
[ -n "${log_level}" ] && uci set network."${section}".log_level="${log_level}"
[ -n "${multicast_mode}" ] && uci set network."${section}".multicast_mode="${multicast_mode}"
[ -n "${network_coding}" ] && uci set network."${section}".network_coding="${network_coding}"
[ -n "${orig_interval}" ] && uci set network."${section}".orig_interval="${orig_interval}"
}
if [ -f /etc/config/batman-adv ]; then
config_load network
config_foreach proto_batadv_to_batadv_hardif 'interface'
uci commit network
config_load batman-adv
config_foreach mv_batadv_config_section 'mesh'
uci commit network
batman-adv: Split batadv proto in meshif and hardif part batman-adv allows to configure three different objects: * batadv hardif - network interface used by batadv meshif to transport the batman-adv packets - its master interface is set to the batadv meshif * batadv (meshif/softif) - virtual interface that emulates a normal 802.3 interface on top - encapsulates traffic and forwards it via the batadv hardifs * batadv vlan - potential VLAN ID on top of batadv meshif - allows filtering of traffic from specific VIDs While batadv vlan objects were already represented as an own proto "batadv_vlan", the batadv meshif could never be fully configured using /etc/config/network. Instead, parts of its configuration were stored in /etc/config/batman_adv and some in the interfaces with the "batadv" proto. To increase the confusion, the "batadv" proto wasn't used to define the batadv meshif but to identify batadv (slave) hardifs. The batman-adv meshifs were also never created directly but only when a hardif was configured. The actual modification of the configuration settings was then applied using a hotplug script hack. The batadv meshif network interface could therefore only be created when an hardif was available and not manipulated with ifup/ifdown. Also `/etc/init.d/network reload` didn't modify the batadv meshif interface configuration correctly. The "batadv" is now renamed to "batadv_hardif" and a new "batadv" proto is used to configure the main (meshif) network interface with all its configuration. A simple network configuration with WiFi & ethernet interfaces and static IP on top of bat0 would look like: # batadv meshif bat0 config interface 'bat0' option proto 'batadv' option routing_algo 'BATMAN_IV' option aggregated_ogms 1 option ap_isolation 0 option bonding 0 option fragmentation 1 #option gw_bandwidth '10000/2000' option gw_mode 'off' #option gw_sel_class 20 option log_level 0 option orig_interval 1000 option bridge_loop_avoidance 1 option distributed_arp_table 1 option multicast_mode 1 option network_coding 0 option hop_penalty 30 option isolation_mark '0x00000000/0x00000000' # add *single* wifi-iface with network bat0_hardif_wlan as hardif to bat0 config interface 'bat0_hardif_wlan' option mtu '1536' option proto 'batadv_hardif' option master 'bat0' # option ifname is filled out by the wifi-iface # add eth0 as hardif to bat0 config interface 'bat0_hardif_eth0' option proto 'batadv_hardif' option master 'bat0' option ifname 'eth0' option mtu '1536' # configure IP on bat0 config interface 'bat0_lan' option ifname 'bat0' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' option ip6assign '60' Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-02-24 17:51:13 +01:00
rm -f /etc/config/batman-adv
fi
exit 0