Hi misc,

I was playing around with ifstated, trying to understand exactly how
it behaves, and came up with a few assumptions for which I could not
find any contradiction or confirmation in the docs. So I'd appreciate
if someone familiar with ifstated internals could shed some light.

-----------------------------------
1. If for some reason several set-state directives of a given state's
body are processed, the last one applies.

It is especially relevant when you have event A and event B set to
true, and rules like:

if A && B
 set-state X
if A
 set-state Y
if B
 set-state Z

Some people would probably expect ifstated to enter state X, but it
that case it would go to Z.
I actually found one example of this problem in mailing list archives
(2009 Nov 03), and the poster was apparently instructed to avoid && in
his tests but I don't think that was a correct answer.


-----------------------------------
2. There is no rules of precedence between && and ||, operation are
processed from left to right, and not according to the usual order
(http://en.wikipedia.org/wiki/Logical_connective#Order_of_precedence)

So when you write : A || B && C
You should expect : ( A || B ) && C
Instead of the usually expected : A || ( B && C )


-----------------------------------
3. This point is actually properly documented in ifstated.conf man
page, but apparently ignored in the sample ifstated.conf file.
Man page states that "Macros can be defined that will later be
expanded in context." But if you look at /usr/src/etc/ifstated.conf,
you can see at the bottom the macro $carp_sync being negated without
use of parentheses, which is per my understanding equivalent to negate
only the first test of the macro (which gives funky results).


If my assumptions are correct, I think it would be nice to have 1 and
2 quickly mentioned in ifstated.conf's man page, and
/usr/src/etc/ifstated.conf corrected.

--- etc/ifstated.conf.orig      Thu Apr 15 13:47:45 2010
+++ etc/ifstated.conf   Thu Apr 15 13:50:53 2010
@@ -12,8 +12,8 @@

 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"
+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


Please let me know if you think any of the above is wrong.

Regards,
William

Reply via email to