Skip to contentSkip to conversation

ipvs: sparse fixes

PATCH In review Simon Horman 3 participants 11 messages Sep 16, 2008 – Sep 21, 2008

Subsystems (3)
lore
Share & tools
lore

Simon Horman

author maintainer
#0 lore raw

cover ipvs: sparse fixes

Some fixes and annotations for sparse warnings.

Signature · 3 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
author maintainer
#1 lore raw

PATCH 1/3 ipvs: only unlock in ip_vs_edit_service() if already locked

Jumping to out unlocks __ip_vs_svc_lock, but that lock is not taken until after code that may jump to out.

This problem was detected by sparse.

make C=1
CHECK net/ipv4/ipvs/ip_vs_ctl.c
net/ipv4/ipvs/ip_vs_ctl.c:1332:2: warning: context imbalance in 'ip_vs_edit_service' - unexpected unlock

net/ipv4/ipvs/ip_vs_ctl.c +4 -3
Index: lvs-2.6/net/ipv4/ipvs/ip_vs_ctl.c
===================================================================
@@ -1305,7 +1305,7 @@ ip_vs_edit_service(struct ip_vs_service 
 		 */
 		if ((ret = ip_vs_unbind_scheduler(svc))) {
 			old_sched = sched;
-			goto out;
+			goto out_unlock;
 		}
 
 		/*
@@ -1324,12 +1324,13 @@ ip_vs_edit_service(struct ip_vs_service 
 			 */
 			ip_vs_bind_scheduler(svc, old_sched);
 			old_sched = sched;
-			goto out;
+			goto out_unlock;
 		}
 	}
 
-  out:
+  out_unlock:
 	write_unlock_bh(&__ip_vs_svc_lock);
+  out:
 
 	if (old_sched)
 		ip_vs_scheduler_put(old_sched);
Signature · 4 lines
-- 
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
#2 lore raw

PATCH 1/1 ipvs: Fix unused label warning

---
 net/ipv4/ipvs/ip_vs_ctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Simon, small fixup patch for your patch. It wasn't obvious from the patch, that now only the IPV6 support needs this label.

net/ipv4/ipvs/ip_vs_ctl.c +2 -0
index 771551d..0302cf3 100644
@@ -1330,7 +1330,9 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u)
 
   out_unlock:
 	write_unlock_bh(&__ip_vs_svc_lock);
+#ifdef CONFIG_IP_VS_IPV6
   out:
+#endif
 
 	if (old_sched)
 		ip_vs_scheduler_put(old_sched);
author maintainer Applied
#3 lore raw

Re: [PATCH] ipvs: Fix unused label warning

Quoted 7 lines · Sven Wegener
---
 net/ipv4/ipvs/ip_vs_ctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Simon, small fixup patch for your patch. It wasn't obvious from the patch, that now only the IPV6 support needs this label.

Thanks, sorry for messing that up.

Applied

Signature · 3 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
author maintainer
#4 lore raw

PATCH 2/3 ipvs: supply a valid 0 address to ip_vs_conn_new()

In reply to Simon Horman

ip_vs_conn_new expects a union nf_inet_addr as the type for its address parameters, not a plain integer.

This problem was detected by sparse.

make C=1
CHECK net/ipv4/ipvs/ip_vs_core.c
net/ipv4/ipvs/ip_vs_core.c:469:9: warning: Using plain integer as NULL pointer

