public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Moritz Warning <moritzwarning@web.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [RFC] batman-adv boot setup scheme on OpenWRT
Date: Sun, 09 Dec 2012 17:03:11 +0100	[thread overview]
Message-ID: <50C4B63F.60101@web.de> (raw)
In-Reply-To: <201212092231.50649.lindner_marek@yahoo.de>

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

Here you go. :)
It would be good idea if Gui had a look at it before it is applied.

On 12/09/2012 03:31 PM, Marek Lindner wrote:
> On Sunday, December 09, 2012 19:10:56 Moritz Warning wrote:
>> I have tried batman-adv-netifd-proto-batadv.patch along with some Makefile
>> adjustments to get it compile. Afaict it works.
> Thanks for testing! Do you mind sharing & explaining these changes ? Would be 
> a good idea to push the working variant, don't you think ?
>
> Cheers,
> Marek
>


[-- Attachment #2: batman-adv-netifd-proto-batadv.patch --]
[-- Type: text/x-patch, Size: 5367 bytes --]

From d37c189ef8d87e44d2d6a28bbae0c960147d2098 Mon Sep 17 00:00:00 2001
From: Moritz Warning <moritzwarning@web.de>
Date: Sun, 9 Dec 2012 16:57:04 +0100
Subject: [PATCH] batman-adv netifd proto batadv

---
 batman-adv-devel/Makefile                          |    4 +--
 batman-adv-devel/files/etc/config/batman-adv       |    1 -
 .../files/etc/hotplug.d/iface/99-batman-adv        |   12 -------
 .../files/etc/hotplug.d/net/99-batman-adv          |    3 --
 batman-adv-devel/files/lib/batman-adv/config.sh    |   34 --------------------
 batman-adv-devel/files/lib/netifd/proto/batadv.sh  |   30 +++++++++++++++++
 6 files changed, 32 insertions(+), 52 deletions(-)
 delete mode 100644 batman-adv-devel/files/etc/hotplug.d/iface/99-batman-adv
 create mode 100644 batman-adv-devel/files/lib/netifd/proto/batadv.sh

diff --git a/batman-adv-devel/Makefile b/batman-adv-devel/Makefile
index e80b49a..7bbb75e 100644
--- a/batman-adv-devel/Makefile
+++ b/batman-adv-devel/Makefile
@@ -113,11 +113,11 @@ define Build/Clean
 endef
 
 define KernelPackage/batman-adv-devel/install
-	$(INSTALL_DIR) $(1)/etc/config $(1)/etc/hotplug.d/net $(1)/etc/hotplug.d/iface $(1)/lib/batman-adv $(1)/usr/sbin
+	$(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_BIN) ./files/etc/hotplug.d/iface/99-batman-adv $(1)/etc/hotplug.d/iface
+	$(INSTALL_BIN) ./files/lib/netifd/proto/batadv.sh $(1)/lib/netifd/proto
 	$(INSTALL_BIN) ./files/usr/sbin/batman-adv $(1)/usr/sbin
 	$(BATCTL_INSTALL)
 endef
diff --git a/batman-adv-devel/files/etc/config/batman-adv b/batman-adv-devel/files/etc/config/batman-adv
index 6ec9e03..6a62203 100644
--- a/batman-adv-devel/files/etc/config/batman-adv
+++ b/batman-adv-devel/files/etc/config/batman-adv
@@ -1,6 +1,5 @@
 
 config 'mesh' 'bat0'
-	option 'interfaces' 'mesh'
 	option 'aggregated_ogms'
 	option 'ap_isolation'
 	option 'bonding'
diff --git a/batman-adv-devel/files/etc/hotplug.d/iface/99-batman-adv b/batman-adv-devel/files/etc/hotplug.d/iface/99-batman-adv
deleted file mode 100644
index 9206c42..0000000
--- a/batman-adv-devel/files/etc/hotplug.d/iface/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
-        ifup)
-                [ -d /sys/class/net/$DEVICE/batman_adv/ ] && config_foreach bat_add_interface mesh "$DEVICE"
-                ;;
-esac
diff --git a/batman-adv-devel/files/etc/hotplug.d/net/99-batman-adv b/batman-adv-devel/files/etc/hotplug.d/net/99-batman-adv
index 47132c1..f0c391f 100644
--- a/batman-adv-devel/files/etc/hotplug.d/net/99-batman-adv
+++ b/batman-adv-devel/files/etc/hotplug.d/net/99-batman-adv
@@ -9,7 +9,4 @@ case "$ACTION" in
 	add)
 		[ -d /sys/class/net/$INTERFACE/mesh/ ] && bat_config "$INTERFACE"
 		;;
-	remove)
-		[ -d /sys/class/net/$INTERFACE/batman_adv/ ] && config_foreach bat_del_interface mesh "$INTERFACE"
-		;;
 esac
diff --git a/batman-adv-devel/files/lib/batman-adv/config.sh b/batman-adv-devel/files/lib/batman-adv/config.sh
index 5260c01..ae102e9 100644
--- a/batman-adv-devel/files/lib/batman-adv/config.sh
+++ b/batman-adv-devel/files/lib/batman-adv/config.sh
@@ -44,37 +44,3 @@ bat_config()
 	[ -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
 }
-
-bat_add_interface()
-{
-	local mesh="$1"
-	local interface="$2"
-	local interfaces
-
-	config_get interfaces $mesh interfaces
-	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
-		}
-	
-		[ "$iface" = "$interface" ] && echo $mesh > /sys/class/net/$iface/batman_adv/mesh_iface
-	done
-}
-
-bat_del_interface()
-{
-	local mesh="$1"
-	local interface="$2"
-	local interfaces
-
-	config_get interfaces $mesh interfaces
-	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
-		}
-
-		[ "$iface" = "$interface" ] && echo none > /sys/class/net/$iface/batman_adv/mesh_iface
-	done
-}
diff --git a/batman-adv-devel/files/lib/netifd/proto/batadv.sh b/batman-adv-devel/files/lib/netifd/proto/batadv.sh
new file mode 100644
index 0000000..632a209
--- /dev/null
+++ b/batman-adv-devel/files/lib/netifd/proto/batadv.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_batadv_init_config() {
+	proto_config_add_string "mesh"
+}
+
+proto_batadv_setup() {
+	local config="$1"
+	local iface="$2"
+
+	local mesh
+	json_get_vars mesh
+
+	echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface"
+	proto_init_update "$iface" 1
+	proto_send_update "$config"
+}
+
+proto_batadv_teardown() {
+	local config="$1"
+	local iface="$2"
+
+	echo "none" > "/sys/class/net/$iface/batman_adv/mesh_iface" || true
+}
+
+add_protocol batadv
-- 
1.7.10.4


  reply	other threads:[~2012-12-09 16:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-23 12:52 [B.A.T.M.A.N.] [RFC] batman-adv boot setup scheme on OpenWRT Gui Iribarren
2012-11-23 14:00 ` Gui Iribarren
2012-11-26 10:40   ` Marek Lindner
2012-11-26 10:45     ` Sven Eckelmann
2012-12-02 13:19       ` Gui Iribarren
2012-12-09 11:10         ` Moritz Warning
2012-12-09 14:31           ` Marek Lindner
2012-12-09 16:03             ` Moritz Warning [this message]
2012-12-09 16:20               ` Antonio Quartulli
2012-12-09 16:35               ` Gui Iribarren
2012-12-10  0:13                 ` Jo-Philipp Wich
2012-12-09 16:50               ` Moritz Warning
2012-11-25 17:12 ` Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50C4B63F.60101@web.de \
    --to=moritzwarning@web.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox