kern/126984: [carp][patch] add carp userland notifications via
devctl(4)
Alexander V. Chernikov
melifaro at ipfw.ru
Sat Aug 30 20:40:00 UTC 2008
>Number: 126984
>Category: kern
>Synopsis: [carp][patch] add carp userland notifications via devctl(4)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Aug 30 20:40:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Alexander V. Chernikov
>Release: 8.0
>Organization:
>Environment:
FreeBSD ws.su29.net 8.0-CURRENT FreeBSD 8.0-CURRENT #11: Thu Mar 13 05:13:16 MSK 2008 melifaro at ws.su29.net:/usr/obj/usr/src/sys/CURR amd64
>Description:
Small patch to get change in carp(4) interface state more easily. Userland notification is done via devctl(4) and can be configured in devd.conf. This is useful when user wants to get notification for this event on e-mail or sms or needs to perform some additional actions. Changes are documented in carp(4) manual page and usage example is available in devd.conf
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
--- sys/netinet/ip_carp.c.orig 2008-08-18 02:49:50.000000000 +0400
+++ sys/netinet/ip_carp.c 2008-08-18 02:16:50.000000000 +0400
@@ -35,6 +35,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/limits.h>
@@ -2108,6 +2109,7 @@
static void
carp_set_state(struct carp_softc *sc, int state)
{
+ char vhid_buf[15], *dev_msg;
if (sc->sc_carpdev)
CARP_SCLOCK_ASSERT(sc);
@@ -2119,15 +2121,20 @@
switch (state) {
case BACKUP:
SC2IFP(sc)->if_link_state = LINK_STATE_DOWN;
+ dev_msg = "CARP_SLAVE";
break;
case MASTER:
SC2IFP(sc)->if_link_state = LINK_STATE_UP;
+ dev_msg = "CARP_MASTER";
break;
default:
SC2IFP(sc)->if_link_state = LINK_STATE_UNKNOWN;
+ dev_msg = "CARP_UNKNOWN";
break;
}
rt_ifmsg(SC2IFP(sc));
+ snprintf(vhid_buf, sizeof(vhid_buf), "vhid=%d", sc->sc_vhid);
+ devctl_notify("IFNET", SC2IFP(sc)->if_xname, dev_msg, vhid_buf);
}
void
--- etc/devd.conf.orig 2008-08-31 00:01:05.000000000 +0400
+++ etc/devd.conf 2008-08-31 00:08:17.000000000 +0400
@@ -302,4 +302,16 @@
match "subsystem" "ACAD";
action "/etc/acpi_ac $notify";
};
+
+# Example of CARP notify handler
+# The following variables are set:
+# subsystem: name of CARP interface
+# type: event (CARP_SLAVE for becoming SLAVE, CARP_MASTER for master)
+# vhid: CARP inrface VHID
+notify 100 {
+ match "system" "IFNET";
+ match "type" "CARP_SLAVE";
+ action "/usr/local/etc/carp_down.sh $subsystem $vhid $type";
+};
+
*/
--- share/man/man4/carp.4.orig 2008-08-30 23:57:07.000000000 +0400
+++ share/man/man4/carp.4 2008-08-30 23:59:29.000000000 +0400
@@ -168,6 +168,22 @@
than the state information is packed and synced with the second router.
If the reply would be load balanced to second router, it will be
dropped due to no state.
+.Sh NOTIFICATIONS
+Notifications on becoming MASTER/SLAVE are sent via
+.Xr devctl 4
+interface. The following events in IFNET system are generated:
+.Bl -tag -width ".Va CARP_MASTER"
+.It Va CARP_SLAVE
+System has become SLAVE on given carp interface.
+.It Va CARP_MASTER
+System has become MASTER on given carp interface.
+.El
+.Pp
+Additionaly,
+.Cm subsystem
+variable is set to interface name and
+.Cm vhid
+variable is set to given interface VHID.
.Sh EXAMPLES
For firewalls and routers with multiple interfaces, it is desirable to
failover all of the
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list