Hello,

I have a webserver that obtains its external static IP via dhclient from my
ISP.

I actually have two webservers, one is a master and one a slave.  Using carp
on the internal network side I am able to have two definable and detectable
states for each webserver, master and slave which is dependent on the carp
state (and hopefully the NIC states).

For other reasons (see: http://bsdstuff.googlepages.com/dhcarp) I use ifstated
to run dhclient on my external interface when the server is in the master
state (this allows either webserver to accept incoming connections if it is
the master, and the slave just has the external NIC down).

The problem I am having with ifstated and its determination of the status of
the external NIC (em1).  As shown below, when I enter the "master" state, I
run dhclient ... this works fine and obtains an IP just fine.  Ifstated will
initially detect em1 as up (em1.link.up = true).  The problem is that
immediately following this ifstated will detect em1 as down then up again.
What this means is that I can't use the status of this NIC for anything as it
gives a false reading every time and will send the ifstated state machine into
the wrong state when everything is actually fine.

I can configure ifstated to just ignore the status of the external NIC, but
this means if the NIC goes down or the cable is pulled then ifstated does not
detect this (though everything else is covered).

I am aware of the first false positive, but I can't find a configuration for
ifstated that allows for this.  I also do not understand why the state
fluctuates at first.

Notes about this setup:
- both webservers have two NICs, external = em1, internal = em0.
- both internal NICs have a private address in the same subnet and are part of
a carp interface (carp0) on the same private subnet.
- the carp interface is just used for detecting state, since the carp status
can be polled in ifstated and decisions made accordingly (this means I can
failover to the slave webserver if the carp master goes down or the carp
master internal interface fails ... but not the external interface).

/etc/ifstated.conf - (I have added an extra state to demonstrate the problem,
I have also removed the actual lines to change to the "backup" state as the
problem is just in the master state)

#cat /etc/ifstated.conf
# dhcarp (ifstated.conf), Version 1.2 - Master CARP Host:

# Copyright (c) 2007-2008 Richard R. Charron
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#    - Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#    - Redistributions in binary form must reproduce the above
#      copyright notice, this list of conditions and the following
#      disclaimer in the documentation and/or other materials provided
#      with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# ----------------------------------------------------------------------
#

# Initial State
init-state auto

# Macros
if_master = "carp0.link.up"
if_backup = "!carp0.link.up"
test_link_up = "em0.link.up && em1.link.up"
test_link_down = "em0.link.down || em1.link.down"
if_net_up = '( "ping -q -c 1 -w 1 142.179.176.1> /dev/null" every 10)'

# detect initial state based upon if the this server is the carp master or
not
state auto {
        if $if_master {
                set-state master
        }
        if $if_backup {
                set-state backup
        }
}

state master {
        init {
                run "/sbin/ifconfig `/bin/cat em1`\
                lladdr MY_MAC_ADDRESS_GOES_HERE up"

                run "/sbin/dhclient em1"
        }


         # here is my first test to show that the NICs are up (or are they?)
         if ! $test_link_down {
         if $test_link_up {
                   set-state master-ready
         }
         }
}

state master-ready {
        init {
                run "/bin/echo ' MASTER - READY '"
        }

        if $test_link_down {
                run "/bin/echo ' MASTER-READY - a link is down'"
        }
        if ! $test_link_down {
                run "/bin/echo ' MASTER-READY - links are up'"
        }

}

state backup {
        init {
                run "/usr/bin/pkill -9 dhclient"

                run "/sbin/ifconfig em1\
                delete lladdr OTHER_MAC_ADDRESS_GOES_HERE down"
        }

}

# cat /etc/hostname.em0
inet 192.168.10.7 255.255.255.0 NONE

#cat /etc/hostname.em1
down

# cat /etc/hostname.carp0
inet 192.168.10.95 255.255.255.0 192.168.0.255 vhid 1 pass foo carpdev em0


Here is the output from the command "ifstated -vd":
# ifstated -vd
if_master = "carp0.link.up"
if_backup = "!carp0.link.up"
test_link_up = "em0.link.up && em1.link.up"
test_link_down = "em0.link.down || em1.link.down"
if_net_up = "( "ping -q -c 1 -w 1 MY_GATEWAY_IP_ADDRESS> /dev/null" every
10)"
initial state: auto
changing state to auto
changing state to master
running /sbin/ifconfig em1          lladdr MY_MAC_ADDRESS_GOES_HERE up
running /sbin/dhclient em1
em1: no link .... got link
DHCPREQUEST on em1 to 255.255.255.255 port 67
DHCPREQUEST on em1 to 255.255.255.255 port 67
DHCPDISCOVER on em1 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on em1 to 255.255.255.255 port 67 interval 13
DHCPDISCOVER on em1 to 255.255.255.255 port 67 interval 21
DHCPOFFER from MY_GATEWAY_IP_ADDRESS
DHCPOFFER from MY_GATEWAY_IP_ADDRESS
DHCPOFFER already seen.
DHCPREQUEST on em1 to 255.255.255.255 port 67
DHCPACK from MY_GATEWAY_IP_ADDRESS
bound to MY_STATIC_IP_ADDRESS -- renewal in 7200 seconds.
changing state to master-ready
running /bin/echo ' MASTER - READY '
 MASTER - READY