net/ipv4/ipvs/ip_vs_core.c +2 -1
Index: lvs-2.6/net/ipv4/ipvs/ip_vs_core.c
===================================================================
@@ -457,6 +457,7 @@ int ip_vs_leave(struct ip_vs_service *sv
 	if (sysctl_ip_vs_cache_bypass && svc->fwmark && unicast) {
 		int ret, cs;
 		struct ip_vs_conn *cp;
+		union nf_inet_addr daddr =  { .all = { 0, 0, 0, 0 } };
 
 		ip_vs_service_put(svc);
 
@@ -465,7 +466,7 @@ int ip_vs_leave(struct ip_vs_service *sv
 		cp = ip_vs_conn_new(svc->af, iph.protocol,
 				    &iph.saddr, pptr[0],
 				    &iph.daddr, pptr[1],
-				    0, 0,
+				    &daddr, 0,
 				    IP_VS_CONN_F_BYPASS,
 				    NULL);
 		if (cp == NULL)
Signature · 4 lines
-- 
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
#5 lore raw

Re: [patch 2/3] ipvs: supply a valid 0 address to ip_vs_conn_new()

Quoted 16 lines · Simon Horman

ip_vs_conn_new expects a union nf_inet_addr as the type for its address parameters, not a plain integer.

This problem was detected by sparse.

make C=1
CHECK net/ipv4/ipvs/ip_vs_core.c
net/ipv4/ipvs/ip_vs_core.c:469:9: warning: Using plain integer as NULL pointer

Index: lvs-2.6/net/ipv4/ipvs/ip_vs_core.c
===================================================================

net/ipv4/ipvs/ip_vs_core.c int ip_vs_leave(struct ip_vs_service *sv · line 460

Quoted 4 lines
net/ipv4/ipvs/ip_vs_core.c +1 -0
@@ -457,6 +457,7 @@ int ip_vs_leave(struct ip_vs_service *sv
 	if (sysctl_ip_vs_cache_bypass && svc->fwmark && unicast) {
 		int ret, cs;
 		struct ip_vs_conn *cp;
+		union nf_inet_addr daddr =  { .all = { 0, 0, 0, 0 } };

Could be static and const, to avoid allocation and initialization on the stack every time. But I don't think this a critical code path.

Quoted 12 lines
net/ipv4/ipvs/ip_vs_core.c +1 -1
 		ip_vs_service_put(svc);
 
@@ -465,7 +466,7 @@ int ip_vs_leave(struct ip_vs_service *sv
 		cp = ip_vs_conn_new(svc->af, iph.protocol,
 				    &iph.saddr, pptr[0],
 				    &iph.daddr, pptr[1],
-				    0, 0,
+				    &daddr, 0,
 				    IP_VS_CONN_F_BYPASS,
 				    NULL);
 		if (cp == NULL)
author maintainer
#6 lore raw

Re: [patch 2/3] ipvs: supply a valid 0 address to ip_vs_conn_new()

Quoted 13 lines · Sven Wegener
Quoted 11 lines · Simon Horman

ip_vs_conn_new expects a union nf_inet_addr as the type for its address parameters, not a plain integer.

This problem was detected by sparse.

make C=1
CHECK net/ipv4/ipvs/ip_vs_core.c
net/ipv4/ipvs/ip_vs_core.c:469:9: warning: Using plain integer as NULL pointer

Quoted 12 lines

net/ipv4/ipvs/ip_vs_core.c int ip_vs_leave(struct ip_vs_service *sv · line 460

Quoted 9 lines

Index: lvs-2.6/net/ipv4/ipvs/ip_vs_core.c
===================================================================

net/ipv4/ipvs/ip_vs_core.c +1 -0
@@ -457,6 +457,7 @@ int ip_vs_leave(struct ip_vs_service *sv
 	if (sysctl_ip_vs_cache_bypass && svc->fwmark && unicast) {
 		int ret, cs;
 		struct ip_vs_conn *cp;
+		union nf_inet_addr daddr =  { .all = { 0, 0, 0, 0 } };

Could be static and const, to avoid allocation and initialization on the stack every time. But I don't think this a critical code path.

Agreed, but I think I would rather leave it as is for now.

Quoted 12 lines
Quoted 12 lines
net/ipv4/ipvs/ip_vs_core.c +1 -1
 		ip_vs_service_put(svc);
 
@@ -465,7 +466,7 @@ int ip_vs_leave(struct ip_vs_service *sv
 		cp = ip_vs_conn_new(svc->af, iph.protocol,
 				    &iph.saddr, pptr[0],
 				    &iph.daddr, pptr[1],
-				    0, 0,
+				    &daddr, 0,
 				    IP_VS_CONN_F_BYPASS,
 				    NULL);
 		if (cp == NULL)
Signature · 3 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
author maintainer
#7 lore raw

PATCH 3/3 ipvs: add __aquire/__release annotations to ip_vs_info_seq_start/ip_vs_info_seq_stop

In reply to Simon Horman

This teaches sparse that the following are not problems:

make C=1
CHECK net/ipv4/ipvs/ip_vs_ctl.c
net/ipv4/ipvs/ip_vs_ctl.c:1793:14: warning: context imbalance in 'ip_vs_info_seq_start' - wrong count at exit net/ipv4/ipvs/ip_vs_ctl.c:1842:13: warning: context imbalance in 'ip_vs_info_seq_stop' - unexpected unlock

net/ipv4/ipvs/ip_vs_ctl.c +2 -0
Index: lvs-2.6/net/ipv4/ipvs/ip_vs_ctl.c
===================================================================
@@ -1787,6 +1787,7 @@ static struct ip_vs_service *ip_vs_info_
 }
 
 static void *ip_vs_info_seq_start(struct seq_file *seq, loff_t *pos)
+__acquires(__ip_vs_svc_lock)
 {
 
 	read_lock_bh(&__ip_vs_svc_lock);
@@ -1840,6 +1841,7 @@ static void *ip_vs_info_seq_next(struct 
 }
 
 static void ip_vs_info_seq_stop(struct seq_file *seq, void *v)
+__releases(__ip_vs_svc_lock)
 {
 	read_unlock_bh(&__ip_vs_svc_lock);
 }
Signature · 4 lines
-- 
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
#9 lore raw
Quoted 5 lines · Sven Wegener
Quoted 1 line · Simon Horman

Some fixes and annotations for sparse warnings.

All look good to me.

To me too. Sorry for the v6-related screwups and thanks for fixing!

Julius

Signature · 3 lines
Julius Volz - Corporate Operations - SysOps

Google Switzerland GmbH - Identification No.: CH-020.4.028.116-1
author maintainer
#10 lore raw
Quoted 8 lines · Julius Volz
Quoted 5 lines · Sven Wegener
Quoted 1 line · Simon Horman

Some fixes and annotations for sparse warnings.

All look good to me.

To me too. Sorry for the v6-related screwups and thanks for fixing!

Not at all. Thanks for all your help :-)

Signature · 3 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en