A slightly better fix for this is possible now with 1.2.3-RC and 2.0, but it's still not ideal.
The CARP interface will now report a transition to MASTER as a "link up" event, and a transition to BACKUP as a "link down" event to the system. These can be caught with devd and used to call scripts on these events – no more need to rely on cron or a delay. This will happen instantaneously once the CARP interface on the backup takes over.
This is more meant for a full install, but I suppose it could be altered to work as the initial solution was for a livecd/embedded platform.
If you are running a recent (as of the date on this post) snapshot of 1.2.3, or 2.0, you can try this.
Edit /etc/devd.conf, and add the following:
notify 100 {
match "system" "IFNET";
match "type" "LINK_UP";
match "subsystem" "carp";
action "/usr/local/bin/carpup $subsystem";
};
notify 100 {
match "system" "IFNET";
match "type" "LINK_DOWN";
match "subsystem" "carp";
action "/usr/local/bin/carpdown $subsystem";
};
In this instance, you don't really need the $subsystem variable, but it may be useful if you want to perform other actions. It contains the name of the actual carp interface that transitioned. If you want to lock this down to just one carp interface, you could change the subsystem match to "carp0" or "carp1", whichever you like.
Restart devd (or reboot):
killall -9 devd && /sbin/devd
You can then create the scripts mentioned on the "action" line above. For this case, it would be two different scripts:
/usr/local/bin/carpup
#!/bin/sh
/sbin/ifconfig bridge0 up
/usr/local/bin/carpdown
#!/bin/sh
/sbin/ifconfig bridge0 down
Finally, make sure those are executable:
chmod a+x /usr/local/bin/carpup
chmod a+x /usr/local/bin/carpdown
You could add anything else that you want to these scripts. Calling some sort of notification program would be useful, or whatever else is desired.
I'm trying to come up with some sort of generic detection code that would take the carp interface, and attempt to see if its parent interface is a bridge member, and if so, bring down that bridge member. A little more complex, but it is a more generic solution that should work in more, similar, scenarios.