From 3d5acdf381aeab6241e62ffdc8fefdc3e981491b Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Sun, 28 Jul 2013 18:38:20 -0300 Subject: [PATCH 1/6] batman-adv: better integration with netifd, turn config.sh into a netifd proto Signed-off-by: Gui Iribarren --- .../config.sh => netifd/proto/batmesh.sh} | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) rename batman-adv/files/lib/{batman-adv/config.sh => netifd/proto/batmesh.sh} (62%) mode change 100644 => 100755 diff --git a/batman-adv/files/lib/batman-adv/config.sh b/batman-adv/files/lib/netifd/proto/batmesh.sh old mode 100644 new mode 100755 similarity index 62% rename from batman-adv/files/lib/batman-adv/config.sh rename to batman-adv/files/lib/netifd/proto/batmesh.sh index 471c1f2..f88cfcd --- a/batman-adv/files/lib/batman-adv/config.sh +++ b/batman-adv/files/lib/netifd/proto/batmesh.sh @@ -1,35 +1,40 @@ #!/bin/sh +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + bat_load_module() { [ -d "/sys/module/batman_adv/" ] && return - - . /lib/functions.sh load_modules /etc/modules.d/*-crc16 /etc/modules.d/*-crypto* /etc/modules.d/*-lib-crc* /etc/modules.d/*-batman-adv* } -bat_config() -{ - local mesh="$1" +proto_batmesh_init_config() { + proto_config_add_string "aggregated_ogms" + proto_config_add_string "ap_isolation" + proto_config_add_string "bonding" + proto_config_add_string "bridge_loop_avoidance" + proto_config_add_string "distributed_arp_table" + proto_config_add_string "fragmentation" + proto_config_add_string "gw_bandwidth" + proto_config_add_string "gw_mode" + proto_config_add_string "gw_sel_class" + proto_config_add_string "hop_penalty" + proto_config_add_string "network_coding" + proto_config_add_string "log_level" + proto_config_add_string "orig_interval" + proto_config_add_string "vis_mode" +} + +proto_batmesh_setup() { + local config="$1" + local mesh="$2" local aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation local gw_bandwidth gw_mode gw_sel_class hop_penalty network_coding log_level orig_interval vis_mode - - config_get aggregated_ogms "$mesh" aggregated_ogms - config_get ap_isolation "$mesh" ap_isolation - config_get bonding "$mesh" bonding - config_get bridge_loop_avoidance "$mesh" bridge_loop_avoidance - config_get distributed_arp_table "$mesh" distributed_arp_table - config_get fragmentation "$mesh" fragmentation - config_get gw_bandwidth "$mesh" gw_bandwidth - config_get gw_mode "$mesh" gw_mode - config_get gw_sel_class "$mesh" gw_sel_class - config_get hop_penalty "$mesh" hop_penalty - config_get network_coding "$mesh" network_coding - config_get log_level "$mesh" log_level - config_get orig_interval "$mesh" orig_interval - config_get vis_mode "$mesh" vis_mode - - [ ! -f "/sys/class/net/$mesh/mesh/orig_interval" ] && echo "batman-adv mesh $mesh does not exist - check your interface configuration" && return 1 + + json_get_vars aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation + json_get_vars gw_bandwidth gw_mode gw_sel_class hop_penalty network_coding log_level orig_interval vis_mode [ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$mesh/mesh/aggregate_ogms [ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation @@ -45,4 +50,9 @@ bat_config() [ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&- [ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval [ -n "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode + + proto_init_update "$mesh" 1 + proto_send_update "$config" } + +add_protocol batmesh From 38e641e37a8741c1b47dcb867afc9fff94a4e211 Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Sun, 28 Jul 2013 18:42:37 -0300 Subject: [PATCH 2/6] batman-adv: better integration with netifd - use iface for coherence Signed-off-by: Gui Iribarren --- batman-adv/files/lib/netifd/proto/batmesh.sh | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/batman-adv/files/lib/netifd/proto/batmesh.sh b/batman-adv/files/lib/netifd/proto/batmesh.sh index f88cfcd..2038739 100755 --- a/batman-adv/files/lib/netifd/proto/batmesh.sh +++ b/batman-adv/files/lib/netifd/proto/batmesh.sh @@ -29,29 +29,29 @@ proto_batmesh_init_config() { proto_batmesh_setup() { local config="$1" - local mesh="$2" + local iface="$2" local aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation local gw_bandwidth gw_mode gw_sel_class hop_penalty network_coding log_level orig_interval vis_mode json_get_vars aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation json_get_vars gw_bandwidth gw_mode gw_sel_class hop_penalty network_coding log_level orig_interval vis_mode - [ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$mesh/mesh/aggregate_ogms - [ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation - [ -n "$bonding" ] && echo $bonding > /sys/class/net/$mesh/mesh/bonding - [ -n "$bridge_loop_avoidance" ] && echo $bridge_loop_avoidance > /sys/class/net/$mesh/mesh/bridge_loop_avoidance 2>&- - [ -n "$distributed_arp_table" ] && echo $distributed_arp_table > /sys/class/net/$mesh/mesh/distributed_arp_table 2>&- - [ -n "$fragmentation" ] && echo $fragmentation > /sys/class/net/$mesh/mesh/fragmentation - [ -n "$gw_bandwidth" ] && echo $gw_bandwidth > /sys/class/net/$mesh/mesh/gw_bandwidth - [ -n "$gw_mode" ] && echo $gw_mode > /sys/class/net/$mesh/mesh/gw_mode - [ -n "$gw_sel_class" ] && echo $gw_sel_class > /sys/class/net/$mesh/mesh/gw_sel_class - [ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty - [ -n "$network_coding" ] && echo $network_coding > /sys/class/net/$mesh/mesh/network_coding 2>&- - [ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&- - [ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval - [ -n "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode + [ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$iface/mesh/aggregate_ogms + [ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$iface/mesh/ap_isolation + [ -n "$bonding" ] && echo $bonding > /sys/class/net/$iface/mesh/bonding + [ -n "$bridge_loop_avoidance" ] && echo $bridge_loop_avoidance > /sys/class/net/$iface/mesh/bridge_loop_avoidance 2>&- + [ -n "$distributed_arp_table" ] && echo $distributed_arp_table > /sys/class/net/$iface/mesh/distributed_arp_table 2>&- + [ -n "$fragmentation" ] && echo $fragmentation > /sys/class/net/$iface/mesh/fragmentation + [ -n "$gw_bandwidth" ] && echo $gw_bandwidth > /sys/class/net/$iface/mesh/gw_bandwidth + [ -n "$gw_mode" ] && echo $gw_mode > /sys/class/net/$iface/mesh/gw_mode + [ -n "$gw_sel_class" ] && echo $gw_sel_class > /sys/class/net/$iface/mesh/gw_sel_class + [ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$iface/mesh/hop_penalty + [ -n "$network_coding" ] && echo $network_coding > /sys/class/net/$iface/mesh/network_coding 2>&- + [ -n "$log_level" ] && echo $log_level > /sys/class/net/$iface/mesh/log_level 2>&- + [ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$iface/mesh/orig_interval + [ -n "$vis_mode" ] && echo $vis_mode > /sys/class/net/$iface/mesh/vis_mode - proto_init_update "$mesh" 1 + proto_init_update "$iface" 1 proto_send_update "$config" } From ca73c28f1f40bde5369540b697cd95476bf457ea Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Sun, 28 Jul 2013 18:46:43 -0300 Subject: [PATCH 3/6] batman-adv: netifd integration, call bat_load_module before slave interface setup Signed-off-by: Gui Iribarren --- batman-adv/files/lib/netifd/proto/batadv.sh | 8 ++++++++ batman-adv/files/lib/netifd/proto/batmesh.sh | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/batman-adv/files/lib/netifd/proto/batadv.sh b/batman-adv/files/lib/netifd/proto/batadv.sh index 632a209..201084a 100644 --- a/batman-adv/files/lib/netifd/proto/batadv.sh +++ b/batman-adv/files/lib/netifd/proto/batadv.sh @@ -4,6 +4,12 @@ . ../netifd-proto.sh init_proto "$@" +bat_load_module() +{ + [ -d "/sys/module/batman_adv/" ] && return + load_modules /etc/modules.d/*-crc16 /etc/modules.d/*-crypto* /etc/modules.d/*-lib-crc* /etc/modules.d/*-batman-adv* +} + proto_batadv_init_config() { proto_config_add_string "mesh" } @@ -15,6 +21,8 @@ proto_batadv_setup() { local mesh json_get_vars mesh + bat_load_module + echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface" proto_init_update "$iface" 1 proto_send_update "$config" diff --git a/batman-adv/files/lib/netifd/proto/batmesh.sh b/batman-adv/files/lib/netifd/proto/batmesh.sh index 2038739..ba6e783 100755 --- a/batman-adv/files/lib/netifd/proto/batmesh.sh +++ b/batman-adv/files/lib/netifd/proto/batmesh.sh @@ -4,12 +4,6 @@ . ../netifd-proto.sh init_proto "$@" -bat_load_module() -{ - [ -d "/sys/module/batman_adv/" ] && return - load_modules /etc/modules.d/*-crc16 /etc/modules.d/*-crypto* /etc/modules.d/*-lib-crc* /etc/modules.d/*-batman-adv* -} - proto_batmesh_init_config() { proto_config_add_string "aggregated_ogms" proto_config_add_string "ap_isolation" From 2cee074d1995dffdd42dc5dec677453cd90733aa Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Sun, 28 Jul 2013 18:49:03 -0300 Subject: [PATCH 4/6] batman-adv: netifd integration, drop obsoleted files Signed-off-by: Gui Iribarren --- batman-adv/files/etc/config/batman-adv | 20 ------------------- .../files/etc/hotplug.d/net/99-batman-adv | 12 ----------- 2 files changed, 32 deletions(-) delete mode 100644 batman-adv/files/etc/config/batman-adv delete mode 100644 batman-adv/files/etc/hotplug.d/net/99-batman-adv diff --git a/batman-adv/files/etc/config/batman-adv b/batman-adv/files/etc/config/batman-adv deleted file mode 100644 index 79d660d..0000000 --- a/batman-adv/files/etc/config/batman-adv +++ /dev/null @@ -1,20 +0,0 @@ - -config 'mesh' 'bat0' - option 'aggregated_ogms' - option 'ap_isolation' - option 'bonding' - option 'fragmentation' - option 'gw_bandwidth' - option 'gw_mode' - option 'gw_sel_class' - option 'log_level' - option 'orig_interval' - option 'vis_mode' - option 'bridge_loop_avoidance' - option 'distributed_arp_table' - option 'network_coding' - option 'hop_penalty' - -# yet another batX instance -# config 'mesh' 'bat5' -# option 'interfaces' 'second_mesh' diff --git a/batman-adv/files/etc/hotplug.d/net/99-batman-adv b/batman-adv/files/etc/hotplug.d/net/99-batman-adv deleted file mode 100644 index f0c391f..0000000 --- a/batman-adv/files/etc/hotplug.d/net/99-batman-adv +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -. /lib/batman-adv/config.sh - -bat_load_module -config_load batman-adv - -case "$ACTION" in - add) - [ -d /sys/class/net/$INTERFACE/mesh/ ] && bat_config "$INTERFACE" - ;; -esac From c6f07c65784be916c5cf61ff44f44747a3555c15 Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Sun, 28 Jul 2013 20:15:29 -0300 Subject: [PATCH 5/6] batman-adv: provide migration script for old-style settings -> netifd Signed-off-by: Gui Iribarren --- .../uci-defaults/batadv-netifd-uci-migrations | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 batman-adv/files/etc/uci-defaults/batadv-netifd-uci-migrations diff --git a/batman-adv/files/etc/uci-defaults/batadv-netifd-uci-migrations b/batman-adv/files/etc/uci-defaults/batadv-netifd-uci-migrations new file mode 100755 index 0000000..df33a7d --- /dev/null +++ b/batman-adv/files/etc/uci-defaults/batadv-netifd-uci-migrations @@ -0,0 +1,38 @@ +#!/bin/sh +# Copyright (C) 2012 Gui Iribarren +# This is free software, licensed under the GNU General Public License v3. + +local batmeshes="$(uci -q show batman-adv \ + | sed -ne 's/^batman-adv.\([^.]*\)=mesh$/\1/p')" + +for mesh in $batmeshes ; do + + local batifaces="$(uci -q get batman-adv.$mesh.interfaces)" + + for iface in $batifaces ; do + if [ "$(uci -q get "network.$iface")" == "interface" ] ; then + uci set network.$iface.proto=batadv + uci set network.$iface.mesh=$mesh + uci set batman-adv.$mesh.interfaces="$(echo $batifaces | sed "s/\<$iface\>//g")" + fi + done + + local batparams="aggregated_ogms ap_isolation bonding bridge_loop_avoidance \ + distributed_arp_table fragmentation gw_bandwidth gw_mode gw_sel_class \ + hop_penalty network_coding log_level orig_interval vis_mode" + + for param in $batparams ; do + local value="$(uci -q get batman-adv.$mesh.$param)" + if [ "$value" ] ; then + uci set network.$mesh=interface + uci set network.$mesh.proto=batmesh + uci set network.$mesh.ifname=$mesh + uci set network.$mesh.$param=$value + uci delete batman-adv.$mesh.$param + fi + done + + uci commit network + uci commit batman-adv +done + From a5ff5808e3e7f1a6f4a40061cbaec02e14a99285 Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Sun, 28 Jul 2013 20:25:06 -0300 Subject: [PATCH 6/6] batman-adv: update Makefile to reflect tree changes, bump package release Signed-off-by: Gui Iribarren --- batman-adv/Makefile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/batman-adv/Makefile b/batman-adv/Makefile index 977d180..bba4833 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -12,7 +12,7 @@ PKG_NAME:=batman-adv PKG_VERSION:=2013.3.0 BATCTL_VERSION:=2013.3.0 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_MD5SUM:=d070c0879cd8fe8125315a4566fabd2d BATCTL_MD5SUM:=747535b0296f0013a6f99373a51d41fc @@ -124,11 +124,10 @@ define Build/Clean endef define KernelPackage/batman-adv/install - $(INSTALL_DIR) $(1)/etc/config $(1)/etc/hotplug.d/net $(1)/etc/hotplug.d/iface $(1)/lib/batman-adv $(1)/usr/sbin $(1)/lib/netifd/proto - $(INSTALL_DATA) ./files/etc/config/batman-adv $(1)/etc/config - $(INSTALL_DATA) ./files/lib/batman-adv/config.sh $(1)/lib/batman-adv - $(INSTALL_BIN) ./files/etc/hotplug.d/net/99-batman-adv $(1)/etc/hotplug.d/net + $(INSTALL_DIR) $(1)/usr/sbin $(1)/lib/netifd/proto $(INSTALL_BIN) ./files/lib/netifd/proto/batadv.sh $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/lib/netifd/proto/batmesh.sh $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/etc/uci-defaults/batadv-netifd-uci-migrations $(1)/etc/uci-defaults/ $(BATCTL_INSTALL) endef