Perl script bug?

Ian Eiloart <[email protected]> Fri, 07 Jul 2006 14:22:15 +0100
Newsgroups gmane.comp.apache.mod-wackamole.general
Message-ID <[email protected]>
I have a wackamole configuration as shown in full below.

I have two hosts, two VIFS and two IP addresses in each VIF. I need to 
start and stop services as IP addresses are acquired and lost.

I've written a perl library, with functions onup, ondown, postup and 
postdown - but the postup and postdown functions do nothing at the moment.

My problem is this. When I test wackamole with wackatrl -f and wackatrl -s, 
the IP addresses come up and down as expected. But, whether I say "wackatrl 
-f" or "wackatrl -s", BOTH onup() and ondown() get executed. So, my 
services get started and stopped at the same time.

I notice that in config_gram.y, this section appears:

       |       W_RUNDYNAMIC W_STRING W_ACTION_TYPE
                        { char *path = $2.string;
                          if(strstr(path, "::") || !strchr(path, ':')) {
#ifdef USE_EMBEDDED_PERL
                            register_perl(path, DLFUNCS_TYPE_ON_UP);
                                                ^^^^^^^^^^^^^^^^^^
#else
                            wack_alarm(EXIT, "RunDynamic with perl-style 
parameter, without embedded perl interpreter");
#endif
                          } else {
                            char *func = strchr(path, ':');
                            if(func) { *(func++) = '\0'; }
                            register_shared(path, func, $3.number);
                          }
                        }

Should that DLFUNCS_TYPE_ON_UP read $3.number instead? Doesn't seem to work 
well, though. It seems when I do this then my 'on down' script gets called 
repeatedly - every 5 seconds.

-- 
Ian Eiloart
IT Services, University of Sussex

# The Spread daemon we are going to connect to.  It should be on the local 
box
Spread = 4803
SpreadRetryInterval = 5s
# The group name
Group = mail1
# Named socket for online control
Control = /var/run/wack.it
### Where is our perl library
PerlUseLib /opt/local/etc/
### What is the name of the library
PerlUse wackamole
### What is the name of the script
RunDynamic wackamole::onup on up
RunDynamic wackamole::ondown on down
RunDynamic wackamole::postup post up
RunDynamic wackamole::postdown post down
#RunDynamic wackamole::onup post up
### This is for loading C libraries
#RunDynamic funcs:killhup on up

# if we expressed a preference, we'd have to maintain more than
# one version of this file. There's little to be gained, so we won't bother
Prefer none

# List all the virtual interfaces (ALL of them)
VirtualInterfaces {
        # every VIF must include an IMAP IP address
        # to ensure loads are properly balanced for process counts
        # and should also include MX, MSA, and DNS addresses
        { en0:139.184.132.85/32 en0:139.184.132.240/32}
        { en0:139.184.132.84/32 en0:139.184.132.241/32}
}

# Collect and broadcast the IPs in our ARP table every so often
Arp-Cache = 90s

# List who we will notify
#       Here the netblock (/24 or /28) can be deceptive.  It is NOT a 
netmask
#       for a single IP.  It is how one will describe that they want to
#       notify ALL IPs in a segment.
Notify {
        # Let's notify our router:
        en0:139.184.132.1/32
        en0:139.184.133.255/23
        en0:139.184.132.6/32
        # Wackamole shares arp-cache across machines, this says to
        # notify every IP address in the aggregate shared arp-cache.
        arp-cache
}
balance {
        # This field is the maximum number of IP addresses that will move
        # from one wackamole to another during a round of balancing.
        AcquisitionsPerRound = all
        # Time interval in each balancing round.
        interval = 4s
}
# How long it takes us to mature
mature = 5s