]> err.no Git - linux-2.6/blobdiff - net/sunrpc/rpcb_clnt.c
the scheduled ieee80211 softmac removal
[linux-2.6] / net / sunrpc / rpcb_clnt.c
index c1310f7962248eff81b5bb25ebee42150199794e..56aa018dce3a026b063262e086b6456e2af6b1fa 100644 (file)
@@ -54,45 +54,6 @@ enum {
 #define RPCB_HIGHPROC_3                RPCBPROC_TADDR2UADDR
 #define RPCB_HIGHPROC_4                RPCBPROC_GETSTAT
 
-/*
- * r_addr
- *
- * Quoting RFC 3530, section 2.2:
- *
- * For TCP over IPv4 and for UDP over IPv4, the format of r_addr is the
- * US-ASCII string:
- *
- *     h1.h2.h3.h4.p1.p2
- *
- * The prefix, "h1.h2.h3.h4", is the standard textual form for
- * representing an IPv4 address, which is always four octets long.
- * Assuming big-endian ordering, h1, h2, h3, and h4, are respectively,
- * the first through fourth octets each converted to ASCII-decimal.
- * Assuming big-endian ordering, p1 and p2 are, respectively, the first
- * and second octets each converted to ASCII-decimal.  For example, if a
- * host, in big-endian order, has an address of 0x0A010307 and there is
- * a service listening on, in big endian order, port 0x020F (decimal
- * 527), then the complete universal address is "10.1.3.7.2.15".
- *
- * ...
- *
- * For TCP over IPv6 and for UDP over IPv6, the format of r_addr is the
- * US-ASCII string:
- *
- *     x1:x2:x3:x4:x5:x6:x7:x8.p1.p2
- *
- * The suffix "p1.p2" is the service port, and is computed the same way
- * as with universal addresses for TCP and UDP over IPv4.  The prefix,
- * "x1:x2:x3:x4:x5:x6:x7:x8", is the standard textual form for
- * representing an IPv6 address as defined in Section 2.2 of [RFC2373].
- * Additionally, the two alternative forms specified in Section 2.2 of
- * [RFC2373] are also acceptable.
- *
- * XXX: Currently this implementation does not explicitly convert the
- *      stored address to US-ASCII on non-ASCII systems.
- */
-#define RPCB_MAXADDRLEN                (128u)
-
 /*
  * r_owner
  *
@@ -112,9 +73,9 @@ struct rpcbind_args {
        u32                     r_vers;
        u32                     r_prot;
        unsigned short          r_port;
-       char *                  r_netid;
-       char                    r_addr[RPCB_MAXADDRLEN];
-       char *                  r_owner;
+       const char *            r_netid;
+       const char *            r_addr;
+       const char *            r_owner;
 };
 
 static struct rpc_procinfo rpcb_procedures2[];
@@ -148,7 +109,7 @@ static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status)
 }
 
 static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
-                                   size_t salen, int proto, int version,
+                                   size_t salen, int proto, u32 version,
                                    int privileged)
 {
        struct rpc_create_args args = {
@@ -159,8 +120,7 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
                .program        = &rpcb_program,
                .version        = version,
                .authflavor     = RPC_AUTH_UNIX,
-               .flags          = (RPC_CLNT_CREATE_NOPING |
-                                  RPC_CLNT_CREATE_INTR),
+               .flags          = RPC_CLNT_CREATE_NOPING,
        };
 
        switch (srvaddr->sa_family) {
@@ -239,13 +199,15 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
  * @vers: RPC version number to bind
  * @prot: transport protocol to use to make this request
  *
+ * Return value is the requested advertised port number,
+ * or a negative errno value.
+ *
  * Called from outside the RPC client in a synchronous task context.
  * Uses default timeout parameters specified by underlying transport.
  *
- * XXX: Needs to support IPv6, and rpcbind versions 3 and 4
+ * XXX: Needs to support IPv6
  */
-int rpcb_getport_sync(struct sockaddr_in *sin, __u32 prog,
-                     __u32 vers, int prot)
+int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot)
 {
        struct rpcbind_args map = {
                .r_prog         = prog,
@@ -259,15 +221,13 @@ int rpcb_getport_sync(struct sockaddr_in *sin, __u32 prog,
                .rpc_resp       = &map.r_port,
        };
        struct rpc_clnt *rpcb_clnt;
-       char hostname[40];
        int status;
 
        dprintk("RPC:       %s(" NIPQUAD_FMT ", %u, %u, %d)\n",
-               __FUNCTION__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
+               __func__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
 
-       sprintf(hostname, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr));
-       rpcb_clnt = rpcb_create(hostname, (struct sockaddr *)sin,
-                               sizeof(sin), prot, 2, 0);
+       rpcb_clnt = rpcb_create(NULL, (struct sockaddr *)sin,
+                               sizeof(*sin), prot, 2, 0);
        if (IS_ERR(rpcb_clnt))
                return PTR_ERR(rpcb_clnt);
 
@@ -311,7 +271,7 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi
 void rpcb_getport_async(struct rpc_task *task)
 {
        struct rpc_clnt *clnt = task->tk_client;
-       int bind_version;
+       u32 bind_version;
        struct rpc_xprt *xprt = task->tk_xprt;
        struct rpc_clnt *rpcb_clnt;
        static struct rpcbind_args *map;
@@ -323,7 +283,7 @@ void rpcb_getport_async(struct rpc_task *task)
        struct rpcb_info *info;
 
        dprintk("RPC: %5u %s(%s, %u, %u, %d)\n",
-               task->tk_pid, __FUNCTION__,
+               task->tk_pid, __func__,
                clnt->cl_server, clnt->cl_prog, clnt->cl_vers, xprt->prot);
 
        /* Autobind on cloned rpc clients is discouraged */
@@ -332,7 +292,7 @@ void rpcb_getport_async(struct rpc_task *task)
        if (xprt_test_and_set_binding(xprt)) {
                status = -EAGAIN;       /* tell caller to check again */
                dprintk("RPC: %5u %s: waiting for another binder\n",
-                       task->tk_pid, __FUNCTION__);
+                       task->tk_pid, __func__);
                goto bailout_nowake;
        }
 
@@ -344,7 +304,7 @@ void rpcb_getport_async(struct rpc_task *task)
        if (xprt_bound(xprt)) {
                status = 0;
                dprintk("RPC: %5u %s: already bound\n",
-                       task->tk_pid, __FUNCTION__);
+                       task->tk_pid, __func__);
                goto bailout_nofree;
        }
 
@@ -361,27 +321,27 @@ void rpcb_getport_async(struct rpc_task *task)
        default:
                status = -EAFNOSUPPORT;
                dprintk("RPC: %5u %s: bad address family\n",
-                               task->tk_pid, __FUNCTION__);
+                               task->tk_pid, __func__);
                goto bailout_nofree;
        }
        if (info[xprt->bind_index].rpc_proc == NULL) {
                xprt->bind_index = 0;
                status = -EPFNOSUPPORT;
                dprintk("RPC: %5u %s: no more getport versions available\n",
-                       task->tk_pid, __FUNCTION__);
+                       task->tk_pid, __func__);
                goto bailout_nofree;
        }
        bind_version = info[xprt->bind_index].rpc_vers;
 
        dprintk("RPC: %5u %s: trying rpcbind version %u\n",
-               task->tk_pid, __FUNCTION__, bind_version);
+               task->tk_pid, __func__, bind_version);
 
        rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot,
                                bind_version, 0);
        if (IS_ERR(rpcb_clnt)) {
                status = PTR_ERR(rpcb_clnt);
                dprintk("RPC: %5u %s: rpcb_create failed, error %ld\n",
-                       task->tk_pid, __FUNCTION__, PTR_ERR(rpcb_clnt));
+                       task->tk_pid, __func__, PTR_ERR(rpcb_clnt));
                goto bailout_nofree;
        }
 
