Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Jun 2008 18:42:29 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 143208 for review
Message-ID:  <200806091842.m59IgTm4005744@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=143208

Change 143208 by zec@zec_tpx32 on 2008/06/09 18:41:43

	Attempt to fix rpc.lockd triggered panics.  The problem
	was (and still most probably is) caused by network stack
	functions being called without curvnet context being set
	first.
	
	The canonical remedy is insertioin of CURVNET_SET() /
	CURVNET_RESTORE() macro pairs at proper places in the
	offending callers.  Obviously to insert such macros at
	_proper_ places one should have a clear understanding
	on how the calling code works, and I have absolutely no
	clue on what and how the kernel-level RPC stuff is
	supposed to do...
	
	Reported by: kris@

Affected files ...

.. //depot/projects/vimage/src/sys/rpc/clnt_dg.c#2 edit
.. //depot/projects/vimage/src/sys/rpc/rpc_generic.c#2 edit
.. //depot/projects/vimage/src/sys/rpc/svc_dg.c#2 edit
.. //depot/projects/vimage/src/sys/rpc/svc_generic.c#2 edit

Differences ...

==== //depot/projects/vimage/src/sys/rpc/clnt_dg.c#2 (text+ko) ====


==== //depot/projects/vimage/src/sys/rpc/rpc_generic.c#2 (text+ko) ====

@@ -42,6 +42,7 @@
  */
 
 #include "opt_inet6.h"
+#include "opt_vimage.h"
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -54,6 +55,7 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/syslog.h>
+#include <sys/vimage.h>
 
 #include <rpc/rpc.h>
 #include <rpc/nettype.h>
@@ -183,9 +185,12 @@
 	struct sockopt opt;
 	int error;
 
+	CURVNET_SET(so->so_vnet);
 	error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
-	if (error)
+	if (error) {
+		CURVNET_RESTORE();
 		return 0;
+	}
 
 	sip->si_alen = sa->sa_len;
 	family = sa->sa_family;
@@ -198,6 +203,7 @@
 	opt.sopt_valsize = sizeof type;
 	opt.sopt_td = NULL;
 	error = sogetopt(so, &opt);
+	CURVNET_RESTORE();
 	if (error)
 		return 0;
 
@@ -694,7 +700,9 @@
 	struct sockaddr *sa;
 	int error, bound;
 
+	CURVNET_SET(so->so_vnet);
 	error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
+	CURVNET_RESTORE();
 	if (error)
 		return (0);
 

==== //depot/projects/vimage/src/sys/rpc/svc_dg.c#2 (text+ko) ====

@@ -43,6 +43,8 @@
  * svc_dg.c, Server side for connectionless RPC.
  */
 
+#include "opt_vimage.h"
+
 #include <sys/param.h>
 #include <sys/lock.h>
 #include <sys/kernel.h>
@@ -55,6 +57,7 @@
 #include <sys/socketvar.h>
 #include <sys/systm.h>
 #include <sys/uio.h>
+#include <sys/vimage.h>
 
 #include <rpc/rpc.h>
 
@@ -125,7 +128,9 @@
 	xprt->xp_p2 = NULL;
 	xprt->xp_ops = &svc_dg_ops;
 
+	CURVNET_SET(so->so_vnet);
 	error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
+	CURVNET_RESTORE();
 	if (error)
 		goto freedata;
 

==== //depot/projects/vimage/src/sys/rpc/svc_generic.c#2 (text+ko) ====

@@ -46,6 +46,7 @@
  */
 
 #include "opt_inet6.h"
+#include "opt_vimage.h"
 
 #include <sys/param.h>
 #include <sys/lock.h>
@@ -59,6 +60,7 @@
 #include <sys/systm.h>
 #include <sys/sx.h>
 #include <sys/ucred.h>
+#include <sys/vimage.h>
 
 #include <rpc/rpc.h>
 #include <rpc/rpcb_clnt.h>
@@ -203,7 +205,9 @@
 	socklen_t salen;
 
 	if (sa == NULL) {
+		CURVNET_SET(so->so_vnet);
 		error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
+		CURVNET_RESTORE();
 		if (error)
 			return (error);
 		freesa = TRUE;
@@ -324,6 +328,7 @@
 	/*
 	 * If the socket is unbound, try to bind it.
 	 */
+	CURVNET_SET(so->so_vnet);
 	if (madeso || !__rpc_sockisbound(so)) {
 		if (bindaddr == NULL) {
 			if (bindresvport(so, NULL)) {
@@ -393,9 +398,11 @@
 	if (nconf) {
 		xprt->xp_netid = strdup(nconf->nc_netid, M_RPC);
 	}
+	CURVNET_RESTORE();
 	return (xprt);
 
 freedata:
+	CURVNET_RESTORE();
 	if (madeso)
 		(void)soclose(so);
 	if (xprt) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806091842.m59IgTm4005744>