Commit 6eac7d3f authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: constify rpc_clnt fields cl_server and cl_protname

...and get rid of the superfluous cl_inline_name.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 4cb54ca2
...@@ -41,8 +41,8 @@ struct rpc_clnt { ...@@ -41,8 +41,8 @@ struct rpc_clnt {
cl_vers, /* RPC version number */ cl_vers, /* RPC version number */
cl_maxproc; /* max procedure number */ cl_maxproc; /* max procedure number */
char * cl_server; /* server machine name */ const char * cl_server; /* server machine name */
char * cl_protname; /* protocol name */ const char * cl_protname; /* protocol name */
struct rpc_auth * cl_auth; /* authenticator */ struct rpc_auth * cl_auth; /* authenticator */
struct rpc_stat * cl_stats; /* per-program statistics */ struct rpc_stat * cl_stats; /* per-program statistics */
struct rpc_iostats * cl_metrics; /* per-client statistics */ struct rpc_iostats * cl_metrics; /* per-client statistics */
...@@ -62,7 +62,6 @@ struct rpc_clnt { ...@@ -62,7 +62,6 @@ struct rpc_clnt {
struct rpc_rtt cl_rtt_default; struct rpc_rtt cl_rtt_default;
struct rpc_timeout cl_timeout_default; struct rpc_timeout cl_timeout_default;
struct rpc_program * cl_program; struct rpc_program * cl_program;
char cl_inline_name[32];
char *cl_principal; /* target to authenticate to */ char *cl_principal; /* target to authenticate to */
}; };
...@@ -97,7 +96,7 @@ struct rpc_procinfo { ...@@ -97,7 +96,7 @@ struct rpc_procinfo {
unsigned int p_count; /* call count */ unsigned int p_count; /* call count */
unsigned int p_timer; /* Which RTT timer to use */ unsigned int p_timer; /* Which RTT timer to use */
u32 p_statidx; /* Which procedure to account */ u32 p_statidx; /* Which procedure to account */
char * p_name; /* name of procedure */ const char * p_name; /* name of procedure */
}; };
#ifdef __KERNEL__ #ifdef __KERNEL__
...@@ -109,7 +108,7 @@ struct rpc_create_args { ...@@ -109,7 +108,7 @@ struct rpc_create_args {
size_t addrsize; size_t addrsize;
struct sockaddr *saddress; struct sockaddr *saddress;
const struct rpc_timeout *timeout; const struct rpc_timeout *timeout;
char *servername; const char *servername;
struct rpc_program *program; struct rpc_program *program;
u32 prognumber; /* overrides program->number */ u32 prognumber; /* overrides program->number */
u32 version; u32 version;
......
...@@ -273,15 +273,9 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru ...@@ -273,15 +273,9 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
goto out_err; goto out_err;
clnt->cl_parent = clnt; clnt->cl_parent = clnt;
clnt->cl_server = clnt->cl_inline_name; clnt->cl_server = kstrdup(args->servername, GFP_KERNEL);
if (len > sizeof(clnt->cl_inline_name)) { if (clnt->cl_server == NULL)
char *buf = kmalloc(len, GFP_KERNEL); goto out_no_server;
if (buf != NULL)
clnt->cl_server = buf;
else
len = sizeof(clnt->cl_inline_name);
}
strlcpy(clnt->cl_server, args->servername, len);
clnt->cl_xprt = xprt; clnt->cl_xprt = xprt;
clnt->cl_procinfo = version->procs; clnt->cl_procinfo = version->procs;
...@@ -346,8 +340,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru ...@@ -346,8 +340,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
out_no_principal: out_no_principal:
rpc_free_iostats(clnt->cl_metrics); rpc_free_iostats(clnt->cl_metrics);
out_no_stats: out_no_stats:
if (clnt->cl_server != clnt->cl_inline_name) kfree(clnt->cl_server);
kfree(clnt->cl_server); out_no_server:
kfree(clnt); kfree(clnt);
out_err: out_err:
xprt_put(xprt); xprt_put(xprt);
...@@ -470,6 +464,9 @@ rpc_clone_client(struct rpc_clnt *clnt) ...@@ -470,6 +464,9 @@ rpc_clone_client(struct rpc_clnt *clnt)
new = kmemdup(clnt, sizeof(*new), GFP_KERNEL); new = kmemdup(clnt, sizeof(*new), GFP_KERNEL);
if (!new) if (!new)
goto out_no_clnt; goto out_no_clnt;
new->cl_server = kstrdup(clnt->cl_server, GFP_KERNEL);
if (new->cl_server == NULL)
goto out_no_server;
new->cl_parent = clnt; new->cl_parent = clnt;
/* Turn off autobind on clones */ /* Turn off autobind on clones */
new->cl_autobind = 0; new->cl_autobind = 0;
...@@ -500,6 +497,8 @@ rpc_clone_client(struct rpc_clnt *clnt) ...@@ -500,6 +497,8 @@ rpc_clone_client(struct rpc_clnt *clnt)
out_no_principal: out_no_principal:
rpc_free_iostats(new->cl_metrics); rpc_free_iostats(new->cl_metrics);
out_no_stats: out_no_stats:
kfree(new->cl_server);
out_no_server:
kfree(new); kfree(new);
out_no_clnt: out_no_clnt:
dprintk("RPC: %s: returned error %d\n", __func__, err); dprintk("RPC: %s: returned error %d\n", __func__, err);
...@@ -565,13 +564,9 @@ rpc_free_client(struct rpc_clnt *clnt) ...@@ -565,13 +564,9 @@ rpc_free_client(struct rpc_clnt *clnt)
{ {
dprintk("RPC: destroying %s client for %s\n", dprintk("RPC: destroying %s client for %s\n",
clnt->cl_protname, clnt->cl_server); clnt->cl_protname, clnt->cl_server);
if (clnt->cl_parent != clnt) { if (clnt->cl_parent != clnt)
rpc_release_client(clnt->cl_parent); rpc_release_client(clnt->cl_parent);
goto out_free; kfree(clnt->cl_server);
}
if (clnt->cl_server != clnt->cl_inline_name)
kfree(clnt->cl_server);
out_free:
rpc_unregister_client(clnt); rpc_unregister_client(clnt);
rpc_clnt_remove_pipedir(clnt); rpc_clnt_remove_pipedir(clnt);
rpc_free_iostats(clnt->cl_metrics); rpc_free_iostats(clnt->cl_metrics);
......
...@@ -343,7 +343,7 @@ int rpcb_create_local(struct net *net) ...@@ -343,7 +343,7 @@ int rpcb_create_local(struct net *net)
return result; return result;
} }
static struct rpc_clnt *rpcb_create(struct net *net, char *hostname, static struct rpc_clnt *rpcb_create(struct net *net, const char *hostname,
struct sockaddr *srvaddr, size_t salen, struct sockaddr *srvaddr, size_t salen,
int proto, u32 version) int proto, u32 version)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment