Skip to contentSkip to conversation

batman-adv load module patch

B.A.T.M.A.N. HeXiLeD 2 participants 4 messages Mar 26, 2012 – Mar 28, 2012 1 message not in the archive

lore
Share & tools
lore

HeXiLeD

author
#1 lore raw
In reply to a message not in the archive

I have been trying to apply the patch which tries to fix the openwrt scripts in regards having batman-adv to bring up all it's attached interfaces but something seems not to be working.

Patch

------------------------------------------------------------------------

batman-adv/files/lib/batman-adv/config.sh +14 -3
@@ -1,6 +1,15 @@
 #!/bin/sh
 
-bat_config(){
+bat_load_module()
+{
+	[ -d "/sys/module/batman_adv/" ] && return
+	
+	. /etc/functions.sh
+	load_modules /etc/modules.d/*-lib-crc16 /etc/modules.d/*-batman-adv	
+}
+
+bat_config()
+{
 	local mesh="$1"
 	local aggregated_ogms bonding fragmentation gw_bandwidth gw_mode gw_sel_class log_level orig_interval hop_penalty vis_mode
 
@@ -30,7 +39,8 @@
 	
 }
 
-bat_add_interface(){
+bat_add_interface()
+{
 	local mesh="$1"
 	local interface="$2"
 	local interfaces
@@ -47,7 +57,8 @@
 	done
 }
 
-bat_del_interface(){
+bat_del_interface()
+{
 	local mesh="$1"
 	local interface="$2"
 	local interfaces
batman-adv/files/usr/sbin/batman-adv +1 -0
@@ -26,6 +26,7 @@
 
 # can also be used with "batman-adv start bat0"
 start() {
+	bat_load_module
 	config_load batman-adv
 
 	if [ -n "$1" ]; then
batman-adv/files/etc/hotplug.d/net/99-batman-adv +1 -0
@@ -2,6 +2,7 @@
 
 . /lib/batman-adv/config.sh
 
+bat_load_module
 config_load batman-adv
 
 case "$ACTION" in

------------------------------------------------------------------------
The patch should be working with my current revision:

URL: svn://svn.openwrt.org/openwrt/branches/backfire Repository Root: svn://svn.openwrt.org/openwrt Repository UUID: 3c298f89-4303-0410-b956-a3cf2f4a3e73
Revision: 31071
Node Kind: directory
Schedule: normal
Last Changed Author: jow
Last Changed Rev: 30898
Last Changed Date: 2012-03-11 22:09:16 -0400 (Sun, 11 Mar 2012)

As it seemed to be for 30313
https://dev.openwrt.org/browser/branches/packages_10.03.2/net/batman-adv/files/lib/batman-adv/config.sh

However it fails

Path:
OPENWRT/backfire/feeds/packages/net/batman-adv/files/etc/hotplug.d/net/99-batman-adv
------------------------------------------------------------------------

$ patch -p2 < batman-adv_load-module-when-needed.patch 99-batman-adv 
patching file 99-batman-adv
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 30.
Hunk #3 FAILED at 47.
3 out of 3 hunks FAILED -- saving rejects to file 99-batman-adv.rej
patching file 99-batman-adv
Hunk #1 FAILED at 26.
1 out of 1 hunk FAILED -- saving rejects to file 99-batman-adv.rej
patching file 99-batman-adv
$ patch -p1< batman-adv_load-module-when-needed.patch 
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a/batman-adv/files/lib/batman-adv/config.sh        (revision 30804)
|+++ b/batman-adv/files/lib/batman-adv/config.sh        (working copy)
--------------------------
File to patch: 99-batman-adv
patching file 99-batman-adv
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 30.
Hunk #3 FAILED at 47.
3 out of 3 hunks FAILED -- saving rejects to file 99-batman-adv.rej
can't find file to patch at input line 42
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a/batman-adv/files/usr/sbin/batman-adv     (revision 30804)
|+++ b/batman-adv/files/usr/sbin/batman-adv     (working copy)

Changing the patch number and increasing it does not work.

------------------------------------------------------------------------

99-batman-adv.rej

$ cat 99-batman-adv.rej
--- batman-adv/files/lib/batman-adv/config.sh   (revision 30804)
+++ batman-adv/files/lib/batman-adv/config.sh   (working copy)
@@ -1,6 +1,15 @@
 #!/bin/sh

-bat_config(){
+bat_load_module()
+{
+ [ -d "/sys/module/batman_adv/" ] && return
+
+ . /etc/functions.sh
+ load_modules /etc/modules.d/*-lib-crc16 /etc/modules.d/*-batman-adv
+}
+
+bat_config()
+{
local mesh="$1"
local aggregated_ogms bonding fragmentation gw_bandwidth gw_mode gw_sel_class log_level orig_interval hop_penalty vis_mode

@@ -30,7 +39,8 @@

}

-bat_add_interface(){
+bat_add_interface()

+{
        local mesh="$1"
        local interface="$2"
        local interfaces

@@ -47,7 +57,8 @@
done
}

-bat_del_interface(){
+bat_del_interface()

+{
        local mesh="$1"
        local interface="$2"
        local interfaces

------------------------------------------------------------------------

Solutions?

batman-adv/files/lib/batman-adv/config.sh +14 -3
@@ -1,6 +1,15 @@
 #!/bin/sh
 
-bat_config(){
+bat_load_module()
+{
+	[ -d "/sys/module/batman_adv/" ] && return
+	
+	. /etc/functions.sh
+	load_modules /etc/modules.d/*-lib-crc16 /etc/modules.d/*-batman-adv	
+}
+
+bat_config()
+{
 	local mesh="$1"
 	local aggregated_ogms bonding fragmentation gw_bandwidth gw_mode gw_sel_class log_level orig_interval hop_penalty vis_mode
 
@@ -30,7 +39,8 @@
 	
 }
 
-bat_add_interface(){
+bat_add_interface()
+{
 	local mesh="$1"
 	local interface="$2"
 	local interfaces
@@ -47,7 +57,8 @@
 	done
 }
 
-bat_del_interface(){
+bat_del_interface()
+{
 	local mesh="$1"
 	local interface="$2"
 	local interfaces
batman-adv/files/usr/sbin/batman-adv +1 -0
@@ -26,6 +26,7 @@
 
 # can also be used with "batman-adv start bat0"
 start() {
+	bat_load_module
 	config_load batman-adv
 
 	if [ -n "$1" ]; then
batman-adv/files/etc/hotplug.d/net/99-batman-adv +1 -0
@@ -2,6 +2,7 @@
 
 . /lib/batman-adv/config.sh
 
+bat_load_module
 config_load batman-adv
 
 case "$ACTION" in
#2 lore raw
Quoted 3 lines · On Tuesday, March 27, 2012 00:43:11 HeXiLeD wrote:

I have been trying to apply the patch which tries to fix the openwrt scripts in regards having batman-adv to bring up all it's attached interfaces but something seems not to be working.

Seems to be same problem we already discussed in the IRC channel.

Quoted 1 line
$ patch -p2 < batman-adv_load-module-when-needed.patch 99-batman-adv

That is not the way to apply a patch. Omit the last argument.

Quoted 2 lines
$ patch -p1< batman-adv_load-module-when-needed.patch
can't find file to patch at input line 3

Wrong path.

Quoted 2 lines
$ patch -p1< batman-adv_load-module-when-needed.patch 
can't find file to patch at input line 3

Wrong path.

You have to find the correct package path and don't supply too many arguments to make it work.

Regards,
Marek

author
#3 lore raw

You are correct. I was patching while inside of the same directory as the file to patch.

I was able to patch now, from ../files directory.
------------------------------------------------------------------------
OPENWRT/backfire/feeds/packages/net $ patch -p1<
batman-adv_load-module-when-needed.patch

patching file batman-adv/files/lib/batman-adv/config.sh

Hunk #2 succeeded at 36 with fuzz 1 (offset -3 lines).

Hunk #3 succeeded at 54 (offset -3 lines).

patching file batman-adv/files/usr/sbin/batman-adv

Hunk #1 succeeded at 25 (offset -1 lines).

patching file batman-adv/files/etc/hotplug.d/net/99-batman-adv

------------------------------------------------------------------------
After the patch i compiled and used the builds.
I tried one build from source and another made with the image builder

At boot; batman-adv still does not load both interfaces, only 1. (wlan0) In other to load both: batman-adv restart must be executed.

config 'mesh' 'bat0'
option 'ap_isolation' '0'
option 'bonding' '0'
option 'aggregation' '1'
option 'fragmentation' '1'
option 'gw_bandwidth' '3mbit/384kbit'
option 'gw_mode' 'client'
option 'gw_sel_class' '5'
option 'orig_interval' '1000'
option 'vis_mode' 'client'
option 'interfaces' 'wlan0 eth0.0

This concludes that the patch might not be working. Correct me if i am wrong.

------------------------------------------------------------------------

Quoted 27 lines · Marek Lindner
Quoted 3 lines · On Tuesday, March 27, 2012 00:43:11 HeXiLeD wrote:

I have been trying to apply the patch which tries to fix the openwrt scripts in regards having batman-adv to bring up all it's attached interfaces but something seems not to be working.

Seems to be same problem we already discussed in the IRC channel.

Quoted 1 line
$ patch -p2 < batman-adv_load-module-when-needed.patch 99-batman-adv

That is not the way to apply a patch. Omit the last argument.

Quoted 2 lines
$ patch -p1< batman-adv_load-module-when-needed.patch
can't find file to patch at input line 3

Wrong path.

Quoted 2 lines
$ patch -p1< batman-adv_load-module-when-needed.patch 
can't find file to patch at input line 3

Wrong path.

You have to find the correct package path and don't supply too many arguments to make it work.

Regards,
Marek

#4 lore raw
Quoted 5 lines · On Wednesday, March 28, 2012 13:21:00 HeXiLeD wrote:

After the patch i compiled and used the builds.
I tried one build from source and another made with the image builder

At boot; batman-adv still does not load both interfaces, only 1. (wlan0) In other to load both: batman-adv restart must be executed.

Did you verify that the patched script actually is on your router ? A quick peek into the installed shell scripts should eliminate this doubt.

Regards,
Marek