* [2.4/2.6] ipvs: improve conn rehashing, other fixes
@ 2004-03-21 18:46 Julian Anastasov
2004-03-22 7:07 ` David S. Miller
0 siblings, 1 reply; 10+ messages in thread
From: Julian Anastasov @ 2004-03-21 18:46 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Wensong Zhang
[-- Attachment #1: Type: TEXT/PLAIN, Size: 401 bytes --]
Hello,
Attached are some fixes for IPVS for Linux 2.4 and 2.6:
- Brett E. <brettspamacct@fastclick.com> noticed the missing svc
lock for dest edit
- improve the rehashing during cport changes
- one old/lost fix for 2.4: the h.raw update for tunneling
The same changes are here:
http://www.ssi.bg/~ja/tmp/ipvs-2.6/
http://www.ssi.bg/~ja/tmp/ipvs-2.4/
Regards
--
Julian Anastasov <ja@ssi.bg>
[-- Attachment #2: 2.4 - svc lock --]
[-- Type: TEXT/PLAIN, Size: 536 bytes --]
diff -ur v2.4.25/linux/net/ipv4/ipvs/ip_vs_ctl.c linux/net/ipv4/ipvs/ip_vs_ctl.c
--- v2.4.25/linux/net/ipv4/ipvs/ip_vs_ctl.c 2003-11-28 22:04:14.000000000 +0200
+++ linux/net/ipv4/ipvs/ip_vs_ctl.c 2004-03-20 11:24:28.574545872 +0200
@@ -892,9 +892,13 @@
__ip_vs_update_dest(svc, dest, ur);
+ write_lock_bh(&__ip_vs_svc_lock);
+
/* call the update_service, because server weight may be changed */
svc->scheduler->update_service(svc);
+ write_unlock_bh(&__ip_vs_svc_lock);
+
LeaveFunction(2);
return 0;
[-- Attachment #3: 2.4 - improve unhashing --]
[-- Type: TEXT/PLAIN, Size: 3508 bytes --]
diff -ur v2.4.25/linux/net/ipv4/ipvs/ip_vs_conn.c linux/net/ipv4/ipvs/ip_vs_conn.c
--- v2.4.25/linux/net/ipv4/ipvs/ip_vs_conn.c 2003-11-28 22:04:14.000000000 +0200
+++ linux/net/ipv4/ipvs/ip_vs_conn.c 2004-03-21 19:33:35.802303232 +0200
@@ -141,25 +141,27 @@
static int ip_vs_conn_hash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (cp->flags & IP_VS_CONN_F_HASHED) {
- IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* Hash by protocol, client address and port */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
ct_write_lock(hash);
- list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
- cp->flags |= IP_VS_CONN_F_HASHED;
- atomic_inc(&cp->refcnt);
+ if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
+ list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
+ cp->flags |= IP_VS_CONN_F_HASHED;
+ atomic_inc(&cp->refcnt);
+ ret = 1;
+ } else {
+ IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
+ "called from %p\n", __builtin_return_address(0));
+ ret = 0;
+ }
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -170,24 +172,23 @@
static int ip_vs_conn_unhash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
- IP_VS_ERR("ip_vs_conn_unhash(): request for unhash flagged, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* unhash it and decrease its reference counter */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
ct_write_lock(hash);
- list_del(&cp->c_list);
- cp->flags &= ~IP_VS_CONN_F_HASHED;
- atomic_dec(&cp->refcnt);
+ if (cp->flags & IP_VS_CONN_F_HASHED) {
+ list_del(&cp->c_list);
+ cp->flags &= ~IP_VS_CONN_F_HASHED;
+ atomic_dec(&cp->refcnt);
+ ret = 1;
+ } else
+ ret = 0;
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -725,15 +726,20 @@
/*
* Check if it is no_cport connection ...
*/
- if (cp->flags & IP_VS_CONN_F_NO_CPORT) {
- atomic_dec(&ip_vs_conn_no_cport_cnt);
- ip_vs_conn_unhash(cp);
- cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
- cp->cport = h.portp[0];
- /* hash on new dport */
- ip_vs_conn_hash(cp);
+ if (unlikely(cp->flags & IP_VS_CONN_F_NO_CPORT)) {
+ if (ip_vs_conn_unhash(cp)) {
+ spin_lock(&cp->lock);
+ if (cp->flags & IP_VS_CONN_F_NO_CPORT) {
+ atomic_dec(&ip_vs_conn_no_cport_cnt);
+ cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
+ cp->cport = h.portp[0];
+ IP_VS_DBG(10, "filled cport=%d\n", ntohs(cp->dport));
+ }
+ spin_unlock(&cp->lock);
- IP_VS_DBG(10, "filled cport=%d\n", ntohs(cp->dport));
+ /* hash on new dport */
+ ip_vs_conn_hash(cp);
+ }
}
if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(iph->tos))))
@@ -1142,11 +1148,14 @@
/*
* Invalidate the connection template
*/
- ip_vs_conn_unhash(ct);
- ct->dport = 65535;
- ct->vport = 65535;
- ct->cport = 0;
- ip_vs_conn_hash(ct);
+ if (ct->cport) {
+ if (ip_vs_conn_unhash(ct)) {
+ ct->dport = 65535;
+ ct->vport = 65535;
+ ct->cport = 0;
+ ip_vs_conn_hash(ct);
+ }
+ }
/*
* Simply decrease the refcnt of the template,
@@ -1200,7 +1209,8 @@
/*
* unhash it if it is hashed in the conn table
*/
- ip_vs_conn_unhash(cp);
+ if (!ip_vs_conn_unhash(cp))
+ goto expire_later;
/*
* refcnt==1 implies I'm the only one referrer
[-- Attachment #4: 2.4 - h.raw --]
[-- Type: TEXT/PLAIN, Size: 654 bytes --]
diff -ur v2.4.25/linux/net/ipv4/ipvs/ip_vs_conn.c linux/net/ipv4/ipvs/ip_vs_conn.c
--- v2.4.25/linux/net/ipv4/ipvs/ip_vs_conn.c 2003-11-28 22:04:14.000000000 +0200
+++ linux/net/ipv4/ipvs/ip_vs_conn.c 2004-03-20 11:19:35.121157568 +0200
@@ -890,8 +890,6 @@
/* update checksum because skb might be defragmented */
ip_send_check(old_iph);
- skb->h.raw = skb->nh.raw;
-
/*
* Okay, now see if we can stuff it in the buffer as-is.
*/
@@ -911,6 +909,7 @@
old_iph = skb->nh.iph;
}
+ skb->h.raw = skb->nh.raw;
skb->nh.raw = skb_push(skb, sizeof(struct iphdr));
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
[-- Attachment #5: 2.6 - svc lock --]
[-- Type: TEXT/PLAIN, Size: 1049 bytes --]
# 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.1818 -> 1.1819
# net/ipv4/ipvs/ip_vs_ctl.c 1.14 -> 1.15
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/20 brettspamacct@fastclick.com 1.1819
# [IPVS]: Hold the svc lock during service update in dest edit
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
--- a/net/ipv4/ipvs/ip_vs_ctl.c Sat Mar 20 16:45:13 2004
+++ b/net/ipv4/ipvs/ip_vs_ctl.c Sat Mar 20 16:45:13 2004
@@ -898,8 +898,12 @@
__ip_vs_update_dest(svc, dest, udest);
+ write_lock_bh(&__ip_vs_svc_lock);
+
/* call the update_service, because server weight may be changed */
svc->scheduler->update_service(svc);
+
+ write_unlock_bh(&__ip_vs_svc_lock);
LeaveFunction(2);
[-- Attachment #6: 2.6 - improve unhashing --]
[-- Type: TEXT/PLAIN, Size: 3729 bytes --]
# 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.1818 -> 1.1819
# net/ipv4/ipvs/ip_vs_conn.c 1.13 -> 1.14
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/21 ja@ssi.bg 1.1819
# [IPVS]: Improve the rehashing with new cport
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
--- a/net/ipv4/ipvs/ip_vs_conn.c Sun Mar 21 19:44:22 2004
+++ b/net/ipv4/ipvs/ip_vs_conn.c Sun Mar 21 19:44:22 2004
@@ -125,25 +125,27 @@
static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (cp->flags & IP_VS_CONN_F_HASHED) {
- IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* Hash by protocol, client address and port */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
ct_write_lock(hash);
- list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
- cp->flags |= IP_VS_CONN_F_HASHED;
- atomic_inc(&cp->refcnt);
+ if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
+ list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
+ cp->flags |= IP_VS_CONN_F_HASHED;
+ atomic_inc(&cp->refcnt);
+ ret = 1;
+ } else {
+ IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
+ "called from %p\n", __builtin_return_address(0));
+ ret = 0;
+ }
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -154,24 +156,24 @@
static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
- IP_VS_ERR("ip_vs_conn_unhash(): request for unhash flagged, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* unhash it and decrease its reference counter */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
+
ct_write_lock(hash);
- list_del(&cp->c_list);
- cp->flags &= ~IP_VS_CONN_F_HASHED;
- atomic_dec(&cp->refcnt);
+ if (cp->flags & IP_VS_CONN_F_HASHED) {
+ list_del(&cp->c_list);
+ cp->flags &= ~IP_VS_CONN_F_HASHED;
+ atomic_dec(&cp->refcnt);
+ ret = 1;
+ } else
+ ret = 0;
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -285,12 +287,18 @@
*/
void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __u16 cport)
{
- atomic_dec(&ip_vs_conn_no_cport_cnt);
- ip_vs_conn_unhash(cp);
- cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
- cp->cport = cport;
- /* hash on new dport */
- ip_vs_conn_hash(cp);
+ if (ip_vs_conn_unhash(cp)) {
+ spin_lock(&cp->lock);
+ if (cp->flags & IP_VS_CONN_F_NO_CPORT) {
+ atomic_dec(&ip_vs_conn_no_cport_cnt);
+ cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
+ cp->cport = cport;
+ }
+ spin_unlock(&cp->lock);
+
+ /* hash on new dport */
+ ip_vs_conn_hash(cp);
+ }
}
@@ -457,11 +465,14 @@
/*
* Invalidate the connection template
*/
- ip_vs_conn_unhash(ct);
- ct->dport = 65535;
- ct->vport = 65535;
- ct->cport = 0;
- ip_vs_conn_hash(ct);
+ if (ct->cport) {
+ if (ip_vs_conn_unhash(ct)) {
+ ct->dport = 65535;
+ ct->vport = 65535;
+ ct->cport = 0;
+ ip_vs_conn_hash(ct);
+ }
+ }
/*
* Simply decrease the refcnt of the template,
@@ -493,7 +504,8 @@
/*
* unhash it if it is hashed in the conn table
*/
- ip_vs_conn_unhash(cp);
+ if (!ip_vs_conn_unhash(cp))
+ goto expire_later;
/*
* refcnt==1 implies I'm the only one referrer
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-21 18:46 [2.4/2.6] ipvs: improve conn rehashing, other fixes Julian Anastasov
@ 2004-03-22 7:07 ` David S. Miller
2004-03-22 11:26 ` Julian Anastasov
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: David S. Miller @ 2004-03-22 7:07 UTC (permalink / raw)
To: Julian Anastasov; +Cc: netdev, wensong
These look find to me at first glance.
Wensong, resend to me under seperate cover once you've
reviewed.
THanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-22 7:07 ` David S. Miller
@ 2004-03-22 11:26 ` Julian Anastasov
2004-03-22 13:21 ` Wensong Zhang
2004-03-22 16:58 ` Wensong Zhang
2 siblings, 0 replies; 10+ messages in thread
From: Julian Anastasov @ 2004-03-22 11:26 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, wensong
Hello,
On Sun, 21 Mar 2004, David S. Miller wrote:
> These look find to me at first glance.
>
> Wensong, resend to me under seperate cover once you've
> reviewed.
Dave, if it is not too late, can you skip the change for
ip_vs_ctl.c (ip_vs_updsvc-*.diff) that adds the missing svc lock, it
seems it is not needed as the lock protects only the service list.
> THanks.
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-22 7:07 ` David S. Miller
2004-03-22 11:26 ` Julian Anastasov
@ 2004-03-22 13:21 ` Wensong Zhang
2004-03-22 16:58 ` Wensong Zhang
2 siblings, 0 replies; 10+ messages in thread
From: Wensong Zhang @ 2004-03-22 13:21 UTC (permalink / raw)
To: David S. Miller; +Cc: Julian Anastasov, netdev
On Sun, 21 Mar 2004, David S. Miller wrote:
>
> Wensong, resend to me under seperate cover once you've
> reviewed.
>
Actually, Julian and I had discussed the patches before he sent them to
you.
I see if Julian can make BK changesets now, otherwise I do.
Cheers,
Wensong
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-22 7:07 ` David S. Miller
2004-03-22 11:26 ` Julian Anastasov
2004-03-22 13:21 ` Wensong Zhang
@ 2004-03-22 16:58 ` Wensong Zhang
2004-03-23 2:36 ` David S. Miller
2 siblings, 1 reply; 10+ messages in thread
From: Wensong Zhang @ 2004-03-22 16:58 UTC (permalink / raw)
To: David S. Miller; +Cc: Julian Anastasov, netdev
[-- Attachment #1: Type: TEXT/PLAIN, Size: 282 bytes --]
Hi,
On Sun, 21 Mar 2004, David S. Miller wrote:
>
> These look find to me at first glance.
>
> Wensong, resend to me under seperate cover once you've
> reviewed.
>
Dave, please check the attached patches. There are three patches for 2.4,
and two for 2.6.
Thanks,
Wensong
[-- Attachment #2: Type: TEXT/PLAIN, Size: 1173 bytes --]
# 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.1337 -> 1.1338
# net/ipv4/ipvs/ip_vs_conn.c 1.4 -> 1.5
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/22 ja@ssi.bg 1.1338
# [IPVS] Fix to update the skb->h.raw after skb reallocation in tunnel_xmit
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
--- a/net/ipv4/ipvs/ip_vs_conn.c Mon Mar 22 23:30:53 2004
+++ b/net/ipv4/ipvs/ip_vs_conn.c Mon Mar 22 23:30:53 2004
@@ -892,8 +892,6 @@
/* update checksum because skb might be defragmented */
ip_send_check(old_iph);
- skb->h.raw = skb->nh.raw;
-
/*
* Okay, now see if we can stuff it in the buffer as-is.
*/
@@ -913,6 +911,7 @@
old_iph = skb->nh.iph;
}
+ skb->h.raw = skb->nh.raw;
skb->nh.raw = skb_push(skb, sizeof(struct iphdr));
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
[-- Attachment #3: Type: TEXT/PLAIN, Size: 4000 bytes --]
# 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.1335 -> 1.1336
# net/ipv4/ipvs/ip_vs_conn.c 1.3 -> 1.4
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/22 ja@ssi.bg 1.1336
# [IPVS] Fix connection rehashing with new cport
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
--- a/net/ipv4/ipvs/ip_vs_conn.c Mon Mar 22 23:00:20 2004
+++ b/net/ipv4/ipvs/ip_vs_conn.c Mon Mar 22 23:00:20 2004
@@ -137,25 +137,27 @@
static int ip_vs_conn_hash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (cp->flags & IP_VS_CONN_F_HASHED) {
- IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* Hash by protocol, client address and port */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
ct_write_lock(hash);
- list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
- cp->flags |= IP_VS_CONN_F_HASHED;
- atomic_inc(&cp->refcnt);
+ if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
+ list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
+ cp->flags |= IP_VS_CONN_F_HASHED;
+ atomic_inc(&cp->refcnt);
+ ret = 1;
+ } else {
+ IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
+ "called from %p\n", __builtin_return_address(0));
+ ret = 0;
+ }
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -166,24 +168,23 @@
static int ip_vs_conn_unhash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
- IP_VS_ERR("ip_vs_conn_unhash(): request for unhash flagged, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* unhash it and decrease its reference counter */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
ct_write_lock(hash);
- list_del(&cp->c_list);
- cp->flags &= ~IP_VS_CONN_F_HASHED;
- atomic_dec(&cp->refcnt);
+ if (cp->flags & IP_VS_CONN_F_HASHED) {
+ list_del(&cp->c_list);
+ cp->flags &= ~IP_VS_CONN_F_HASHED;
+ atomic_dec(&cp->refcnt);
+ ret = 1;
+ } else
+ ret = 0;
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -721,15 +722,20 @@
/*
* Check if it is no_cport connection ...
*/
- if (cp->flags & IP_VS_CONN_F_NO_CPORT) {
- atomic_dec(&ip_vs_conn_no_cport_cnt);
- ip_vs_conn_unhash(cp);
- cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
- cp->cport = h.portp[0];
- /* hash on new dport */
- ip_vs_conn_hash(cp);
+ if (unlikely(cp->flags & IP_VS_CONN_F_NO_CPORT)) {
+ if (ip_vs_conn_unhash(cp)) {
+ spin_lock(&cp->lock);
+ if (cp->flags & IP_VS_CONN_F_NO_CPORT) {
+ atomic_dec(&ip_vs_conn_no_cport_cnt);
+ cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
+ cp->cport = h.portp[0];
+ IP_VS_DBG(10, "filled cport=%d\n", ntohs(cp->dport));
+ }
+ spin_unlock(&cp->lock);
- IP_VS_DBG(10, "filled cport=%d\n", ntohs(cp->dport));
+ /* hash on new dport */
+ ip_vs_conn_hash(cp);
+ }
}
if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(iph->tos))))
@@ -1138,11 +1144,14 @@
/*
* Invalidate the connection template
*/
- ip_vs_conn_unhash(ct);
- ct->dport = 65535;
- ct->vport = 65535;
- ct->cport = 0;
- ip_vs_conn_hash(ct);
+ if (ct->cport) {
+ if (ip_vs_conn_unhash(ct)) {
+ ct->dport = 65535;
+ ct->vport = 65535;
+ ct->cport = 0;
+ ip_vs_conn_hash(ct);
+ }
+ }
/*
* Simply decrease the refcnt of the template,
@@ -1196,7 +1205,8 @@
/*
* unhash it if it is hashed in the conn table
*/
- ip_vs_conn_unhash(cp);
+ if (!ip_vs_conn_unhash(cp))
+ goto expire_later;
/*
* refcnt==1 implies I'm the only one referrer
[-- Attachment #4: Type: TEXT/PLAIN, Size: 1288 bytes --]
# 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.1336 -> 1.1337
# net/ipv4/ipvs/ip_vs_ctl.c 1.5 -> 1.6
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/22 wensong@linux-vs.org 1.1337
# [IPVS] Fix to hold the lock before updating a service
#
# Brett E. <brettspamacct@fastclick.com> noticed the missing service lock
# for editing dest.
#
# Julian Anastasov <ja@ssi.bg> provided the patch.
#
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
--- a/net/ipv4/ipvs/ip_vs_ctl.c Mon Mar 22 23:10:47 2004
+++ b/net/ipv4/ipvs/ip_vs_ctl.c Mon Mar 22 23:10:47 2004
@@ -889,8 +889,15 @@
__ip_vs_update_dest(svc, dest, ur);
+ write_lock_bh(&__ip_vs_svc_lock);
+
+ /* Wait until all other svc users go away */
+ while (atomic_read(&svc->usecnt) > 1) {};
+
/* call the update_service, because server weight may be changed */
svc->scheduler->update_service(svc);
+
+ write_unlock_bh(&__ip_vs_svc_lock);
LeaveFunction(2);
[-- Attachment #5: Type: TEXT/PLAIN, Size: 3731 bytes --]
# 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.1694 -> 1.1695
# net/ipv4/ipvs/ip_vs_conn.c 1.13 -> 1.14
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/22 ja@ssi.bg 1.1695
# [IPVS] Fix connection rehashing with new cport
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
--- a/net/ipv4/ipvs/ip_vs_conn.c Mon Mar 22 23:36:33 2004
+++ b/net/ipv4/ipvs/ip_vs_conn.c Mon Mar 22 23:36:33 2004
@@ -125,25 +125,27 @@
static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (cp->flags & IP_VS_CONN_F_HASHED) {
- IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* Hash by protocol, client address and port */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
ct_write_lock(hash);
- list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
- cp->flags |= IP_VS_CONN_F_HASHED;
- atomic_inc(&cp->refcnt);
+ if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
+ list_add(&cp->c_list, &ip_vs_conn_tab[hash]);
+ cp->flags |= IP_VS_CONN_F_HASHED;
+ atomic_inc(&cp->refcnt);
+ ret = 1;
+ } else {
+ IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
+ "called from %p\n", __builtin_return_address(0));
+ ret = 0;
+ }
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -154,24 +156,24 @@
static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
{
unsigned hash;
-
- if (!(cp->flags & IP_VS_CONN_F_HASHED)) {
- IP_VS_ERR("ip_vs_conn_unhash(): request for unhash flagged, "
- "called from %p\n", __builtin_return_address(0));
- return 0;
- }
+ int ret;
/* unhash it and decrease its reference counter */
hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
+
ct_write_lock(hash);
- list_del(&cp->c_list);
- cp->flags &= ~IP_VS_CONN_F_HASHED;
- atomic_dec(&cp->refcnt);
+ if (cp->flags & IP_VS_CONN_F_HASHED) {
+ list_del(&cp->c_list);
+ cp->flags &= ~IP_VS_CONN_F_HASHED;
+ atomic_dec(&cp->refcnt);
+ ret = 1;
+ } else
+ ret = 0;
ct_write_unlock(hash);
- return 1;
+ return ret;
}
@@ -285,12 +287,18 @@
*/
void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __u16 cport)
{
- atomic_dec(&ip_vs_conn_no_cport_cnt);
- ip_vs_conn_unhash(cp);
- cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
- cp->cport = cport;
- /* hash on new dport */
- ip_vs_conn_hash(cp);
+ if (ip_vs_conn_unhash(cp)) {
+ spin_lock(&cp->lock);
+ if (cp->flags & IP_VS_CONN_F_NO_CPORT) {
+ atomic_dec(&ip_vs_conn_no_cport_cnt);
+ cp->flags &= ~IP_VS_CONN_F_NO_CPORT;
+ cp->cport = cport;
+ }
+ spin_unlock(&cp->lock);
+
+ /* hash on new dport */
+ ip_vs_conn_hash(cp);
+ }
}
@@ -457,11 +465,14 @@
/*
* Invalidate the connection template
*/
- ip_vs_conn_unhash(ct);
- ct->dport = 65535;
- ct->vport = 65535;
- ct->cport = 0;
- ip_vs_conn_hash(ct);
+ if (ct->cport) {
+ if (ip_vs_conn_unhash(ct)) {
+ ct->dport = 65535;
+ ct->vport = 65535;
+ ct->cport = 0;
+ ip_vs_conn_hash(ct);
+ }
+ }
/*
* Simply decrease the refcnt of the template,
@@ -493,7 +504,8 @@
/*
* unhash it if it is hashed in the conn table
*/
- ip_vs_conn_unhash(cp);
+ if (!ip_vs_conn_unhash(cp))
+ goto expire_later;
/*
* refcnt==1 implies I'm the only one referrer
[-- Attachment #6: Type: TEXT/PLAIN, Size: 1287 bytes --]
# 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.1830 -> 1.1831
# net/ipv4/ipvs/ip_vs_ctl.c 1.14 -> 1.15
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/23 wensong@linux-vs.org 1.1831
# [IPVS] Fix to hold the lock before updating a service
#
# Brett E. <brettspamacct@fastclick.com> noticed the missing service lock
# for editing dest.
#
# Julian Anastasov <ja@ssi.bg> provided the patch.
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
--- a/net/ipv4/ipvs/ip_vs_ctl.c Tue Mar 23 00:57:58 2004
+++ b/net/ipv4/ipvs/ip_vs_ctl.c Tue Mar 23 00:57:58 2004
@@ -898,8 +898,15 @@
__ip_vs_update_dest(svc, dest, udest);
+ write_lock_bh(&__ip_vs_svc_lock);
+
+ /* Wait until all other svc users go away */
+ while (atomic_read(&svc->usecnt) > 1) {};
+
/* call the update_service, because server weight may be changed */
svc->scheduler->update_service(svc);
+
+ write_unlock_bh(&__ip_vs_svc_lock);
LeaveFunction(2);
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-22 16:58 ` Wensong Zhang
@ 2004-03-23 2:36 ` David S. Miller
2004-03-23 8:34 ` Julian Anastasov
0 siblings, 1 reply; 10+ messages in thread
From: David S. Miller @ 2004-03-23 2:36 UTC (permalink / raw)
To: Wensong Zhang; +Cc: ja, netdev
On Tue, 23 Mar 2004 00:58:38 +0800 (CST)
Wensong Zhang <wensong@linux-vs.org> wrote:
> Dave, please check the attached patches. There are three patches for 2.4,
> and two for 2.6.
I am going to apply everything except the ip_vs_ctl.c change as
Julian has tol me under seperate cover that the locking he adds
there is not really necessary.
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-23 2:36 ` David S. Miller
@ 2004-03-23 8:34 ` Julian Anastasov
2004-03-23 8:40 ` David S. Miller
0 siblings, 1 reply; 10+ messages in thread
From: Julian Anastasov @ 2004-03-23 8:34 UTC (permalink / raw)
To: David S. Miller; +Cc: Wensong Zhang, netdev
Hello,
On Mon, 22 Mar 2004, David S. Miller wrote:
> On Tue, 23 Mar 2004 00:58:38 +0800 (CST)
> Wensong Zhang <wensong@linux-vs.org> wrote:
>
> > Dave, please check the attached patches. There are three patches for 2.4,
> > and two for 2.6.
>
> I am going to apply everything except the ip_vs_ctl.c change as
> Julian has tol me under seperate cover that the locking he adds
> there is not really necessary.
It was the old version. Please, apply everything sent from
Wensong. The old versions protect only the list which is not needed
on edit but the new versions from Wensong ensure that the service is
updated safely while there are no other CPUs using the schedulers.
By this way, after my last posting, we fix missing locking in the
following schedulers: WRR, RR, SH, DH. Now the benefit is that we
do not add locking in the fast path, instead, we add it only on
edit (slow path).
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-23 8:34 ` Julian Anastasov
@ 2004-03-23 8:40 ` David S. Miller
2004-03-23 8:48 ` Julian Anastasov
0 siblings, 1 reply; 10+ messages in thread
From: David S. Miller @ 2004-03-23 8:40 UTC (permalink / raw)
To: Julian Anastasov; +Cc: wensong, netdev
On Tue, 23 Mar 2004 10:34:54 +0200 (EET)
Julian Anastasov <ja@ssi.bg> wrote:
> It was the old version. Please, apply everything sent from
> Wensong. The old versions protect only the list which is not needed
> on edit but the new versions from Wensong ensure that the service is
> updated safely while there are no other CPUs using the schedulers.
Sorry, wires got crossed. Julian/Wensong, could you please resend
that ip_vs_ctl.c locking change under seperate cover then?
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-23 8:40 ` David S. Miller
@ 2004-03-23 8:48 ` Julian Anastasov
2004-03-24 21:59 ` David S. Miller
0 siblings, 1 reply; 10+ messages in thread
From: Julian Anastasov @ 2004-03-23 8:48 UTC (permalink / raw)
To: David S. Miller; +Cc: wensong, netdev
[-- Attachment #1: Type: TEXT/PLAIN, Size: 622 bytes --]
Hello,
On Tue, 23 Mar 2004, David S. Miller wrote:
> On Tue, 23 Mar 2004 10:34:54 +0200 (EET)
> Julian Anastasov <ja@ssi.bg> wrote:
>
> > It was the old version. Please, apply everything sent from
> > Wensong. The old versions protect only the list which is not needed
> > on edit but the new versions from Wensong ensure that the service is
> > updated safely while there are no other CPUs using the schedulers.
>
> Sorry, wires got crossed. Julian/Wensong, could you please resend
> that ip_vs_ctl.c locking change under seperate cover then?
I still keep them, attached.
Regards
--
Julian Anastasov <ja@ssi.bg>
[-- Attachment #2: 2.4 - update_service --]
[-- Type: TEXT/PLAIN, Size: 1288 bytes --]
# 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.1336 -> 1.1337
# net/ipv4/ipvs/ip_vs_ctl.c 1.5 -> 1.6
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/22 wensong@linux-vs.org 1.1337
# [IPVS] Fix to hold the lock before updating a service
#
# Brett E. <brettspamacct@fastclick.com> noticed the missing service lock
# for editing dest.
#
# Julian Anastasov <ja@ssi.bg> provided the patch.
#
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
--- a/net/ipv4/ipvs/ip_vs_ctl.c Mon Mar 22 23:10:47 2004
+++ b/net/ipv4/ipvs/ip_vs_ctl.c Mon Mar 22 23:10:47 2004
@@ -889,8 +889,15 @@
__ip_vs_update_dest(svc, dest, ur);
+ write_lock_bh(&__ip_vs_svc_lock);
+
+ /* Wait until all other svc users go away */
+ while (atomic_read(&svc->usecnt) > 1) {};
+
/* call the update_service, because server weight may be changed */
svc->scheduler->update_service(svc);
+
+ write_unlock_bh(&__ip_vs_svc_lock);
LeaveFunction(2);
[-- Attachment #3: 2.6 - update_service --]
[-- Type: TEXT/PLAIN, Size: 1287 bytes --]
# 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.1830 -> 1.1831
# net/ipv4/ipvs/ip_vs_ctl.c 1.14 -> 1.15
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/23 wensong@linux-vs.org 1.1831
# [IPVS] Fix to hold the lock before updating a service
#
# Brett E. <brettspamacct@fastclick.com> noticed the missing service lock
# for editing dest.
#
# Julian Anastasov <ja@ssi.bg> provided the patch.
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
--- a/net/ipv4/ipvs/ip_vs_ctl.c Tue Mar 23 00:57:58 2004
+++ b/net/ipv4/ipvs/ip_vs_ctl.c Tue Mar 23 00:57:58 2004
@@ -898,8 +898,15 @@
__ip_vs_update_dest(svc, dest, udest);
+ write_lock_bh(&__ip_vs_svc_lock);
+
+ /* Wait until all other svc users go away */
+ while (atomic_read(&svc->usecnt) > 1) {};
+
/* call the update_service, because server weight may be changed */
svc->scheduler->update_service(svc);
+
+ write_unlock_bh(&__ip_vs_svc_lock);
LeaveFunction(2);
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [2.4/2.6] ipvs: improve conn rehashing, other fixes
2004-03-23 8:48 ` Julian Anastasov
@ 2004-03-24 21:59 ` David S. Miller
0 siblings, 0 replies; 10+ messages in thread
From: David S. Miller @ 2004-03-24 21:59 UTC (permalink / raw)
To: Julian Anastasov; +Cc: wensong, netdev
On Tue, 23 Mar 2004 10:48:40 +0200 (EET)
Julian Anastasov <ja@ssi.bg> wrote:
> > Sorry, wires got crossed. Julian/Wensong, could you please resend
> > that ip_vs_ctl.c locking change under seperate cover then?
>
> I still keep them, attached.
Applied, thanks a lot.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2004-03-24 21:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-21 18:46 [2.4/2.6] ipvs: improve conn rehashing, other fixes Julian Anastasov
2004-03-22 7:07 ` David S. Miller
2004-03-22 11:26 ` Julian Anastasov
2004-03-22 13:21 ` Wensong Zhang
2004-03-22 16:58 ` Wensong Zhang
2004-03-23 2:36 ` David S. Miller
2004-03-23 8:34 ` Julian Anastasov
2004-03-23 8:40 ` David S. Miller
2004-03-23 8:48 ` Julian Anastasov
2004-03-24 21:59 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).