running /bin/echo ' MASTER-READY - links are up'
 MASTER-READY - links are up
started
running /bin/echo ' MASTER-READY - a link is down'
 MASTER-READY - a link is down
running /bin/echo ' MASTER-READY - links are up'
 MASTER-READY - links are up
running /bin/echo ' MASTER-READY - links are up'
 MASTER-READY - links are up

As you can see, ifstated goes from master->master-ready (by detecting the link
as up) and then when in master-ready state the link is detected as down again,
then up.

Does anyone have suggestions on why this is happening or how to deal with it?
Thanks.
- Tom


dmesg:
OpenBSD 4.3 (GENERIC) #698: Wed Mar 12 11:07:05 MDT 2008
    [EMAIL PROTECTED]:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Xeon(R) CPU E5440 @ 2.83GHz ("GenuineIntel" 686-class) 2.83
GHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUS
H,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,
xTPR
cpu0: unknown i686 EBL_CR_POWERON value 3 (0xc20c149f)
real mem  = 3484319744 (3322MB)
avail mem = 3380543488 (3223MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 02/05/08, BIOS32 rev. 0 @ 0xffe90,
SMBIOS rev. 2.5 @ 0xcfb9c000 (66 entries)
bios0: vendor Dell Inc. version "2.2.6" date 02/05/2008
bios0: Dell Inc. PowerEdge 1950
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP APIC SPCR HPET MCFG WD__ SLIC ERST HEST BERT EINJ
TCPA
acpi0: wakeup devices PCI0(S5)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 4 (PEX2)
acpiprt2 at acpi0: bus 5 (UPST)
acpiprt3 at acpi0: bus 6 (DWN1)
acpiprt4 at acpi0: bus 8 (DWN2)
acpiprt5 at acpi0: bus 1 (PEX3)
acpiprt6 at acpi0: bus 0 (PE2P)
acpiprt7 at acpi0: bus 10 (PEX4)
acpiprt8 at acpi0: bus 12 (PEX6)
acpiprt9 at acpi0: bus 2 (SBEX)
acpiprt10 at acpi0: bus 14 (COMP)
acpicpu0 at acpi0: C3
bios0: ROM list: 0xc0000/0x9000! 0xc9000/0x1000 0xca000/0x1e00 0xcc000/0x5e00
0xec000/0x4000!
ipmi at mainbus0 not configured
cpu0 at mainbus0
cpu0: Enhanced SpeedStep disabled by BIOS
pci0 at mainbus0 bus 0: configuration mode 1 (no bios)
pchb0 at pci0 dev 0 function 0 "Intel 5000X Host" rev 0x12
ppb0 at pci0 dev 2 function 0 "Intel 5000 PCIE" rev 0x12
pci1 at ppb0 bus 4
ppb1 at pci1 dev 0 function 0 "Intel 6321ESB PCIE" rev 0x01
pci2 at ppb1 bus 5
ppb2 at pci2 dev 0 function 0 "Intel 6321ESB PCIE" rev 0x01
pci3 at ppb2 bus 6
ppb3 at pci3 dev 0 function 0 "ServerWorks PCIE-PCIX" rev 0xc3
pci4 at ppb3 bus 7
bnx0 at pci4 dev 0 function 0 "Broadcom BCM5708" rev 0x12: irq 5
ppb4 at pci2 dev 1 function 0 "Intel 6321ESB PCIE" rev 0x01
pci5 at ppb4 bus 8
ppb5 at pci1 dev 0 function 3 "Intel 6321ESB PCIE-PCIX" rev 0x01
pci6 at ppb5 bus 9
ppb6 at pci0 dev 3 function 0 "Intel 5000 PCIE" rev 0x12
pci7 at ppb6 bus 1
mfi0 at pci7 dev 0 function 0 "Symbios Logic SAS1078" rev 0x04: irq 5, Dell
PERC 6/i integrated
mfi0: logical drives 1, version 6.0.2-0002, 256MB RAM
scsibus0 at mfi0: 1 targets
sd0 at scsibus0 targ 0 lun 0:  SCSI3 0/direct fixed
sd0: 69376MB, 8844 cyl, 255 head, 63 sec, 512 bytes/sec, 142082048 sec total
ppb7 at pci0 dev 4 function 0 "Intel 5000 PCIE x8" rev 0x12
pci8 at ppb7 bus 10
em0 at pci8 dev 0 function 0 "Intel PRO/1000 PT (82571EB)" rev 0x06: irq 5,
address A_MAC_ADDRESS
em1 at pci8 dev 0 function 1 "Intel PRO/1000 PT (82571EB)" rev 0x06: irq 11,
address MY_MAC_ADDRESS
ppb8 at pci0 dev 5 function 0 "Intel 5000 PCIE" rev 0x12
pci9 at ppb8 bus 11
ppb9 at pci0 dev 6 function 0 "Intel 5000 PCIE x8" rev 0x12
pci10 at ppb9 bus 12
ppb10 at pci0 dev 7 function 0 "Intel 5000 PCIE" rev 0x12
pci11 at ppb10 bus 13
pchb1 at pci0 dev 16 function 0 "Intel 5000 Error Reporting" rev 0x12
pchb2 at pci0 dev 16 function 1 "Intel 5000 Error Reporting" rev 0x12
pchb3 at pci0 dev 16 function 2 "Intel 5000 Error Reporting" rev 0x12
pchb4 at pci0 dev 17 function 0 "Intel 5000 Reserved" rev 0x12
pchb5 at pci0 dev 19 function 0 "Intel 5000 Reserved" rev 0x12
pchb6 at pci0 dev 21 function 0 "Intel 5000 FBD" rev 0x12
pchb7 at pci0 dev 22 function 0 "Intel 5000 FBD" rev 0x12
ppb11 at pci0 dev 28 function 0 "Intel 6321ESB PCIE" rev 0x09
pci12 at ppb11 bus 2
ppb12 at pci12 dev 0 function 0 "ServerWorks PCIE-PCIX" rev 0xc3
pci13 at ppb12 bus 3
bnx1 at pci13 dev 0 function 0 "Broadcom BCM5708" rev 0x12: irq 5
uhci0 at pci0 dev 29 function 0 "Intel 6321ESB USB" rev 0x09: irq 11
uhci1 at pci0 dev 29 function 1 "Intel 6321ESB USB" rev 0x09: irq 10
uhci2 at pci0 dev 29 function 2 "Intel 6321ESB USB" rev 0x09: irq 11
uhci3 at pci0 dev 29 function 3 "Intel 6321ESB USB" rev 0x09: irq 10
ehci0 at pci0 dev 29 function 7 "Intel 6321ESB USB" rev 0x09: irq 11
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb13 at pci0 dev 30 function 0 "Intel 82801BA Hub-to-PCI" rev 0xd9
pci14 at ppb13 bus 14
vga1 at pci14 dev 13 function 0 "ATI ES1000" rev 0x02
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
ichpcib0 at pci0 dev 31 function 0 "Intel 6321ESB LPC" rev 0x09: PM disabled
pciide0 at pci0 dev 31 function 1 "Intel 6321ESB IDE" rev 0x09: DMA, channel 0
configured to compatibility, channel 1 configured to compatibility
atapiscsi0 at pciide0 channel 0 drive 0
scsibus1 at atapiscsi0: 2 targets
cd0 at scsibus1 targ 0 lun 0:  SCSI0 5/cdrom removable
cd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 ignored (disabled)
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci3: USB revision 1.0
uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at ichpcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
midi0 at pcppi0:
spkr0 at pcppi0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
pccom0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pccom1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
biomask fde5 netmask fde5 ttymask ffe7
mtrr: Pentium Pro MTRR support
uhub5 at uhub0 port 5 "Cypress Semiconductor USB2 Hub" rev 2.00/0.0b addr 2
uhidev0 at uhub5 port 1 configuration 1 interface 0 "Dell Dell USB Keyboard"
rev 1.10/3.01 addr 3
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
softraid0 at root
root on sd0a swap on sd0b dump on sd0b
bnx1: address 00:1d:09:6a:65:ee
brgphy0 at bnx1 phy 1: BCM5708C 10/100/1000baseT PHY, rev. 6
bnx0: address 00:1d:09:6a:65:f0
brgphy1 at bnx0 phy 1: BCM5708C 10/100/1000baseT PHY, rev. 6
wskbd1: disconnecting from wsdisplay0
wskbd1 detached
ukbd0 detached
uhidev0 detached
uhidev0 at uhub5 port 1 configuration 1 interface 0 "Dell Dell USB Keyboard"
rev 1.10/3.01 addr 3
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
wskbd1: disconnecting from wsdisplay0
wskbd1 detached
ukbd0 detached
uhidev0 detached
uhidev0 at uhub5 port 2 configuration 1 interface 0 "Dell Dell USB Keyboard"
rev 1.10/3.01 addr 3
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
_________________________________________________________________
Pack up or back upuse SkyDrive to transfer files or keep extra copies. Learn
how.
hthttp://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh
_skydrive_packup_042008

Reply via email to