On Thu, Jan 04, 2018 at 06:34:26PM +0100, Landry Breuil wrote:
> Hi,
>
> i know ifstated was designed with carp in mind, but nothing from the
> manpage seems to forbid one to use it with other interfaces, thus im
> trying to make it work with ppp so that i can just up a potentially
> existing ppp0 interface and ifstated would magically start xl2tpd to up
> a tunnel.
>
> fiddling with this, i came up with this sample config which... behaves
> weird:
>
> init-state vpn_unknown
>
> state vpn_up {
> if ppp1.link.unknown {
> run 'echo "ppp1 is up->unk" > /tmp/foo'
> }
> if ppp1.link.down {
> run 'echo "ppp1 is up->down" > /tmp/foo'
>
> }
> }
> state vpn_unknown {
> if ppp1.link.up {
> run 'echo "ppp1 is unk->up" > /tmp/foo'
> set-state vpn_up
> }
> if ppp1.link.down {
> run 'echo "ppp1 is unk->down" > /tmp/foo'
> set-state vpn_down
> }
> }
>
> $ifconfig ppp1
> ppp1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
> index 8 priority 0 llprio 3
> groups: ppp
>
> $doas ifstated -vd -f t.conf
> initial state: vpn_unknown
> changing state to vpn_unknown
> running echo "ppp1 is unk->up" > /tmp/foo
> changing state to vpn_up
> running echo "ppp1 is up->unk" > /tmp/foo
> started
>
> i dont really understand the state flipping here... it's as if at first
> ppp1.link.up was true, then immediately the link state is unknown.. or
> maybe it just evaluates the first statement to true, when no macros are
> used ? the config is valid according to the grammar, but the behaviour
> is .. weird. Dunno if the grammar or the examples or the manpage should be
> adapted/clarified ?
>
Hi,
i've been happy with the config below, but it's not ppp.
i do suggest to try similar up or !up instead of down/unknown.
-Artturi
urndis_up = "urndis0.link.up"
_avail_fast = '( "ifconfig urndis0 -debug 2> /dev/null" every 5)'
_avail_init = '( "ifconfig urndis0 -debug 2> /dev/null" every 15)'
_avail_slow = '( "ifconfig urndis0 -debug 2> /dev/null" every 30)'
# The ip address below is the address of the android peer
peer = '( "ping -q -c 1 -w 1 192.168.42.129 > /dev/null" every 5)'
state auto {
if $urndis_up
set-state running
if ! $urndis_up
if $_avail_init
set-state bringup
}
state absent {
if $_avail_fast
set-state bringup
}
state bringup {
init {
run "ksh /etc/netstart urndis0"
run "sleep 2"
}
if $peer
set-state running
}
state lost {
if $urndis_up && $peer
set-state running
if ! $_avail_fast
set-state absent
}
state running {
if ! $urndis_up
set-state lost
if ! $_avail_slow
set-state absent
}