@@ -389,7 +349,7 @@ void rpcb_getport_async(struct rpc_task *task)
        if (!map) {
                status = -ENOMEM;
                dprintk("RPC: %5u %s: no memory available\n",
-                       task->tk_pid, __FUNCTION__);
+                       task->tk_pid, __func__);
                goto bailout_nofree;
        }
        map->r_prog = clnt->cl_prog;
@@ -398,9 +358,7 @@ void rpcb_getport_async(struct rpc_task *task)
        map->r_port = 0;
        map->r_xprt = xprt_get(xprt);
        map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID);
-       memcpy(map->r_addr,
-              rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR),
-              sizeof(map->r_addr));
+       map->r_addr = rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR);
        map->r_owner = RPCB_OWNER_STRING;       /* ignored for GETADDR */
 
        child = rpcb_call_async(rpcb_clnt, map, xprt->bind_index);
@@ -408,7 +366,7 @@ void rpcb_getport_async(struct rpc_task *task)
        if (IS_ERR(child)) {
                status = -EIO;
                dprintk("RPC: %5u %s: rpc_run_task failed\n",
-                       task->tk_pid, __FUNCTION__);
+                       task->tk_pid, __func__);
                goto bailout;
        }
        rpc_put_task(child);
@@ -526,7 +484,7 @@ static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 *p,
         * Simple sanity check.  The smallest possible universal
         * address is an IPv4 address string containing 11 bytes.
         */
-       if (addr_len < 11 || addr_len > RPCB_MAXADDRLEN)
+       if (addr_len < 11 || addr_len > RPCBIND_MAXUADDRLEN)
                goto out_err;
 
        /*
@@ -577,7 +535,7 @@ out_err:
 #define RPCB_boolean_sz                (1u)
 
 #define RPCB_netid_sz          (1+XDR_QUADLEN(RPCBIND_MAXNETIDLEN))
-#define RPCB_addr_sz           (1+XDR_QUADLEN(RPCB_MAXADDRLEN))
+#define RPCB_addr_sz           (1+XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
 #define RPCB_ownerstring_sz    (1+XDR_QUADLEN(RPCB_MAXOWNERLEN))
 
 #define RPCB_mappingargs_sz    RPCB_program_sz+RPCB_version_sz+        \