carp: add carp_group_demote_adj() master
authorJan Lentfer <Jan.Lentfer@web.de>
Mon, 9 Aug 2010 21:10:58 +0000 (23:10 +0200)
committerJan Lentfer <Jan.Lentfer@web.de>
Mon, 9 Aug 2010 21:12:23 +0000 (23:12 +0200)
sys/netinet/ip_carp.c
sys/netinet/ip_carp.h

index 46a55be..dc933ea 100644 (file)
@@ -2058,6 +2058,29 @@ carp_set_state(struct carp_softc *sc, int state)
        rt_ifmsg(cifp);
 }
 
        rt_ifmsg(cifp);
 }
 
+void
+carp_group_demote_adj(struct ifnet *ifp, int adj)
+{
+       struct ifg_list *ifgl;
+       int *dm;
+       
+       TAILQ_FOREACH(ifgl, &ifp->if_groups, ifgl_next) {
+               if (!strcmp(ifgl->ifgl_group->ifg_group, IFG_ALL))
+                       continue;
+               dm = &ifgl->ifgl_group->ifg_carp_demoted;
+
+               if (*dm + adj >= 0)
+                       *dm += adj;
+               else
+                       *dm = 0;
+
+               if (adj > 0 && *dm == 1)
+                       carp_send_ad_all();
+               CARP_LOG("%s demoted group %s to %d", ifp->if_xname,
+                    ifgl->ifgl_group->ifg_group, *dm);
+       }
+}
+
 void
 carp_carpdev_state(void *v)
 {
 void
 carp_carpdev_state(void *v)
 {
index 4b5517b..656eb05 100644 (file)
@@ -170,6 +170,7 @@ struct ifcarpvhaddr {
 
 #ifdef _KERNEL
 void            carp_carpdev_state(void *);
 
 #ifdef _KERNEL
 void            carp_carpdev_state(void *);
+void            carp_group_demote_adj(struct ifnet *, int);
 void            carp_input(struct mbuf *, ...);
 int             carp6_input(struct mbuf **, int *, int);
 int             carp_output(struct ifnet *, struct mbuf *, struct sockaddr *,
 void            carp_input(struct mbuf *, ...);
 int             carp6_input(struct mbuf **, int *, int);
 int             carp_output(struct ifnet *, struct mbuf *, struct sockaddr *,