# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.1354 -> 1.1355 # net/ipv4/ipvs/ip_vs_nq.c 1.2 -> 1.3 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/09/27 ja@xxxxxx 1.1355 # [IPV4/IPVS] The NQ scheduler must not return servers with weight 0 # -------------------------------------------- # diff -Nru a/net/ipv4/ipvs/ip_vs_nq.c b/net/ipv4/ipvs/ip_vs_nq.c --- a/net/ipv4/ipvs/ip_vs_nq.c Sat Sep 27 13:47:18 2003 +++ b/net/ipv4/ipvs/ip_vs_nq.c Sat Sep 27 13:47:18 2003 @@ -81,8 +81,8 @@ static struct ip_vs_dest * ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph) { - struct ip_vs_dest *dest, *least; - unsigned int loh, doh; + struct ip_vs_dest *dest, *least = NULL; + unsigned int loh = 0, doh; IP_VS_DBG(6, "ip_vs_nq_schedule(): Scheduling...\n"); @@ -99,27 +99,10 @@ * new connections. */ - list_for_each_entry(least, &svc->destinations, n_list) { - if (!(least->flags & IP_VS_DEST_F_OVERLOAD) && - atomic_read(&least->weight) > 0) { - loh = ip_vs_nq_dest_overhead(least); - - /* return the server directly if it is idle */ - if (atomic_read(&least->activeconns) == 0) - goto out; - - goto nextstage; - } - } - return NULL; - - /* - * Find the destination with the least load. - */ - nextstage: list_for_each_entry(dest, &svc->destinations, n_list) { - if (dest->flags & IP_VS_DEST_F_OVERLOAD) + if (dest->flags & IP_VS_DEST_F_OVERLOAD || + !atomic_read(&dest->weight)) continue; doh = ip_vs_nq_dest_overhead(dest); @@ -127,15 +110,20 @@ /* return the server directly if it is idle */ if (atomic_read(&dest->activeconns) == 0) { least = dest; + loh = doh; goto out; } - if (loh * atomic_read(&dest->weight) > - doh * atomic_read(&least->weight)) { + if (!least || + (loh * atomic_read(&dest->weight) > + doh * atomic_read(&least->weight))) { least = dest; loh = doh; } } + + if (!least) + return NULL; out: IP_VS_DBG(6, "NQ: server %u.%u.%u.%u:%u "