Mailing List Archive

Perl script bug?
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


_______________________________________________
wackamole-users mailing list
wackamole-users@lists.backhand.org
http://lists.backhand.org/mailman/listinfo/wackamole-users
Re: Perl script bug? [ In reply to ]
--On 7 July 2006 14:22:15 +0100 Ian Eiloart <iane@sussex.ac.uk> wrote:

>
> 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.
>

Oh, I lied. On closer observation - what actually seems to be happening is
that all my functions are being run only when an interface comes up. An
interface going down doesn't trigger any function execution at all.

That seems to accord with my reading of the code. Unfortunately, I'm not
sure I know how to fix it.


--
Ian Eiloart
IT Services, University of Sussex

_______________________________________________
wackamole-users mailing list
wackamole-users@lists.backhand.org
http://lists.backhand.org/mailman/listinfo/wackamole-users
Re: Perl script bug? [ In reply to ]
Can you try checking out the CVS version and seeing if that exhibits
the same problem?

On Jul 7, 2006, at 11:32 AM, Ian Eiloart wrote:

>
>
> --On 7 July 2006 14:22:15 +0100 Ian Eiloart <iane@sussex.ac.uk> wrote:
>
>>
>> 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.
>>
>
> Oh, I lied. On closer observation - what actually seems to be
> happening is that all my functions are being run only when an
> interface comes up. An interface going down doesn't trigger any
> function execution at all.
>
> That seems to accord with my reading of the code. Unfortunately,
> I'm not sure I know how to fix it.
>
>
> --
> Ian Eiloart
> IT Services, University of Sussex
>
> _______________________________________________
> wackamole-users mailing list
> wackamole-users@lists.backhand.org
> http://lists.backhand.org/mailman/listinfo/wackamole-users

// Theo Schlossnagle
// CTO -- http://www.omniti.com/~jesus/
// OmniTI Computer Consulting, Inc. -- http://www.omniti.com/
// Ecelerity: Run with it.
Re: Perl script bug? [ In reply to ]
--On 7 July 2006 11:37:24 -0400 Theo Schlossnagle <jesus@omniti.com> wrote:

> Can you try checking out the CVS version and seeing if that exhibits the
> same problem?

OK. I had to fix my perl scripts, so they don't expect null terminated
strings! So, that fix seems good. I didn't try this before, since I'm not
familiar with CVS and I wasn't too bothered about the null terminated
strings.

In both the CVS and release versions, I had to fix defines.h. I reversed
the definition order of

#include <net/bpf.h>
#include <pcap.h>

That fixed the release version, but not the CVS version. I used the fixed
release version

Now, lets see if it works!

Well, the behaviour is changed. After wackatrl -f, the down script (only)
is called repeatedly. It's called for the VIF that just went down, twice.
Then it's called for the other VIF (which was always held by the other
host), twice. Then there's a four or five second pause and the whole
sequence is repeated, apparently endlessly.

After wackatrl -s the up script is called twice with a 10 second interval
between the calls, on the correct interface. I can see that the interface
is up on both calls (my perl script calls ifconfig to find out if the
interface really is available, and logs the result. Between the two calls
to onup, I see ondown continues to be called. After the second call of
onup, the ondown calls cease.

The passive host seems to behave OK.

The only really worrying thing about this is the repeated calls to stop
services. I guess it isn't a killer - if the interface is down, who cares
what happens to its services. And, if I stop wackamole, the behaviour
obviously isn't bad.

I'll have another look at this on Monday. Thanks for your help, Theo!

> On Jul 7, 2006, at 11:32 AM, Ian Eiloart wrote:
>
>>
>>
>> --On 7 July 2006 14:22:15 +0100 Ian Eiloart <iane@sussex.ac.uk> wrote:
>>
>>>
>>> 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.
>>>
>>
>> Oh, I lied. On closer observation - what actually seems to be
>> happening is that all my functions are being run only when an
>> interface comes up. An interface going down doesn't trigger any
>> function execution at all.
>>
>> That seems to accord with my reading of the code. Unfortunately,
>> I'm not sure I know how to fix it.
>>
>>
>> --
>> Ian Eiloart
>> IT Services, University of Sussex
>>
>> _______________________________________________
>> wackamole-users mailing list
>> wackamole-users@lists.backhand.org
>> http://lists.backhand.org/mailman/listinfo/wackamole-users
>
> // Theo Schlossnagle
> // CTO -- http://www.omniti.com/~jesus/
> // OmniTI Computer Consulting, Inc. -- http://www.omniti.com/
> // Ecelerity: Run with it.
>
>



--
Ian Eiloart
IT Services, University of Sussex

_______________________________________________
wackamole-users mailing list
wackamole-users@lists.backhand.org
http://lists.backhand.org/mailman/listinfo/wackamole-users