this might be related to carp's incorrect way oif dealing with routes. 
can peole please test this diff for me and report back? it allows bgpd 
to act correctly even wen a carp interface was not master at the time 
of bgpd startup. it will fix other problems too, it might fix yours. if 
people don't test this it'll just rot in my tree...

tech talk: it adds the missing route messages upon route 
insertion/deletion.

Index: ip_carp.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_carp.c,v
retrieving revision 1.135
diff -u -p -r1.135 ip_carp.c
--- ip_carp.c   27 Mar 2007 21:58:16 -0000      1.135
+++ ip_carp.c   28 Mar 2007 23:18:51 -0000
@@ -368,15 +368,18 @@ carp_setroute(struct carp_softc *sc, int
        struct ifaddr *ifa;
        int s;
 
+       /* XXX this mess needs fixing */
+
        s = splsoftnet();
        TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {
                switch (ifa->ifa_addr->sa_family) {
                case AF_INET: {
-                       int count = 0;
+                       int count = 0, error;
                        struct sockaddr sa;
                        struct rtentry *rt;
                        struct radix_node_head *rnh;
                        struct radix_node *rn;
+                       struct rt_addrinfo info;
                        int hr_otherif, nr_ourif;
 
                        /*
@@ -395,9 +398,15 @@ carp_setroute(struct carp_softc *sc, int
                        }
 
                        /* Remove the existing host route, if any */
-                       rtrequest(RTM_DELETE, ifa->ifa_addr,
-                           ifa->ifa_addr, ifa->ifa_netmask,
-                           RTF_HOST, NULL, 0);
+                       bzero(&info, sizeof(info));
+                       info.rti_info[RTAX_DST] = ifa->ifa_addr;
+                       info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
+                       info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
+                       info.rti_flags = RTF_HOST;
+                       error = rtrequest1(RTM_DELETE, &info, NULL, 0);
+                       rt_missmsg(RTM_DELETE, &info, info.rti_flags, NULL,
+                           error, 0);
+
 
                        /* Check for our address on another interface */
                        /* XXX cries for proper API */
@@ -420,26 +429,39 @@ carp_setroute(struct carp_softc *sc, int
                                if (hr_otherif) {
                                        ifa->ifa_rtrequest = NULL;
                                        ifa->ifa_flags &= ~RTF_CLONING;
-
-                                       rtrequest(RTM_ADD, ifa->ifa_addr,
-                                           ifa->ifa_addr, ifa->ifa_netmask,
-                                           RTF_UP | RTF_HOST, NULL, 0);
+                                       bzero(&info, sizeof(info));
+                                       info.rti_info[RTAX_DST] = ifa->ifa_addr;
+                                       info.rti_info[RTAX_GATEWAY] = 
ifa->ifa_addr;
+                                       info.rti_info[RTAX_NETMASK] = 
ifa->ifa_netmask;
+                                       info.rti_flags = RTF_UP | RTF_HOST;
+                                       error = rtrequest1(RTM_ADD, &info, 
NULL, 0);
+                                       rt_missmsg(RTM_ADD, &info, 
info.rti_flags, NULL,
+                                           error, 0);
                                }
                                if (!hr_otherif || nr_ourif || !rt) {
                                        if (nr_ourif && !(rt->rt_flags &
-                                           RTF_CLONING))
-                                               rtrequest(RTM_DELETE, &sa,
-                                                   ifa->ifa_addr,
-                                                   ifa->ifa_netmask, 0, NULL,
-                                                   0);
+                                           RTF_CLONING)) {
+                                               bzero(&info, sizeof(info));
+                                               info.rti_info[RTAX_DST] = &sa;
+                                               info.rti_info[RTAX_GATEWAY] = 
ifa->ifa_addr;
+                                               info.rti_info[RTAX_NETMASK] = 
ifa->ifa_netmask;
+                                               error = rtrequest1(RTM_DELETE, 
&info, NULL, 0);
+                                               rt_missmsg(RTM_DELETE, &info, 
info.rti_flags, NULL,
+                                                   error, 0);
+                                       }
 
                                        ifa->ifa_rtrequest = arp_rtrequest;
                                        ifa->ifa_flags |= RTF_CLONING;
 
-                                       if (rtrequest(RTM_ADD, ifa->ifa_addr,
-                                           ifa->ifa_addr, ifa->ifa_netmask, 0,
-                                           NULL, 0) == 0)
+                                       bzero(&info, sizeof(info));
+                                       info.rti_info[RTAX_DST] = ifa->ifa_addr;
+                                       info.rti_info[RTAX_GATEWAY] = 
ifa->ifa_addr;
+                                       info.rti_info[RTAX_NETMASK] = 
ifa->ifa_netmask;
+                                       error = rtrequest1(RTM_ADD, &info, 
NULL, 0);
+                                       if (error == 0)
                                                ifa->ifa_flags |= IFA_ROUTE;
+                                       rt_missmsg(RTM_ADD, &info, 
info.rti_flags, NULL,
+                                           error, 0);
                                }
                                break;
                        case RTM_DELETE:



* Fran??ois Rousseau <[EMAIL PROTECTED]> [2007-04-07 00:51]:
> Hi,
> 
> I'm configuring 2 server to use as a gateway for multihoming.
> 
> I use:
> 
> OpenBSD 4.0 stable and OpenBSD 4.0 release
> OpenBGPD
> OpenOSPFD
> CARP for failover
> 
> I have 2 router with 3 interfaces and 5 carp interfaces by router.
> 
> interface1 = eBGP with 2 upstream provider
> interface2 = Link between the 2 routers, OSPF, iBGP (10.10.10.0/30)
> (em0 and bge0)
> interface3 = 5 * carp --> use as gateway for my servers (bge2)
> 
> Right now the BGP, and the CARP work correctly.
> 
> My problem is with the OSPF part.  OSPF by itself work correctly but
> it didn't announce any route concerning the carp interface.
> 
> If I start ospfd with "ospfd -dv" I see many:
> "if_fsm: event UP resulted in action START and changing state for
> interface carpX from DOWN to DOWN"
> 
> -------------------
> 
> Router1:
> ospfd.conf
> 
> router-id 0.0.0.1
> redistribute 44.25.32.41/30
> 
> area 0.0.0.0 {
>   auth-type crypt
>   auth-md 1 "iii"
>   auth-md 2 "jjj"
>   auth-md-keyid 1
> 
>  interface em0 {
>      metric 10
>  }
>  interface carp0 {
>      passive
>  }
>  interface carp1
>  interface carp2
>  interface carp3
>  interface carp4
> }
> 
> 
> 
> hostname.bge2:
>  inet 83.201.76.2 255.255.255.0 NONE description "My network"
> 
> -----------------
> 
> Router2:
> ospfd.conf
> 
> router-id 0.0.0.2
> redistribute 211.6.17.17/30
> 
> area 0.0.0.0 {
>   auth-type crypt
>   auth-md 1 "iii"
>   auth-md 2 "jjj"
>   auth-md-keyid 1
> 
>  interface bge0
>  interface carp0 {
>      passive
>  }
>  interface carp1
>  interface carp2
>  interface carp3
>  interface carp4
> }
> 
> 
> 
> hostname.bge2:
>  inet 23.182.158.2 255.255.255.0 NONE description "My network"
> 
> 
> ---------------
> 
> Both router:
> 
> CARP:
> hostname.carp0:
>   inet 23.182.158.1 255.255.255.0 23.182.158.255 vhid 1 pass
> temppass2 carpdev bge2
> 
> hostname.carp1:
>    inet 83.201.77.1 255.255.255.0 83.201.77.255 vhid2 pass temppass2
> carpdev bge2
> 
> hostname.carp2:
>    inet 83.201.78.1 255.255.255.0 83.201.78.255 vhid3 pass temppass2
> carpdev bge2
> 
> hostname.carp3:
>    inet 83.201.79.1 255.255.255.0 83.201.79.255 vhid4 pass temppass2
> carpdev bge2
> 
> hostname.carp4:
>  inet 83.201.76.1 255.255.255.0 83.201.76.255 vhid5 pass temppass2 carpdev 
>  bge2
> 
> 
> 
> Thanks,
> FranC'ois
> 

-- 
Henning Brauer, [EMAIL PROTECTED], [EMAIL PROTECTED]
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting - Hamburg & Amsterdam

Reply via email to