Hi,
as a different approach, you can use the new "router" option from
relayd(8) in -current.
1.) Replace the complex ifstated state machine with a relayd using a
router configuration block. Specifing a source address in the checks
is currently not supported, but you can specify an IP TTL of 1 to make
sure that the reply is really from a next hop and not routed from
somewhere else. A possible relayd.conf based on your setup:
---
interval 20
table <links> { 192.168.5.2 ip ttl 1, 192.168.6.1 ip ttl }
router "internet" {
route 0.0.0.0/0
forward to <links> check icmp
}
---
2.) Run relayd. Now you can use the 'route' and the 'relayctl show'
commands to monitor your state.
3.) You can replace the "alldown" case by adding fallback-routes with
a higher priority value. Identical routes with different priorities
can co-exist in the routing table and the kernel will handle the
fallback automatically. Note: A higher priorty value means actually a
lower priority, the kernel will use any active routes with a lower
value first.
# route add -mpath -priority 12 default 192.168.5.2
# route add -mpath -priority 12 default 192.168.6.1
(You can put these commands with a '!' in your hostname.if files)
reyk
On Mon, Sep 07, 2009 at 09:56:31AM +1000, a complex ifstated.conf was posted:
> ---
>
> link1 = '( "ping -I 192.168.5.10 -q -c 1 -w 1 192.168.5.2 > /dev/null"
> every 20 )'
> link2 = '( "ping -I 192.168.6.10 -q -c 1 -w 1 192.168.6.1 > /dev/null"
> every 20 )'
>
> init-state "primary"
>
> state primary {
> init {
> run "route add -mpath default 192.168.5.2"
> run "route add -mpath default 192.168.6.1"
> }
>
> if ! $link1
> set-state link2only
>
> if ! $link2
> set-state link1only
> }
>
> # only link1 is up
> state link1only {
> init {
> run "route delete default 192.168.6.1"
> run "route add -mpath default 192.168.5.2"
> }
>
> if ! $link1
> set-state alldown
>
> if $link2
> set-state primary
> }
>
> # only link2 is up
> state link2only {
> init {
> run "route delete default 192.168.5.2"
> run "route add -mpath default 192.168.6.1"
> }
>
> if $link1
> set-state primary
>
> if ! $link2
> set-state alldown
> }
>
> # all down !
> state alldown {
> init {
> run "route add -mpath default 192.168.5.2"
> run "route add -mpath default 192.168.6.1"
> }
>
> if $link1
> set-state link1only
>
> if $link2
> set-state link2only
>
> }
>
> ---