public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: trond.myklebust@netapp.com, bfields@citi.umich.edu
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 3/8] SUNRPC: Split portmap unregister API into separate function
Date: Mon, 30 Jun 2008 18:45:45 -0400	[thread overview]
Message-ID: <20080630224545.24887.61618.stgit@ellison.1015granger.net> (raw)
In-Reply-To: <20080630224147.24887.18730.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>

Create a separate server-level interface for unregistering RPC services.

The mechanics of and the API for registering and unregistering RPC
services will diverge further as support for IPv6 is added.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 net/sunrpc/svc.c |   71 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 59 insertions(+), 12 deletions(-)


diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index d0e7865..a41b163 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -27,6 +27,8 @@
 
 #define RPCDBG_FACILITY	RPCDBG_SVCDSP
 
+static void svc_unregister(const struct svc_serv *serv);
+
 #define svc_serv_is_pooled(serv)    ((serv)->sv_function)
 
 /*
@@ -426,9 +428,8 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
 		spin_lock_init(&pool->sp_lock);
 	}
 
-
 	/* Remove any stale portmap registrations */
-	svc_register(serv, 0, 0);
+	svc_unregister(serv);
 
 	return serv;
 }
@@ -496,8 +497,7 @@ svc_destroy(struct svc_serv *serv)
 	if (svc_serv_is_pooled(serv))
 		svc_pool_map_put();
 
-	/* Unregister service with the portmapper */
-	svc_register(serv, 0, 0);
+	svc_unregister(serv);
 	kfree(serv->sv_pools);
 	kfree(serv);
 }
@@ -758,12 +758,10 @@ int
 svc_register(struct svc_serv *serv, int proto, unsigned short port)
 {
 	struct svc_program	*progp;
-	unsigned long		flags;
 	unsigned int		i;
 	int			error = 0, dummy;
 
-	if (!port)
-		clear_thread_flag(TIF_SIGPENDING);
+	BUG_ON(proto == 0 && port == 0);
 
 	for (progp = serv->sv_program; progp; progp = progp->pg_next) {
 		for (i = 0; i < progp->pg_nvers; i++) {
@@ -791,13 +789,62 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
 		}
 	}
 
-	if (!port) {
-		spin_lock_irqsave(&current->sighand->siglock, flags);
-		recalc_sigpending();
-		spin_unlock_irqrestore(&current->sighand->siglock, flags);
+	return error;
+}
+
+/*
+ * The local rpcbind daemon listens on either only IPv6 or only
+ * IPv4.  The kernel can't tell how it's configured.
+ *
+ * However, AF_INET addresses are mapped to AF_INET6 in IPv6-only
+ * configurations, so even an unregistration request on AF_INET
+ * will get to a local rpcbind daemon listening only on AF_INET6.
+ *
+ * So we always unregister via AF_INET (the loopback address is
+ * fairly unambiguous anyway).
+ *
+ * At this point we don't need rpcbind version 4 for unregistration:
+ * A v2 UNSET request will clear all transports (netids), addresses,
+ * and address families for [program, version].
+ *
+ * This should allow automatic support for both an all-IPv4 and
+ * an all-IPv6 configuration.
+ */
+static void __svc_unregister(struct svc_program *program, u32 version)
+{
+	int error, boolean;
+
+	error = rpcb_register(program->pg_prog, version, 0, 0, &boolean);
+	dprintk("svc: svc_unregister(%sv%u), error %d, %s\n",
+			program->pg_name, version, error,
+			(boolean ? "succeeded" : "failed"));
+}
+
+/*
+ * All transport protocols and ports for this service are removed from
+ * the local rpcbind database.  The result of unregistration is reported
+ * via dprintk for those who want verification of the result, but is
+ * otherwise not important.
+ */
+static void svc_unregister(const struct svc_serv *serv)
+{
+	struct svc_program *program;
+	unsigned long flags;
+	u32 version;
+
+	clear_thread_flag(TIF_SIGPENDING);
+
+	for (program = serv->sv_program; program; program = program->pg_next) {
+		for (version = 0; version < program->pg_nvers; version++) {
+			if (program->pg_vers[version] == NULL)
+				continue;
+			__svc_unregister(program, version);
+		}
 	}
 
-	return error;
+	spin_lock_irqsave(&current->sighand->siglock, flags);
+	recalc_sigpending();
+	spin_unlock_irqrestore(&current->sighand->siglock, flags);
 }
 
 /*


  parent reply	other threads:[~2008-06-30 22:46 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-30 22:45 [PATCH 0/8] rpcbind v4 support in net/sunrpc/svc* Chuck Lever
     [not found] ` <20080630224147.24887.18730.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-06-30 22:45   ` [PATCH 1/8] SUNRPC: Add address family field to svc_serv data structure Chuck Lever
     [not found]     ` <20080630224529.24887.47412.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-07-03 21:14       ` J. Bruce Fields
2008-07-04 13:45         ` Chuck Lever
2008-06-30 22:45   ` [PATCH 2/8] SUNRPC: Use proper INADDR_ANY when setting up RPC services on IPv6 Chuck Lever
2008-06-30 22:45   ` Chuck Lever [this message]
     [not found]     ` <20080630224545.24887.61618.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-07-18 23:21       ` [PATCH 3/8] SUNRPC: Split portmap unregister API into separate function J. Bruce Fields
2008-07-21  3:17         ` Chuck Lever
     [not found]           ` <76bd70e30807202017hec9d1der1bbbf5c5dcedac45-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-23 16:58             ` J. Bruce Fields
2008-06-30 22:45   ` [PATCH 4/8] SUNRPC: Clean up svc_register Chuck Lever
     [not found]     ` <20080630224553.24887.73617.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-07-18 23:29       ` J. Bruce Fields
2008-07-21 19:24         ` Chuck Lever
2008-06-30 22:46   ` [PATCH 5/8] SUNRPC: Use new rpcb_v4_register() interface in svc_register() Chuck Lever
     [not found]     ` <20080630224601.24887.59241.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-07-18 23:40       ` J. Bruce Fields
2008-07-21 19:26         ` Chuck Lever
2008-06-30 22:46   ` [PATCH 6/8] SUNRPC: Add kernel build option to disable server-side use of rpcbind v3/v4 Chuck Lever
     [not found]     ` <20080630224609.24887.20585.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-07-18 23:42       ` J. Bruce Fields
2008-07-21 19:30         ` Chuck Lever
     [not found]           ` <76bd70e30807211230y4b7c2b21qa89d8cca05e08dab-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-30 16:18             ` J. Bruce Fields
2008-06-30 22:46   ` [PATCH 7/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets Chuck Lever
     [not found]     ` <20080630224616.24887.13171.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-07-19  1:05       ` J. Bruce Fields
2008-07-21 19:32         ` Chuck Lever
2008-06-30 22:46   ` [PATCH 8/8] NFS: Enable NFSv4 callback server to listen on AF_INET6 sockets Chuck Lever
2008-07-19  1:07   ` [PATCH 0/8] rpcbind v4 support in net/sunrpc/svc* J. Bruce Fields
2008-07-20 21:17     ` J. Bruce Fields
2008-07-21 19:07       ` Chuck Lever
     [not found]         ` <76bd70e30807211207q4fc509e0h4a1a560fe8097de7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-23 21:53           ` J. Bruce Fields
2008-07-23 22:47             ` Chuck Lever
     [not found]               ` <76bd70e30807231547j19e9fd8dv7a14c2795226dcd6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-23 23:05                 ` Trond Myklebust

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080630224545.24887.61618.stgit@ellison.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=bfields@citi.umich.edu \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@netapp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox