[Midnightbsd-cvs] src [9915] trunk/sys/rpc: sync with freebsd 10
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri May 25 08:45:40 EDT 2018
Revision: 9915
http://svnweb.midnightbsd.org/src/?rev=9915
Author: laffer1
Date: 2018-05-25 08:45:40 -0400 (Fri, 25 May 2018)
Log Message:
-----------
sync with freebsd 10
Modified Paths:
--------------
trunk/sys/rpc/auth.h
trunk/sys/rpc/auth_none.c
trunk/sys/rpc/auth_unix.c
trunk/sys/rpc/authunix_prot.c
trunk/sys/rpc/clnt.h
trunk/sys/rpc/clnt_dg.c
trunk/sys/rpc/clnt_rc.c
trunk/sys/rpc/clnt_stat.h
trunk/sys/rpc/clnt_vc.c
trunk/sys/rpc/getnetconfig.c
trunk/sys/rpc/netconfig.h
trunk/sys/rpc/nettype.h
trunk/sys/rpc/pmap_prot.h
trunk/sys/rpc/replay.c
trunk/sys/rpc/replay.h
trunk/sys/rpc/rpc.h
trunk/sys/rpc/rpc_callmsg.c
trunk/sys/rpc/rpc_com.h
trunk/sys/rpc/rpc_generic.c
trunk/sys/rpc/rpc_msg.h
trunk/sys/rpc/rpc_prot.c
trunk/sys/rpc/rpcb_clnt.c
trunk/sys/rpc/rpcb_clnt.h
trunk/sys/rpc/rpcb_prot.c
trunk/sys/rpc/rpcb_prot.h
trunk/sys/rpc/rpcm_subs.h
trunk/sys/rpc/rpcsec_gss/rpcsec_gss.c
trunk/sys/rpc/rpcsec_gss/rpcsec_gss_conf.c
trunk/sys/rpc/rpcsec_gss/rpcsec_gss_int.h
trunk/sys/rpc/rpcsec_gss/rpcsec_gss_misc.c
trunk/sys/rpc/rpcsec_gss/rpcsec_gss_prot.c
trunk/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
trunk/sys/rpc/rpcsec_gss.h
trunk/sys/rpc/svc.c
trunk/sys/rpc/svc.h
trunk/sys/rpc/svc_auth.c
trunk/sys/rpc/svc_auth.h
trunk/sys/rpc/svc_auth_unix.c
trunk/sys/rpc/svc_dg.c
trunk/sys/rpc/svc_generic.c
trunk/sys/rpc/svc_vc.c
trunk/sys/rpc/types.h
trunk/sys/rpc/xdr.h
Added Paths:
-----------
trunk/sys/rpc/clnt_bck.c
trunk/sys/rpc/krpc.h
Modified: trunk/sys/rpc/auth.h
===================================================================
--- trunk/sys/rpc/auth.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/auth.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,37 +1,37 @@
+/* $MidnightBSD$ */
/* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)auth.h 1.17 88/02/08 SMI
* from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
* from: @(#)auth.h 1.43 98/02/02 SMI
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/auth.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
Modified: trunk/sys/rpc/auth_none.c
===================================================================
--- trunk/sys/rpc/auth_none.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/auth_none.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: auth_none.c,v 1.13 2000/01/22 22:19:17 mycroft Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -34,7 +34,7 @@
static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/auth_none.c 261046 2014-01-22 23:45:27Z mav $");
/*
* auth_none.c
Modified: trunk/sys/rpc/auth_unix.c
===================================================================
--- trunk/sys/rpc/auth_unix.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/auth_unix.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: auth_unix.c,v 1.18 2000/07/06 03:03:30 christos Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -34,7 +34,7 @@
static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/auth_unix.c 261046 2014-01-22 23:45:27Z mav $");
/*
* auth_unix.c, Implements UNIX style authentication parameters.
Modified: trunk/sys/rpc/authunix_prot.c
===================================================================
--- trunk/sys/rpc/authunix_prot.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/authunix_prot.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: authunix_prot.c,v 1.12 2000/01/22 22:19:17 mycroft Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -34,7 +34,7 @@
static char *sccsid = "@(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/authunix_prot.c 261046 2014-01-22 23:45:27Z mav $");
/*
* authunix_prot.c
Modified: trunk/sys/rpc/clnt.h
===================================================================
--- trunk/sys/rpc/clnt.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/clnt.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,53 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */
-/*
- * The contents of this file are subject to the Sun Standards
- * License Version 1.0 the (the "License";) You may not use
- * this file except in compliance with the License. You may
- * obtain a copy of the License at lib/libc/rpc/LICENSE
+/*-
+ * Copyright (c) 2010, Oracle America, Inc.
+ * All rights reserved.
*
- * Software distributed under the License is distributed on
- * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
- * express or implied. See the License for the specific
- * language governing rights and limitations under the License.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * The Original Code is Copyright 1998 by Sun Microsystems, Inc
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * The Initial Developer of the Original Code is: Sun
- * Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)clnt.h 1.31 94/04/29 SMI
* from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/clnt.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
@@ -372,6 +355,7 @@
#define CLGET_RETRIES 26 /* get retry count for reconnect */
#define CLSET_PRIVPORT 27 /* set privileged source port flag */
#define CLGET_PRIVPORT 28 /* get privileged source port flag */
+#define CLSET_BACKCHANNEL 29 /* set backchannel for socket */
#endif
Added: trunk/sys/rpc/clnt_bck.c
===================================================================
--- trunk/sys/rpc/clnt_bck.c (rev 0)
+++ trunk/sys/rpc/clnt_bck.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -0,0 +1,589 @@
+/* $MidnightBSD$ */
+/* $NetBSD: clnt_vc.c,v 1.4 2000/07/14 08:40:42 fvdl Exp $ */
+
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *sccsid2 = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
+static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
+static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
+#endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/rpc/clnt_bck.c 302451 2016-07-08 20:30:20Z ngie $");
+
+/*
+ * clnt_tcp.c, Implements a TCP/IP based, client side RPC.
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ *
+ * TCP based RPC supports 'batched calls'.
+ * A sequence of calls may be batched-up in a send buffer. The rpc call
+ * return immediately to the client even though the call was not necessarily
+ * sent. The batching occurs if the results' xdr routine is NULL (0) AND
+ * the rpc timeout value is zero (see clnt.h, rpc).
+ *
+ * Clients should NOT casually batch calls that in fact return results; that is,
+ * the server side should be aware that a call is batched and not produce any
+ * return message. Batched calls that produce many result messages can
+ * deadlock (netlock) the client and the server....
+ *
+ * Now go hang yourself.
+ */
+
+/*
+ * This code handles the special case of a NFSv4.n backchannel for
+ * callback RPCs. It is similar to clnt_vc.c, but uses the TCP
+ * connection provided by the client to the server.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mutex.h>
+#include <sys/pcpu.h>
+#include <sys/proc.h>
+#include <sys/protosw.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/sx.h>
+#include <sys/syslog.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+
+#include <net/vnet.h>
+
+#include <netinet/tcp.h>
+
+#include <rpc/rpc.h>
+#include <rpc/rpc_com.h>
+#include <rpc/krpc.h>
+
+struct cmessage {
+ struct cmsghdr cmsg;
+ struct cmsgcred cmcred;
+};
+
+static void clnt_bck_geterr(CLIENT *, struct rpc_err *);
+static bool_t clnt_bck_freeres(CLIENT *, xdrproc_t, void *);
+static void clnt_bck_abort(CLIENT *);
+static bool_t clnt_bck_control(CLIENT *, u_int, void *);
+static void clnt_bck_close(CLIENT *);
+static void clnt_bck_destroy(CLIENT *);
+
+static struct clnt_ops clnt_bck_ops = {
+ .cl_abort = clnt_bck_abort,
+ .cl_geterr = clnt_bck_geterr,
+ .cl_freeres = clnt_bck_freeres,
+ .cl_close = clnt_bck_close,
+ .cl_destroy = clnt_bck_destroy,
+ .cl_control = clnt_bck_control
+};
+
+/*
+ * Create a client handle for a connection.
+ * Default options are set, which the user can change using clnt_control()'s.
+ * This code handles the special case of an NFSv4.1 session backchannel
+ * call, which is sent on a TCP connection created against the server
+ * by a client.
+ */
+void *
+clnt_bck_create(
+ struct socket *so, /* Server transport socket. */
+ const rpcprog_t prog, /* program number */
+ const rpcvers_t vers) /* version number */
+{
+ CLIENT *cl; /* client handle */
+ struct ct_data *ct = NULL; /* client handle */
+ struct timeval now;
+ struct rpc_msg call_msg;
+ static uint32_t disrupt;
+ XDR xdrs;
+
+ if (disrupt == 0)
+ disrupt = (uint32_t)(long)so;
+
+ cl = (CLIENT *)mem_alloc(sizeof (*cl));
+ ct = (struct ct_data *)mem_alloc(sizeof (*ct));
+
+ mtx_init(&ct->ct_lock, "ct->ct_lock", NULL, MTX_DEF);
+ ct->ct_threads = 0;
+ ct->ct_closing = FALSE;
+ ct->ct_closed = FALSE;
+ ct->ct_upcallrefs = 0;
+ ct->ct_closeit = FALSE;
+
+ /*
+ * Set up private data struct
+ */
+ ct->ct_wait.tv_sec = -1;
+ ct->ct_wait.tv_usec = -1;
+
+ /*
+ * Initialize call message
+ */
+ getmicrotime(&now);
+ ct->ct_xid = ((uint32_t)++disrupt) ^ __RPC_GETXID(&now);
+ call_msg.rm_xid = ct->ct_xid;
+ call_msg.rm_direction = CALL;
+ call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
+ call_msg.rm_call.cb_prog = (uint32_t)prog;
+ call_msg.rm_call.cb_vers = (uint32_t)vers;
+
+ /*
+ * pre-serialize the static part of the call msg and stash it away
+ */
+ xdrmem_create(&xdrs, ct->ct_mcallc, MCALL_MSG_SIZE,
+ XDR_ENCODE);
+ if (!xdr_callhdr(&xdrs, &call_msg))
+ goto err;
+ ct->ct_mpos = XDR_GETPOS(&xdrs);
+ XDR_DESTROY(&xdrs);
+ ct->ct_waitchan = "rpcbck";
+ ct->ct_waitflag = 0;
+ cl->cl_refs = 1;
+ cl->cl_ops = &clnt_bck_ops;
+ cl->cl_private = ct;
+ cl->cl_auth = authnone_create();
+ TAILQ_INIT(&ct->ct_pending);
+ return (cl);
+
+err:
+ mtx_destroy(&ct->ct_lock);
+ mem_free(ct, sizeof (struct ct_data));
+ mem_free(cl, sizeof (CLIENT));
+ return (NULL);
+}
+
+enum clnt_stat
+clnt_bck_call(
+ CLIENT *cl, /* client handle */
+ struct rpc_callextra *ext, /* call metadata */
+ rpcproc_t proc, /* procedure number */
+ struct mbuf *args, /* pointer to args */
+ struct mbuf **resultsp, /* pointer to results */
+ struct timeval utimeout,
+ SVCXPRT *xprt)
+{
+ struct ct_data *ct = (struct ct_data *) cl->cl_private;
+ AUTH *auth;
+ struct rpc_err *errp;
+ enum clnt_stat stat;
+ XDR xdrs;
+ struct rpc_msg reply_msg;
+ bool_t ok;
+ int nrefreshes = 2; /* number of times to refresh cred */
+ struct timeval timeout;
+ uint32_t xid;
+ struct mbuf *mreq = NULL, *results;
+ struct ct_request *cr;
+ int error;
+
+ cr = malloc(sizeof(struct ct_request), M_RPC, M_WAITOK);
+
+ mtx_lock(&ct->ct_lock);
+
+ if (ct->ct_closing || ct->ct_closed) {
+ mtx_unlock(&ct->ct_lock);
+ free(cr, M_RPC);
+ return (RPC_CANTSEND);
+ }
+ ct->ct_threads++;
+
+ if (ext) {
+ auth = ext->rc_auth;
+ errp = &ext->rc_err;
+ } else {
+ auth = cl->cl_auth;
+ errp = &ct->ct_error;
+ }
+
+ cr->cr_mrep = NULL;
+ cr->cr_error = 0;
+
+ if (ct->ct_wait.tv_usec == -1)
+ timeout = utimeout; /* use supplied timeout */
+ else
+ timeout = ct->ct_wait; /* use default timeout */
+
+call_again:
+ mtx_assert(&ct->ct_lock, MA_OWNED);
+
+ ct->ct_xid++;
+ xid = ct->ct_xid;
+
+ mtx_unlock(&ct->ct_lock);
+
+ /*
+ * Leave space to pre-pend the record mark.
+ */
+ mreq = m_gethdr(M_WAITOK, MT_DATA);
+ mreq->m_data += sizeof(uint32_t);
+ KASSERT(ct->ct_mpos + sizeof(uint32_t) <= MHLEN,
+ ("RPC header too big"));
+ bcopy(ct->ct_mcallc, mreq->m_data, ct->ct_mpos);
+ mreq->m_len = ct->ct_mpos;
+
+ /*
+ * The XID is the first thing in the request.
+ */
+ *mtod(mreq, uint32_t *) = htonl(xid);
+
+ xdrmbuf_create(&xdrs, mreq, XDR_ENCODE);
+
+ errp->re_status = stat = RPC_SUCCESS;
+
+ if ((!XDR_PUTINT32(&xdrs, &proc)) ||
+ (!AUTH_MARSHALL(auth, xid, &xdrs,
+ m_copym(args, 0, M_COPYALL, M_WAITOK)))) {
+ errp->re_status = stat = RPC_CANTENCODEARGS;
+ mtx_lock(&ct->ct_lock);
+ goto out;
+ }
+ mreq->m_pkthdr.len = m_length(mreq, NULL);
+
+ /*
+ * Prepend a record marker containing the packet length.
+ */
+ M_PREPEND(mreq, sizeof(uint32_t), M_WAITOK);
+ *mtod(mreq, uint32_t *) =
+ htonl(0x80000000 | (mreq->m_pkthdr.len - sizeof(uint32_t)));
+
+ cr->cr_xid = xid;
+ mtx_lock(&ct->ct_lock);
+ /*
+ * Check to see if the client end has already started to close down
+ * the connection. The svc code will have set ct_error.re_status
+ * to RPC_CANTRECV if this is the case.
+ * If the client starts to close down the connection after this
+ * point, it will be detected later when cr_error is checked,
+ * since the request is in the ct_pending queue.
+ */
+ if (ct->ct_error.re_status == RPC_CANTRECV) {
+ if (errp != &ct->ct_error) {
+ errp->re_errno = ct->ct_error.re_errno;
+ errp->re_status = RPC_CANTRECV;
+ }
+ stat = RPC_CANTRECV;
+ goto out;
+ }
+ TAILQ_INSERT_TAIL(&ct->ct_pending, cr, cr_link);
+ mtx_unlock(&ct->ct_lock);
+
+ /*
+ * sosend consumes mreq.
+ */
+ sx_xlock(&xprt->xp_lock);
+ error = sosend(xprt->xp_socket, NULL, NULL, mreq, NULL, 0, curthread);
+if (error != 0) printf("sosend=%d\n", error);
+ mreq = NULL;
+ if (error == EMSGSIZE) {
+printf("emsgsize\n");
+ SOCKBUF_LOCK(&xprt->xp_socket->so_snd);
+ sbwait(&xprt->xp_socket->so_snd);
+ SOCKBUF_UNLOCK(&xprt->xp_socket->so_snd);
+ sx_xunlock(&xprt->xp_lock);
+ AUTH_VALIDATE(auth, xid, NULL, NULL);
+ mtx_lock(&ct->ct_lock);
+ TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
+ goto call_again;
+ }
+ sx_xunlock(&xprt->xp_lock);
+
+ reply_msg.acpted_rply.ar_verf.oa_flavor = AUTH_NULL;
+ reply_msg.acpted_rply.ar_verf.oa_base = cr->cr_verf;
+ reply_msg.acpted_rply.ar_verf.oa_length = 0;
+ reply_msg.acpted_rply.ar_results.where = NULL;
+ reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
+
+ mtx_lock(&ct->ct_lock);
+ if (error) {
+ TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
+ errp->re_errno = error;
+ errp->re_status = stat = RPC_CANTSEND;
+ goto out;
+ }
+
+ /*
+ * Check to see if we got an upcall while waiting for the
+ * lock. In both these cases, the request has been removed
+ * from ct->ct_pending.
+ */
+ if (cr->cr_error) {
+ TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
+ errp->re_errno = cr->cr_error;
+ errp->re_status = stat = RPC_CANTRECV;
+ goto out;
+ }
+ if (cr->cr_mrep) {
+ TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
+ goto got_reply;
+ }
+
+ /*
+ * Hack to provide rpc-based message passing
+ */
+ if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
+ TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
+ errp->re_status = stat = RPC_TIMEDOUT;
+ goto out;
+ }
+
+ error = msleep(cr, &ct->ct_lock, ct->ct_waitflag, ct->ct_waitchan,
+ tvtohz(&timeout));
+
+ TAILQ_REMOVE(&ct->ct_pending, cr, cr_link);
+
+ if (error) {
+ /*
+ * The sleep returned an error so our request is still
+ * on the list. Turn the error code into an
+ * appropriate client status.
+ */
+ errp->re_errno = error;
+ switch (error) {
+ case EINTR:
+ stat = RPC_INTR;
+ break;
+ case EWOULDBLOCK:
+ stat = RPC_TIMEDOUT;
+ break;
+ default:
+ stat = RPC_CANTRECV;
+ };
+ errp->re_status = stat;
+ goto out;
+ } else {
+ /*
+ * We were woken up by the svc thread. If the
+ * upcall had a receive error, report that,
+ * otherwise we have a reply.
+ */
+ if (cr->cr_error) {
+ errp->re_errno = cr->cr_error;
+ errp->re_status = stat = RPC_CANTRECV;
+ goto out;
+ }
+ }
+
+got_reply:
+ /*
+ * Now decode and validate the response. We need to drop the
+ * lock since xdr_replymsg may end up sleeping in malloc.
+ */
+ mtx_unlock(&ct->ct_lock);
+
+ if (ext && ext->rc_feedback)
+ ext->rc_feedback(FEEDBACK_OK, proc, ext->rc_feedback_arg);
+
+ xdrmbuf_create(&xdrs, cr->cr_mrep, XDR_DECODE);
+ ok = xdr_replymsg(&xdrs, &reply_msg);
+ cr->cr_mrep = NULL;
+
+ if (ok) {
+ if ((reply_msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
+ (reply_msg.acpted_rply.ar_stat == SUCCESS))
+ errp->re_status = stat = RPC_SUCCESS;
+ else
+ stat = _seterr_reply(&reply_msg, errp);
+
+ if (stat == RPC_SUCCESS) {
+ results = xdrmbuf_getall(&xdrs);
+ if (!AUTH_VALIDATE(auth, xid,
+ &reply_msg.acpted_rply.ar_verf, &results)) {
+ errp->re_status = stat = RPC_AUTHERROR;
+ errp->re_why = AUTH_INVALIDRESP;
+ } else {
+ KASSERT(results,
+ ("auth validated but no result"));
+ *resultsp = results;
+ }
+ } /* end successful completion */
+ /*
+ * If unsuccesful AND error is an authentication error
+ * then refresh credentials and try again, else break
+ */
+ else if (stat == RPC_AUTHERROR)
+ /* maybe our credentials need to be refreshed ... */
+ if (nrefreshes > 0 && AUTH_REFRESH(auth, &reply_msg)) {
+ nrefreshes--;
+ XDR_DESTROY(&xdrs);
+ mtx_lock(&ct->ct_lock);
+ goto call_again;
+ }
+ /* end of unsuccessful completion */
+ /* end of valid reply message */
+ } else
+ errp->re_status = stat = RPC_CANTDECODERES;
+ XDR_DESTROY(&xdrs);
+ mtx_lock(&ct->ct_lock);
+out:
+ mtx_assert(&ct->ct_lock, MA_OWNED);
+
+ KASSERT(stat != RPC_SUCCESS || *resultsp,
+ ("RPC_SUCCESS without reply"));
+
+ if (mreq != NULL)
+ m_freem(mreq);
+ if (cr->cr_mrep != NULL)
+ m_freem(cr->cr_mrep);
+
+ ct->ct_threads--;
+ if (ct->ct_closing)
+ wakeup(ct);
+
+ mtx_unlock(&ct->ct_lock);
+
+ if (auth && stat != RPC_SUCCESS)
+ AUTH_VALIDATE(auth, xid, NULL, NULL);
+
+ free(cr, M_RPC);
+
+ return (stat);
+}
+
+static void
+clnt_bck_geterr(CLIENT *cl, struct rpc_err *errp)
+{
+ struct ct_data *ct = (struct ct_data *) cl->cl_private;
+
+ *errp = ct->ct_error;
+}
+
+static bool_t
+clnt_bck_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr)
+{
+ XDR xdrs;
+ bool_t dummy;
+
+ xdrs.x_op = XDR_FREE;
+ dummy = (*xdr_res)(&xdrs, res_ptr);
+
+ return (dummy);
+}
+
+/*ARGSUSED*/
+static void
+clnt_bck_abort(CLIENT *cl)
+{
+}
+
+static bool_t
+clnt_bck_control(CLIENT *cl, u_int request, void *info)
+{
+
+ return (TRUE);
+}
+
+static void
+clnt_bck_close(CLIENT *cl)
+{
+ struct ct_data *ct = (struct ct_data *) cl->cl_private;
+
+ mtx_lock(&ct->ct_lock);
+
+ if (ct->ct_closed) {
+ mtx_unlock(&ct->ct_lock);
+ return;
+ }
+
+ if (ct->ct_closing) {
+ while (ct->ct_closing)
+ msleep(ct, &ct->ct_lock, 0, "rpcclose", 0);
+ KASSERT(ct->ct_closed, ("client should be closed"));
+ mtx_unlock(&ct->ct_lock);
+ return;
+ }
+
+ ct->ct_closing = FALSE;
+ ct->ct_closed = TRUE;
+ mtx_unlock(&ct->ct_lock);
+ wakeup(ct);
+}
+
+static void
+clnt_bck_destroy(CLIENT *cl)
+{
+ struct ct_data *ct = (struct ct_data *) cl->cl_private;
+
+ clnt_bck_close(cl);
+
+ mtx_destroy(&ct->ct_lock);
+ mem_free(ct, sizeof(struct ct_data));
+ if (cl->cl_netid && cl->cl_netid[0])
+ mem_free(cl->cl_netid, strlen(cl->cl_netid) +1);
+ if (cl->cl_tp && cl->cl_tp[0])
+ mem_free(cl->cl_tp, strlen(cl->cl_tp) +1);
+ mem_free(cl, sizeof(CLIENT));
+}
+
+/*
+ * This call is done by the svc code when a backchannel RPC reply is
+ * received.
+ */
+void
+clnt_bck_svccall(void *arg, struct mbuf *mrep, uint32_t xid)
+{
+ struct ct_data *ct = (struct ct_data *)arg;
+ struct ct_request *cr;
+ int foundreq;
+
+ mtx_lock(&ct->ct_lock);
+ ct->ct_upcallrefs++;
+ /*
+ * See if we can match this reply to a request.
+ */
+ foundreq = 0;
+ TAILQ_FOREACH(cr, &ct->ct_pending, cr_link) {
+ if (cr->cr_xid == xid) {
+ /*
+ * This one matches. We leave the reply mbuf list in
+ * cr->cr_mrep. Set the XID to zero so that we will
+ * ignore any duplicated replies.
+ */
+ cr->cr_xid = 0;
+ cr->cr_mrep = mrep;
+ cr->cr_error = 0;
+ foundreq = 1;
+ wakeup(cr);
+ break;
+ }
+ }
+
+ ct->ct_upcallrefs--;
+ if (ct->ct_upcallrefs < 0)
+ panic("rpcvc svccall refcnt");
+ if (ct->ct_upcallrefs == 0)
+ wakeup(&ct->ct_upcallrefs);
+ mtx_unlock(&ct->ct_lock);
+ if (foundreq == 0)
+ m_freem(mrep);
+}
+
Property changes on: trunk/sys/rpc/clnt_bck.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/rpc/clnt_dg.c
===================================================================
--- trunk/sys/rpc/clnt_dg.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/clnt_dg.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: clnt_dg.c,v 1.4 2000/07/14 08:40:41 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
@@ -37,7 +37,7 @@
static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/clnt_dg.c 303692 2016-08-03 01:19:10Z ngie $");
/*
* Implements a connectionless client side RPC.
@@ -93,8 +93,6 @@
.cl_control = clnt_dg_control
};
-static const char mem_err_clnt_dg[] = "clnt_dg_create: out of memory";
-
/*
* A pending RPC request which awaits a reply. Requests which have
* received their reply will have cr_xid set to zero and cr_mrep to
@@ -316,11 +314,9 @@
cl->cl_netid = NULL;
return (cl);
err2:
- if (cl) {
- mem_free(cl, sizeof (CLIENT));
- if (cu)
- mem_free(cu, sizeof (*cu));
- }
+ mem_free(cl, sizeof (CLIENT));
+ mem_free(cu, sizeof (*cu));
+
return (NULL);
}
@@ -431,7 +427,7 @@
send_again:
mtx_unlock(&cs->cs_lock);
- MGETHDR(mreq, M_WAIT, MT_DATA);
+ mreq = m_gethdr(M_WAITOK, MT_DATA);
KASSERT(cu->cu_mcalllen <= MHLEN, ("RPC header too big"));
bcopy(cu->cu_mcallc, mreq->m_data, cu->cu_mcalllen);
mreq->m_len = cu->cu_mcalllen;
@@ -682,6 +678,7 @@
next_sendtime += retransmit_time;
goto send_again;
}
+ cu->cu_sent += CWNDSCALE;
TAILQ_INSERT_TAIL(&cs->cs_pending, cr, cr_link);
}
@@ -733,6 +730,7 @@
*/
XDR_DESTROY(&xdrs);
mtx_lock(&cs->cs_lock);
+ cu->cu_sent += CWNDSCALE;
TAILQ_INSERT_TAIL(&cs->cs_pending,
cr, cr_link);
cr->cr_mrep = NULL;
Modified: trunk/sys/rpc/clnt_rc.c
===================================================================
--- trunk/sys/rpc/clnt_rc.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/clnt_rc.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr at rabson.org>
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/clnt_rc.c 317473 2017-04-26 22:40:08Z rmacklem $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -45,6 +46,7 @@
#include <rpc/rpc.h>
#include <rpc/rpc_com.h>
+#include <rpc/krpc.h>
static enum clnt_stat clnt_reconnect_call(CLIENT *, struct rpc_callextra *,
rpcproc_t, struct mbuf *, struct mbuf **, struct timeval);
@@ -67,27 +69,6 @@
static int fake_wchan;
-struct rc_data {
- struct mtx rc_lock;
- struct sockaddr_storage rc_addr; /* server address */
- struct netconfig* rc_nconf; /* network type */
- rpcprog_t rc_prog; /* program number */
- rpcvers_t rc_vers; /* version number */
- size_t rc_sendsz;
- size_t rc_recvsz;
- struct timeval rc_timeout;
- struct timeval rc_retry;
- int rc_retries;
- int rc_privport;
- char *rc_waitchan;
- int rc_intr;
- int rc_connecting;
- int rc_closed;
- struct ucred *rc_ucred;
- CLIENT* rc_client; /* underlying RPC client */
- struct rpc_err rc_err;
-};
-
CLIENT *
clnt_reconnect_create(
struct netconfig *nconf, /* network type */
@@ -211,6 +192,8 @@
CLNT_CONTROL(newclient, CLSET_RETRY_TIMEOUT, &rc->rc_retry);
CLNT_CONTROL(newclient, CLSET_WAITCHAN, rc->rc_waitchan);
CLNT_CONTROL(newclient, CLSET_INTERRUPTIBLE, &rc->rc_intr);
+ if (rc->rc_backchannel != NULL)
+ CLNT_CONTROL(newclient, CLSET_BACKCHANNEL, rc->rc_backchannel);
stat = RPC_SUCCESS;
out:
@@ -265,8 +248,7 @@
stat = clnt_reconnect_connect(cl);
if (stat == RPC_SYSTEMERROR) {
error = tsleep(&fake_wchan,
- rc->rc_intr ? PCATCH | PBDRY : 0, "rpccon",
- hz);
+ rc->rc_intr ? PCATCH : 0, "rpccon", hz);
if (error == EINTR || error == ERESTART)
return (RPC_INTR);
tries++;
@@ -385,6 +367,7 @@
clnt_reconnect_control(CLIENT *cl, u_int request, void *info)
{
struct rc_data *rc = (struct rc_data *)cl->cl_private;
+ SVCXPRT *xprt;
if (info == NULL) {
return (FALSE);
@@ -466,6 +449,12 @@
*(int *) info = rc->rc_privport;
break;
+ case CLSET_BACKCHANNEL:
+ xprt = (SVCXPRT *)info;
+ xprt_register(xprt);
+ rc->rc_backchannel = info;
+ break;
+
default:
return (FALSE);
}
@@ -502,9 +491,15 @@
clnt_reconnect_destroy(CLIENT *cl)
{
struct rc_data *rc = (struct rc_data *)cl->cl_private;
+ SVCXPRT *xprt;
if (rc->rc_client)
CLNT_DESTROY(rc->rc_client);
+ if (rc->rc_backchannel) {
+ xprt = (SVCXPRT *)rc->rc_backchannel;
+ xprt_unregister(xprt);
+ SVC_RELEASE(xprt);
+ }
crfree(rc->rc_ucred);
mtx_destroy(&rc->rc_lock);
mem_free(rc, sizeof(*rc));
Modified: trunk/sys/rpc/clnt_stat.h
===================================================================
--- trunk/sys/rpc/clnt_stat.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/clnt_stat.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,4 +1,5 @@
-/* $MidnightBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/rpc/clnt_stat.h 177633 2008-03-26 15:23:12Z dfr $ */
/*
* Copyright (c) 1986 - 1991, 1994, 1996, 1997 by Sun Microsystems, Inc.
* All rights reserved.
Modified: trunk/sys/rpc/clnt_vc.c
===================================================================
--- trunk/sys/rpc/clnt_vc.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/clnt_vc.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: clnt_vc.c,v 1.4 2000/07/14 08:40:42 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -35,7 +35,7 @@
static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/clnt_vc.c 318675 2017-05-22 19:57:20Z rmacklem $");
/*
* clnt_tcp.c, Implements a TCP/IP based, client side RPC.
@@ -68,6 +68,7 @@
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/sx.h>
#include <sys/syslog.h>
#include <sys/time.h>
#include <sys/uio.h>
@@ -78,9 +79,8 @@
#include <rpc/rpc.h>
#include <rpc/rpc_com.h>
+#include <rpc/krpc.h>
-#define MCALL_MSG_SIZE 24
-
struct cmessage {
struct cmsghdr cmsg;
struct cmsgcred cmcred;
@@ -107,51 +107,9 @@
.cl_control = clnt_vc_control
};
-static int fake_wchan;
-
-/*
- * A pending RPC request which awaits a reply. Requests which have
- * received their reply will have cr_xid set to zero and cr_mrep to
- * the mbuf chain of the reply.
- */
-struct ct_request {
- TAILQ_ENTRY(ct_request) cr_link;
- uint32_t cr_xid; /* XID of request */
- struct mbuf *cr_mrep; /* reply received by upcall */
- int cr_error; /* any error from upcall */
- char cr_verf[MAX_AUTH_BYTES]; /* reply verf */
-};
-
-TAILQ_HEAD(ct_request_list, ct_request);
-
-struct ct_data {
- struct mtx ct_lock;
- int ct_threads; /* number of threads in clnt_vc_call */
- bool_t ct_closing; /* TRUE if we are closing */
- bool_t ct_closed; /* TRUE if we are closed */
- struct socket *ct_socket; /* connection socket */
- bool_t ct_closeit; /* close it on destroy */
- struct timeval ct_wait; /* wait interval in milliseconds */
- struct sockaddr_storage ct_addr; /* remote addr */
- struct rpc_err ct_error;
- uint32_t ct_xid;
- char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */
- size_t ct_mpos; /* pos after marshal */
- const char *ct_waitchan;
- int ct_waitflag;
- struct mbuf *ct_record; /* current reply record */
- size_t ct_record_resid; /* how much left of reply to read */
- bool_t ct_record_eor; /* true if reading last fragment */
- struct ct_request_list ct_pending;
- int ct_upcallrefs; /* Ref cnt of upcalls in prog. */
-};
-
static void clnt_vc_upcallsdone(struct ct_data *);
-static const char clnt_vc_errstr[] = "%s : %s";
-static const char clnt_vc_str[] = "clnt_vc_create";
-static const char clnt_read_vc_str[] = "read_vc";
-static const char __no_mem_str[] = "out of memory";
+static int fake_wchan;
/*
* Create a client handle for a connection.
@@ -202,7 +160,7 @@
interrupted = 0;
sleep_flag = PSOCK;
if (intrflag != 0)
- sleep_flag |= (PCATCH | PBDRY);
+ sleep_flag |= PCATCH;
while ((so->so_state & SS_ISCONNECTING)
&& so->so_error == 0) {
error = msleep(&so->so_timeo, SOCK_MTX(so),
@@ -316,14 +274,10 @@
return (cl);
err:
- if (cl) {
- if (ct) {
- mtx_destroy(&ct->ct_lock);
- mem_free(ct, sizeof (struct ct_data));
- }
- if (cl)
- mem_free(cl, sizeof (CLIENT));
- }
+ mtx_destroy(&ct->ct_lock);
+ mem_free(ct, sizeof (struct ct_data));
+ mem_free(cl, sizeof (CLIENT));
+
return ((CLIENT *)NULL);
}
@@ -401,7 +355,7 @@
/*
* Leave space to pre-pend the record mark.
*/
- MGETHDR(mreq, M_WAIT, MT_DATA);
+ mreq = m_gethdr(M_WAITOK, MT_DATA);
mreq->m_data += sizeof(uint32_t);
KASSERT(ct->ct_mpos + sizeof(uint32_t) <= MHLEN,
("RPC header too big"));
@@ -429,7 +383,7 @@
/*
* Prepend a record marker containing the packet length.
*/
- M_PREPEND(mreq, sizeof(uint32_t), M_WAIT);
+ M_PREPEND(mreq, sizeof(uint32_t), M_WAITOK);
*mtod(mreq, uint32_t *) =
htonl(0x80000000 | (mreq->m_pkthdr.len - sizeof(uint32_t)));
@@ -525,7 +479,6 @@
errp->re_errno = error;
switch (error) {
case EINTR:
- case ERESTART:
stat = RPC_INTR;
break;
case EWOULDBLOCK:
@@ -659,6 +612,7 @@
{
struct ct_data *ct = (struct ct_data *)cl->cl_private;
void *infop = info;
+ SVCXPRT *xprt;
mtx_lock(&ct->ct_lock);
@@ -758,7 +712,7 @@
case CLSET_INTERRUPTIBLE:
if (*(int *) info)
- ct->ct_waitflag = PCATCH | PBDRY;
+ ct->ct_waitflag = PCATCH;
else
ct->ct_waitflag = 0;
break;
@@ -770,6 +724,14 @@
*(int *) info = FALSE;
break;
+ case CLSET_BACKCHANNEL:
+ xprt = (SVCXPRT *)info;
+ if (ct->ct_backchannelxprt == NULL) {
+ xprt->xp_p2 = ct;
+ ct->ct_backchannelxprt = xprt;
+ }
+ break;
+
default:
mtx_unlock(&ct->ct_lock);
return (FALSE);
@@ -835,10 +797,20 @@
{
struct ct_data *ct = (struct ct_data *) cl->cl_private;
struct socket *so = NULL;
+ SVCXPRT *xprt;
clnt_vc_close(cl);
mtx_lock(&ct->ct_lock);
+ xprt = ct->ct_backchannelxprt;
+ ct->ct_backchannelxprt = NULL;
+ if (xprt != NULL) {
+ mtx_unlock(&ct->ct_lock); /* To avoid a LOR. */
+ sx_xlock(&xprt->xp_lock);
+ mtx_lock(&ct->ct_lock);
+ xprt->xp_p2 = NULL;
+ sx_xunlock(&xprt->xp_lock);
+ }
if (ct->ct_socket) {
if (ct->ct_closeit) {
@@ -877,12 +849,15 @@
{
struct ct_data *ct = (struct ct_data *) arg;
struct uio uio;
- struct mbuf *m;
+ struct mbuf *m, *m2;
struct ct_request *cr;
int error, rcvflag, foundreq;
- uint32_t xid, header;
+ uint32_t xid_plus_direction[2], header;
bool_t do_read;
+ SVCXPRT *xprt;
+ struct cf_conn *cd;
+ CTASSERT(sizeof(xid_plus_direction) == 2 * sizeof(uint32_t));
ct->ct_upcallrefs++;
uio.uio_td = curthread;
do {
@@ -996,45 +971,89 @@
&& ct->ct_record_eor) {
/*
* The XID is in the first uint32_t of
- * the reply.
+ * the reply and the message direction
+ * is the second one.
*/
- if (ct->ct_record->m_len < sizeof(xid) &&
+ if (ct->ct_record->m_len <
+ sizeof(xid_plus_direction) &&
m_length(ct->ct_record, NULL) <
- sizeof(xid)) {
+ sizeof(xid_plus_direction)) {
m_freem(ct->ct_record);
break;
}
- m_copydata(ct->ct_record, 0, sizeof(xid),
- (char *)&xid);
- xid = ntohl(xid);
-
- mtx_lock(&ct->ct_lock);
- foundreq = 0;
- TAILQ_FOREACH(cr, &ct->ct_pending, cr_link) {
- if (cr->cr_xid == xid) {
+ m_copydata(ct->ct_record, 0,
+ sizeof(xid_plus_direction),
+ (char *)xid_plus_direction);
+ xid_plus_direction[0] =
+ ntohl(xid_plus_direction[0]);
+ xid_plus_direction[1] =
+ ntohl(xid_plus_direction[1]);
+ /* Check message direction. */
+ if (xid_plus_direction[1] == CALL) {
+ /* This is a backchannel request. */
+ mtx_lock(&ct->ct_lock);
+ xprt = ct->ct_backchannelxprt;
+ if (xprt == NULL) {
+ mtx_unlock(&ct->ct_lock);
+ /* Just throw it away. */
+ m_freem(ct->ct_record);
+ ct->ct_record = NULL;
+ } else {
+ cd = (struct cf_conn *)
+ xprt->xp_p1;
+ m2 = cd->mreq;
/*
- * This one
- * matches. We leave
- * the reply mbuf in
- * cr->cr_mrep. Set
- * the XID to zero so
- * that we will ignore
- * any duplicaed
- * replies.
+ * The requests are chained
+ * in the m_nextpkt list.
*/
- cr->cr_xid = 0;
- cr->cr_mrep = ct->ct_record;
- cr->cr_error = 0;
- foundreq = 1;
- wakeup(cr);
- break;
+ while (m2 != NULL &&
+ m2->m_nextpkt != NULL)
+ /* Find end of list. */
+ m2 = m2->m_nextpkt;
+ if (m2 != NULL)
+ m2->m_nextpkt =
+ ct->ct_record;
+ else
+ cd->mreq =
+ ct->ct_record;
+ ct->ct_record->m_nextpkt =
+ NULL;
+ ct->ct_record = NULL;
+ xprt_active(xprt);
+ mtx_unlock(&ct->ct_lock);
}
+ } else {
+ mtx_lock(&ct->ct_lock);
+ foundreq = 0;
+ TAILQ_FOREACH(cr, &ct->ct_pending,
+ cr_link) {
+ if (cr->cr_xid ==
+ xid_plus_direction[0]) {
+ /*
+ * This one
+ * matches. We leave
+ * the reply mbuf in
+ * cr->cr_mrep. Set
+ * the XID to zero so
+ * that we will ignore
+ * any duplicated
+ * replies.
+ */
+ cr->cr_xid = 0;
+ cr->cr_mrep =
+ ct->ct_record;
+ cr->cr_error = 0;
+ foundreq = 1;
+ wakeup(cr);
+ break;
+ }
+ }
+ mtx_unlock(&ct->ct_lock);
+
+ if (!foundreq)
+ m_freem(ct->ct_record);
+ ct->ct_record = NULL;
}
- mtx_unlock(&ct->ct_lock);
-
- if (!foundreq)
- m_freem(ct->ct_record);
- ct->ct_record = NULL;
}
}
} while (m);
Modified: trunk/sys/rpc/getnetconfig.c
===================================================================
--- trunk/sys/rpc/getnetconfig.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/getnetconfig.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr at rabson.org>
@@ -28,7 +29,7 @@
#include "opt_inet6.h"
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/getnetconfig.c 177633 2008-03-26 15:23:12Z dfr $");
#include <sys/param.h>
#include <sys/malloc.h>
Added: trunk/sys/rpc/krpc.h
===================================================================
--- trunk/sys/rpc/krpc.h (rev 0)
+++ trunk/sys/rpc/krpc.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -0,0 +1,115 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/sys/rpc/krpc.h 269398 2014-08-01 21:10:41Z rmacklem $
+ */
+
+#ifndef _RPC_KRPC_H_
+#define _RPC_KRPC_H_
+
+#ifdef _KERNEL
+/*
+ * Definitions now shared between client and server RPC for backchannels.
+ */
+#define MCALL_MSG_SIZE 24
+
+void clnt_bck_svccall(void *, struct mbuf *, uint32_t);
+enum clnt_stat clnt_bck_call(CLIENT *, struct rpc_callextra *, rpcproc_t,
+ struct mbuf *, struct mbuf **, struct timeval, SVCXPRT *);
+
+/*
+ * A pending RPC request which awaits a reply. Requests which have
+ * received their reply will have cr_xid set to zero and cr_mrep to
+ * the mbuf chain of the reply.
+ */
+struct ct_request {
+ TAILQ_ENTRY(ct_request) cr_link;
+ uint32_t cr_xid; /* XID of request */
+ struct mbuf *cr_mrep; /* reply received by upcall */
+ int cr_error; /* any error from upcall */
+ char cr_verf[MAX_AUTH_BYTES]; /* reply verf */
+};
+
+TAILQ_HEAD(ct_request_list, ct_request);
+
+struct rc_data {
+ struct mtx rc_lock;
+ struct sockaddr_storage rc_addr; /* server address */
+ struct netconfig* rc_nconf; /* network type */
+ rpcprog_t rc_prog; /* program number */
+ rpcvers_t rc_vers; /* version number */
+ size_t rc_sendsz;
+ size_t rc_recvsz;
+ struct timeval rc_timeout;
+ struct timeval rc_retry;
+ int rc_retries;
+ int rc_privport;
+ char *rc_waitchan;
+ int rc_intr;
+ int rc_connecting;
+ int rc_closed;
+ struct ucred *rc_ucred;
+ CLIENT* rc_client; /* underlying RPC client */
+ struct rpc_err rc_err;
+ void *rc_backchannel;
+};
+
+struct ct_data {
+ struct mtx ct_lock;
+ int ct_threads; /* number of threads in clnt_vc_call */
+ bool_t ct_closing; /* TRUE if we are closing */
+ bool_t ct_closed; /* TRUE if we are closed */
+ struct socket *ct_socket; /* connection socket */
+ bool_t ct_closeit; /* close it on destroy */
+ struct timeval ct_wait; /* wait interval in milliseconds */
+ struct sockaddr_storage ct_addr; /* remote addr */
+ struct rpc_err ct_error;
+ uint32_t ct_xid;
+ char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */
+ size_t ct_mpos; /* pos after marshal */
+ const char *ct_waitchan;
+ int ct_waitflag;
+ struct mbuf *ct_record; /* current reply record */
+ size_t ct_record_resid; /* how much left of reply to read */
+ bool_t ct_record_eor; /* true if reading last fragment */
+ struct ct_request_list ct_pending;
+ int ct_upcallrefs; /* Ref cnt of upcalls in prog. */
+ SVCXPRT *ct_backchannelxprt; /* xprt for backchannel */
+};
+
+struct cf_conn { /* kept in xprt->xp_p1 for actual connection */
+ enum xprt_stat strm_stat;
+ struct mbuf *mpending; /* unparsed data read from the socket */
+ struct mbuf *mreq; /* current record being built from mpending */
+ uint32_t resid; /* number of bytes needed for fragment */
+ bool_t eor; /* reading last fragment of current record */
+};
+
+#endif /* _KERNEL */
+
+#endif /* _RPC_KRPC_H_ */
Property changes on: trunk/sys/rpc/krpc.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/rpc/netconfig.h
===================================================================
--- trunk/sys/rpc/netconfig.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/netconfig.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
/* $NetBSD: netconfig.h,v 1.1 2000/06/02 22:57:54 fvdl Exp $ */
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/rpc/netconfig.h 177633 2008-03-26 15:23:12Z dfr $ */
#ifndef _NETCONFIG_H_
Modified: trunk/sys/rpc/nettype.h
===================================================================
--- trunk/sys/rpc/nettype.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/nettype.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,33 +1,33 @@
+/* $MidnightBSD$ */
/* $NetBSD: nettype.h,v 1.2 2000/07/06 03:17:19 christos Exp $ */
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/rpc/nettype.h 261046 2014-01-22 23:45:27Z mav $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
Modified: trunk/sys/rpc/pmap_prot.h
===================================================================
--- trunk/sys/rpc/pmap_prot.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/pmap_prot.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,36 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: pmap_prot.h,v 1.8 2000/06/02 22:57:55 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)pmap_prot.h 1.14 88/02/08 SMI
* from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/pmap_prot.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
Modified: trunk/sys/rpc/replay.c
===================================================================
--- trunk/sys/rpc/replay.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/replay.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr at rabson.org>
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/replay.c 211853 2010-08-26 23:33:04Z pjd $");
#include <sys/param.h>
#include <sys/hash.h>
Modified: trunk/sys/rpc/replay.h
===================================================================
--- trunk/sys/rpc/replay.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/replay.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr at rabson.org>
@@ -24,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/replay.h 184588 2008-11-03 10:38:00Z dfr $
*/
#ifndef _RPC_REPLAY_H
Modified: trunk/sys/rpc/rpc.h
===================================================================
--- trunk/sys/rpc/rpc.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpc.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,36 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpc.h,v 1.13 2000/06/02 22:57:56 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)rpc.h 1.9 88/02/08 SMI
* from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/rpc.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
Modified: trunk/sys/rpc/rpc_callmsg.c
===================================================================
--- trunk/sys/rpc/rpc_callmsg.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpc_callmsg.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpc_callmsg.c,v 1.16 2000/07/14 08:40:42 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -34,7 +34,7 @@
static char *sccsid = "@(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpc_callmsg.c 261046 2014-01-22 23:45:27Z mav $");
/*
* rpc_callmsg.c
Modified: trunk/sys/rpc/rpc_com.h
===================================================================
--- trunk/sys/rpc/rpc_com.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpc_com.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,34 +1,34 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/rpc_com.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
Modified: trunk/sys/rpc/rpc_generic.c
===================================================================
--- trunk/sys/rpc/rpc_generic.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpc_generic.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpc_generic.c,v 1.4 2000/09/28 09:07:04 kleink Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
@@ -34,7 +34,7 @@
/* #pragma ident "@(#)rpc_generic.c 1.17 94/04/24 SMI" */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpc_generic.c 319615 2017-06-06 07:22:26Z delphij $");
/*
* rpc_generic.c, Miscl routines for RPC.
@@ -312,6 +312,8 @@
switch (af) {
case AF_INET:
+ if (nbuf->len < sizeof(*sin))
+ return NULL;
sin = nbuf->buf;
if (inet_ntop(af, &sin->sin_addr, namebuf, sizeof namebuf)
== NULL)
@@ -324,6 +326,8 @@
break;
#ifdef INET6
case AF_INET6:
+ if (nbuf->len < sizeof(*sin6))
+ return NULL;
sin6 = nbuf->buf;
if (inet_ntop(af, &sin6->sin6_addr, namebuf6, sizeof namebuf6)
== NULL)
@@ -367,6 +371,10 @@
port = 0;
sin = NULL;
+
+ if (uaddr == NULL)
+ return NULL;
+
addrstr = strdup(uaddr, M_RPC);
if (addrstr == NULL)
return NULL;
@@ -391,15 +399,11 @@
}
ret = (struct netbuf *)malloc(sizeof *ret, M_RPC, M_WAITOK);
- if (ret == NULL)
- goto out;
switch (af) {
case AF_INET:
sin = (struct sockaddr_in *)malloc(sizeof *sin, M_RPC,
M_WAITOK);
- if (sin == NULL)
- goto out;
memset(sin, 0, sizeof *sin);
sin->sin_family = AF_INET;
sin->sin_port = htons(port);
@@ -416,8 +420,6 @@
case AF_INET6:
sin6 = (struct sockaddr_in6 *)malloc(sizeof *sin6, M_RPC,
M_WAITOK);
- if (sin6 == NULL)
- goto out;
memset(sin6, 0, sizeof *sin6);
sin6->sin6_family = AF_INET6;
sin6->sin6_port = htons(port);
@@ -434,8 +436,6 @@
case AF_LOCAL:
sun = (struct sockaddr_un *)malloc(sizeof *sun, M_RPC,
M_WAITOK);
- if (sun == NULL)
- goto out;
memset(sun, 0, sizeof *sun);
sun->sun_family = AF_LOCAL;
strncpy(sun->sun_path, addrstr, sizeof(sun->sun_path) - 1);
@@ -704,7 +704,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);
@@ -750,9 +752,7 @@
struct mbuf *mrep;
enum clnt_stat stat;
- MGET(mreq, M_WAIT, MT_DATA);
- MCLGET(mreq, M_WAIT);
- mreq->m_len = 0;
+ mreq = m_getcl(M_WAITOK, MT_DATA, 0);
xdrmbuf_create(&xdrs, mreq, XDR_ENCODE);
if (!xargs(&xdrs, argsp)) {
@@ -794,7 +794,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;
Modified: trunk/sys/rpc/rpc_msg.h
===================================================================
--- trunk/sys/rpc/rpc_msg.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpc_msg.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,36 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)rpc_msg.h 1.7 86/07/16 SMI
* from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/rpc_msg.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
Modified: trunk/sys/rpc/rpc_prot.c
===================================================================
--- trunk/sys/rpc/rpc_prot.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpc_prot.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpc_prot.c,v 1.16 2000/06/02 23:11:13 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -34,7 +34,7 @@
static char *sccsid = "@(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpc_prot.c 261046 2014-01-22 23:45:27Z mav $");
/*
* rpc_prot.c
Modified: trunk/sys/rpc/rpcb_clnt.c
===================================================================
--- trunk/sys/rpc/rpcb_clnt.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcb_clnt.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,49 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpcb_clnt.c,v 1.6 2000/07/16 06:41:43 itojun Exp $ */
-/*
- * The contents of this file are subject to the Sun Standards
- * License Version 1.0 the (the "License";) You may not use
- * this file except in compliance with the License. You may
- * obtain a copy of the License at lib/libc/rpc/LICENSE
+/*-
+ * Copyright (c) 2010, Oracle America, Inc.
+ * All rights reserved.
*
- * Software distributed under the License is distributed on
- * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
- * express or implied. See the License for the specific
- * language governing rights and limitations under the License.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * The Original Code is Copyright 1998 by Sun Microsystems, Inc
- *
- * The Initial Developer of the Original Code is: Sun
- * Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
@@ -56,7 +39,7 @@
static char sccsid[] = "@(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpcb_clnt.c 319615 2017-06-06 07:22:26Z delphij $");
/*
* rpcb_clnt.c
@@ -82,7 +65,6 @@
#include <rpc/rpc_com.h>
static struct timeval tottimeout = { 60, 0 };
-static const struct timeval rmttimeout = { 3, 0 };
static const char nullstring[] = "\000";
static CLIENT *local_rpcb(void);
@@ -89,6 +71,7 @@
#if 0
+static const struct timeval rmttimeout = { 3, 0 };
static struct timeval rpcbrmttime = { 15, 0 };
#define CACHESIZE 6
@@ -1069,7 +1052,7 @@
*
* Assuming that the address is all properly allocated
*/
-int
+bool_t
rpcb_getaddr(program, version, nconf, address, host)
rpcprog_t program;
rpcvers_t version;
@@ -1305,6 +1288,11 @@
return (FALSE);
}
pp = &objp->buf;
+
+ if (objp->maxlen > RPC_MAXDATASIZE) {
+ return (FALSE);
+ }
+
dummy = xdr_bytes(xdrs, (char **) pp,
(u_int *)&(objp->len), objp->maxlen);
return (dummy);
Modified: trunk/sys/rpc/rpcb_clnt.h
===================================================================
--- trunk/sys/rpc/rpcb_clnt.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcb_clnt.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,33 +1,33 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpcb_clnt.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/rpc/rpcb_clnt.h 261046 2014-01-22 23:45:27Z mav $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
Modified: trunk/sys/rpc/rpcb_prot.c
===================================================================
--- trunk/sys/rpc/rpcb_prot.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcb_prot.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: rpcb_prot.c,v 1.3 2000/07/14 08:40:42 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
@@ -38,7 +38,7 @@
static char sccsid[] = "@(#)rpcb_prot.c 1.9 89/04/21 Copyr 1984 Sun Micro";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpcb_prot.c 319615 2017-06-06 07:22:26Z delphij $");
/*
* rpcb_prot.c
@@ -53,6 +53,7 @@
#include <sys/malloc.h>
#include <rpc/rpc.h>
+#include <rpc/rpc_com.h>
#include <rpc/rpcb_prot.h>
bool_t
@@ -75,13 +76,13 @@
if (!xdr_uint32_t(xdrs, &objp->r_vers)) {
return (FALSE);
}
- if (!xdr_string(xdrs, &objp->r_netid, (u_int)~0)) {
+ if (!xdr_string(xdrs, &objp->r_netid, RPC_MAXDATASIZE)) {
return (FALSE);
}
- if (!xdr_string(xdrs, &objp->r_addr, (u_int)~0)) {
+ if (!xdr_string(xdrs, &objp->r_addr, RPC_MAXDATASIZE)) {
return (FALSE);
}
- if (!xdr_string(xdrs, &objp->r_owner, (u_int)~0)) {
+ if (!xdr_string(xdrs, &objp->r_owner, RPC_MAXDATASIZE)) {
return (FALSE);
}
return (TRUE);
@@ -176,19 +177,19 @@
bool_t
xdr_rpcb_entry(XDR *xdrs, rpcb_entry *objp)
{
- if (!xdr_string(xdrs, &objp->r_maddr, (u_int)~0)) {
+ if (!xdr_string(xdrs, &objp->r_maddr, RPC_MAXDATASIZE)) {
return (FALSE);
}
- if (!xdr_string(xdrs, &objp->r_nc_netid, (u_int)~0)) {
+ if (!xdr_string(xdrs, &objp->r_nc_netid, RPC_MAXDATASIZE)) {
return (FALSE);
}
if (!xdr_uint32_t(xdrs, &objp->r_nc_semantics)) {
return (FALSE);
}
- if (!xdr_string(xdrs, &objp->r_nc_protofmly, (u_int)~0)) {
+ if (!xdr_string(xdrs, &objp->r_nc_protofmly, RPC_MAXDATASIZE)) {
return (FALSE);
}
- if (!xdr_string(xdrs, &objp->r_nc_proto, (u_int)~0)) {
+ if (!xdr_string(xdrs, &objp->r_nc_proto, RPC_MAXDATASIZE)) {
return (FALSE);
}
return (TRUE);
Modified: trunk/sys/rpc/rpcb_prot.h
===================================================================
--- trunk/sys/rpc/rpcb_prot.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcb_prot.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Please do not edit this file.
* It was generated using rpcgen.
@@ -12,35 +13,34 @@
extern "C" {
#endif
-/*
- * $MidnightBSD$
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * $FreeBSD: stable/10/sys/rpc/rpcb_prot.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
* Copyright (c) 1988 by Sun Microsystems, Inc.
Modified: trunk/sys/rpc/rpcm_subs.h
===================================================================
--- trunk/sys/rpc/rpcm_subs.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcm_subs.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,4 +1,5 @@
/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/rpc/rpcm_subs.h 248195 2013-03-12 12:17:19Z glebius $ */
/* $OpenBSD: nfsm_subs.h,v 1.11 2000/01/05 20:50:52 millert Exp $ */
/* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */
@@ -80,7 +81,7 @@
#define rpcm_build(a,c,s) \
{ if ((s) > M_TRAILINGSPACE(mb)) { \
- MGET(mb2, M_WAIT, MT_DATA); \
+ mb2 = m_get(M_WAITOK, MT_DATA); \
if ((s) > MLEN) \
panic("build > MLEN"); \
mb->m_next = mb2; \
Modified: trunk/sys/rpc/rpcsec_gss/rpcsec_gss.c
===================================================================
--- trunk/sys/rpc/rpcsec_gss/rpcsec_gss.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcsec_gss/rpcsec_gss.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Doug Rabson
* All rights reserved.
@@ -59,11 +60,11 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- $Id: rpcsec_gss.c,v 1.2 2013-01-05 20:24:00 laffer1 Exp $
+ $Id: auth_gss.c,v 1.32 2002/01/15 15:43:00 andros Exp $
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpcsec_gss/rpcsec_gss.c 253049 2013-07-09 01:05:28Z rmacklem $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,6 +83,8 @@
#include <rpc/rpc.h>
#include <rpc/rpcsec_gss.h>
+#include <kgssapi/krb5/kcrypto.h>
+
#include "rpcsec_gss_int.h"
static void rpc_gss_nextverf(AUTH*);
@@ -122,6 +125,7 @@
AUTH *gd_auth; /* link back to AUTH */
struct ucred *gd_ucred; /* matching local cred */
char *gd_principal; /* server principal name */
+ char *gd_clntprincipal; /* client principal name */
rpc_gss_options_req_t gd_options; /* GSS context options */
enum rpcsec_gss_state gd_state; /* connection state */
gss_buffer_desc gd_verf; /* save GSS_S_COMPLETE
@@ -153,7 +157,7 @@
static int rpc_gss_count;
static AUTH *rpc_gss_seccreate_int(CLIENT *, struct ucred *, const char *,
- gss_OID, rpc_gss_service_t, u_int, rpc_gss_options_req_t *,
+ const char *, gss_OID, rpc_gss_service_t, u_int, rpc_gss_options_req_t *,
rpc_gss_options_ret_t *);
static void
@@ -251,8 +255,8 @@
/*
* We missed in the cache - create a new association.
*/
- auth = rpc_gss_seccreate_int(clnt, cred, principal, mech_oid, service,
- GSS_C_QOP_DEFAULT, NULL, NULL);
+ auth = rpc_gss_seccreate_int(clnt, cred, NULL, principal, mech_oid,
+ service, GSS_C_QOP_DEFAULT, NULL, NULL);
if (!auth)
return (NULL);
@@ -304,9 +308,10 @@
}
AUTH *
-rpc_gss_seccreate(CLIENT *clnt, struct ucred *cred, const char *principal,
- const char *mechanism, rpc_gss_service_t service, const char *qop,
- rpc_gss_options_req_t *options_req, rpc_gss_options_ret_t *options_ret)
+rpc_gss_seccreate(CLIENT *clnt, struct ucred *cred, const char *clnt_principal,
+ const char *principal, const char *mechanism, rpc_gss_service_t service,
+ const char *qop, rpc_gss_options_req_t *options_req,
+ rpc_gss_options_ret_t *options_ret)
{
gss_OID oid;
u_int qop_num;
@@ -324,13 +329,33 @@
qop_num = GSS_C_QOP_DEFAULT;
}
- return (rpc_gss_seccreate_int(clnt, cred, principal, oid, service,
- qop_num, options_req, options_ret));
+ return (rpc_gss_seccreate_int(clnt, cred, clnt_principal, principal,
+ oid, service, qop_num, options_req, options_ret));
}
+void
+rpc_gss_refresh_auth(AUTH *auth)
+{
+ struct rpc_gss_data *gd;
+ rpc_gss_options_ret_t options;
+
+ gd = AUTH_PRIVATE(auth);
+ /*
+ * If the state != ESTABLISHED, try and initialize
+ * the authenticator again. This will happen if the
+ * user's credentials have expired. It may succeed now,
+ * if they have done a kinit or similar.
+ */
+ if (gd->gd_state != RPCSEC_GSS_ESTABLISHED) {
+ memset(&options, 0, sizeof (options));
+ (void) rpc_gss_init(auth, &options);
+ }
+}
+
static AUTH *
-rpc_gss_seccreate_int(CLIENT *clnt, struct ucred *cred, const char *principal,
- gss_OID mech_oid, rpc_gss_service_t service, u_int qop_num,
+rpc_gss_seccreate_int(CLIENT *clnt, struct ucred *cred,
+ const char *clnt_principal, const char *principal, gss_OID mech_oid,
+ rpc_gss_service_t service, u_int qop_num,
rpc_gss_options_req_t *options_req, rpc_gss_options_ret_t *options_ret)
{
AUTH *auth;
@@ -379,6 +404,10 @@
gd->gd_auth = auth;
gd->gd_ucred = crdup(cred);
gd->gd_principal = strdup(principal, M_RPC);
+ if (clnt_principal != NULL)
+ gd->gd_clntprincipal = strdup(clnt_principal, M_RPC);
+ else
+ gd->gd_clntprincipal = NULL;
if (options_req) {
@@ -719,6 +748,8 @@
OM_uint32 maj_stat, min_stat, call_stat;
const char *mech;
struct rpc_callextra ext;
+ gss_OID mech_oid;
+ gss_OID_set mechlist;
rpc_gss_log_debug("in rpc_gss_refresh()");
@@ -745,6 +776,65 @@
gd->gd_cred.gc_proc = RPCSEC_GSS_INIT;
gd->gd_cred.gc_seq = 0;
+ /*
+ * For KerberosV, if there is a client principal name, that implies
+ * that this is a host based initiator credential in the default
+ * keytab file. For this case, it is necessary to do a
+ * gss_acquire_cred(). When this is done, the gssd daemon will
+ * do the equivalent of "kinit -k" to put a TGT for the name in
+ * the credential cache file for the gssd daemon.
+ */
+ if (gd->gd_clntprincipal != NULL &&
+ rpc_gss_mech_to_oid("kerberosv5", &mech_oid) &&
+ gd->gd_mech == mech_oid) {
+ /* Get rid of any old credential. */
+ if (gd->gd_options.my_cred != GSS_C_NO_CREDENTIAL) {
+ gss_release_cred(&min_stat, &gd->gd_options.my_cred);
+ gd->gd_options.my_cred = GSS_C_NO_CREDENTIAL;
+ }
+
+ /*
+ * The mechanism must be set to KerberosV for acquisition
+ * of credentials to work reliably.
+ */
+ maj_stat = gss_create_empty_oid_set(&min_stat, &mechlist);
+ if (maj_stat != GSS_S_COMPLETE) {
+ options_ret->major_status = maj_stat;
+ options_ret->minor_status = min_stat;
+ goto out;
+ }
+ maj_stat = gss_add_oid_set_member(&min_stat, gd->gd_mech,
+ &mechlist);
+ if (maj_stat != GSS_S_COMPLETE) {
+ options_ret->major_status = maj_stat;
+ options_ret->minor_status = min_stat;
+ gss_release_oid_set(&min_stat, &mechlist);
+ goto out;
+ }
+
+ principal_desc.value = (void *)gd->gd_clntprincipal;
+ principal_desc.length = strlen(gd->gd_clntprincipal);
+ maj_stat = gss_import_name(&min_stat, &principal_desc,
+ GSS_C_NT_HOSTBASED_SERVICE, &name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ options_ret->major_status = maj_stat;
+ options_ret->minor_status = min_stat;
+ gss_release_oid_set(&min_stat, &mechlist);
+ goto out;
+ }
+ /* Acquire the credentials. */
+ maj_stat = gss_acquire_cred(&min_stat, name, 0,
+ mechlist, GSS_C_INITIATE,
+ &gd->gd_options.my_cred, NULL, NULL);
+ gss_release_name(&min_stat, &name);
+ gss_release_oid_set(&min_stat, &mechlist);
+ if (maj_stat != GSS_S_COMPLETE) {
+ options_ret->major_status = maj_stat;
+ options_ret->minor_status = min_stat;
+ goto out;
+ }
+ }
+
principal_desc.value = (void *)gd->gd_principal;
principal_desc.length = strlen(gd->gd_principal);
maj_stat = gss_import_name(&min_stat, &principal_desc,
@@ -1036,6 +1126,8 @@
CLNT_RELEASE(gd->gd_clnt);
crfree(gd->gd_ucred);
free(gd->gd_principal, M_RPC);
+ if (gd->gd_clntprincipal != NULL)
+ free(gd->gd_clntprincipal, M_RPC);
if (gd->gd_verf.value)
xdr_free((xdrproc_t) xdr_gss_buffer_desc,
(char *) &gd->gd_verf);
Modified: trunk/sys/rpc/rpcsec_gss/rpcsec_gss_conf.c
===================================================================
--- trunk/sys/rpc/rpcsec_gss/rpcsec_gss_conf.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcsec_gss/rpcsec_gss_conf.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Doug Rabson
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpcsec_gss/rpcsec_gss_conf.c 184588 2008-11-03 10:38:00Z dfr $");
#include <sys/param.h>
#include <sys/systm.h>
Modified: trunk/sys/rpc/rpcsec_gss/rpcsec_gss_int.h
===================================================================
--- trunk/sys/rpc/rpcsec_gss/rpcsec_gss_int.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcsec_gss/rpcsec_gss_int.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
rpcsec_gss.h
@@ -32,9 +33,9 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- $Id: rpcsec_gss_int.h,v 1.2 2013-01-05 20:24:00 laffer1 Exp $
+ $Id: auth_gss.h,v 1.12 2001/04/30 19:44:47 andros Exp $
*/
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/rpc/rpcsec_gss/rpcsec_gss_int.h 184588 2008-11-03 10:38:00Z dfr $ */
#ifndef _RPCSEC_GSS_INT_H
#define _RPCSEC_GSS_INT_H
Modified: trunk/sys/rpc/rpcsec_gss/rpcsec_gss_misc.c
===================================================================
--- trunk/sys/rpc/rpcsec_gss/rpcsec_gss_misc.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcsec_gss/rpcsec_gss_misc.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Doug Rabson
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpcsec_gss/rpcsec_gss_misc.c 184588 2008-11-03 10:38:00Z dfr $");
#include <sys/param.h>
#include <sys/kobj.h>
Modified: trunk/sys/rpc/rpcsec_gss/rpcsec_gss_prot.c
===================================================================
--- trunk/sys/rpc/rpcsec_gss/rpcsec_gss_prot.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcsec_gss/rpcsec_gss_prot.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
rpcsec_gss_prot.c
@@ -32,11 +33,11 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- $Id: rpcsec_gss_prot.c,v 1.2 2013-01-05 20:24:00 laffer1 Exp $
+ $Id: authgss_prot.c,v 1.18 2000/09/01 04:14:03 dugsong Exp $
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpcsec_gss/rpcsec_gss_prot.c 249096 2013-04-04 15:16:53Z gnn $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -107,7 +108,7 @@
struct mbuf *m = *mp;
uint32_t n;
- M_PREPEND(m, sizeof(uint32_t), M_WAIT);
+ M_PREPEND(m, sizeof(uint32_t), M_WAITOK);
n = htonl(v);
bcopy(&n, mtod(m, uint32_t *), sizeof(uint32_t));
*mp = m;
@@ -243,7 +244,7 @@
*/
len = get_uint32(&results);
message = results;
- results = m_split(results, len, M_WAIT);
+ results = m_split(results, len, M_WAITOK);
if (!results) {
m_freem(message);
return (FALSE);
Modified: trunk/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
===================================================================
--- trunk/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Doug Rabson
* All rights reserved.
@@ -57,11 +58,11 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- $Id: svc_rpcsec_gss.c,v 1.2 2013-01-05 20:24:00 laffer1 Exp $
+ $Id: svc_auth_gss.c,v 1.27 2002/01/15 15:43:00 andros Exp $
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c 299619 2016-05-13 08:30:26Z ngie $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -121,9 +122,6 @@
};
#define SVC_RPC_GSS_SEQWINDOW 128
-#ifndef RPCAUTH_UNIXGIDS
-#define RPCAUTH_UNIXGIDS 16
-#endif
struct svc_rpc_gss_clientid {
unsigned long ci_hostid;
@@ -150,7 +148,7 @@
int cl_rpcflavor; /* RPC pseudo sec flavor */
bool_t cl_done_callback; /* TRUE after call */
void *cl_cookie; /* user cookie from callback */
- gid_t cl_gid_storage[RPCAUTH_UNIXGIDS];
+ gid_t cl_gid_storage[NGROUPS];
gss_OID cl_mech; /* mechanism */
gss_qop_t cl_qop; /* quality of protection */
uint32_t cl_seqlast; /* sequence window origin */
@@ -334,7 +332,7 @@
* Construct a gss_buffer containing the full name formatted
* as "name/node at domain" where node and domain are optional.
*/
- namelen = strlen(name);
+ namelen = strlen(name) + 1;
if (node) {
namelen += strlen(node) + 1;
}
@@ -776,7 +774,7 @@
uc->gid = 65534;
uc->gidlist = client->cl_gid_storage;
- numgroups = RPCAUTH_UNIXGIDS;
+ numgroups = NGROUPS;
maj_stat = gss_pname_to_unix_cred(&min_stat, name, client->cl_mech,
&uc->uid, &uc->gid, &numgroups, &uc->gidlist[0]);
if (GSS_ERROR(maj_stat))
Modified: trunk/sys/rpc/rpcsec_gss.h
===================================================================
--- trunk/sys/rpc/rpcsec_gss.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/rpcsec_gss.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Doug Rabson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/rpcsec_gss.h 253049 2013-07-09 01:05:28Z rmacklem $
*/
#ifndef _RPCSEC_GSS_H
@@ -153,9 +154,9 @@
rpc_gss_service_t service);
typedef void rpc_gss_secpurge_ftype(CLIENT *clnt);
typedef AUTH *rpc_gss_seccreate_ftype(CLIENT *clnt, struct ucred *cred,
- const char *principal, const char *mechanism,
- rpc_gss_service_t service, const char *qop,
- rpc_gss_options_req_t *options_req,
+ const char *clnt_principal, const char *principal,
+ const char *mechanism, rpc_gss_service_t service,
+ const char *qop, rpc_gss_options_req_t *options_req,
rpc_gss_options_ret_t *options_ret);
typedef bool_t rpc_gss_set_defaults_ftype(AUTH *auth,
rpc_gss_service_t service, const char *qop);
@@ -183,6 +184,7 @@
const char *domain);
typedef int rpc_gss_svc_max_data_length_ftype(struct svc_req *req,
int max_tp_unit_len);
+typedef void rpc_gss_refresh_auth_ftype(AUTH *auth);
struct rpc_gss_entries {
rpc_gss_secfind_ftype *rpc_gss_secfind;
@@ -204,6 +206,7 @@
rpc_gss_clear_callback_ftype *rpc_gss_clear_callback;
rpc_gss_get_principal_name_ftype *rpc_gss_get_principal_name;
rpc_gss_svc_max_data_length_ftype *rpc_gss_svc_max_data_length;
+ rpc_gss_refresh_auth_ftype *rpc_gss_refresh_auth;
};
extern struct rpc_gss_entries rpc_gss_entries;
@@ -229,8 +232,9 @@
}
static __inline AUTH *
-rpc_gss_seccreate_call(CLIENT *clnt, struct ucred *cred, const char *principal,
- const char *mechanism, rpc_gss_service_t service, const char *qop,
+rpc_gss_seccreate_call(CLIENT *clnt, struct ucred *cred,
+ const char *clnt_principal, const char *principal, const char *mechanism,
+ rpc_gss_service_t service, const char *qop,
rpc_gss_options_req_t *options_req, rpc_gss_options_ret_t *options_ret)
{
AUTH *ret = NULL;
@@ -237,8 +241,8 @@
if (rpc_gss_entries.rpc_gss_seccreate != NULL)
ret = (*rpc_gss_entries.rpc_gss_seccreate)(clnt, cred,
- principal, mechanism, service, qop, options_req,
- options_ret);
+ clnt_principal, principal, mechanism, service, qop,
+ options_req, options_ret);
return (ret);
}
@@ -406,14 +410,29 @@
return (ret);
}
+static __inline void
+rpc_gss_refresh_auth_call(AUTH *auth)
+{
+
+ if (rpc_gss_entries.rpc_gss_refresh_auth != NULL)
+ (*rpc_gss_entries.rpc_gss_refresh_auth)(auth);
+}
+
AUTH *rpc_gss_secfind(CLIENT *clnt, struct ucred *cred,
const char *principal, gss_OID mech_oid, rpc_gss_service_t service);
void rpc_gss_secpurge(CLIENT *clnt);
-#endif
+void rpc_gss_refresh_auth(AUTH *auth);
AUTH *rpc_gss_seccreate(CLIENT *clnt, struct ucred *cred,
+ const char *clnt_principal, const char *principal,
+ const char *mechanism, rpc_gss_service_t service,
+ const char *qop, rpc_gss_options_req_t *options_req,
+ rpc_gss_options_ret_t *options_ret);
+#else /* !_KERNEL */
+AUTH *rpc_gss_seccreate(CLIENT *clnt, struct ucred *cred,
const char *principal, const char *mechanism, rpc_gss_service_t service,
const char *qop, rpc_gss_options_req_t *options_req,
rpc_gss_options_ret_t *options_ret);
+#endif /* _KERNEL */
bool_t rpc_gss_set_defaults(AUTH *auth, rpc_gss_service_t service,
const char *qop);
int rpc_gss_max_data_length(AUTH *handle, int max_tp_unit_len);
Modified: trunk/sys/rpc/svc.c
===================================================================
--- trunk/sys/rpc/svc.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: svc.c,v 1.21 2000/07/06 03:10:35 christos Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -34,7 +34,7 @@
static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/svc.c 314034 2017-02-21 09:29:46Z avg $");
/*
* svc.c, Server-side remote procedure call interface.
@@ -57,6 +57,8 @@
#include <sys/queue.h>
#include <sys/socketvar.h>
#include <sys/systm.h>
+#include <sys/smp.h>
+#include <sys/sx.h>
#include <sys/ucred.h>
#include <rpc/rpc.h>
@@ -70,18 +72,24 @@
static struct svc_callout *svc_find(SVCPOOL *pool, rpcprog_t, rpcvers_t,
char *);
-static void svc_new_thread(SVCPOOL *pool);
+static void svc_new_thread(SVCGROUP *grp);
static void xprt_unregister_locked(SVCXPRT *xprt);
+static void svc_change_space_used(SVCPOOL *pool, long delta);
+static bool_t svc_request_space_available(SVCPOOL *pool);
+static void svcpool_cleanup(SVCPOOL *pool);
/* *************** SVCXPRT related stuff **************** */
static int svcpool_minthread_sysctl(SYSCTL_HANDLER_ARGS);
static int svcpool_maxthread_sysctl(SYSCTL_HANDLER_ARGS);
+static int svcpool_threads_sysctl(SYSCTL_HANDLER_ARGS);
SVCPOOL*
svcpool_create(const char *name, struct sysctl_oid_list *sysctl_base)
{
SVCPOOL *pool;
+ SVCGROUP *grp;
+ int g;
pool = malloc(sizeof(SVCPOOL), M_RPC, M_WAITOK|M_ZERO);
@@ -89,53 +97,69 @@
pool->sp_name = name;
pool->sp_state = SVCPOOL_INIT;
pool->sp_proc = NULL;
- TAILQ_INIT(&pool->sp_xlist);
- TAILQ_INIT(&pool->sp_active);
TAILQ_INIT(&pool->sp_callouts);
- LIST_INIT(&pool->sp_threads);
- LIST_INIT(&pool->sp_idlethreads);
+ TAILQ_INIT(&pool->sp_lcallouts);
pool->sp_minthreads = 1;
pool->sp_maxthreads = 1;
- pool->sp_threadcount = 0;
+ pool->sp_groupcount = 1;
+ for (g = 0; g < SVC_MAXGROUPS; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_init(&grp->sg_lock, "sg_lock", NULL, MTX_DEF);
+ grp->sg_pool = pool;
+ grp->sg_state = SVCPOOL_ACTIVE;
+ TAILQ_INIT(&grp->sg_xlist);
+ TAILQ_INIT(&grp->sg_active);
+ LIST_INIT(&grp->sg_idlethreads);
+ grp->sg_minthreads = 1;
+ grp->sg_maxthreads = 1;
+ }
/*
- * Don't use more than a quarter of mbuf clusters or more than
- * 45Mb buffering requests.
+ * Don't use more than a quarter of mbuf clusters. Nota bene:
+ * nmbclusters is an int, but nmbclusters*MCLBYTES may overflow
+ * on LP64 architectures, so cast to u_long to avoid undefined
+ * behavior. (ILP32 architectures cannot have nmbclusters
+ * large enough to overflow for other reasons.)
*/
- pool->sp_space_high = nmbclusters * MCLBYTES / 4;
- if (pool->sp_space_high > 45 << 20)
- pool->sp_space_high = 45 << 20;
- pool->sp_space_low = 2 * pool->sp_space_high / 3;
+ pool->sp_space_high = (u_long)nmbclusters * MCLBYTES / 4;
+ pool->sp_space_low = (pool->sp_space_high / 3) * 2;
sysctl_ctx_init(&pool->sp_sysctl);
if (sysctl_base) {
SYSCTL_ADD_PROC(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"minthreads", CTLTYPE_INT | CTLFLAG_RW,
- pool, 0, svcpool_minthread_sysctl, "I", "");
+ pool, 0, svcpool_minthread_sysctl, "I",
+ "Minimal number of threads");
SYSCTL_ADD_PROC(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"maxthreads", CTLTYPE_INT | CTLFLAG_RW,
- pool, 0, svcpool_maxthread_sysctl, "I", "");
+ pool, 0, svcpool_maxthread_sysctl, "I",
+ "Maximal number of threads");
+ SYSCTL_ADD_PROC(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ "threads", CTLTYPE_INT | CTLFLAG_RD,
+ pool, 0, svcpool_threads_sysctl, "I",
+ "Current number of threads");
SYSCTL_ADD_INT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
- "threads", CTLFLAG_RD, &pool->sp_threadcount, 0, "");
+ "groups", CTLFLAG_RD, &pool->sp_groupcount, 0,
+ "Number of thread groups");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_used", CTLFLAG_RD,
- &pool->sp_space_used, 0,
+ &pool->sp_space_used,
"Space in parsed but not handled requests.");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_used_highest", CTLFLAG_RD,
- &pool->sp_space_used_highest, 0,
+ &pool->sp_space_used_highest,
"Highest space used since reboot.");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_high", CTLFLAG_RW,
- &pool->sp_space_high, 0,
+ &pool->sp_space_high,
"Maximum space in parsed but not handled requests.");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_low", CTLFLAG_RW,
- &pool->sp_space_low, 0,
+ &pool->sp_space_low,
"Low water mark for request space.");
SYSCTL_ADD_INT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
@@ -152,34 +176,61 @@
return pool;
}
-void
-svcpool_destroy(SVCPOOL *pool)
+/*
+ * Code common to svcpool_destroy() and svcpool_close(), which cleans up
+ * the pool data structures.
+ */
+static void
+svcpool_cleanup(SVCPOOL *pool)
{
+ SVCGROUP *grp;
SVCXPRT *xprt, *nxprt;
struct svc_callout *s;
+ struct svc_loss_callout *sl;
struct svcxprt_list cleanup;
+ int g;
TAILQ_INIT(&cleanup);
- mtx_lock(&pool->sp_lock);
- while (TAILQ_FIRST(&pool->sp_xlist)) {
- xprt = TAILQ_FIRST(&pool->sp_xlist);
- xprt_unregister_locked(xprt);
- TAILQ_INSERT_TAIL(&cleanup, xprt, xp_link);
+ for (g = 0; g < SVC_MAXGROUPS; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ while ((xprt = TAILQ_FIRST(&grp->sg_xlist)) != NULL) {
+ xprt_unregister_locked(xprt);
+ TAILQ_INSERT_TAIL(&cleanup, xprt, xp_link);
+ }
+ mtx_unlock(&grp->sg_lock);
}
+ TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) {
+ SVC_RELEASE(xprt);
+ }
- while (TAILQ_FIRST(&pool->sp_callouts)) {
- s = TAILQ_FIRST(&pool->sp_callouts);
+ mtx_lock(&pool->sp_lock);
+ while ((s = TAILQ_FIRST(&pool->sp_callouts)) != NULL) {
mtx_unlock(&pool->sp_lock);
svc_unreg(pool, s->sc_prog, s->sc_vers);
mtx_lock(&pool->sp_lock);
}
+ while ((sl = TAILQ_FIRST(&pool->sp_lcallouts)) != NULL) {
+ mtx_unlock(&pool->sp_lock);
+ svc_loss_unreg(pool, sl->slc_dispatch);
+ mtx_lock(&pool->sp_lock);
+ }
mtx_unlock(&pool->sp_lock);
+}
- TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) {
- SVC_RELEASE(xprt);
+void
+svcpool_destroy(SVCPOOL *pool)
+{
+ SVCGROUP *grp;
+ int g;
+
+ svcpool_cleanup(pool);
+
+ for (g = 0; g < SVC_MAXGROUPS; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_destroy(&grp->sg_lock);
}
-
mtx_destroy(&pool->sp_lock);
if (pool->sp_rcache)
@@ -189,17 +240,50 @@
free(pool, M_RPC);
}
-static bool_t
-svcpool_active(SVCPOOL *pool)
+/*
+ * Similar to svcpool_destroy(), except that it does not destroy the actual
+ * data structures. As such, "pool" may be used again.
+ */
+void
+svcpool_close(SVCPOOL *pool)
{
- enum svcpool_state state = pool->sp_state;
+ SVCGROUP *grp;
+ int g;
- if (state == SVCPOOL_INIT || state == SVCPOOL_CLOSING)
- return (FALSE);
- return (TRUE);
+ svcpool_cleanup(pool);
+
+ /* Now, initialize the pool's state for a fresh svc_run() call. */
+ mtx_lock(&pool->sp_lock);
+ pool->sp_state = SVCPOOL_INIT;
+ mtx_unlock(&pool->sp_lock);
+ for (g = 0; g < SVC_MAXGROUPS; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ grp->sg_state = SVCPOOL_ACTIVE;
+ mtx_unlock(&grp->sg_lock);
+ }
}
/*
+ * Sysctl handler to get the present thread count on a pool
+ */
+static int
+svcpool_threads_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ SVCPOOL *pool;
+ int threads, error, g;
+
+ pool = oidp->oid_arg1;
+ threads = 0;
+ mtx_lock(&pool->sp_lock);
+ for (g = 0; g < pool->sp_groupcount; g++)
+ threads += pool->sp_groups[g].sg_threadcount;
+ mtx_unlock(&pool->sp_lock);
+ error = sysctl_handle_int(oidp, &threads, 0, req);
+ return (error);
+}
+
+/*
* Sysctl handler to set the minimum thread count on a pool
*/
static int
@@ -206,7 +290,7 @@
svcpool_minthread_sysctl(SYSCTL_HANDLER_ARGS)
{
SVCPOOL *pool;
- int newminthreads, error, n;
+ int newminthreads, error, g;
pool = oidp->oid_arg1;
newminthreads = pool->sp_minthreads;
@@ -215,21 +299,11 @@
if (newminthreads > pool->sp_maxthreads)
return (EINVAL);
mtx_lock(&pool->sp_lock);
- if (newminthreads > pool->sp_minthreads
- && svcpool_active(pool)) {
- /*
- * If the pool is running and we are
- * increasing, create some more threads now.
- */
- n = newminthreads - pool->sp_threadcount;
- if (n > 0) {
- mtx_unlock(&pool->sp_lock);
- while (n--)
- svc_new_thread(pool);
- mtx_lock(&pool->sp_lock);
- }
+ pool->sp_minthreads = newminthreads;
+ for (g = 0; g < pool->sp_groupcount; g++) {
+ pool->sp_groups[g].sg_minthreads = max(1,
+ pool->sp_minthreads / pool->sp_groupcount);
}
- pool->sp_minthreads = newminthreads;
mtx_unlock(&pool->sp_lock);
}
return (error);
@@ -242,8 +316,7 @@
svcpool_maxthread_sysctl(SYSCTL_HANDLER_ARGS)
{
SVCPOOL *pool;
- SVCTHREAD *st;
- int newmaxthreads, error;
+ int newmaxthreads, error, g;
pool = oidp->oid_arg1;
newmaxthreads = pool->sp_maxthreads;
@@ -252,17 +325,11 @@
if (newmaxthreads < pool->sp_minthreads)
return (EINVAL);
mtx_lock(&pool->sp_lock);
- if (newmaxthreads < pool->sp_maxthreads
- && svcpool_active(pool)) {
- /*
- * If the pool is running and we are
- * decreasing, wake up some idle threads to
- * encourage them to exit.
- */
- LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink)
- cv_signal(&st->st_cond);
+ pool->sp_maxthreads = newmaxthreads;
+ for (g = 0; g < pool->sp_groupcount; g++) {
+ pool->sp_groups[g].sg_maxthreads = max(1,
+ pool->sp_maxthreads / pool->sp_groupcount);
}
- pool->sp_maxthreads = newmaxthreads;
mtx_unlock(&pool->sp_lock);
}
return (error);
@@ -275,13 +342,17 @@
xprt_register(SVCXPRT *xprt)
{
SVCPOOL *pool = xprt->xp_pool;
+ SVCGROUP *grp;
+ int g;
SVC_ACQUIRE(xprt);
- mtx_lock(&pool->sp_lock);
+ g = atomic_fetchadd_int(&pool->sp_nextgroup, 1) % pool->sp_groupcount;
+ xprt->xp_group = grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
xprt->xp_registered = TRUE;
xprt->xp_active = FALSE;
- TAILQ_INSERT_TAIL(&pool->sp_xlist, xprt, xp_link);
- mtx_unlock(&pool->sp_lock);
+ TAILQ_INSERT_TAIL(&grp->sg_xlist, xprt, xp_link);
+ mtx_unlock(&grp->sg_lock);
}
/*
@@ -292,15 +363,13 @@
static void
xprt_unregister_locked(SVCXPRT *xprt)
{
- SVCPOOL *pool = xprt->xp_pool;
+ SVCGROUP *grp = xprt->xp_group;
+ mtx_assert(&grp->sg_lock, MA_OWNED);
KASSERT(xprt->xp_registered == TRUE,
("xprt_unregister_locked: not registered"));
- if (xprt->xp_active) {
- TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink);
- xprt->xp_active = FALSE;
- }
- TAILQ_REMOVE(&pool->sp_xlist, xprt, xp_link);
+ xprt_inactive_locked(xprt);
+ TAILQ_REMOVE(&grp->sg_xlist, xprt, xp_link);
xprt->xp_registered = FALSE;
}
@@ -307,39 +376,38 @@
void
xprt_unregister(SVCXPRT *xprt)
{
- SVCPOOL *pool = xprt->xp_pool;
+ SVCGROUP *grp = xprt->xp_group;
- mtx_lock(&pool->sp_lock);
+ mtx_lock(&grp->sg_lock);
if (xprt->xp_registered == FALSE) {
/* Already unregistered by another thread */
- mtx_unlock(&pool->sp_lock);
+ mtx_unlock(&grp->sg_lock);
return;
}
xprt_unregister_locked(xprt);
- mtx_unlock(&pool->sp_lock);
+ mtx_unlock(&grp->sg_lock);
SVC_RELEASE(xprt);
}
-static void
+/*
+ * Attempt to assign a service thread to this transport.
+ */
+static int
xprt_assignthread(SVCXPRT *xprt)
{
- SVCPOOL *pool = xprt->xp_pool;
+ SVCGROUP *grp = xprt->xp_group;
SVCTHREAD *st;
- /*
- * Attempt to assign a service thread to this
- * transport.
- */
- LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink) {
- if (st->st_xprt == NULL && STAILQ_EMPTY(&st->st_reqs))
- break;
- }
+ mtx_assert(&grp->sg_lock, MA_OWNED);
+ st = LIST_FIRST(&grp->sg_idlethreads);
if (st) {
+ LIST_REMOVE(st, st_ilink);
SVC_ACQUIRE(xprt);
xprt->xp_thread = st;
st->st_xprt = xprt;
cv_signal(&st->st_cond);
+ return (TRUE);
} else {
/*
* See if we can create a new thread. The
@@ -349,45 +417,52 @@
* from a socket upcall). Don't create more
* than one thread per second.
*/
- if (pool->sp_state == SVCPOOL_ACTIVE
- && pool->sp_lastcreatetime < time_uptime
- && pool->sp_threadcount < pool->sp_maxthreads) {
- pool->sp_state = SVCPOOL_THREADWANTED;
+ if (grp->sg_state == SVCPOOL_ACTIVE
+ && grp->sg_lastcreatetime < time_uptime
+ && grp->sg_threadcount < grp->sg_maxthreads) {
+ grp->sg_state = SVCPOOL_THREADWANTED;
}
}
+ return (FALSE);
}
void
xprt_active(SVCXPRT *xprt)
{
- SVCPOOL *pool = xprt->xp_pool;
+ SVCGROUP *grp = xprt->xp_group;
- mtx_lock(&pool->sp_lock);
+ mtx_lock(&grp->sg_lock);
if (!xprt->xp_registered) {
/*
* Race with xprt_unregister - we lose.
*/
- mtx_unlock(&pool->sp_lock);
+ mtx_unlock(&grp->sg_lock);
return;
}
if (!xprt->xp_active) {
- TAILQ_INSERT_TAIL(&pool->sp_active, xprt, xp_alink);
xprt->xp_active = TRUE;
- xprt_assignthread(xprt);
+ if (xprt->xp_thread == NULL) {
+ if (!svc_request_space_available(xprt->xp_pool) ||
+ !xprt_assignthread(xprt))
+ TAILQ_INSERT_TAIL(&grp->sg_active, xprt,
+ xp_alink);
+ }
}
- mtx_unlock(&pool->sp_lock);
+ mtx_unlock(&grp->sg_lock);
}
void
xprt_inactive_locked(SVCXPRT *xprt)
{
- SVCPOOL *pool = xprt->xp_pool;
+ SVCGROUP *grp = xprt->xp_group;
+ mtx_assert(&grp->sg_lock, MA_OWNED);
if (xprt->xp_active) {
- TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink);
+ if (xprt->xp_thread == NULL)
+ TAILQ_REMOVE(&grp->sg_active, xprt, xp_alink);
xprt->xp_active = FALSE;
}
}
@@ -395,14 +470,27 @@
void
xprt_inactive(SVCXPRT *xprt)
{
- SVCPOOL *pool = xprt->xp_pool;
+ SVCGROUP *grp = xprt->xp_group;
- mtx_lock(&pool->sp_lock);
+ mtx_lock(&grp->sg_lock);
xprt_inactive_locked(xprt);
- mtx_unlock(&pool->sp_lock);
+ mtx_unlock(&grp->sg_lock);
}
/*
+ * Variant of xprt_inactive() for use only when sure that port is
+ * assigned to thread. For example, withing receive handlers.
+ */
+void
+xprt_inactive_self(SVCXPRT *xprt)
+{
+
+ KASSERT(xprt->xp_thread != NULL,
+ ("xprt_inactive_self(%p) with NULL xp_thread", xprt));
+ xprt->xp_active = FALSE;
+}
+
+/*
* Add a service program to the callout list.
* The dispatch routine will be called when a rpc request for this
* program number comes in.
@@ -492,6 +580,55 @@
mtx_unlock(&pool->sp_lock);
}
+/*
+ * Add a service connection loss program to the callout list.
+ * The dispatch routine will be called when some port in ths pool die.
+ */
+bool_t
+svc_loss_reg(SVCXPRT *xprt, void (*dispatch)(SVCXPRT *))
+{
+ SVCPOOL *pool = xprt->xp_pool;
+ struct svc_loss_callout *s;
+
+ mtx_lock(&pool->sp_lock);
+ TAILQ_FOREACH(s, &pool->sp_lcallouts, slc_link) {
+ if (s->slc_dispatch == dispatch)
+ break;
+ }
+ if (s != NULL) {
+ mtx_unlock(&pool->sp_lock);
+ return (TRUE);
+ }
+ s = malloc(sizeof(struct svc_loss_callout), M_RPC, M_NOWAIT);
+ if (s == NULL) {
+ mtx_unlock(&pool->sp_lock);
+ return (FALSE);
+ }
+ s->slc_dispatch = dispatch;
+ TAILQ_INSERT_TAIL(&pool->sp_lcallouts, s, slc_link);
+ mtx_unlock(&pool->sp_lock);
+ return (TRUE);
+}
+
+/*
+ * Remove a service connection loss program from the callout list.
+ */
+void
+svc_loss_unreg(SVCPOOL *pool, void (*dispatch)(SVCXPRT *))
+{
+ struct svc_loss_callout *s;
+
+ mtx_lock(&pool->sp_lock);
+ TAILQ_FOREACH(s, &pool->sp_lcallouts, slc_link) {
+ if (s->slc_dispatch == dispatch) {
+ TAILQ_REMOVE(&pool->sp_lcallouts, s, slc_link);
+ free(s, M_RPC);
+ break;
+ }
+ }
+ mtx_unlock(&pool->sp_lock);
+}
+
/* ********************** CALLOUT list related stuff ************* */
/*
@@ -535,7 +672,7 @@
if (!SVCAUTH_WRAP(&rqstp->rq_auth, &body))
return (FALSE);
- ok = SVC_REPLY(xprt, rply, rqstp->rq_addr, body);
+ ok = SVC_REPLY(xprt, rply, rqstp->rq_addr, body, &rqstp->rq_reply_seq);
if (rqstp->rq_addr) {
free(rqstp->rq_addr, M_SONAME);
rqstp->rq_addr = NULL;
@@ -563,9 +700,7 @@
rply.acpted_rply.ar_results.where = NULL;
rply.acpted_rply.ar_results.proc = (xdrproc_t) xdr_void;
- MGET(m, M_WAIT, MT_DATA);
- MCLGET(m, M_WAIT);
- m->m_len = 0;
+ m = m_getcl(M_WAITOK, MT_DATA, 0);
xdrmbuf_create(&xdrs, m, XDR_ENCODE);
ok = xdr_results(&xdrs, xdr_location);
XDR_DESTROY(&xdrs);
@@ -745,15 +880,13 @@
* parameters.
*/
SVCXPRT *
-svc_xprt_alloc()
+svc_xprt_alloc(void)
{
SVCXPRT *xprt;
SVCXPRT_EXT *ext;
xprt = mem_alloc(sizeof(SVCXPRT));
- memset(xprt, 0, sizeof(SVCXPRT));
ext = mem_alloc(sizeof(SVCXPRT_EXT));
- memset(ext, 0, sizeof(SVCXPRT_EXT));
xprt->xp_p3 = ext;
refcount_init(&xprt->xp_refs, 1);
@@ -764,8 +897,7 @@
* Free a server transport structure.
*/
void
-svc_xprt_free(xprt)
- SVCXPRT *xprt;
+svc_xprt_free(SVCXPRT *xprt)
{
mem_free(xprt->xp_p3, sizeof(SVCXPRT_EXT));
@@ -786,6 +918,7 @@
struct svc_req *r;
struct rpc_msg msg;
struct mbuf *args;
+ struct svc_loss_callout *s;
enum xprt_stat stat;
/* now receive msgs from xprtprt (support batch calls) */
@@ -814,7 +947,7 @@
break;
case RS_DONE:
SVC_REPLY(xprt, &repmsg, r->rq_addr,
- repbody);
+ repbody, &r->rq_reply_seq);
if (r->rq_addr) {
free(r->rq_addr, M_SONAME);
r->rq_addr = NULL;
@@ -864,6 +997,8 @@
r = NULL;
}
if ((stat = SVC_STAT(xprt)) == XPRT_DIED) {
+ TAILQ_FOREACH(s, &pool->sp_lcallouts, slc_link)
+ (*s->slc_dispatch)(xprt);
xprt_unregister(xprt);
}
@@ -916,7 +1051,7 @@
}
static void
-svc_checkidle(SVCPOOL *pool)
+svc_checkidle(SVCGROUP *grp)
{
SVCXPRT *xprt, *nxprt;
time_t timo;
@@ -923,7 +1058,7 @@
struct svcxprt_list cleanup;
TAILQ_INIT(&cleanup);
- TAILQ_FOREACH_SAFE(xprt, &pool->sp_xlist, xp_link, nxprt) {
+ TAILQ_FOREACH_SAFE(xprt, &grp->sg_xlist, xp_link, nxprt) {
/*
* Only some transports have idle timers. Don't time
* something out which is just waking up.
@@ -938,94 +1073,118 @@
}
}
- mtx_unlock(&pool->sp_lock);
+ mtx_unlock(&grp->sg_lock);
TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) {
SVC_RELEASE(xprt);
}
- mtx_lock(&pool->sp_lock);
-
+ mtx_lock(&grp->sg_lock);
}
static void
svc_assign_waiting_sockets(SVCPOOL *pool)
{
+ SVCGROUP *grp;
SVCXPRT *xprt;
+ int g;
- TAILQ_FOREACH(xprt, &pool->sp_active, xp_alink) {
- if (!xprt->xp_thread) {
- xprt_assignthread(xprt);
+ for (g = 0; g < pool->sp_groupcount; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ while ((xprt = TAILQ_FIRST(&grp->sg_active)) != NULL) {
+ if (xprt_assignthread(xprt))
+ TAILQ_REMOVE(&grp->sg_active, xprt, xp_alink);
+ else
+ break;
}
+ mtx_unlock(&grp->sg_lock);
}
}
-static bool_t
-svc_request_space_available(SVCPOOL *pool)
+static void
+svc_change_space_used(SVCPOOL *pool, long delta)
{
+ unsigned long value;
- mtx_assert(&pool->sp_lock, MA_OWNED);
-
- if (pool->sp_space_throttled) {
- /*
- * Below the low-water yet? If so, assign any waiting sockets.
- */
- if (pool->sp_space_used < pool->sp_space_low) {
+ value = atomic_fetchadd_long(&pool->sp_space_used, delta) + delta;
+ if (delta > 0) {
+ if (value >= pool->sp_space_high && !pool->sp_space_throttled) {
+ pool->sp_space_throttled = TRUE;
+ pool->sp_space_throttle_count++;
+ }
+ if (value > pool->sp_space_used_highest)
+ pool->sp_space_used_highest = value;
+ } else {
+ if (value < pool->sp_space_low && pool->sp_space_throttled) {
pool->sp_space_throttled = FALSE;
svc_assign_waiting_sockets(pool);
- return TRUE;
}
-
- return FALSE;
- } else {
- if (pool->sp_space_used
- >= pool->sp_space_high) {
- pool->sp_space_throttled = TRUE;
- pool->sp_space_throttle_count++;
- return FALSE;
- }
-
- return TRUE;
}
}
+static bool_t
+svc_request_space_available(SVCPOOL *pool)
+{
+
+ if (pool->sp_space_throttled)
+ return (FALSE);
+ return (TRUE);
+}
+
static void
-svc_run_internal(SVCPOOL *pool, bool_t ismaster)
+svc_run_internal(SVCGROUP *grp, bool_t ismaster)
{
+ SVCPOOL *pool = grp->sg_pool;
SVCTHREAD *st, *stpref;
SVCXPRT *xprt;
enum xprt_stat stat;
struct svc_req *rqstp;
+ struct proc *p;
+ long sz;
int error;
st = mem_alloc(sizeof(*st));
+ mtx_init(&st->st_lock, "st_lock", NULL, MTX_DEF);
+ st->st_pool = pool;
st->st_xprt = NULL;
STAILQ_INIT(&st->st_reqs);
cv_init(&st->st_cond, "rpcsvc");
- mtx_lock(&pool->sp_lock);
- LIST_INSERT_HEAD(&pool->sp_threads, st, st_link);
+ mtx_lock(&grp->sg_lock);
/*
* If we are a new thread which was spawned to cope with
* increased load, set the state back to SVCPOOL_ACTIVE.
*/
- if (pool->sp_state == SVCPOOL_THREADSTARTING)
- pool->sp_state = SVCPOOL_ACTIVE;
+ if (grp->sg_state == SVCPOOL_THREADSTARTING)
+ grp->sg_state = SVCPOOL_ACTIVE;
- while (pool->sp_state != SVCPOOL_CLOSING) {
+ while (grp->sg_state != SVCPOOL_CLOSING) {
/*
+ * Create new thread if requested.
+ */
+ if (grp->sg_state == SVCPOOL_THREADWANTED) {
+ grp->sg_state = SVCPOOL_THREADSTARTING;
+ grp->sg_lastcreatetime = time_uptime;
+ mtx_unlock(&grp->sg_lock);
+ svc_new_thread(grp);
+ mtx_lock(&grp->sg_lock);
+ continue;
+ }
+
+ /*
* Check for idle transports once per second.
*/
- if (time_uptime > pool->sp_lastidlecheck) {
- pool->sp_lastidlecheck = time_uptime;
- svc_checkidle(pool);
+ if (time_uptime > grp->sg_lastidlecheck) {
+ grp->sg_lastidlecheck = time_uptime;
+ svc_checkidle(grp);
}
xprt = st->st_xprt;
- if (!xprt && STAILQ_EMPTY(&st->st_reqs)) {
+ if (!xprt) {
/*
* Enforce maxthreads count.
*/
- if (pool->sp_threadcount > pool->sp_maxthreads)
+ if (grp->sg_threadcount > grp->sg_maxthreads)
break;
/*
@@ -1033,24 +1192,25 @@
* active transport which isn't being serviced
* by a thread.
*/
- if (svc_request_space_available(pool)) {
- TAILQ_FOREACH(xprt, &pool->sp_active,
- xp_alink) {
- if (!xprt->xp_thread) {
- SVC_ACQUIRE(xprt);
- xprt->xp_thread = st;
- st->st_xprt = xprt;
- break;
- }
- }
+ if (svc_request_space_available(pool) &&
+ (xprt = TAILQ_FIRST(&grp->sg_active)) != NULL) {
+ TAILQ_REMOVE(&grp->sg_active, xprt, xp_alink);
+ SVC_ACQUIRE(xprt);
+ xprt->xp_thread = st;
+ st->st_xprt = xprt;
+ continue;
}
- if (st->st_xprt)
- continue;
- LIST_INSERT_HEAD(&pool->sp_idlethreads, st, st_ilink);
- error = cv_timedwait_sig(&st->st_cond, &pool->sp_lock,
- 5 * hz);
- LIST_REMOVE(st, st_ilink);
+ LIST_INSERT_HEAD(&grp->sg_idlethreads, st, st_ilink);
+ if (ismaster || (!ismaster &&
+ grp->sg_threadcount > grp->sg_minthreads))
+ error = cv_timedwait_sig(&st->st_cond,
+ &grp->sg_lock, 5 * hz);
+ else
+ error = cv_wait_sig(&st->st_cond,
+ &grp->sg_lock);
+ if (st->st_xprt == NULL)
+ LIST_REMOVE(st, st_ilink);
/*
* Reduce worker thread count when idle.
@@ -1057,121 +1217,96 @@
*/
if (error == EWOULDBLOCK) {
if (!ismaster
- && (pool->sp_threadcount
- > pool->sp_minthreads)
- && !st->st_xprt
- && STAILQ_EMPTY(&st->st_reqs))
+ && (grp->sg_threadcount
+ > grp->sg_minthreads)
+ && !st->st_xprt)
break;
- }
- if (error == EWOULDBLOCK)
- continue;
- if (error) {
- if (pool->sp_state != SVCPOOL_CLOSING) {
- mtx_unlock(&pool->sp_lock);
+ } else if (error != 0) {
+ KASSERT(error == EINTR || error == ERESTART,
+ ("non-signal error %d", error));
+ mtx_unlock(&grp->sg_lock);
+ p = curproc;
+ PROC_LOCK(p);
+ if (P_SHOULDSTOP(p) ||
+ (p->p_flag & P_TOTAL_STOP) != 0) {
+ thread_suspend_check(0);
+ PROC_UNLOCK(p);
+ mtx_lock(&grp->sg_lock);
+ } else {
+ PROC_UNLOCK(p);
svc_exit(pool);
- mtx_lock(&pool->sp_lock);
+ mtx_lock(&grp->sg_lock);
+ break;
}
- break;
}
-
- if (pool->sp_state == SVCPOOL_THREADWANTED) {
- pool->sp_state = SVCPOOL_THREADSTARTING;
- pool->sp_lastcreatetime = time_uptime;
- mtx_unlock(&pool->sp_lock);
- svc_new_thread(pool);
- mtx_lock(&pool->sp_lock);
- }
continue;
}
+ mtx_unlock(&grp->sg_lock);
- if (xprt) {
- /*
- * Drain the transport socket and queue up any
- * RPCs.
- */
- xprt->xp_lastactive = time_uptime;
- stat = XPRT_IDLE;
- do {
- if (!svc_request_space_available(pool))
- break;
- rqstp = NULL;
- mtx_unlock(&pool->sp_lock);
- stat = svc_getreq(xprt, &rqstp);
- mtx_lock(&pool->sp_lock);
- if (rqstp) {
- /*
- * See if the application has
- * a preference for some other
- * thread.
- */
- stpref = st;
- if (pool->sp_assign)
- stpref = pool->sp_assign(st,
- rqstp);
-
- pool->sp_space_used +=
- rqstp->rq_size;
- if (pool->sp_space_used
- > pool->sp_space_used_highest)
- pool->sp_space_used_highest =
- pool->sp_space_used;
+ /*
+ * Drain the transport socket and queue up any RPCs.
+ */
+ xprt->xp_lastactive = time_uptime;
+ do {
+ if (!svc_request_space_available(pool))
+ break;
+ rqstp = NULL;
+ stat = svc_getreq(xprt, &rqstp);
+ if (rqstp) {
+ svc_change_space_used(pool, rqstp->rq_size);
+ /*
+ * See if the application has a preference
+ * for some other thread.
+ */
+ if (pool->sp_assign) {
+ stpref = pool->sp_assign(st, rqstp);
rqstp->rq_thread = stpref;
STAILQ_INSERT_TAIL(&stpref->st_reqs,
rqstp, rq_link);
- stpref->st_reqcount++;
-
- /*
- * If we assigned the request
- * to another thread, make
- * sure its awake and continue
- * reading from the
- * socket. Otherwise, try to
- * find some other thread to
- * read from the socket and
- * execute the request
- * immediately.
- */
- if (stpref != st) {
- cv_signal(&stpref->st_cond);
- continue;
- } else {
- break;
- }
+ mtx_unlock(&stpref->st_lock);
+ if (stpref != st)
+ rqstp = NULL;
+ } else {
+ rqstp->rq_thread = st;
+ STAILQ_INSERT_TAIL(&st->st_reqs,
+ rqstp, rq_link);
}
- } while (stat == XPRT_MOREREQS
- && pool->sp_state != SVCPOOL_CLOSING);
-
- /*
- * Move this transport to the end of the
- * active list to ensure fairness when
- * multiple transports are active. If this was
- * the last queued request, svc_getreq will
- * end up calling xprt_inactive to remove from
- * the active list.
- */
- xprt->xp_thread = NULL;
- st->st_xprt = NULL;
- if (xprt->xp_active) {
- xprt_assignthread(xprt);
- TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink);
- TAILQ_INSERT_TAIL(&pool->sp_active, xprt,
- xp_alink);
}
- mtx_unlock(&pool->sp_lock);
- SVC_RELEASE(xprt);
- mtx_lock(&pool->sp_lock);
+ } while (rqstp == NULL && stat == XPRT_MOREREQS
+ && grp->sg_state != SVCPOOL_CLOSING);
+
+ /*
+ * Move this transport to the end of the active list to
+ * ensure fairness when multiple transports are active.
+ * If this was the last queued request, svc_getreq will end
+ * up calling xprt_inactive to remove from the active list.
+ */
+ mtx_lock(&grp->sg_lock);
+ xprt->xp_thread = NULL;
+ st->st_xprt = NULL;
+ if (xprt->xp_active) {
+ if (!svc_request_space_available(pool) ||
+ !xprt_assignthread(xprt))
+ TAILQ_INSERT_TAIL(&grp->sg_active,
+ xprt, xp_alink);
}
+ mtx_unlock(&grp->sg_lock);
+ SVC_RELEASE(xprt);
/*
* Execute what we have queued.
*/
+ mtx_lock(&st->st_lock);
while ((rqstp = STAILQ_FIRST(&st->st_reqs)) != NULL) {
- size_t sz = rqstp->rq_size;
- mtx_unlock(&pool->sp_lock);
+ STAILQ_REMOVE_HEAD(&st->st_reqs, rq_link);
+ mtx_unlock(&st->st_lock);
+ sz = (long)rqstp->rq_size;
svc_executereq(rqstp);
- mtx_lock(&pool->sp_lock);
- pool->sp_space_used -= sz;
+ svc_change_space_used(pool, -sz);
+ mtx_lock(&st->st_lock);
}
+ mtx_unlock(&st->st_lock);
+ mtx_lock(&grp->sg_lock);
}
if (st->st_xprt) {
@@ -1179,18 +1314,15 @@
st->st_xprt = NULL;
SVC_RELEASE(xprt);
}
-
KASSERT(STAILQ_EMPTY(&st->st_reqs), ("stray reqs on exit"));
- LIST_REMOVE(st, st_link);
- pool->sp_threadcount--;
-
- mtx_unlock(&pool->sp_lock);
-
+ mtx_destroy(&st->st_lock);
cv_destroy(&st->st_cond);
mem_free(st, sizeof(*st));
+ grp->sg_threadcount--;
if (!ismaster)
- wakeup(pool);
+ wakeup(grp);
+ mtx_unlock(&grp->sg_lock);
}
static void
@@ -1197,18 +1329,20 @@
svc_thread_start(void *arg)
{
- svc_run_internal((SVCPOOL *) arg, FALSE);
+ svc_run_internal((SVCGROUP *) arg, FALSE);
kthread_exit();
}
static void
-svc_new_thread(SVCPOOL *pool)
+svc_new_thread(SVCGROUP *grp)
{
+ SVCPOOL *pool = grp->sg_pool;
struct thread *td;
- pool->sp_threadcount++;
- kthread_add(svc_thread_start, pool,
- pool->sp_proc, &td, 0, 0,
+ mtx_lock(&grp->sg_lock);
+ grp->sg_threadcount++;
+ mtx_unlock(&grp->sg_lock);
+ kthread_add(svc_thread_start, grp, pool->sp_proc, &td, 0, 0,
"%s: service", pool->sp_name);
}
@@ -1215,9 +1349,10 @@
void
svc_run(SVCPOOL *pool)
{
- int i;
+ int g, i;
struct proc *p;
struct thread *td;
+ SVCGROUP *grp;
p = curproc;
td = curthread;
@@ -1225,33 +1360,56 @@
"%s: master", pool->sp_name);
pool->sp_state = SVCPOOL_ACTIVE;
pool->sp_proc = p;
- pool->sp_lastcreatetime = time_uptime;
- pool->sp_threadcount = 1;
- for (i = 1; i < pool->sp_minthreads; i++) {
- svc_new_thread(pool);
+ /* Choose group count based on number of threads and CPUs. */
+ pool->sp_groupcount = max(1, min(SVC_MAXGROUPS,
+ min(pool->sp_maxthreads / 2, mp_ncpus) / 6));
+ for (g = 0; g < pool->sp_groupcount; g++) {
+ grp = &pool->sp_groups[g];
+ grp->sg_minthreads = max(1,
+ pool->sp_minthreads / pool->sp_groupcount);
+ grp->sg_maxthreads = max(1,
+ pool->sp_maxthreads / pool->sp_groupcount);
+ grp->sg_lastcreatetime = time_uptime;
}
- svc_run_internal(pool, TRUE);
+ /* Starting threads */
+ pool->sp_groups[0].sg_threadcount++;
+ for (g = 0; g < pool->sp_groupcount; g++) {
+ grp = &pool->sp_groups[g];
+ for (i = ((g == 0) ? 1 : 0); i < grp->sg_minthreads; i++)
+ svc_new_thread(grp);
+ }
+ svc_run_internal(&pool->sp_groups[0], TRUE);
- mtx_lock(&pool->sp_lock);
- while (pool->sp_threadcount > 0)
- msleep(pool, &pool->sp_lock, 0, "svcexit", 0);
- mtx_unlock(&pool->sp_lock);
+ /* Waiting for threads to stop. */
+ for (g = 0; g < pool->sp_groupcount; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ while (grp->sg_threadcount > 0)
+ msleep(grp, &grp->sg_lock, 0, "svcexit", 0);
+ mtx_unlock(&grp->sg_lock);
+ }
}
void
svc_exit(SVCPOOL *pool)
{
+ SVCGROUP *grp;
SVCTHREAD *st;
+ int g;
- mtx_lock(&pool->sp_lock);
-
pool->sp_state = SVCPOOL_CLOSING;
- LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink)
- cv_signal(&st->st_cond);
-
- mtx_unlock(&pool->sp_lock);
+ for (g = 0; g < pool->sp_groupcount; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ if (grp->sg_state != SVCPOOL_CLOSING) {
+ grp->sg_state = SVCPOOL_CLOSING;
+ LIST_FOREACH(st, &grp->sg_idlethreads, st_ilink)
+ cv_signal(&st->st_cond);
+ }
+ mtx_unlock(&grp->sg_lock);
+ }
}
bool_t
@@ -1289,24 +1447,13 @@
svc_freereq(struct svc_req *rqstp)
{
SVCTHREAD *st;
- SVCXPRT *xprt;
SVCPOOL *pool;
st = rqstp->rq_thread;
- xprt = rqstp->rq_xprt;
- if (xprt)
- pool = xprt->xp_pool;
- else
- pool = NULL;
if (st) {
- mtx_lock(&pool->sp_lock);
- KASSERT(rqstp == STAILQ_FIRST(&st->st_reqs),
- ("Freeing request out of order"));
- STAILQ_REMOVE_HEAD(&st->st_reqs, rq_link);
- st->st_reqcount--;
+ pool = st->st_pool;
if (pool->sp_done)
pool->sp_done(st, rqstp);
- mtx_unlock(&pool->sp_lock);
}
if (rqstp->rq_auth.svc_ah_ops)
Modified: trunk/sys/rpc/svc.h
===================================================================
--- trunk/sys/rpc/svc.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,36 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)svc.h 1.35 88/12/17 SMI
* from: @(#)svc.h 1.27 94/04/25 SMI
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/svc.h 314034 2017-02-21 09:29:46Z avg $
*/
/*
@@ -104,9 +104,11 @@
struct sockaddr **, struct mbuf **);
/* get transport status */
enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
+ /* get transport acknowledge sequence */
+ bool_t (*xp_ack)(struct __rpc_svcxprt *, uint32_t *);
/* send reply */
bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *,
- struct sockaddr *, struct mbuf *);
+ struct sockaddr *, struct mbuf *, uint32_t *);
/* destroy this struct */
void (*xp_destroy)(struct __rpc_svcxprt *);
/* catch-all function */
@@ -136,6 +138,7 @@
#ifdef _KERNEL
struct __rpc_svcpool;
+struct __rpc_svcgroup;
struct __rpc_svcthread;
#endif
@@ -143,6 +146,7 @@
* Server side transport handle. In the kernel, transports have a
* reference count which tracks the number of currently assigned
* worker threads plus one for the service pool's reference.
+ * For NFSv4.1 sessions, a reference is also held for a backchannel.
*/
typedef struct __rpc_svcxprt {
#ifdef _KERNEL
@@ -149,6 +153,7 @@
volatile u_int xp_refs;
struct sx xp_lock;
struct __rpc_svcpool *xp_pool; /* owning pool (see below) */
+ struct __rpc_svcgroup *xp_group; /* owning group (see below) */
TAILQ_ENTRY(__rpc_svcxprt) xp_link;
TAILQ_ENTRY(__rpc_svcxprt) xp_alink;
bool_t xp_registered; /* xprt_register has been called */
@@ -167,6 +172,8 @@
time_t xp_lastactive; /* time of last RPC */
u_int64_t xp_sockref; /* set by nfsv4 to identify socket */
int xp_upcallset; /* socket upcall is set up */
+ uint32_t xp_snd_cnt; /* # of bytes to send to socket */
+ uint32_t xp_snt_cnt; /* # of bytes sent to socket */
#else
int xp_fd;
u_short xp_port; /* associated port number */
@@ -231,7 +238,16 @@
};
TAILQ_HEAD(svc_callout_list, svc_callout);
-struct __rpc_svcthread;
+/*
+ * The services connection loss list
+ * The dispatch routine takes request structs and runs the
+ * apropriate procedure.
+ */
+struct svc_loss_callout {
+ TAILQ_ENTRY(svc_loss_callout) slc_link;
+ void (*slc_dispatch)(SVCXPRT *);
+};
+TAILQ_HEAD(svc_loss_callout_list, svc_loss_callout);
/*
* Service request
@@ -254,6 +270,7 @@
void *rq_p1; /* application workspace */
int rq_p2; /* application workspace */
uint64_t rq_p3; /* application workspace */
+ uint32_t rq_reply_seq; /* reply socket sequence # */
char rq_credarea[3*MAX_AUTH_BYTES];
};
STAILQ_HEAD(svc_reqlist, svc_req);
@@ -276,17 +293,49 @@
* thread to read and execute pending RPCs.
*/
typedef struct __rpc_svcthread {
+ struct mtx_padalign st_lock; /* protects st_reqs field */
+ struct __rpc_svcpool *st_pool;
SVCXPRT *st_xprt; /* transport we are processing */
struct svc_reqlist st_reqs; /* RPC requests to execute */
- int st_reqcount; /* number of queued reqs */
struct cv st_cond; /* sleeping for work */
- LIST_ENTRY(__rpc_svcthread) st_link; /* all threads list */
LIST_ENTRY(__rpc_svcthread) st_ilink; /* idle threads list */
LIST_ENTRY(__rpc_svcthread) st_alink; /* application thread list */
+ int st_p2; /* application workspace */
+ uint64_t st_p3; /* application workspace */
} SVCTHREAD;
LIST_HEAD(svcthread_list, __rpc_svcthread);
/*
+ * A thread group contain all information needed to assign subset of
+ * transports to subset of threads. On systems with many CPUs and many
+ * threads that allows to reduce lock congestion and improve performance.
+ * Hundreds of threads on dozens of CPUs sharing the single pool lock do
+ * not scale well otherwise.
+ */
+TAILQ_HEAD(svcxprt_list, __rpc_svcxprt);
+enum svcpool_state {
+ SVCPOOL_INIT, /* svc_run not called yet */
+ SVCPOOL_ACTIVE, /* normal running state */
+ SVCPOOL_THREADWANTED, /* new service thread requested */
+ SVCPOOL_THREADSTARTING, /* new service thread started */
+ SVCPOOL_CLOSING /* svc_exit called */
+};
+typedef struct __rpc_svcgroup {
+ struct mtx_padalign sg_lock; /* protect the thread/req lists */
+ struct __rpc_svcpool *sg_pool;
+ enum svcpool_state sg_state; /* current pool state */
+ struct svcxprt_list sg_xlist; /* all transports in the group */
+ struct svcxprt_list sg_active; /* transports needing service */
+ struct svcthread_list sg_idlethreads; /* idle service threads */
+
+ int sg_minthreads; /* minimum service thread count */
+ int sg_maxthreads; /* maximum service thread count */
+ int sg_threadcount; /* current service thread count */
+ time_t sg_lastcreatetime; /* when we last started a thread */
+ time_t sg_lastidlecheck; /* when we last checked idle transports */
+} SVCGROUP;
+
+/*
* In the kernel, we can't use global variables to store lists of
* transports etc. since otherwise we could not have two unrelated RPC
* services running, each on its own thread. We solve this by
@@ -298,31 +347,18 @@
* this to support something similar to the Solaris multi-threaded RPC
* server.
*/
-TAILQ_HEAD(svcxprt_list, __rpc_svcxprt);
-enum svcpool_state {
- SVCPOOL_INIT, /* svc_run not called yet */
- SVCPOOL_ACTIVE, /* normal running state */
- SVCPOOL_THREADWANTED, /* new service thread requested */
- SVCPOOL_THREADSTARTING, /* new service thread started */
- SVCPOOL_CLOSING /* svc_exit called */
-};
typedef SVCTHREAD *pool_assign_fn(SVCTHREAD *, struct svc_req *);
typedef void pool_done_fn(SVCTHREAD *, struct svc_req *);
+#define SVC_MAXGROUPS 16
typedef struct __rpc_svcpool {
- struct mtx sp_lock; /* protect the transport lists */
+ struct mtx_padalign sp_lock; /* protect the transport lists */
const char *sp_name; /* pool name (e.g. "nfsd", "NLM" */
enum svcpool_state sp_state; /* current pool state */
struct proc *sp_proc; /* process which is in svc_run */
- struct svcxprt_list sp_xlist; /* all transports in the pool */
- struct svcxprt_list sp_active; /* transports needing service */
struct svc_callout_list sp_callouts; /* (prog,vers)->dispatch list */
- struct svcthread_list sp_threads; /* service threads */
- struct svcthread_list sp_idlethreads; /* idle service threads */
+ struct svc_loss_callout_list sp_lcallouts; /* loss->dispatch list */
int sp_minthreads; /* minimum service thread count */
int sp_maxthreads; /* maximum service thread count */
- int sp_threadcount; /* current service thread count */
- time_t sp_lastcreatetime; /* when we last started a thread */
- time_t sp_lastidlecheck; /* when we last checked idle transports */
/*
* Hooks to allow an application to control request to thread
@@ -336,15 +372,19 @@
* amount of memory used by RPC requests which are queued
* waiting for execution.
*/
- unsigned int sp_space_low;
- unsigned int sp_space_high;
- unsigned int sp_space_used;
- unsigned int sp_space_used_highest;
+ unsigned long sp_space_low;
+ unsigned long sp_space_high;
+ unsigned long sp_space_used;
+ unsigned long sp_space_used_highest;
bool_t sp_space_throttled;
int sp_space_throttle_count;
struct replay_cache *sp_rcache; /* optional replay cache */
struct sysctl_ctx_list sp_sysctl;
+
+ int sp_groupcount; /* Number of groups in the pool. */
+ int sp_nextgroup; /* Next group to assign port. */
+ SVCGROUP sp_groups[SVC_MAXGROUPS]; /* Thread/port groups. */
} SVCPOOL;
#else
@@ -391,9 +431,13 @@
#define SVC_STAT(xprt) \
(*(xprt)->xp_ops->xp_stat)(xprt)
-#define SVC_REPLY(xprt, msg, addr, m) \
- (*(xprt)->xp_ops->xp_reply) ((xprt), (msg), (addr), (m))
+#define SVC_ACK(xprt, ack) \
+ ((xprt)->xp_ops->xp_ack == NULL ? FALSE : \
+ ((ack) == NULL ? TRUE : (*(xprt)->xp_ops->xp_ack)((xprt), (ack))))
+#define SVC_REPLY(xprt, msg, addr, m, seq) \
+ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg), (addr), (m), (seq))
+
#define SVC_DESTROY(xprt) \
(*(xprt)->xp_ops->xp_destroy)(xprt)
@@ -493,7 +537,33 @@
#endif
__END_DECLS
+#ifdef _KERNEL
/*
+ * Service connection loss registration
+ *
+ * svc_loss_reg(xprt, dispatch)
+ * const SVCXPRT *xprt;
+ * const void (*dispatch)();
+ */
+
+__BEGIN_DECLS
+extern bool_t svc_loss_reg(SVCXPRT *, void (*)(SVCXPRT *));
+__END_DECLS
+
+/*
+ * Service connection loss un-registration
+ *
+ * svc_loss_unreg(xprt, dispatch)
+ * const SVCXPRT *xprt;
+ * const void (*dispatch)();
+ */
+
+__BEGIN_DECLS
+extern void svc_loss_unreg(SVCPOOL *, void (*)(SVCXPRT *));
+__END_DECLS
+#endif
+
+/*
* Transport registration.
*
* xprt_register(xprt)
@@ -523,6 +593,7 @@
extern void xprt_active(SVCXPRT *);
extern void xprt_inactive(SVCXPRT *);
extern void xprt_inactive_locked(SVCXPRT *);
+extern void xprt_inactive_self(SVCXPRT *);
__END_DECLS
#endif
@@ -659,6 +730,12 @@
extern void svcpool_destroy(SVCPOOL *pool);
/*
+ * Close a service pool. Similar to svcpool_destroy(), but it does not
+ * free the data structures. As such, the pool can be used again.
+ */
+extern void svcpool_close(SVCPOOL *pool);
+
+/*
* Transport independent svc_create routine.
*/
extern int svc_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *),
@@ -703,6 +780,15 @@
* const size_t recvsize; -- max recv size
*/
+extern SVCXPRT *svc_vc_create_backchannel(SVCPOOL *);
+
+extern void *clnt_bck_create(struct socket *, const rpcprog_t, const rpcvers_t);
+ /*
+ * struct socket *; -- server transport socket
+ * const rpcprog_t prog; -- RPC program number
+ * const rpcvers_t vers; -- RPC program version
+ */
+
/*
* Generic TLI create routine
*/
Modified: trunk/sys/rpc/svc_auth.c
===================================================================
--- trunk/sys/rpc/svc_auth.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc_auth.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: svc_auth.c,v 1.12 2000/07/06 03:10:35 christos Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
@@ -37,7 +37,7 @@
static char sccsid[] = "@(#)svc_auth.c 1.26 89/02/07 Copyr 1984 Sun Micro";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/svc_auth.c 261046 2014-01-22 23:45:27Z mav $");
/*
* svc_auth.c, Server-side rpc authenticator interface.
Modified: trunk/sys/rpc/svc_auth.h
===================================================================
--- trunk/sys/rpc/svc_auth.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc_auth.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,36 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: svc_auth.h,v 1.8 2000/06/02 22:57:57 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)svc_auth.h 1.6 86/07/16 SMI
* @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/svc_auth.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
Modified: trunk/sys/rpc/svc_auth_unix.c
===================================================================
--- trunk/sys/rpc/svc_auth_unix.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc_auth_unix.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,30 +1,30 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -32,7 +32,7 @@
static char *sccsid = "@(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/svc_auth_unix.c 261046 2014-01-22 23:45:27Z mav $");
/*
* svc_auth_unix.c
Modified: trunk/sys/rpc/svc_dg.c
===================================================================
--- trunk/sys/rpc/svc_dg.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc_dg.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: svc_dg.c,v 1.4 2000/07/06 03:10:35 christos Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
@@ -37,7 +37,7 @@
#ident "@(#)svc_dg.c 1.17 94/04/24 SMI"
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/svc_dg.c 303692 2016-08-03 01:19:10Z ngie $");
/*
* svc_dg.c, Server side for connectionless RPC.
@@ -67,7 +67,7 @@
static bool_t svc_dg_recv(SVCXPRT *, struct rpc_msg *,
struct sockaddr **, struct mbuf **);
static bool_t svc_dg_reply(SVCXPRT *, struct rpc_msg *,
- struct sockaddr *, struct mbuf *);
+ struct sockaddr *, struct mbuf *, uint32_t *);
static void svc_dg_destroy(SVCXPRT *);
static bool_t svc_dg_control(SVCXPRT *, const u_int, void *);
static int svc_dg_soupcall(struct socket *so, void *arg, int waitflag);
@@ -143,9 +143,8 @@
return (xprt);
freedata:
(void) printf(svc_dg_str, __no_mem_str);
- if (xprt) {
- svc_xprt_free(xprt);
- }
+ svc_xprt_free(xprt);
+
return (NULL);
}
@@ -197,10 +196,10 @@
* from racing the upcall after our soreadable() call
* returns false.
*/
- mtx_lock(&xprt->xp_pool->sp_lock);
+ SOCKBUF_LOCK(&xprt->xp_socket->so_rcv);
if (!soreadable(xprt->xp_socket))
- xprt_inactive_locked(xprt);
- mtx_unlock(&xprt->xp_pool->sp_lock);
+ xprt_inactive_self(xprt);
+ SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
}
@@ -209,7 +208,7 @@
SOCKBUF_LOCK(&xprt->xp_socket->so_rcv);
soupcall_clear(xprt->xp_socket, SO_RCV);
SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
}
@@ -231,7 +230,7 @@
static bool_t
svc_dg_reply(SVCXPRT *xprt, struct rpc_msg *msg,
- struct sockaddr *addr, struct mbuf *m)
+ struct sockaddr *addr, struct mbuf *m, uint32_t *seq)
{
XDR xdrs;
struct mbuf *mrep;
@@ -238,8 +237,7 @@
bool_t stat = TRUE;
int error;
- MGETHDR(mrep, M_WAIT, MT_DATA);
- mrep->m_len = 0;
+ mrep = m_gethdr(M_WAITOK, MT_DATA);
xdrmbuf_create(&xdrs, mrep, XDR_ENCODE);
Modified: trunk/sys/rpc/svc_generic.c
===================================================================
--- trunk/sys/rpc/svc_generic.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc_generic.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: svc_generic.c,v 1.3 2000/07/06 03:10:35 christos Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
@@ -38,7 +38,7 @@
static char sccsid[] = "@(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/svc_generic.c 281520 2015-04-14 09:58:10Z mav $");
/*
* svc_generic.c, Server side for RPC.
@@ -87,7 +87,8 @@
rpcvers_t versnum, /* Version number */
const char *nettype) /* Networktype token */
{
- int num = 0;
+ int g, num = 0;
+ SVCGROUP *grp;
SVCXPRT *xprt;
struct netconfig *nconf;
void *handle;
@@ -97,11 +98,14 @@
return (0);
}
while ((nconf = __rpc_getconf(handle)) != NULL) {
- mtx_lock(&pool->sp_lock);
- TAILQ_FOREACH(xprt, &pool->sp_xlist, xp_link) {
- if (strcmp(xprt->xp_netid, nconf->nc_netid) == 0) {
+ for (g = 0; g < SVC_MAXGROUPS; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ TAILQ_FOREACH(xprt, &grp->sg_xlist, xp_link) {
+ if (strcmp(xprt->xp_netid, nconf->nc_netid))
+ continue;
/* Found an old one, use it */
- mtx_unlock(&pool->sp_lock);
+ mtx_unlock(&grp->sg_lock);
(void) rpcb_unset(prognum, versnum, nconf);
if (svc_reg(xprt, prognum, versnum,
dispatch, nconf) == FALSE) {
@@ -109,15 +113,15 @@
"svc_create: could not register prog %u vers %u on %s\n",
(unsigned)prognum, (unsigned)versnum,
nconf->nc_netid);
- mtx_lock(&pool->sp_lock);
+ mtx_lock(&grp->sg_lock);
} else {
num++;
- mtx_lock(&pool->sp_lock);
+ mtx_lock(&grp->sg_lock);
break;
}
}
+ mtx_unlock(&grp->sg_lock);
}
- mtx_unlock(&pool->sp_lock);
if (xprt == NULL) {
/* It was not found. Now create a new one */
xprt = svc_tp_create(pool, dispatch, prognum, versnum,
@@ -165,7 +169,7 @@
taddr = uaddr2taddr(nconf, uaddr);
bind.addr = *taddr;
free(taddr, M_RPC);
- bind.qlen = SOMAXCONN;
+ bind.qlen = -1;
xprt = svc_tli_create(pool, NULL, nconf, &bind, 0, 0);
free(bind.addr.buf, M_RPC);
} else {
@@ -253,7 +257,7 @@
goto freedata;
}
}
- solisten(so, SOMAXCONN, curthread);
+ solisten(so, -1, curthread);
} else {
if (bindresvport(so,
(struct sockaddr *)bindaddr->addr.buf)) {
Modified: trunk/sys/rpc/svc_vc.c
===================================================================
--- trunk/sys/rpc/svc_vc.c 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/svc_vc.c 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,32 +1,32 @@
+/* $MidnightBSD$ */
/* $NetBSD: svc_vc.c,v 1.7 2000/08/03 00:01:53 fvdl Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -34,7 +34,7 @@
static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/rpc/svc_vc.c 309503 2016-12-03 19:03:25Z ngie $");
/*
* svc_vc.c, Server side for Connection Oriented based RPC.
@@ -65,6 +65,7 @@
#include <rpc/rpc.h>
+#include <rpc/krpc.h>
#include <rpc/rpc_com.h>
#include <security/mac/mac_framework.h>
@@ -76,13 +77,22 @@
static bool_t svc_vc_null(void);
static void svc_vc_destroy(SVCXPRT *);
static enum xprt_stat svc_vc_stat(SVCXPRT *);
+static bool_t svc_vc_ack(SVCXPRT *, uint32_t *);
static bool_t svc_vc_recv(SVCXPRT *, struct rpc_msg *,
struct sockaddr **, struct mbuf **);
static bool_t svc_vc_reply(SVCXPRT *, struct rpc_msg *,
- struct sockaddr *, struct mbuf *);
+ struct sockaddr *, struct mbuf *, uint32_t *seq);
static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in);
static bool_t svc_vc_rendezvous_control (SVCXPRT *xprt, const u_int rq,
void *in);
+static void svc_vc_backchannel_destroy(SVCXPRT *);
+static enum xprt_stat svc_vc_backchannel_stat(SVCXPRT *);
+static bool_t svc_vc_backchannel_recv(SVCXPRT *, struct rpc_msg *,
+ struct sockaddr **, struct mbuf **);
+static bool_t svc_vc_backchannel_reply(SVCXPRT *, struct rpc_msg *,
+ struct sockaddr *, struct mbuf *, uint32_t *);
+static bool_t svc_vc_backchannel_control(SVCXPRT *xprt, const u_int rq,
+ void *in);
static SVCXPRT *svc_vc_create_conn(SVCPOOL *pool, struct socket *so,
struct sockaddr *raddr);
static int svc_vc_accept(struct socket *head, struct socket **sop);
@@ -92,7 +102,7 @@
.xp_recv = svc_vc_rendezvous_recv,
.xp_stat = svc_vc_rendezvous_stat,
.xp_reply = (bool_t (*)(SVCXPRT *, struct rpc_msg *,
- struct sockaddr *, struct mbuf *))svc_vc_null,
+ struct sockaddr *, struct mbuf *, uint32_t *))svc_vc_null,
.xp_destroy = svc_vc_rendezvous_destroy,
.xp_control = svc_vc_rendezvous_control
};
@@ -100,17 +110,18 @@
static struct xp_ops svc_vc_ops = {
.xp_recv = svc_vc_recv,
.xp_stat = svc_vc_stat,
+ .xp_ack = svc_vc_ack,
.xp_reply = svc_vc_reply,
.xp_destroy = svc_vc_destroy,
.xp_control = svc_vc_control
};
-struct cf_conn { /* kept in xprt->xp_p1 for actual connection */
- enum xprt_stat strm_stat;
- struct mbuf *mpending; /* unparsed data read from the socket */
- struct mbuf *mreq; /* current record being built from mpending */
- uint32_t resid; /* number of bytes needed for fragment */
- bool_t eor; /* reading last fragment of current record */
+static struct xp_ops svc_vc_backchannel_ops = {
+ .xp_recv = svc_vc_backchannel_recv,
+ .xp_stat = svc_vc_backchannel_stat,
+ .xp_reply = svc_vc_backchannel_reply,
+ .xp_destroy = svc_vc_backchannel_destroy,
+ .xp_control = svc_vc_backchannel_control
};
/*
@@ -137,8 +148,12 @@
struct sockaddr* sa;
int error;
- if (so->so_state & SS_ISCONNECTED) {
+ SOCK_LOCK(so);
+ if (so->so_state & (SS_ISCONNECTED|SS_ISDISCONNECTED)) {
+ SOCK_UNLOCK(so);
+ CURVNET_SET(so->so_vnet);
error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa);
+ CURVNET_RESTORE();
if (error)
return (NULL);
xprt = svc_vc_create_conn(pool, so, sa);
@@ -145,6 +160,7 @@
free(sa, M_SONAME);
return (xprt);
}
+ SOCK_UNLOCK(so);
xprt = svc_xprt_alloc();
sx_init(&xprt->xp_lock, "xprt->xp_lock");
@@ -154,7 +170,9 @@
xprt->xp_p2 = NULL;
xprt->xp_ops = &svc_vc_rendezvous_ops;
+ CURVNET_SET(so->so_vnet);
error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
+ CURVNET_RESTORE();
if (error) {
goto cleanup_svc_vc_create;
}
@@ -164,7 +182,7 @@
xprt_register(xprt);
- solisten(so, SOMAXCONN, curthread);
+ solisten(so, -1, curthread);
SOCKBUF_LOCK(&so->so_rcv);
xprt->xp_upcallset = 1;
@@ -172,9 +190,11 @@
SOCKBUF_UNLOCK(&so->so_rcv);
return (xprt);
+
cleanup_svc_vc_create:
- if (xprt)
- svc_xprt_free(xprt);
+ sx_destroy(&xprt->xp_lock);
+ svc_xprt_free(xprt);
+
return (NULL);
}
@@ -184,8 +204,8 @@
SVCXPRT *
svc_vc_create_conn(SVCPOOL *pool, struct socket *so, struct sockaddr *raddr)
{
- SVCXPRT *xprt = NULL;
- struct cf_conn *cd = NULL;
+ SVCXPRT *xprt;
+ struct cf_conn *cd;
struct sockaddr* sa = NULL;
struct sockopt opt;
int one = 1;
@@ -234,7 +254,9 @@
memcpy(&xprt->xp_rtaddr, raddr, raddr->sa_len);
+ CURVNET_SET(so->so_vnet);
error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
+ CURVNET_RESTORE();
if (error)
goto cleanup_svc_vc_create;
@@ -258,15 +280,36 @@
return (xprt);
cleanup_svc_vc_create:
- if (xprt) {
- mem_free(xprt, sizeof(*xprt));
- }
- if (cd)
- mem_free(cd, sizeof(*cd));
+ sx_destroy(&xprt->xp_lock);
+ svc_xprt_free(xprt);
+ mem_free(cd, sizeof(*cd));
+
return (NULL);
}
/*
+ * Create a new transport for a backchannel on a clnt_vc socket.
+ */
+SVCXPRT *
+svc_vc_create_backchannel(SVCPOOL *pool)
+{
+ SVCXPRT *xprt = NULL;
+ struct cf_conn *cd = NULL;
+
+ cd = mem_alloc(sizeof(*cd));
+ cd->strm_stat = XPRT_IDLE;
+
+ xprt = svc_xprt_alloc();
+ sx_init(&xprt->xp_lock, "xprt->xp_lock");
+ xprt->xp_pool = pool;
+ xprt->xp_socket = NULL;
+ xprt->xp_p1 = cd;
+ xprt->xp_p2 = NULL;
+ xprt->xp_ops = &svc_vc_backchannel_ops;
+ return (xprt);
+}
+
+/*
* This does all of the accept except the final call to soaccept. The
* caller will call soaccept after dropping its locks (soaccept may
* call malloc).
@@ -348,15 +391,11 @@
* We must re-test for new connections after taking
* the lock to protect us in the case where a new
* connection arrives after our call to accept fails
- * with EWOULDBLOCK. The pool lock protects us from
- * racing the upcall after our TAILQ_EMPTY() call
- * returns false.
+ * with EWOULDBLOCK.
*/
ACCEPT_LOCK();
- mtx_lock(&xprt->xp_pool->sp_lock);
if (TAILQ_EMPTY(&xprt->xp_socket->so_comp))
- xprt_inactive_locked(xprt);
- mtx_unlock(&xprt->xp_pool->sp_lock);
+ xprt_inactive_self(xprt);
ACCEPT_UNLOCK();
sx_xunlock(&xprt->xp_lock);
return (FALSE);
@@ -369,7 +408,7 @@
soupcall_clear(xprt->xp_socket, SO_RCV);
}
SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
}
@@ -376,7 +415,7 @@
sx_xunlock(&xprt->xp_lock);
- sa = 0;
+ sa = NULL;
error = soaccept(so, &sa);
if (error) {
@@ -422,7 +461,6 @@
}
SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
- sx_destroy(&xprt->xp_lock);
if (xprt->xp_socket)
(void)soclose(xprt->xp_socket);
@@ -452,6 +490,22 @@
mem_free(cd, sizeof(*cd));
}
+static void
+svc_vc_backchannel_destroy(SVCXPRT *xprt)
+{
+ struct cf_conn *cd = (struct cf_conn *)xprt->xp_p1;
+ struct mbuf *m, *m2;
+
+ svc_xprt_free(xprt);
+ m = cd->mreq;
+ while (m != NULL) {
+ m2 = m;
+ m = m->m_nextpkt;
+ m_freem(m2);
+ }
+ mem_free(cd, sizeof(*cd));
+}
+
/*ARGSUSED*/
static bool_t
svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in)
@@ -466,12 +520,17 @@
return (FALSE);
}
+static bool_t
+svc_vc_backchannel_control(SVCXPRT *xprt, const u_int rq, void *in)
+{
+
+ return (FALSE);
+}
+
static enum xprt_stat
svc_vc_stat(SVCXPRT *xprt)
{
struct cf_conn *cd;
- struct mbuf *m;
- size_t n;
cd = (struct cf_conn *)(xprt->xp_p1);
@@ -478,32 +537,116 @@
if (cd->strm_stat == XPRT_DIED)
return (XPRT_DIED);
+ if (cd->mreq != NULL && cd->resid == 0 && cd->eor)
+ return (XPRT_MOREREQS);
+
+ if (soreadable(xprt->xp_socket))
+ return (XPRT_MOREREQS);
+
+ return (XPRT_IDLE);
+}
+
+static bool_t
+svc_vc_ack(SVCXPRT *xprt, uint32_t *ack)
+{
+
+ *ack = atomic_load_acq_32(&xprt->xp_snt_cnt);
+ *ack -= xprt->xp_socket->so_snd.sb_cc;
+ return (TRUE);
+}
+
+static enum xprt_stat
+svc_vc_backchannel_stat(SVCXPRT *xprt)
+{
+ struct cf_conn *cd;
+
+ cd = (struct cf_conn *)(xprt->xp_p1);
+
+ if (cd->mreq != NULL)
+ return (XPRT_MOREREQS);
+
+ return (XPRT_IDLE);
+}
+
+/*
+ * If we have an mbuf chain in cd->mpending, try to parse a record from it,
+ * leaving the result in cd->mreq. If we don't have a complete record, leave
+ * the partial result in cd->mreq and try to read more from the socket.
+ */
+static int
+svc_vc_process_pending(SVCXPRT *xprt)
+{
+ struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1;
+ struct socket *so = xprt->xp_socket;
+ struct mbuf *m;
+
/*
- * Return XPRT_MOREREQS if we have buffered data and we are
- * mid-record or if we have enough data for a record
- * marker. Since this is only a hint, we read mpending and
- * resid outside the lock. We do need to take the lock if we
- * have to traverse the mbuf chain.
+ * If cd->resid is non-zero, we have part of the
+ * record already, otherwise we are expecting a record
+ * marker.
*/
- if (cd->mpending) {
- if (cd->resid)
- return (XPRT_MOREREQS);
- n = 0;
- sx_xlock(&xprt->xp_lock);
+ if (!cd->resid && cd->mpending) {
+ /*
+ * See if there is enough data buffered to
+ * make up a record marker. Make sure we can
+ * handle the case where the record marker is
+ * split across more than one mbuf.
+ */
+ size_t n = 0;
+ uint32_t header;
+
m = cd->mpending;
- while (m && n < sizeof(uint32_t)) {
+ while (n < sizeof(uint32_t) && m) {
n += m->m_len;
m = m->m_next;
}
- sx_xunlock(&xprt->xp_lock);
- if (n >= sizeof(uint32_t))
- return (XPRT_MOREREQS);
+ if (n < sizeof(uint32_t)) {
+ so->so_rcv.sb_lowat = sizeof(uint32_t) - n;
+ return (FALSE);
+ }
+ m_copydata(cd->mpending, 0, sizeof(header),
+ (char *)&header);
+ header = ntohl(header);
+ cd->eor = (header & 0x80000000) != 0;
+ cd->resid = header & 0x7fffffff;
+ m_adj(cd->mpending, sizeof(uint32_t));
}
- if (soreadable(xprt->xp_socket))
- return (XPRT_MOREREQS);
+ /*
+ * Start pulling off mbufs from cd->mpending
+ * until we either have a complete record or
+ * we run out of data. We use m_split to pull
+ * data - it will pull as much as possible and
+ * split the last mbuf if necessary.
+ */
+ while (cd->mpending && cd->resid) {
+ m = cd->mpending;
+ if (cd->mpending->m_next
+ || cd->mpending->m_len > cd->resid)
+ cd->mpending = m_split(cd->mpending,
+ cd->resid, M_WAITOK);
+ else
+ cd->mpending = NULL;
+ if (cd->mreq)
+ m_last(cd->mreq)->m_next = m;
+ else
+ cd->mreq = m;
+ while (m) {
+ cd->resid -= m->m_len;
+ m = m->m_next;
+ }
+ }
- return (XPRT_IDLE);
+ /*
+ * Block receive upcalls if we have more data pending,
+ * otherwise report our need.
+ */
+ if (cd->mpending)
+ so->so_rcv.sb_lowat = INT_MAX;
+ else
+ so->so_rcv.sb_lowat =
+ imax(1, imin(cd->resid, so->so_rcv.sb_hiwat / 2));
+ return (TRUE);
}
static bool_t
@@ -513,8 +656,10 @@
struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1;
struct uio uio;
struct mbuf *m;
+ struct socket* so = xprt->xp_socket;
XDR xdrs;
int error, rcvflag;
+ uint32_t xid_plus_direction[2];
/*
* Serialise access to the socket and our own record parsing
@@ -523,99 +668,68 @@
sx_xlock(&xprt->xp_lock);
for (;;) {
- /*
- * If we have an mbuf chain in cd->mpending, try to parse a
- * record from it, leaving the result in cd->mreq. If we don't
- * have a complete record, leave the partial result in
- * cd->mreq and try to read more from the socket.
- */
- if (cd->mpending) {
- /*
- * If cd->resid is non-zero, we have part of the
- * record already, otherwise we are expecting a record
- * marker.
- */
- if (!cd->resid) {
- /*
- * See if there is enough data buffered to
- * make up a record marker. Make sure we can
- * handle the case where the record marker is
- * split across more than one mbuf.
- */
- size_t n = 0;
- uint32_t header;
+ /* If we have no request ready, check pending queue. */
+ while (cd->mpending &&
+ (cd->mreq == NULL || cd->resid != 0 || !cd->eor)) {
+ if (!svc_vc_process_pending(xprt))
+ break;
+ }
- m = cd->mpending;
- while (n < sizeof(uint32_t) && m) {
- n += m->m_len;
- m = m->m_next;
- }
- if (n < sizeof(uint32_t))
- goto readmore;
- m_copydata(cd->mpending, 0, sizeof(header),
- (char *)&header);
- header = ntohl(header);
- cd->eor = (header & 0x80000000) != 0;
- cd->resid = header & 0x7fffffff;
- m_adj(cd->mpending, sizeof(uint32_t));
- }
+ /* Process and return complete request in cd->mreq. */
+ if (cd->mreq != NULL && cd->resid == 0 && cd->eor) {
/*
- * Start pulling off mbufs from cd->mpending
- * until we either have a complete record or
- * we run out of data. We use m_split to pull
- * data - it will pull as much as possible and
- * split the last mbuf if necessary.
+ * Now, check for a backchannel reply.
+ * The XID is in the first uint32_t of the reply
+ * and the message direction is the second one.
*/
- while (cd->mpending && cd->resid) {
- m = cd->mpending;
- if (cd->mpending->m_next
- || cd->mpending->m_len > cd->resid)
- cd->mpending = m_split(cd->mpending,
- cd->resid, M_WAIT);
- else
- cd->mpending = NULL;
- if (cd->mreq)
- m_last(cd->mreq)->m_next = m;
- else
- cd->mreq = m;
- while (m) {
- cd->resid -= m->m_len;
- m = m->m_next;
+ if ((cd->mreq->m_len >= sizeof(xid_plus_direction) ||
+ m_length(cd->mreq, NULL) >=
+ sizeof(xid_plus_direction)) &&
+ xprt->xp_p2 != NULL) {
+ m_copydata(cd->mreq, 0,
+ sizeof(xid_plus_direction),
+ (char *)xid_plus_direction);
+ xid_plus_direction[0] =
+ ntohl(xid_plus_direction[0]);
+ xid_plus_direction[1] =
+ ntohl(xid_plus_direction[1]);
+ /* Check message direction. */
+ if (xid_plus_direction[1] == REPLY) {
+ clnt_bck_svccall(xprt->xp_p2,
+ cd->mreq,
+ xid_plus_direction[0]);
+ cd->mreq = NULL;
+ continue;
}
}
- /*
- * If cd->resid is zero now, we have managed to
- * receive a record fragment from the stream. Check
- * for the end-of-record mark to see if we need more.
- */
- if (cd->resid == 0) {
- if (!cd->eor)
- continue;
+ xdrmbuf_create(&xdrs, cd->mreq, XDR_DECODE);
+ cd->mreq = NULL;
- /*
- * Success - we have a complete record in
- * cd->mreq.
- */
- xdrmbuf_create(&xdrs, cd->mreq, XDR_DECODE);
- cd->mreq = NULL;
- sx_xunlock(&xprt->xp_lock);
+ /* Check for next request in a pending queue. */
+ svc_vc_process_pending(xprt);
+ if (cd->mreq == NULL || cd->resid != 0) {
+ SOCKBUF_LOCK(&so->so_rcv);
+ if (!soreadable(so))
+ xprt_inactive_self(xprt);
+ SOCKBUF_UNLOCK(&so->so_rcv);
+ }
- if (! xdr_callmsg(&xdrs, msg)) {
- XDR_DESTROY(&xdrs);
- return (FALSE);
- }
+ sx_xunlock(&xprt->xp_lock);
- *addrp = NULL;
- *mp = xdrmbuf_getall(&xdrs);
+ if (! xdr_callmsg(&xdrs, msg)) {
XDR_DESTROY(&xdrs);
+ return (FALSE);
+ }
- return (TRUE);
- }
+ *addrp = NULL;
+ *mp = xdrmbuf_getall(&xdrs);
+ XDR_DESTROY(&xdrs);
+
+ return (TRUE);
}
- readmore:
/*
* The socket upcall calls xprt_active() which will eventually
* cause the server to call us here. We attempt to
@@ -628,8 +742,7 @@
uio.uio_td = curthread;
m = NULL;
rcvflag = MSG_DONTWAIT;
- error = soreceive(xprt->xp_socket, NULL, &uio, &m, NULL,
- &rcvflag);
+ error = soreceive(so, NULL, &uio, &m, NULL, &rcvflag);
if (error == EWOULDBLOCK) {
/*
@@ -637,26 +750,24 @@
* taking the lock to protect us in the case
* where a new packet arrives on the socket
* after our call to soreceive fails with
- * EWOULDBLOCK. The pool lock protects us from
- * racing the upcall after our soreadable()
- * call returns false.
+ * EWOULDBLOCK.
*/
- mtx_lock(&xprt->xp_pool->sp_lock);
- if (!soreadable(xprt->xp_socket))
- xprt_inactive_locked(xprt);
- mtx_unlock(&xprt->xp_pool->sp_lock);
+ SOCKBUF_LOCK(&so->so_rcv);
+ if (!soreadable(so))
+ xprt_inactive_self(xprt);
+ SOCKBUF_UNLOCK(&so->so_rcv);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
}
if (error) {
- SOCKBUF_LOCK(&xprt->xp_socket->so_rcv);
+ SOCKBUF_LOCK(&so->so_rcv);
if (xprt->xp_upcallset) {
xprt->xp_upcallset = 0;
- soupcall_clear(xprt->xp_socket, SO_RCV);
+ soupcall_clear(so, SO_RCV);
}
- SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
- xprt_inactive(xprt);
+ SOCKBUF_UNLOCK(&so->so_rcv);
+ xprt_inactive_self(xprt);
cd->strm_stat = XPRT_DIED;
sx_xunlock(&xprt->xp_lock);
return (FALSE);
@@ -666,7 +777,7 @@
/*
* EOF - the other end has closed the socket.
*/
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
cd->strm_stat = XPRT_DIED;
sx_xunlock(&xprt->xp_lock);
return (FALSE);
@@ -680,19 +791,113 @@
}
static bool_t
+svc_vc_backchannel_recv(SVCXPRT *xprt, struct rpc_msg *msg,
+ struct sockaddr **addrp, struct mbuf **mp)
+{
+ struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1;
+ struct ct_data *ct;
+ struct mbuf *m;
+ XDR xdrs;
+
+ sx_xlock(&xprt->xp_lock);
+ ct = (struct ct_data *)xprt->xp_p2;
+ if (ct == NULL) {
+ sx_xunlock(&xprt->xp_lock);
+ return (FALSE);
+ }
+ mtx_lock(&ct->ct_lock);
+ m = cd->mreq;
+ if (m == NULL) {
+ xprt_inactive_self(xprt);
+ mtx_unlock(&ct->ct_lock);
+ sx_xunlock(&xprt->xp_lock);
+ return (FALSE);
+ }
+ cd->mreq = m->m_nextpkt;
+ mtx_unlock(&ct->ct_lock);
+ sx_xunlock(&xprt->xp_lock);
+
+ xdrmbuf_create(&xdrs, m, XDR_DECODE);
+ if (! xdr_callmsg(&xdrs, msg)) {
+ XDR_DESTROY(&xdrs);
+ return (FALSE);
+ }
+ *addrp = NULL;
+ *mp = xdrmbuf_getall(&xdrs);
+ XDR_DESTROY(&xdrs);
+ return (TRUE);
+}
+
+static bool_t
svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg,
- struct sockaddr *addr, struct mbuf *m)
+ struct sockaddr *addr, struct mbuf *m, uint32_t *seq)
{
XDR xdrs;
struct mbuf *mrep;
bool_t stat = TRUE;
+ int error, len;
+
+ /*
+ * Leave space for record mark.
+ */
+ mrep = m_gethdr(M_WAITOK, MT_DATA);
+ mrep->m_data += sizeof(uint32_t);
+
+ xdrmbuf_create(&xdrs, mrep, XDR_ENCODE);
+
+ if (msg->rm_reply.rp_stat == MSG_ACCEPTED &&
+ msg->rm_reply.rp_acpt.ar_stat == SUCCESS) {
+ if (!xdr_replymsg(&xdrs, msg))
+ stat = FALSE;
+ else
+ xdrmbuf_append(&xdrs, m);
+ } else {
+ stat = xdr_replymsg(&xdrs, msg);
+ }
+
+ if (stat) {
+ m_fixhdr(mrep);
+
+ /*
+ * Prepend a record marker containing the reply length.
+ */
+ M_PREPEND(mrep, sizeof(uint32_t), M_WAITOK);
+ len = mrep->m_pkthdr.len;
+ *mtod(mrep, uint32_t *) =
+ htonl(0x80000000 | (len - sizeof(uint32_t)));
+ atomic_add_acq_32(&xprt->xp_snd_cnt, len);
+ error = sosend(xprt->xp_socket, NULL, NULL, mrep, NULL,
+ 0, curthread);
+ if (!error) {
+ atomic_add_rel_32(&xprt->xp_snt_cnt, len);
+ if (seq)
+ *seq = xprt->xp_snd_cnt;
+ stat = TRUE;
+ } else
+ atomic_subtract_32(&xprt->xp_snd_cnt, len);
+ } else {
+ m_freem(mrep);
+ }
+
+ XDR_DESTROY(&xdrs);
+
+ return (stat);
+}
+
+static bool_t
+svc_vc_backchannel_reply(SVCXPRT *xprt, struct rpc_msg *msg,
+ struct sockaddr *addr, struct mbuf *m, uint32_t *seq)
+{
+ struct ct_data *ct;
+ XDR xdrs;
+ struct mbuf *mrep;
+ bool_t stat = TRUE;
int error;
/*
* Leave space for record mark.
*/
- MGETHDR(mrep, M_WAIT, MT_DATA);
- mrep->m_len = 0;
+ mrep = m_gethdr(M_WAITOK, MT_DATA);
mrep->m_data += sizeof(uint32_t);
xdrmbuf_create(&xdrs, mrep, XDR_ENCODE);
@@ -713,12 +918,18 @@
/*
* Prepend a record marker containing the reply length.
*/
- M_PREPEND(mrep, sizeof(uint32_t), M_WAIT);
+ M_PREPEND(mrep, sizeof(uint32_t), M_WAITOK);
*mtod(mrep, uint32_t *) =
htonl(0x80000000 | (mrep->m_pkthdr.len
- sizeof(uint32_t)));
- error = sosend(xprt->xp_socket, NULL, NULL, mrep, NULL,
- 0, curthread);
+ sx_xlock(&xprt->xp_lock);
+ ct = (struct ct_data *)xprt->xp_p2;
+ if (ct != NULL)
+ error = sosend(ct->ct_socket, NULL, NULL, mrep, NULL,
+ 0, curthread);
+ else
+ error = EPIPE;
+ sx_xunlock(&xprt->xp_lock);
if (!error) {
stat = TRUE;
}
@@ -727,7 +938,6 @@
}
XDR_DESTROY(&xdrs);
- xprt->xp_p2 = NULL;
return (stat);
}
@@ -744,7 +954,8 @@
{
SVCXPRT *xprt = (SVCXPRT *) arg;
- xprt_active(xprt);
+ if (soreadable(xprt->xp_socket))
+ xprt_active(xprt);
return (SU_OK);
}
Modified: trunk/sys/rpc/types.h
===================================================================
--- trunk/sys/rpc/types.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/types.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,36 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)types.h 1.18 87/07/24 SMI
* from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/types.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
Modified: trunk/sys/rpc/xdr.h
===================================================================
--- trunk/sys/rpc/xdr.h 2018-05-25 12:44:45 UTC (rev 9914)
+++ trunk/sys/rpc/xdr.h 2018-05-25 12:45:40 UTC (rev 9915)
@@ -1,36 +1,36 @@
+/* $MidnightBSD$ */
/* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
* from: @(#)xdr.h 1.19 87/04/22 SMI
* from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/rpc/xdr.h 261046 2014-01-22 23:45:27Z mav $
*/
/*
More information about the Midnightbsd-cvs
mailing list