> I hacked up something, though I need to double check that
> I made all the substitutions correctly:
I think it is ok. It it is working for half an hour without a problem.
Adding/removing real servers, connecting/disconnecting, simulating
fail-overs no problems detected. And as I looked in the patch the
substitutions looked correct.
Rumen
>
> Index: net-2.6/include/net/ip_vs.h
> ===================================================================
> --- net-2.6.orig/include/net/ip_vs.h 2007-11-01 18:18:23.000000000 +0900
> +++ net-2.6/include/net/ip_vs.h 2007-11-01 18:19:22.000000000 +0900
> @@ -949,6 +949,21 @@ extern int ip_vs_icmp_xmit
> (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int
> offset);
> extern void ip_vs_dst_reset(struct ip_vs_dest *dest);
>
> +static inline void ip_vs_dest_get(struct ip_vs_dest *dest)
> +{
> + atomic_inc(&dest->refcnt);
> +}
> +
> +static inline void ip_vs_dest_put(struct ip_vs_dest *dest)
> +{
> + atomic_dec(&dest->refcnt);
> +}
> +
> +static inline int ip_vs_dest_put_and_test(struct ip_vs_dest *dest)
> +{
> + return atomic_dec_and_test(&dest->refcnt);
> +}
> +
>
> /*
> * This is a simple mechanism to ignore packets when
> Index: net-2.6/net/ipv4/ipvs/ip_vs_conn.c
> ===================================================================
> --- net-2.6.orig/net/ipv4/ipvs/ip_vs_conn.c 2007-11-01 18:14:21.000000000
> +0900
> +++ net-2.6/net/ipv4/ipvs/ip_vs_conn.c 2007-11-01 18:19:22.000000000
> +0900
> @@ -390,7 +390,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, s
> return;
>
> /* Increase the refcnt counter of the dest */
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
>
> /* Bind with the destination and its corresponding transmitter */
> cp->flags |= atomic_read(&dest->conn_flags);
> @@ -497,7 +497,7 @@ static inline void ip_vs_unbind_dest(str
> * dest will be either in service's destination list
> * or in the trash.
> */
> - atomic_dec(&dest->refcnt);
> + ip_vs_dest_put(dest);
> }
>
>
> Index: net-2.6/net/ipv4/ipvs/ip_vs_ctl.c
> ===================================================================
> --- net-2.6.orig/net/ipv4/ipvs/ip_vs_ctl.c 2007-11-01 18:14:21.000000000
> +0900
> +++ net-2.6/net/ipv4/ipvs/ip_vs_ctl.c 2007-11-01 18:19:22.000000000 +0900
> @@ -601,7 +601,7 @@ struct ip_vs_dest *ip_vs_find_dest(__be3
> return NULL;
> dest = ip_vs_lookup_dest(svc, daddr, dport);
> if (dest)
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
> ip_vs_service_put(svc);
>
> return dest;
> @@ -877,7 +877,7 @@ ip_vs_add_dest(struct ip_vs_service *svc
> /*
> * Add the dest entry into the list
> */
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
>
> write_lock_bh(&__ip_vs_svc_lock);
>
> @@ -969,7 +969,7 @@ static void __ip_vs_del_dest(struct ip_v
> * if nobody refers to it (refcnt=0). Otherwise, throw
> * the destination into the trash.
> */
> - if (atomic_dec_and_test(&dest->refcnt)) {
> + if (ip_vs_dest_put_and_test(dest)) {
> ip_vs_dst_reset(dest);
> /* simply decrease svc->refcnt here, let the caller check
> and release the service if nobody refers to it.
> @@ -984,7 +984,7 @@ static void __ip_vs_del_dest(struct ip_v
> NIPQUAD(dest->addr), ntohs(dest->port),
> atomic_read(&dest->refcnt));
> list_add(&dest->n_list, &ip_vs_dest_trash);
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
> }
> }
>
> Index: net-2.6/net/ipv4/ipvs/ip_vs_dh.c
> ===================================================================
> --- net-2.6.orig/net/ipv4/ipvs/ip_vs_dh.c 2007-11-01 18:06:47.000000000
> +0900
> +++ net-2.6/net/ipv4/ipvs/ip_vs_dh.c 2007-11-01 18:19:22.000000000 +0900
> @@ -103,7 +103,7 @@ ip_vs_dh_assign(struct ip_vs_dh_bucket *
> p = p->next;
>
> dest = list_entry(p, struct ip_vs_dest, n_list);
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
> b->dest = dest;
>
> p = p->next;
> @@ -125,7 +125,7 @@ static void ip_vs_dh_flush(struct ip_vs_
> b = tbl;
> for (i=0; i<IP_VS_DH_TAB_SIZE; i++) {
> if (b->dest) {
> - atomic_dec(&b->dest->refcnt);
> + ip_vs_dest_put(b->dest);
> b->dest = NULL;
> }
> b++;
> Index: net-2.6/net/ipv4/ipvs/ip_vs_lblc.c
> ===================================================================
> --- net-2.6.orig/net/ipv4/ipvs/ip_vs_lblc.c 2007-11-01 18:06:47.000000000
> +0900
> +++ net-2.6/net/ipv4/ipvs/ip_vs_lblc.c 2007-11-01 18:19:22.000000000
> +0900
> @@ -174,7 +174,7 @@ ip_vs_lblc_new(__be32 daddr, struct ip_v
> INIT_LIST_HEAD(&en->list);
> en->addr = daddr;
>
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
> en->dest = dest;
>
> return en;
> @@ -188,7 +188,7 @@ static inline void ip_vs_lblc_free(struc
> * We don't kfree dest because it is refered either by its service
> * or the trash dest list.
> */
> - atomic_dec(&en->dest->refcnt);
> + ip_vs_dest_put(en->dest);
> kfree(en);
> }
>
> @@ -548,8 +548,8 @@ ip_vs_lblc_schedule(struct ip_vs_service
> IP_VS_DBG(1, "no destination available\n");
> return NULL;
> }
> - atomic_dec(&en->dest->refcnt);
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_put(en->dest);
> + ip_vs_dest_get(dest);
> en->dest = dest;
> }
> }
> Index: net-2.6/net/ipv4/ipvs/ip_vs_lblcr.c
> ===================================================================
> --- net-2.6.orig/net/ipv4/ipvs/ip_vs_lblcr.c 2007-11-01 18:06:47.000000000
> +0900
> +++ net-2.6/net/ipv4/ipvs/ip_vs_lblcr.c 2007-11-01 18:19:22.000000000
> +0900
> @@ -114,7 +114,7 @@ ip_vs_dest_set_insert(struct ip_vs_dest_
> return NULL;
> }
>
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
> e->dest = dest;
>
> /* link it to the list */
> @@ -140,7 +140,7 @@ ip_vs_dest_set_erase(struct ip_vs_dest_s
> *ep = e->next;
> atomic_dec(&set->size);
> set->lastmod = jiffies;
> - atomic_dec(&e->dest->refcnt);
> + ip_vs_dest_put(e->dest);
> kfree(e);
> break;
> }
> @@ -160,7 +160,7 @@ static void ip_vs_dest_set_eraseall(stru
> * We don't kfree dest because it is refered either
> * by its service or by the trash dest list.
> */
> - atomic_dec(&e->dest->refcnt);
> + ip_vs_dest_put(e->dest);
> kfree(e);
> }
> write_unlock(&set->lock);
> Index: net-2.6/net/ipv4/ipvs/ip_vs_sh.c
> ===================================================================
> --- net-2.6.orig/net/ipv4/ipvs/ip_vs_sh.c 2007-11-01 18:06:47.000000000
> +0900
> +++ net-2.6/net/ipv4/ipvs/ip_vs_sh.c 2007-11-01 18:19:22.000000000 +0900
> @@ -100,7 +100,7 @@ ip_vs_sh_assign(struct ip_vs_sh_bucket *
> p = p->next;
>
> dest = list_entry(p, struct ip_vs_dest, n_list);
> - atomic_inc(&dest->refcnt);
> + ip_vs_dest_get(dest);
> b->dest = dest;
>
> p = p->next;
> @@ -122,7 +122,7 @@ static void ip_vs_sh_flush(struct ip_vs_
> b = tbl;
> for (i=0; i<IP_VS_SH_TAB_SIZE; i++) {
> if (b->dest) {
> - atomic_dec(&b->dest->refcnt);
> + ip_vs_dest_put(b->dest);
> b->dest = NULL;
> }
> b++;
>
> LVS Development mailing list - lvs-devel at LinuxVirtualServer.org
> Send requests to lvs-devel-request at LinuxVirtualServer.org
> or go to http://lists.graemef.net/mailman/listinfo/lvs-devel
|