/lib/batman-adv/config.sh
Commit Message
oopps. I've miss the files
Il 26 febbraio 2012 18:49, Filippo Sallemi <tonyputi@gmail.com> ha scritto:
> Ok in this email my proposal patch.
> I've to sleep 4s if you have an ap + adhoc vifs.
>
> [ "$(echo $interface | awk '$0 ~ /^wlan[0-9]*/')" ] && sleep 4s
>
> For convenience I sleep only if an wlan was triggered. If you have
> only one interface in adhoc mode per radio 3 seconds are enought.
>
> bye
>
> ---------- Messaggio inoltrato ----------
> Da: Marek Lindner <lindner_marek@yahoo.de>
> Date: 11 febbraio 2012 11:08
> Oggetto: Re: /lib/batman-adv/config.sh
> A: Filippo Sallemi <tonyputi@gmail.com>
>
>
> On Friday, February 10, 2012 01:21:21 you wrote:
>> > Yeah - looks good.
>> > I still don't get why we don't need to wait 3/5 seconds anymore. Can you
>> > explain this ?
>>
>> No i'm wrong we need to wait 3 seconds... i think that the sleep call
>> could be moved to hotplug.d/99-batman-adv when an interface is added
>> to mesh interface.
>> I need some time.
>
> Ok - I left the "sleep 3s" in the file. I applied your config_bat/bat_config
> as well as the forgotten ap_isolation config fix.
>
> Since the for loop does not fix the wait problem why do you wish to change it?
> I am referring to your suggested change:
>
> # Load network config here just in case!
> config_load network
> for iface in $interfaces; do
> # copy iface into ifname
> local ifname=$iface
> [ -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] || {
> # if ifname was not found try to find it via uci config
> config_get ifname $iface ifname
> [ -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] ||
> continue
> }
>
> [ "$ifname" = "$interface" ] && echo $mesh >
> /sys/class/net/$ifname/batman_adv/mesh_iface
> done
>
> bat_add_interface() and bat_del_interface() have the same loop but we only
> change one ? The only difference I can see is another added variable and not
> calling "uci -q -P/var/state get network.$iface.ifname". Why ?
>
> Cheers,
> Marek
>
>
> --
> Filippo Sallemi
===================================================================
@@ -14,6 +14,7 @@
config_get orig_interval "$mesh" orig_interval
config_get hop_penalty "$mesh" hop_penalty
config_get vis_mode "$mesh" vis_mode
+ config_get ap_isolation "$mesh" ap_isolation
[ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval
[ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty
@@ -25,22 +26,27 @@
[ -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 "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode
+ [ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation
}
bat_add_interface(){
local mesh="$1"
local interface="$2"
- local interfaces
-
- sleep 3s # some device (ath) is very lazy to start
+ local iface interfaces
+
config_get interfaces $mesh interfaces
+
+ [ "$(echo $interface | awk '$0 ~ /^wlan[0-9]*/')" ] && sleep 4s
+ # Load network config here just in case!
+ config_load network
for iface in $interfaces; do
- [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || {
- iface=$(uci -q -P/var/state get network.$iface.ifname)
- [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || continue
+ local ifname="$iface"
+ [ -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] || {
+ config_get ifname $iface ifname
+ [ -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] || continue
}
-
- [ "$iface" = "$interface" ] && echo $mesh > /sys/class/net/$iface/batman_adv/mesh_iface
+
+ [ "$ifname" = "$interface" ] && echo $mesh > /sys/class/net/$ifname/batman_adv/mesh_iface
done
}
@@ -50,12 +56,16 @@
local interfaces
config_get interfaces $mesh interfaces
+
+ # Load network config here just in case!
+ config_load network
for iface in $interfaces; do
- [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || {
- iface=$(uci -q -P/var/state get network.$iface.ifname)
- [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || continue
+ local ifname="$iface"
+ [ -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] || {
+ config_get ifname $iface ifname
+ [ -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] || continue
}
- [ "$iface" = "$interface" ] && echo none > /sys/class/net/$iface/batman_adv/mesh_iface
+ [ "$ifname" = "$interface" ] && echo none > /sys/class/net/$ifname/batman_adv/mesh_iface
done
}
===================================================================
@@ -1,6 +1,7 @@
-#!/bin/sh /etc/rc.common
+#!/bin/sh
# Copyright (C) 2011 OpenWrt.org
+. /etc/functions.sh
. /lib/batman-adv/config.sh
start_mesh() {
@@ -44,3 +45,15 @@
config_foreach stop_mesh mesh
fi
}
+
+restart() {
+ stop $1
+ start $1
+}
+
+case "$1" in
+ start) start $2 ;;
+ stop) stop $2 ;;
+ restart) restart $2 ;;
+ *) echo "Usage: batman-adv <start|stop|restart> [mesh]"
+esac
===================================================================
@@ -6,7 +6,7 @@
case "$ACTION" in
add)
- [ -d /sys/class/net/$INTERFACE/mesh/ ] && config_bat "$INTERFACE"
+ [ -d /sys/class/net/$INTERFACE/mesh/ ] && bat_config "$INTERFACE"
[ -d /sys/class/net/$INTERFACE/batman_adv/ ] && config_foreach bat_add_interface mesh "$INTERFACE"
;;
remove)