ifstated.conf expression

From: Matthias Teege <matthias-dbq(at)mteege.de>
Date: Sun, 22 Feb 2009 15:39:12 +0100

Moin,

ich habe carp zusammen mit ifstated unter OpenBSD 4.4 konfiguriert
und mich dabei an die Beispielkonfiguration in /etc/ifstated.conf
gehalten. Das Backupsystem wechselt zwischen den Stati "backup" und
"promoted" wobei in meinem Fall, der Stati promoted nie gehalten werden
kann. Ursache dafür ist das Makro "carp_sync" das "falsch" zurückgibt,
obwohl es das nicht sollte.

Hier die ifstated Konfigurationsdatei des Backupsystems:

# init-state primary
init-state backup

carp_up = "carp0.link.up && carp1.link.up"
carp_down = "!carp0.link.up && !carp1.link.up"
carp_sync = "carp0.link.up && carp1.link.up || \
    !carp0.link.up && !carp1.link.up"

# The "net" addresses are other addresses which can be used to determine
# whether we have connectivity. Make sure the hosts are always up, or
# test multiple ip's, 'or'-ing the tests.
net = '( "ping -q -c 1 -t 1 192.168.6.8 > /dev/null" every 10 && \
    "ping -q -c 1 -t 1 192.168.3.8 > /dev/null" every 10)'

# The peer addresses below are the real ip addresses of the OTHER firewall
peer = '( "ping -q -c 1 -t 1 192.168.6.7 > /dev/null" every 10 && \
    "ping -q -c 1 -t 1 192.168.3.7 > /dev/null" every 10)'

state auto {
        if $carp_up
                set-state primary
        if $carp_down
                set-state backup
}

state primary {
        init {
                run "ifconfig carp0 advskew 10"
                run "ifconfig carp1 advskew 10"
        }
        if ! $net
                set-state demoted
}

state demoted {
        init {
                run "ifconfig carp0 advskew 254"
                run "ifconfig carp1 advskew 254"
        }
        if $net
                set-state primary
}

state promoted {
        init {
                run "ifconfig carp0 advskew 0"
                run "ifconfig carp1 advskew 0"
        }
        if $peer || ! $net
                set-state backup
}

state backup {
        init {
                run "ifconfig carp0 advskew 100"
                run "ifconfig carp1 advskew 100"
        }
        # The "sleep 5" below is a hack to dampen the $carp_sync when we come
        # out of promoted state. Thinking about the correct fix...
        if ! $carp_sync && $net && "sleep 5" every 10
                if ! $carp_sync && $net
                        set-state promoted
}

Verwende ich diese Konfiguration wechselt das Backupsystem immer
zwischen dem Status "backup" und "promoted" hin- und her. Ändere ich
die Konfiguration wie folgt:

        if ! $carp_up || ! $carp_down && $net && "sleep 5" every 10
                if ! $carp_up || ! $carp_down && $net
                        set-state promoted

funktioniert die Umschaltung wie sie sollte.

Was ist der Unterschied zwischen dem "! $carp_sync" und "! $carp_up ||
! $carp_down"? Ist meine Anpassungen evtl. fehlerhaft? Ich traue der
Sache nicht, weil dieses Beispiel sowohl unter OpenBSD als auch im
FreeBSD Port enthalten und unbeanstandet ist.

Vielen Dank
Matthias

To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Sun 22 Feb 2009 - 15:39:22 CET

search this site