From patchwork Sun Feb 26 17:50:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Filippo Sallemi X-Patchwork-Id: 1579 Return-Path: Received: from mail-iy0-f169.google.com (mail-iy0-f169.google.com [209.85.210.169]) by open-mesh.org (Postfix) with ESMTPS id 94AB760080C for ; Sun, 26 Feb 2012 18:50:46 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@gmail.com; dkim-adsp=none Received: by iajr24 with SMTP id r24so616118iaj.14 for ; Sun, 26 Feb 2012 09:50:45 -0800 (PST) Received-SPF: pass (google.com: domain of tonyputi@gmail.com designates 10.50.181.228 as permitted sender) client-ip=10.50.181.228; Authentication-Results: mr.google.com; spf=pass (google.com: domain of tonyputi@gmail.com designates 10.50.181.228 as permitted sender) smtp.mail=tonyputi@gmail.com; dkim=pass header.i=tonyputi@gmail.com Received: from mr.google.com ([10.50.181.228]) by 10.50.181.228 with SMTP id dz4mr7503158igc.9.1330278645429 (num_hops = 1); Sun, 26 Feb 2012 09:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=P6kAi+H1iE0X6N5IEr3FPMQFwDL8Vt6EhwrzWaRLA4M=; b=Aw6WbMJVPe+nTagIgDt+RuUhDBhzpZExx5aYWOCk9oWz64/MTZ8bAEW4KaUPoaE8wx RS+IHU4CYhZudNg95QqfWnRAfPIQ6/an3FPUu7/5rYE53LLoUi6UD4JWuhy+BJI70z+4 gOHW+XXRzVhHgLb/KfuEYvv4LBPsIdLgpbT3k= Received: by 10.50.181.228 with SMTP id dz4mr6130562igc.9.1330278645336; Sun, 26 Feb 2012 09:50:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.129.98 with HTTP; Sun, 26 Feb 2012 09:50:25 -0800 (PST) In-Reply-To: References: <201202100053.46289.lindner_marek@yahoo.de> <201202111808.54341.lindner_marek@yahoo.de> From: Filippo Sallemi Date: Sun, 26 Feb 2012 18:50:25 +0100 Message-ID: To: The list for a Better Approach To Mobile Ad-hoc Networking Subject: Re: [B.A.T.M.A.N.] /lib/batman-adv/config.sh X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Feb 2012 17:50:47 -0000 oopps. I've miss the files Il 26 febbraio 2012 18:49, Filippo Sallemi 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 > Date: 11 febbraio 2012 11:08 > Oggetto: Re: /lib/batman-adv/config.sh > A: Filippo Sallemi > > > 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 Index: lib/batman-adv/config.sh =================================================================== --- lib/batman-adv/config.sh (revisione 30733) +++ lib/batman-adv/config.sh (copia locale) @@ -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 } Index: usr/sbin/batman-adv =================================================================== --- usr/sbin/batman-adv (revisione 30733) +++ usr/sbin/batman-adv (copia locale) @@ -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 [mesh]" +esac Index: etc/hotplug.d/net/99-batman-adv =================================================================== --- etc/hotplug.d/net/99-batman-adv (revisione 30733) +++ etc/hotplug.d/net/99-batman-adv (copia locale) @@ -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)