Batman-adv and Uevent (gateway/client modes)
I have reached a point where i need to start using the uevent functionality to work around some network scenarios when the gateways lose internet access but i am having a bit of a difficult time understanding how to do it since making use of uevents which is something new to me.
The explanation here is not helping much either
http://www.open-mesh.org/projects/batman-adv/wiki/Uevent
and i understand that i might need to go to the basics to understand it and learn how to code.
My need to use uevents to change a nodes behaviour is to change a node from server to client and vice versa when it loses connectivity to the WAN (not for example losing connectivity to the dsl router that is actually the gateway but that has the node as a LAN client)
I am assuming that uevents will allow me to work with this physical setup correct?
As far as i understand now and if i am not mistaken when a gateway loses WAN connectivity the node that is making use of uevents will change the node from "server" to "client" on batman-adv .
Now my question is if i can also make it to change the dhcp setup from dhcp server to inactive and receive it´s dhcp service from another gateway node.
In theory something like this would be executed on openwrt when a gateway node detects no connectivity to the wan:
uci set batman-adv.bat0.gw_mode=client ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=0 ;
uci set dhcp.lan.ignore=1 ;
uci commit dhcp ;/etc/init.d/dnsmasq restart ;
when it detects wan connectivity it will want to become a server and will auto execute:
uci set batman-adv.bat0.gw_mode=server ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=1 ;
uci set dhcp.lan.ignore=0 ;
uci commit dhcp ;/etc/init.d/dnsmasq restart ;
A small script can even be made in order so simplify things either automatically or manually and lets call it:
gateway-mode
client-mode
Upon detecting no WAN connectivity the script will be activated.
Am i on the right track so far (at least in theory) ?
Now the second part is how to detect WAN connectivity which is different from noticing that there is no connectivity to the actual gw router that has the node on it's LAN.
I thought about a ping test to a few address from which after 100% loss reply from all; something or Uevent will activate the gateway/client mode script but it creates another problem ahead.
In a quick conversation with ordex on irc i understand that i have to invoke the wiki docs uevent functions with the parameters i want at the moment i decide.
This can be the gateway/client mode script
correct ?
Since uevent is something new to me; can someone recommend some freshman tutorial that may take me in the right direction. I have no clue where or how to start looking to code it and also when coded; where will it be added.
I also would like to ask anyone that has uevent working how they are using it for the same type of need and maybe even share some recipe.
Signature · 7 lines
Site: http://wirelesspt.net Mesh: http://tinyurl.com/wirelesspt Admin: http://wirelesspt.net/wiki/Cmsv Suporte técnico via sms: 91 19 11 798 Donativos/Paypal: http://tinyurl.com/doar-verba Chave publica PGP/SSH: http://wirelesspt.net/arquivos/pk Email assinado digitalmente pelo emissor assegurando autenticidade
Quoted 17 lines · cmsv
I have reached a point where i need to start using the uevent functionality to work around some network scenarios when the gateways lose internet access but i am having a bit of a difficult time understanding how to do it since making use of uevents which is something new to me.
The explanation here is not helping much either
http://www.open-mesh.org/projects/batman-adv/wiki/Ueventand i understand that i might need to go to the basics to understand it and learn how to code.
My need to use uevents to change a nodes behaviour is to change a node from server to client and vice versa when it loses connectivity to the WAN (not for example losing connectivity to the dsl router that is actually the gateway but that has the node as a LAN client)
Quoted 6 lines
I am assuming that uevents will allow me to work with this physical setup correct?
As far as i understand now and if i am not mistaken when a gateway loses WAN connectivity the node that is making use of uevents will change the node from "server" to "client" on batman-adv .
That won't happen automatically, you need some userspace script to handle the event and change batman-adv gw mode
Please check
https://colectivo.altermundi.net/projects/altermesh-packages/repository/show/batman-adv-auto-gw-mode
which in turn depends on
https://colectivo.altermundi.net/projects/altermesh-packages/repository/show/watchping
you should read the source code of batman-adv-auto-gw-mode (just a few lines / files) and i'll comment a bit about it along this email,
you can grab the "binaries" (actually ipk-packaged bash scripts) and try them right away
http://chef.mesh.altermundi.net/downloads/r36139/ar71xx/packages/batman-adv-auto-gw-mode_2013-04-11-237-1_ar71xx.ipk
http://chef.mesh.altermundi.net/downloads/r36139/ar71xx/packages/watchping_2013-04-11-237-1_ar71xx.ipk
mind you, the default behaviour of sending the hostname in dhcp requests has changed in recent trunk builds, so this feature might not work reliable; but on the other hand, that might not make any difference in your scenario :) (you don't seem to care about hostnames)
Quoted 27 lines
Now my question is if i can also make it to change the dhcp setup from dhcp server to inactive and receive it´s dhcp service from another gateway node
In theory something like this would be executed on openwrt when a gateway node detects no connectivity to the wan:
uci set batman-adv.bat0.gw_mode=client ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=0 ;
uci set dhcp.lan.ignore=1 ;
uci commit dhcp ;/etc/init.d/dnsmasqrestart ;when it detects wan connectivity it will want to become a server and will auto execute:
uci set batman-adv.bat0.gw_mode=server ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=1 ;
uci set dhcp.lan.ignore=0 ;
uci commit dhcp ;/etc/init.d/dnsmasqrestart ;
Quoted 4 lines
A small script can even be made in order so simplify things either automatically or manually and lets call it:
gateway-mode
client-mode
this would equiv to
/etc/watchping/wan-ok.d/batman-gw/etc/watchping/wan-fail.d/batman-gw
Quoted 10 lines
Upon detecting no WAN connectivity the script will be activated.
Am i on the right track so far (at least in theory) ?
Now the second part is how to detect WAN connectivity which is different from noticing that there is no connectivity to the actual gw router that has the node on it's LAN.
Quoted 8 lines
I thought about a ping test to a few address from which after 100% loss reply from all; something or Uevent will activate the gateway/client mode script but it creates another problem ahead.
In a quick conversation with ordex on irc i understand that i have to invoke the wiki docs uevent functions with the parameters i want at the moment i decide.
This can be the gateway/client mode script
Yes, in my case /etc/hotplug.d/net/99-batman-gw
Quoted 15 lines
correct ?
Since uevent is something new to me; can someone recommend some freshman tutorial that may take me in the right direction. I have no clue where or how to start looking to code it and also when coded; where will it be added.
I also would like to ask anyone that has uevent working how they are using it for the same type of need and maybe even share some recipe.
I took a look at your scripts and it seems we both have the same kind of idea.
Quoted 21 lines · Gui Iribarren
Quoted 20 lines · cmsv
I have reached a point where i need to start using the uevent functionality to work around some network scenarios when the gateways lose internet access but i am having a bit of a difficult time understanding how to do it since making use of uevents which is something new to me.
The explanation here is not helping much either
http://www.open-mesh.org/projects/batman-adv/wiki/Ueventand i understand that i might need to go to the basics to understand it and learn how to code.
My need to use uevents to change a nodes behaviour is to change a node from server to client and vice versa when it loses connectivity to the WAN (not for example losing connectivity to the dsl router that is actually the gateway but that has the node as a LAN client)
I am assuming that uevents will allow me to work with this physical setup correct?
Quoted 7 lines
Quoted 3 lines
As far as i understand now and if i am not mistaken when a gateway loses WAN connectivity the node that is making use of uevents will change the node from "server" to "client" on batman-adv .
That won't happen automatically, you need some userspace script to handle the event and change batman-adv gw mode
correct.
Quoted 5 lines
Please check
https://colectivo.altermundi.net/projects/altermesh-packages/repository/show/batman-adv-auto-gw-mode
Quoted 8 lines
which in turn depends on
https://colectivo.altermundi.net/projects/altermesh-packages/repository/show/watchping
you should read the source code of batman-adv-auto-gw-mode (just a few lines / files) and i'll comment a bit about it along this email,
The code is very much what i am looking for in terms of functionality
Quoted 7 lines
you can grab the "binaries" (actually ipk-packaged bash scripts) and try them right away
I installed both and all files were installed in their proper directories but for some reason it did not work :
# /etc/init.d/watchping start uci: Entry not found
and :
# cat /etc/uci-defaults/watchping #!/bin/sh
uci -q get system.@watchping[0] || {
uci batch <<EOF
add system watchping
set system.@watchping[0].interface=wan set system.@watchping[0].timeout=2m set system.@watchping[0].pinghosts=8.8.8.8 set system.@watchping[0].pinginterval=20s commit system
EOF
}
/etc/uci-defaults# ./watchping
cfg0a252a
inserted the code into /etc/config/system . that was the only way it got there. Was it suppose to be auto-configured after the installation of the package ?
Quoted 7 lines
mind you, the default behaviour of sending the hostname in dhcp requests has changed in recent trunk builds, so this feature might not work reliable; but on the other hand, that might not make any difference in your scenario :) (you don't seem to care about hostnames)
I am currently using:
DISTRIB_ID="OpenWrt"
DISTRIB_RELEASE="Attitude Adjustment" DISTRIB_REVISION="r35153" DISTRIB_CODENAME="attitude_adjustment" DISTRIB_TARGET="ar71xx/generic" DISTRIB_DESCRIPTION="OpenWrt Attitude Adjustment 12.09-rc1"
and will stay with AA for a while.
Quoted 34 lines
Quoted 29 lines
Now my question is if i can also make it to change the dhcp setup from dhcp server to inactive and receive it´s dhcp service from another gateway node
In theory something like this would be executed on openwrt when a gateway node detects no connectivity to the wan:
uci set batman-adv.bat0.gw_mode=client ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=0 ;
uci set dhcp.lan.ignore=1 ;
uci commit dhcp ;/etc/init.d/dnsmasqrestart ;when it detects wan connectivity it will want to become a server and will auto execute:
uci set batman-adv.bat0.gw_mode=server ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=1 ;
uci set dhcp.lan.ignore=0 ;
uci commit dhcp ;/etc/init.d/dnsmasqrestart ;Quoted 4 lines
A small script can even be made in order so simplify things either automatically or manually and lets call it:
gateway-mode
client-mode
Quoted 4 lines
this would equiv to
/etc/watchping/wan-ok.d/batman-gw/etc/watchping/wan-fail.d/batman-gw
I do see that inside these directories i have only a README file. Are these directories to have my own scripts or other scripts that come with your package ?
Quoted 15 lines
Quoted 15 lines
Upon detecting no WAN connectivity the script will be activated.
Am i on the right track so far (at least in theory) ?
Now the second part is how to detect WAN connectivity which is different from noticing that there is no connectivity to the actual gw router that has the node on it's LAN.
I thought about a ping test to a few address from which after 100% loss reply from all; something or Uevent will activate the gateway/client mode script but it creates another problem ahead.
Quoted 6 lines
Quoted 4 lines
In a quick conversation with ordex on irc i understand that i have to invoke the wiki docs uevent functions with the parameters i want at the moment i decide.
This can be the gateway/client mode scriptYes, in my case
/etc/hotplug.d/net/99-batman-gw
The only file i have there is /etc/hotplug.d/net/99-batman-adv id you rename me ?
your link to batman-adv-auto-gw-mode/files/etc/hotplug.d/net/99-batman-gw is empty.
Quoted 18 lines
Quoted 16 lines
correct ?
Since uevent is something new to me; can someone recommend some freshman tutorial that may take me in the right direction. I have no clue where or how to start looking to code it and also when coded; where will it be added.
I also would like to ask anyone that has uevent working how they are using it for the same type of need and maybe even share some recipe.
Quoted 9 lines · cmsv
I have reached a point where i need to start using the uevent functionality to work around some network scenarios when the gateways lose internet access but i am having a bit of a difficult time understanding how to do it since making use of uevents which is something new to me.
The explanation here is not helping much either
http://www.open-mesh.org/projects/batman-adv/wiki/Uevent
Quoted 7 lines
and i understand that i might need to go to the basics to understand it and learn how to code.
My need to use uevents to change a nodes behaviour is to change a node from server to client and vice versa when it loses connectivity to the WAN (not for example losing connectivity to the dsl router that is actually the gateway but that has the node as a LAN client)
The uevents in batman-adv (as explained in the wiki) are "messages" sent by the kernel module when a particular event (internal to batman-adv) occurs.
WAN on/off is an event which comes from an external source and so you do not need to bother the batman-adv's uevents.
Quoted 4 lines
I am assuming that uevents will allow me to work with this physical setup correct?
Not uevents from batman-adv. If something else can trigger a uevent for you then yes. But you will not get any help from the uevents in batman-adv in this case.
Quoted 4 lines
As far as i understand now and if i am not mistaken when a gateway loses WAN connectivity the node that is making use of uevents will change the node from "server" to "client" on batman-adv .
This is a mechanism that you have to implement in your firmware. batman-adv alone cannot do that because it does not know when the connection goes down.
I can say that this is probably a behaviour that you may want, but batman-adv won't help you in this.
Quoted 26 lines
Now my question is if i can also make it to change the dhcp setup from dhcp server to inactive and receive it´s dhcp service from another gateway node.
In theory something like this would be executed on openwrt when a gateway node detects no connectivity to the wan:
uci set batman-adv.bat0.gw_mode=client ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=0 ;
uci set dhcp.lan.ignore=1 ;
uci commit dhcp ;/etc/init.d/dnsmasqrestart ;when it detects wan connectivity it will want to become a server and will auto execute:
uci set batman-adv.bat0.gw_mode=server ;
uci commit batman-adv ;
batman-adv reboot ;
uci set dhcp.lan.force=1 ;
uci set dhcp.lan.ignore=0 ;
uci commit dhcp ;/etc/init.d/dnsmasqrestart ;
Quoted 9 lines
A small script can even be made in order so simplify things either automatically or manually and lets call it:
gateway-mode
client-modeUpon detecting no WAN connectivity the script will be activated.
Am i on the right track so far (at least in theory) ?
Maybe. All this stuff I guess have to be applied on an OpenWRT system, but I don't know it enough to answer. Maybe on the Openwrt channel/list somebody will be able to help you in this direction.
Quoted 11 lines
Now the second part is how to detect WAN connectivity which is different from noticing that there is no connectivity to the actual gw router that has the node on it's LAN.
I thought about a ping test to a few address from which after 100% loss reply from all; something or Uevent will activate the gateway/client mode script but it creates another problem ahead.
In a quick conversation with ordex on irc i understand that i have to invoke the wiki docs uevent functions with the parameters i want at the moment i decide.
This is an internal function that can be used by a developer to "add new uevents to batman-adv". Here you want to play with something totally external and totally unrelated to batman-adv. So the uevents wikipage can't help you :)
Quoted 4 lines
This can be the gateway/client mode script
correct ?
Quoted 10 lines
Since uevent is something new to me; can someone recommend some freshman tutorial that may take me in the right direction. I have no clue where or how to start looking to code it and also when coded; where will it be added.
I also would like to ask anyone that has uevent working how they are using it for the same type of need and maybe even share some recipe.
Sometimes I used ifplugd to detect whether an Ethernet link was UP or not..you may want to look into it as well.
Cheers,
Signature · 4 lines
Antonio Quartulli ..each of us alone is worth nothing.. Ernesto "Che" Guevara