aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/auth.c2
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c20
-rw-r--r--net/sunrpc/auth_gss/gss_generic_token.c10
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c4
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_seqnum.c4
-rw-r--r--net/sunrpc/auth_gss/gss_mech_switch.c4
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_token.c48
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_unseal.c2
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c6
-rw-r--r--net/sunrpc/cache.c76
-rw-r--r--net/sunrpc/clnt.c28
-rw-r--r--net/sunrpc/pmap_clnt.c4
-rw-r--r--net/sunrpc/rpc_pipe.c4
-rw-r--r--net/sunrpc/sched.c8
-rw-r--r--net/sunrpc/stats.c2
-rw-r--r--net/sunrpc/svc.c24
-rw-r--r--net/sunrpc/svcauth.c4
-rw-r--r--net/sunrpc/svcauth_unix.c15
-rw-r--r--net/sunrpc/svcsock.c355
-rw-r--r--net/sunrpc/sysctl.c10
-rw-r--r--net/sunrpc/xdr.c6
-rw-r--r--net/sunrpc/xprt.c4
22 files changed, 384 insertions, 256 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 993ff1a5d945..76f7eac4082d 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -213,7 +213,7 @@ retry:
213 rpcauth_gc_credcache(auth, &free); 213 rpcauth_gc_credcache(auth, &free);
214 hlist_for_each_safe(pos, next, &cache->hashtable[nr]) { 214 hlist_for_each_safe(pos, next, &cache->hashtable[nr]) {
215 struct rpc_cred *entry; 215 struct rpc_cred *entry;
216 entry = hlist_entry(pos, struct rpc_cred, cr_hash); 216 entry = hlist_entry(pos, struct rpc_cred, cr_hash);
217 if (entry->cr_ops->crmatch(acred, entry, flags)) { 217 if (entry->cr_ops->crmatch(acred, entry, flags)) {
218 hlist_del(&entry->cr_hash); 218 hlist_del(&entry->cr_hash);
219 cred = entry; 219 cred = entry;
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index e1a104abb782..718fb94ad0f7 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -2,7 +2,7 @@
2 * linux/net/sunrpc/auth_gss/auth_gss.c 2 * linux/net/sunrpc/auth_gss/auth_gss.c
3 * 3 *
4 * RPCSEC_GSS client authentication. 4 * RPCSEC_GSS client authentication.
5 * 5 *
6 * Copyright (c) 2000 The Regents of the University of Michigan. 6 * Copyright (c) 2000 The Regents of the University of Michigan.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
@@ -74,7 +74,7 @@ static struct rpc_credops gss_credops;
74* as it is passed to gssd to signal the use of 74* as it is passed to gssd to signal the use of
75* machine creds should be part of the shared rpc interface */ 75* machine creds should be part of the shared rpc interface */
76 76
77#define CA_RUN_AS_MACHINE 0x00000200 77#define CA_RUN_AS_MACHINE 0x00000200
78 78
79/* dump the buffer in `emacs-hexl' style */ 79/* dump the buffer in `emacs-hexl' style */
80#define isprint(c) ((c > 0x1f) && (c < 0x7f)) 80#define isprint(c) ((c > 0x1f) && (c < 0x7f))
@@ -607,8 +607,8 @@ gss_pipe_destroy_msg(struct rpc_pipe_msg *msg)
607 } 607 }
608} 608}
609 609
610/* 610/*
611 * NOTE: we have the opportunity to use different 611 * NOTE: we have the opportunity to use different
612 * parameters based on the input flavor (which must be a pseudoflavor) 612 * parameters based on the input flavor (which must be a pseudoflavor)
613 */ 613 */
614static struct rpc_auth * 614static struct rpc_auth *
@@ -869,7 +869,7 @@ gss_validate(struct rpc_task *task, __be32 *p)
869 869
870 flav = ntohl(*p++); 870 flav = ntohl(*p++);
871 if ((len = ntohl(*p++)) > RPC_MAX_AUTH_SIZE) 871 if ((len = ntohl(*p++)) > RPC_MAX_AUTH_SIZE)
872 goto out_bad; 872 goto out_bad;
873 if (flav != RPC_AUTH_GSS) 873 if (flav != RPC_AUTH_GSS)
874 goto out_bad; 874 goto out_bad;
875 seq = htonl(task->tk_rqstp->rq_seqno); 875 seq = htonl(task->tk_rqstp->rq_seqno);
@@ -925,7 +925,7 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
925 *integ_len = htonl(integ_buf.len); 925 *integ_len = htonl(integ_buf.len);
926 926
927 /* guess whether we're in the head or the tail: */ 927 /* guess whether we're in the head or the tail: */
928 if (snd_buf->page_len || snd_buf->tail[0].iov_len) 928 if (snd_buf->page_len || snd_buf->tail[0].iov_len)
929 iov = snd_buf->tail; 929 iov = snd_buf->tail;
930 else 930 else
931 iov = snd_buf->head; 931 iov = snd_buf->head;
@@ -1030,7 +1030,7 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1030 maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages); 1030 maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages);
1031 /* RPC_SLACK_SPACE should prevent this ever happening: */ 1031 /* RPC_SLACK_SPACE should prevent this ever happening: */
1032 BUG_ON(snd_buf->len > snd_buf->buflen); 1032 BUG_ON(snd_buf->len > snd_buf->buflen);
1033 status = -EIO; 1033 status = -EIO;
1034 /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was 1034 /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was
1035 * done anyway, so it's safe to put the request on the wire: */ 1035 * done anyway, so it's safe to put the request on the wire: */
1036 if (maj_stat == GSS_S_CONTEXT_EXPIRED) 1036 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
@@ -1079,7 +1079,7 @@ gss_wrap_req(struct rpc_task *task,
1079 status = gss_wrap_req_integ(cred, ctx, encode, 1079 status = gss_wrap_req_integ(cred, ctx, encode,
1080 rqstp, p, obj); 1080 rqstp, p, obj);
1081 break; 1081 break;
1082 case RPC_GSS_SVC_PRIVACY: 1082 case RPC_GSS_SVC_PRIVACY:
1083 status = gss_wrap_req_priv(cred, ctx, encode, 1083 status = gss_wrap_req_priv(cred, ctx, encode,
1084 rqstp, p, obj); 1084 rqstp, p, obj);
1085 break; 1085 break;
@@ -1179,7 +1179,7 @@ gss_unwrap_resp(struct rpc_task *task,
1179 if (status) 1179 if (status)
1180 goto out; 1180 goto out;
1181 break; 1181 break;
1182 case RPC_GSS_SVC_PRIVACY: 1182 case RPC_GSS_SVC_PRIVACY:
1183 status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p); 1183 status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p);
1184 if (status) 1184 if (status)
1185 goto out; 1185 goto out;
@@ -1196,7 +1196,7 @@ out:
1196 status); 1196 status);
1197 return status; 1197 return status;
1198} 1198}
1199 1199
1200static struct rpc_authops authgss_ops = { 1200static struct rpc_authops authgss_ops = {
1201 .owner = THIS_MODULE, 1201 .owner = THIS_MODULE,
1202 .au_flavor = RPC_AUTH_GSS, 1202 .au_flavor = RPC_AUTH_GSS,
diff --git a/net/sunrpc/auth_gss/gss_generic_token.c b/net/sunrpc/auth_gss/gss_generic_token.c
index 826df44e7fca..ea8c92ecdae5 100644
--- a/net/sunrpc/auth_gss/gss_generic_token.c
+++ b/net/sunrpc/auth_gss/gss_generic_token.c
@@ -11,7 +11,7 @@
11 11
12/* 12/*
13 * Copyright 1993 by OpenVision Technologies, Inc. 13 * Copyright 1993 by OpenVision Technologies, Inc.
14 * 14 *
15 * Permission to use, copy, modify, distribute, and sell this software 15 * Permission to use, copy, modify, distribute, and sell this software
16 * and its documentation for any purpose is hereby granted without fee, 16 * and its documentation for any purpose is hereby granted without fee,
17 * provided that the above copyright notice appears in all copies and 17 * provided that the above copyright notice appears in all copies and
@@ -21,7 +21,7 @@
21 * without specific, written prior permission. OpenVision makes no 21 * without specific, written prior permission. OpenVision makes no
22 * representations about the suitability of this software for any 22 * representations about the suitability of this software for any
23 * purpose. It is provided "as is" without express or implied warranty. 23 * purpose. It is provided "as is" without express or implied warranty.
24 * 24 *
25 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 25 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
26 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 26 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
27 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 27 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
@@ -201,7 +201,7 @@ g_verify_token_header(struct xdr_netobj *mech, int *body_size,
201 return(G_BAD_TOK_HEADER); 201 return(G_BAD_TOK_HEADER);
202 if (*buf++ != 0x06) 202 if (*buf++ != 0x06)
203 return(G_BAD_TOK_HEADER); 203 return(G_BAD_TOK_HEADER);
204 204
205 if ((toksize-=1) < 0) 205 if ((toksize-=1) < 0)
206 return(G_BAD_TOK_HEADER); 206 return(G_BAD_TOK_HEADER);
207 toid.len = *buf++; 207 toid.len = *buf++;
@@ -211,9 +211,9 @@ g_verify_token_header(struct xdr_netobj *mech, int *body_size,
211 toid.data = buf; 211 toid.data = buf;
212 buf+=toid.len; 212 buf+=toid.len;
213 213
214 if (! g_OID_equal(&toid, mech)) 214 if (! g_OID_equal(&toid, mech))
215 ret = G_WRONG_MECH; 215 ret = G_WRONG_MECH;
216 216
217 /* G_WRONG_MECH is not returned immediately because it's more important 217 /* G_WRONG_MECH is not returned immediately because it's more important
218 to return G_BAD_TOK_HEADER if the token header is in fact bad */ 218 to return G_BAD_TOK_HEADER if the token header is in fact bad */
219 219
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index d926cda88623..0a9948de0992 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -58,7 +58,7 @@ krb5_encrypt(
58 int length) 58 int length)
59{ 59{
60 u32 ret = -EINVAL; 60 u32 ret = -EINVAL;
61 struct scatterlist sg[1]; 61 struct scatterlist sg[1];
62 u8 local_iv[16] = {0}; 62 u8 local_iv[16] = {0};
63 struct blkcipher_desc desc = { .tfm = tfm, .info = local_iv }; 63 struct blkcipher_desc desc = { .tfm = tfm, .info = local_iv };
64 64
@@ -67,7 +67,7 @@ krb5_encrypt(
67 67
68 if (crypto_blkcipher_ivsize(tfm) > 16) { 68 if (crypto_blkcipher_ivsize(tfm) > 16) {
69 dprintk("RPC: gss_k5encrypt: tfm iv size to large %d\n", 69 dprintk("RPC: gss_k5encrypt: tfm iv size to large %d\n",
70 crypto_blkcipher_ivsize(tfm)); 70 crypto_blkcipher_ivsize(tfm));
71 goto out; 71 goto out;
72 } 72 }
73 73
diff --git a/net/sunrpc/auth_gss/gss_krb5_seqnum.c b/net/sunrpc/auth_gss/gss_krb5_seqnum.c
index c604baf3a5f6..3e315a68efaa 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seqnum.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seqnum.c
@@ -11,7 +11,7 @@
11 11
12/* 12/*
13 * Copyright 1993 by OpenVision Technologies, Inc. 13 * Copyright 1993 by OpenVision Technologies, Inc.
14 * 14 *
15 * Permission to use, copy, modify, distribute, and sell this software 15 * Permission to use, copy, modify, distribute, and sell this software
16 * and its documentation for any purpose is hereby granted without fee, 16 * and its documentation for any purpose is hereby granted without fee,
17 * provided that the above copyright notice appears in all copies and 17 * provided that the above copyright notice appears in all copies and
@@ -21,7 +21,7 @@
21 * without specific, written prior permission. OpenVision makes no 21 * without specific, written prior permission. OpenVision makes no
22 * representations about the suitability of this software for any 22 * representations about the suitability of this software for any
23 * purpose. It is provided "as is" without express or implied warranty. 23 * purpose. It is provided "as is" without express or implied warranty.
24 * 24 *
25 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 25 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
26 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 26 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
27 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 27 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c
index 3db745379d06..3423890e4a30 100644
--- a/net/sunrpc/auth_gss/gss_mech_switch.c
+++ b/net/sunrpc/auth_gss/gss_mech_switch.c
@@ -6,14 +6,14 @@
6 * 6 *
7 * J. Bruce Fields <bfields@umich.edu> 7 * J. Bruce Fields <bfields@umich.edu>
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its 18 * 3. Neither the name of the University nor the names of its
19 * contributors may be used to endorse or promote products derived 19 * contributors may be used to endorse or promote products derived
diff --git a/net/sunrpc/auth_gss/gss_spkm3_token.c b/net/sunrpc/auth_gss/gss_spkm3_token.c
index 35188b6ea8f7..8400b621971e 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_token.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_token.c
@@ -59,7 +59,7 @@ asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits)
59 59
60 /* count trailing 0's */ 60 /* count trailing 0's */
61 for(i = in->len; i > 0; i--) { 61 for(i = in->len; i > 0; i--) {
62 if (*ptr == 0) { 62 if (*ptr == 0) {
63 ptr--; 63 ptr--;
64 elen--; 64 elen--;
65 } else 65 } else
@@ -82,7 +82,7 @@ asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits)
82 82
83/* 83/*
84 * decode_asn1_bitstring() 84 * decode_asn1_bitstring()
85 * 85 *
86 * decode a bitstring into a buffer of the expected length. 86 * decode a bitstring into a buffer of the expected length.
87 * enclen = bit string length 87 * enclen = bit string length
88 * explen = expected length (define in rfc) 88 * explen = expected length (define in rfc)
@@ -97,9 +97,9 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen)
97 return 1; 97 return 1;
98} 98}
99 99
100/* 100/*
101 * SPKMInnerContextToken choice SPKM_MIC asn1 token layout 101 * SPKMInnerContextToken choice SPKM_MIC asn1 token layout
102 * 102 *
103 * contextid is always 16 bytes plain data. max asn1 bitstring len = 17. 103 * contextid is always 16 bytes plain data. max asn1 bitstring len = 17.
104 * 104 *
105 * tokenlen = pos[0] to end of token (max pos[45] with MD5 cksum) 105 * tokenlen = pos[0] to end of token (max pos[45] with MD5 cksum)
@@ -107,21 +107,21 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen)
107 * pos value 107 * pos value
108 * ---------- 108 * ----------
109 * [0] a4 SPKM-MIC tag 109 * [0] a4 SPKM-MIC tag
110 * [1] ?? innertoken length (max 44) 110 * [1] ?? innertoken length (max 44)
111 * 111 *
112 * 112 *
113 * tok_hdr piece of checksum data starts here 113 * tok_hdr piece of checksum data starts here
114 * 114 *
115 * the maximum mic-header len = 9 + 17 = 26 115 * the maximum mic-header len = 9 + 17 = 26
116 * mic-header 116 * mic-header
117 * ---------- 117 * ----------
118 * [2] 30 SEQUENCE tag 118 * [2] 30 SEQUENCE tag
119 * [3] ?? mic-header length: (max 23) = TokenID + ContextID 119 * [3] ?? mic-header length: (max 23) = TokenID + ContextID
120 * 120 *
121 * TokenID - all fields constant and can be hardcoded 121 * TokenID - all fields constant and can be hardcoded
122 * ------- 122 * -------
123 * [4] 02 Type 2 123 * [4] 02 Type 2
124 * [5] 02 Length 2 124 * [5] 02 Length 2
125 * [6][7] 01 01 TokenID (SPKM_MIC_TOK) 125 * [6][7] 01 01 TokenID (SPKM_MIC_TOK)
126 * 126 *
127 * ContextID - encoded length not constant, calculated 127 * ContextID - encoded length not constant, calculated
@@ -131,17 +131,17 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen)
131 * [10] ?? ctxzbit 131 * [10] ?? ctxzbit
132 * [11] contextid 132 * [11] contextid
133 * 133 *
134 * mic_header piece of checksum data ends here. 134 * mic_header piece of checksum data ends here.
135 * 135 *
136 * int-cksum - encoded length not constant, calculated 136 * int-cksum - encoded length not constant, calculated
137 * --------- 137 * ---------
138 * [??] 03 Type 3 138 * [??] 03 Type 3
139 * [??] ?? encoded length 139 * [??] ?? encoded length
140 * [??] ?? md5zbit 140 * [??] ?? md5zbit
141 * [??] int-cksum (NID_md5 = 16) 141 * [??] int-cksum (NID_md5 = 16)
142 * 142 *
143 * maximum SPKM-MIC innercontext token length = 143 * maximum SPKM-MIC innercontext token length =
144 * 10 + encoded contextid_size(17 max) + 2 + encoded 144 * 10 + encoded contextid_size(17 max) + 2 + encoded
145 * cksum_size (17 maxfor NID_md5) = 46 145 * cksum_size (17 maxfor NID_md5) = 46
146 */ 146 */
147 147
@@ -178,8 +178,8 @@ spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen, unsigned char *ct
178/* 178/*
179 * spkm3_mic_innercontext_token() 179 * spkm3_mic_innercontext_token()
180 * 180 *
181 * *tokp points to the beginning of the SPKM_MIC token described 181 * *tokp points to the beginning of the SPKM_MIC token described
182 * in rfc 2025, section 3.2.1: 182 * in rfc 2025, section 3.2.1:
183 * 183 *
184 * toklen is the inner token length 184 * toklen is the inner token length
185 */ 185 */
@@ -209,7 +209,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
209 209
210 /* spkm3 innercontext token preamble */ 210 /* spkm3 innercontext token preamble */
211 if ((ptr[0] != 0xa4) || (ptr[2] != 0x30)) { 211 if ((ptr[0] != 0xa4) || (ptr[2] != 0x30)) {
212 dprintk("RPC: BAD SPKM ictoken preamble\n"); 212 dprintk("RPC: BAD SPKM ictoken preamble\n");
213 goto out; 213 goto out;
214 } 214 }
215 215
@@ -245,9 +245,9 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
245 goto out; 245 goto out;
246 246
247 /* 247 /*
248 * in the current implementation: the optional int-alg is not present 248 * in the current implementation: the optional int-alg is not present
249 * so the default int-alg (md5) is used the optional snd-seq field is 249 * so the default int-alg (md5) is used the optional snd-seq field is
250 * also not present 250 * also not present
251 */ 251 */
252 252
253 if (*mic_hdrlen != 6 + ctxelen) { 253 if (*mic_hdrlen != 6 + ctxelen) {
@@ -255,7 +255,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
255 goto out; 255 goto out;
256 } 256 }
257 /* checksum */ 257 /* checksum */
258 *cksum = (&ptr[10] + ctxelen); /* ctxelen includes ptr[10] */ 258 *cksum = (&ptr[10] + ctxelen); /* ctxelen includes ptr[10] */
259 259
260 ret = GSS_S_COMPLETE; 260 ret = GSS_S_COMPLETE;
261out: 261out:
diff --git a/net/sunrpc/auth_gss/gss_spkm3_unseal.c b/net/sunrpc/auth_gss/gss_spkm3_unseal.c
index e54581ca7570..35a1b34c4a1d 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_unseal.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_unseal.c
@@ -45,7 +45,7 @@
45 45
46/* 46/*
47 * spkm3_read_token() 47 * spkm3_read_token()
48 * 48 *
49 * only SPKM_MIC_TOK with md5 intg-alg is supported 49 * only SPKM_MIC_TOK with md5 intg-alg is supported
50 */ 50 */
51u32 51u32
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 066c64a97fd8..8fde38ecaf21 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -172,8 +172,8 @@ static struct cache_head *rsi_alloc(void)
172} 172}
173 173
174static void rsi_request(struct cache_detail *cd, 174static void rsi_request(struct cache_detail *cd,
175 struct cache_head *h, 175 struct cache_head *h,
176 char **bpp, int *blen) 176 char **bpp, int *blen)
177{ 177{
178 struct rsi *rsii = container_of(h, struct rsi, h); 178 struct rsi *rsii = container_of(h, struct rsi, h);
179 179
@@ -184,7 +184,7 @@ static void rsi_request(struct cache_detail *cd,
184 184
185 185
186static int rsi_parse(struct cache_detail *cd, 186static int rsi_parse(struct cache_detail *cd,
187 char *mesg, int mlen) 187 char *mesg, int mlen)
188{ 188{
189 /* context token expiry major minor context token */ 189 /* context token expiry major minor context token */
190 char *buf = mesg; 190 char *buf = mesg;
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 14274490f92e..8612044b9189 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -274,7 +274,7 @@ int cache_check(struct cache_detail *detail,
274 * 274 *
275 * A table is then only scanned if the current time is at least 275 * A table is then only scanned if the current time is at least
276 * the nextcheck time. 276 * the nextcheck time.
277 * 277 *
278 */ 278 */
279 279
280static LIST_HEAD(cache_list); 280static LIST_HEAD(cache_list);
@@ -282,9 +282,9 @@ static DEFINE_SPINLOCK(cache_list_lock);
282static struct cache_detail *current_detail; 282static struct cache_detail *current_detail;
283static int current_index; 283static int current_index;
284 284
285static struct file_operations cache_file_operations; 285static const struct file_operations cache_file_operations;
286static struct file_operations content_file_operations; 286static const struct file_operations content_file_operations;
287static struct file_operations cache_flush_operations; 287static const struct file_operations cache_flush_operations;
288 288
289static void do_cache_clean(struct work_struct *work); 289static void do_cache_clean(struct work_struct *work);
290static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); 290static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean);
@@ -296,16 +296,16 @@ void cache_register(struct cache_detail *cd)
296 struct proc_dir_entry *p; 296 struct proc_dir_entry *p;
297 cd->proc_ent->owner = cd->owner; 297 cd->proc_ent->owner = cd->owner;
298 cd->channel_ent = cd->content_ent = NULL; 298 cd->channel_ent = cd->content_ent = NULL;
299 299
300 p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, 300 p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR,
301 cd->proc_ent); 301 cd->proc_ent);
302 cd->flush_ent = p; 302 cd->flush_ent = p;
303 if (p) { 303 if (p) {
304 p->proc_fops = &cache_flush_operations; 304 p->proc_fops = &cache_flush_operations;
305 p->owner = cd->owner; 305 p->owner = cd->owner;
306 p->data = cd; 306 p->data = cd;
307 } 307 }
308 308
309 if (cd->cache_request || cd->cache_parse) { 309 if (cd->cache_request || cd->cache_parse) {
310 p = create_proc_entry("channel", S_IFREG|S_IRUSR|S_IWUSR, 310 p = create_proc_entry("channel", S_IFREG|S_IRUSR|S_IWUSR,
311 cd->proc_ent); 311 cd->proc_ent);
@@ -316,16 +316,16 @@ void cache_register(struct cache_detail *cd)
316 p->data = cd; 316 p->data = cd;
317 } 317 }
318 } 318 }
319 if (cd->cache_show) { 319 if (cd->cache_show) {
320 p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR, 320 p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR,
321 cd->proc_ent); 321 cd->proc_ent);
322 cd->content_ent = p; 322 cd->content_ent = p;
323 if (p) { 323 if (p) {
324 p->proc_fops = &content_file_operations; 324 p->proc_fops = &content_file_operations;
325 p->owner = cd->owner; 325 p->owner = cd->owner;
326 p->data = cd; 326 p->data = cd;
327 } 327 }
328 } 328 }
329 } 329 }
330 rwlock_init(&cd->hash_lock); 330 rwlock_init(&cd->hash_lock);
331 INIT_LIST_HEAD(&cd->queue); 331 INIT_LIST_HEAD(&cd->queue);
@@ -417,15 +417,15 @@ static int cache_clean(void)
417 current_index++; 417 current_index++;
418 418
419 /* find a cleanable entry in the bucket and clean it, or set to next bucket */ 419 /* find a cleanable entry in the bucket and clean it, or set to next bucket */
420 420
421 if (current_detail && current_index < current_detail->hash_size) { 421 if (current_detail && current_index < current_detail->hash_size) {
422 struct cache_head *ch, **cp; 422 struct cache_head *ch, **cp;
423 struct cache_detail *d; 423 struct cache_detail *d;
424 424
425 write_lock(&current_detail->hash_lock); 425 write_lock(&current_detail->hash_lock);
426 426
427 /* Ok, now to clean this strand */ 427 /* Ok, now to clean this strand */
428 428
429 cp = & current_detail->hash_table[current_index]; 429 cp = & current_detail->hash_table[current_index];
430 ch = *cp; 430 ch = *cp;
431 for (; ch; cp= & ch->next, ch= *cp) { 431 for (; ch; cp= & ch->next, ch= *cp) {
@@ -477,9 +477,9 @@ static void do_cache_clean(struct work_struct *work)
477} 477}
478 478
479 479
480/* 480/*
481 * Clean all caches promptly. This just calls cache_clean 481 * Clean all caches promptly. This just calls cache_clean
482 * repeatedly until we are sure that every cache has had a chance to 482 * repeatedly until we are sure that every cache has had a chance to
483 * be fully cleaned 483 * be fully cleaned
484 */ 484 */
485void cache_flush(void) 485void cache_flush(void)
@@ -508,7 +508,7 @@ void cache_purge(struct cache_detail *detail)
508 * All deferred requests are stored in a hash table, 508 * All deferred requests are stored in a hash table,
509 * indexed by "struct cache_head *". 509 * indexed by "struct cache_head *".
510 * As it may be wasteful to store a whole request 510 * As it may be wasteful to store a whole request
511 * structure, we allow the request to provide a 511 * structure, we allow the request to provide a
512 * deferred form, which must contain a 512 * deferred form, which must contain a
513 * 'struct cache_deferred_req' 513 * 'struct cache_deferred_req'
514 * This cache_deferred_req contains a method to allow 514 * This cache_deferred_req contains a method to allow
@@ -584,7 +584,7 @@ static void cache_revisit_request(struct cache_head *item)
584 584
585 INIT_LIST_HEAD(&pending); 585 INIT_LIST_HEAD(&pending);
586 spin_lock(&cache_defer_lock); 586 spin_lock(&cache_defer_lock);
587 587
588 lp = cache_defer_hash[hash].next; 588 lp = cache_defer_hash[hash].next;
589 if (lp) { 589 if (lp) {
590 while (lp != &cache_defer_hash[hash]) { 590 while (lp != &cache_defer_hash[hash]) {
@@ -614,7 +614,7 @@ void cache_clean_deferred(void *owner)
614 614
615 INIT_LIST_HEAD(&pending); 615 INIT_LIST_HEAD(&pending);
616 spin_lock(&cache_defer_lock); 616 spin_lock(&cache_defer_lock);
617 617
618 list_for_each_entry_safe(dreq, tmp, &cache_defer_list, recent) { 618 list_for_each_entry_safe(dreq, tmp, &cache_defer_list, recent) {
619 if (dreq->owner == owner) { 619 if (dreq->owner == owner) {
620 list_del(&dreq->hash); 620 list_del(&dreq->hash);
@@ -639,7 +639,7 @@ void cache_clean_deferred(void *owner)
639 * On write, an update request is processed 639 * On write, an update request is processed
640 * Poll works if anything to read, and always allows write 640 * Poll works if anything to read, and always allows write
641 * 641 *
642 * Implemented by linked list of requests. Each open file has 642 * Implemented by linked list of requests. Each open file has
643 * a ->private that also exists in this list. New request are added 643 * a ->private that also exists in this list. New request are added
644 * to the end and may wakeup and preceding readers. 644 * to the end and may wakeup and preceding readers.
645 * New readers are added to the head. If, on read, an item is found with 645 * New readers are added to the head. If, on read, an item is found with
@@ -887,7 +887,7 @@ cache_release(struct inode *inode, struct file *filp)
887 887
888 888
889 889
890static struct file_operations cache_file_operations = { 890static const struct file_operations cache_file_operations = {
891 .owner = THIS_MODULE, 891 .owner = THIS_MODULE,
892 .llseek = no_llseek, 892 .llseek = no_llseek,
893 .read = cache_read, 893 .read = cache_read,
@@ -1059,10 +1059,10 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1059 * Messages are, like requests, separated into fields by 1059 * Messages are, like requests, separated into fields by
1060 * spaces and dequotes as \xHEXSTRING or embedded \nnn octal 1060 * spaces and dequotes as \xHEXSTRING or embedded \nnn octal
1061 * 1061 *
1062 * Message is 1062 * Message is
1063 * reply cachename expiry key ... content.... 1063 * reply cachename expiry key ... content....
1064 * 1064 *
1065 * key and content are both parsed by cache 1065 * key and content are both parsed by cache
1066 */ 1066 */
1067 1067
1068#define isodigit(c) (isdigit(c) && c <= '7') 1068#define isodigit(c) (isdigit(c) && c <= '7')
@@ -1132,7 +1132,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
1132 unsigned hash, entry; 1132 unsigned hash, entry;
1133 struct cache_head *ch; 1133 struct cache_head *ch;
1134 struct cache_detail *cd = ((struct handle*)m->private)->cd; 1134 struct cache_detail *cd = ((struct handle*)m->private)->cd;
1135 1135
1136 1136
1137 read_lock(&cd->hash_lock); 1137 read_lock(&cd->hash_lock);
1138 if (!n--) 1138 if (!n--)
@@ -1147,7 +1147,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
1147 do { 1147 do {
1148 hash++; 1148 hash++;
1149 n += 1LL<<32; 1149 n += 1LL<<32;
1150 } while(hash < cd->hash_size && 1150 } while(hash < cd->hash_size &&
1151 cd->hash_table[hash]==NULL); 1151 cd->hash_table[hash]==NULL);
1152 if (hash >= cd->hash_size) 1152 if (hash >= cd->hash_size)
1153 return NULL; 1153 return NULL;
@@ -1245,7 +1245,7 @@ static int content_release(struct inode *inode, struct file *file)
1245 return seq_release(inode, file); 1245 return seq_release(inode, file);
1246} 1246}
1247 1247
1248static struct file_operations content_file_operations = { 1248static const struct file_operations content_file_operations = {
1249 .open = content_open, 1249 .open = content_open,
1250 .read = seq_read, 1250 .read = seq_read,
1251 .llseek = seq_lseek, 1251 .llseek = seq_lseek,
@@ -1297,7 +1297,7 @@ static ssize_t write_flush(struct file * file, const char __user * buf,
1297 return count; 1297 return count;
1298} 1298}
1299 1299
1300static struct file_operations cache_flush_operations = { 1300static const struct file_operations cache_flush_operations = {
1301 .open = nonseekable_open, 1301 .open = nonseekable_open,
1302 .read = read_flush, 1302 .read = read_flush,
1303 .write = write_flush, 1303 .write = write_flush,
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 16c9fbc1db69..c95a61736d1c 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -410,7 +410,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old,
410 rpc_shutdown_client(clnt); 410 rpc_shutdown_client(clnt);
411 clnt = ERR_PTR(err); 411 clnt = ERR_PTR(err);
412 } 412 }
413out: 413out:
414 return clnt; 414 return clnt;
415} 415}
416 416
@@ -431,7 +431,7 @@ static const struct rpc_call_ops rpc_default_ops = {
431 * sleeps on RPC calls 431 * sleeps on RPC calls
432 */ 432 */
433#define RPC_INTR_SIGNALS (sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTERM)) 433#define RPC_INTR_SIGNALS (sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTERM))
434 434
435static void rpc_save_sigmask(sigset_t *oldset, int intr) 435static void rpc_save_sigmask(sigset_t *oldset, int intr)
436{ 436{
437 unsigned long sigallow = sigmask(SIGKILL); 437 unsigned long sigallow = sigmask(SIGKILL);
@@ -474,7 +474,7 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
474 int status; 474 int status;
475 475
476 /* If this client is slain all further I/O fails */ 476 /* If this client is slain all further I/O fails */
477 if (clnt->cl_dead) 477 if (clnt->cl_dead)
478 return -EIO; 478 return -EIO;
479 479
480 BUG_ON(flags & RPC_TASK_ASYNC); 480 BUG_ON(flags & RPC_TASK_ASYNC);
@@ -515,7 +515,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
515 515
516 /* If this client is slain all further I/O fails */ 516 /* If this client is slain all further I/O fails */
517 status = -EIO; 517 status = -EIO;
518 if (clnt->cl_dead) 518 if (clnt->cl_dead)
519 goto out_release; 519 goto out_release;
520 520
521 flags |= RPC_TASK_ASYNC; 521 flags |= RPC_TASK_ASYNC;
@@ -526,7 +526,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
526 goto out_release; 526 goto out_release;
527 527
528 /* Mask signals on GSS_AUTH upcalls */ 528 /* Mask signals on GSS_AUTH upcalls */
529 rpc_task_sigmask(task, &oldset); 529 rpc_task_sigmask(task, &oldset);
530 530
531 rpc_call_setup(task, msg, 0); 531 rpc_call_setup(task, msg, 0);
532 532
@@ -537,7 +537,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
537 else 537 else
538 rpc_put_task(task); 538 rpc_put_task(task);
539 539
540 rpc_restore_sigmask(&oldset); 540 rpc_restore_sigmask(&oldset);
541 return status; 541 return status;
542out_release: 542out_release:
543 rpc_release_calldata(tk_ops, data); 543 rpc_release_calldata(tk_ops, data);
@@ -749,7 +749,7 @@ call_allocate(struct rpc_task *task)
749 struct rpc_xprt *xprt = task->tk_xprt; 749 struct rpc_xprt *xprt = task->tk_xprt;
750 unsigned int bufsiz; 750 unsigned int bufsiz;
751 751
752 dprintk("RPC: %4d call_allocate (status %d)\n", 752 dprintk("RPC: %4d call_allocate (status %d)\n",
753 task->tk_pid, task->tk_status); 753 task->tk_pid, task->tk_status);
754 task->tk_action = call_bind; 754 task->tk_action = call_bind;
755 if (req->rq_buffer) 755 if (req->rq_buffer)
@@ -761,7 +761,7 @@ call_allocate(struct rpc_task *task)
761 761
762 if (xprt->ops->buf_alloc(task, bufsiz << 1) != NULL) 762 if (xprt->ops->buf_alloc(task, bufsiz << 1) != NULL)
763 return; 763 return;
764 printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task); 764 printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task);
765 765
766 if (RPC_IS_ASYNC(task) || !signalled()) { 766 if (RPC_IS_ASYNC(task) || !signalled()) {
767 xprt_release(task); 767 xprt_release(task);
@@ -798,7 +798,7 @@ call_encode(struct rpc_task *task)
798 kxdrproc_t encode; 798 kxdrproc_t encode;
799 __be32 *p; 799 __be32 *p;
800 800
801 dprintk("RPC: %4d call_encode (status %d)\n", 801 dprintk("RPC: %4d call_encode (status %d)\n",
802 task->tk_pid, task->tk_status); 802 task->tk_pid, task->tk_status);
803 803
804 /* Default buffer setup */ 804 /* Default buffer setup */
@@ -933,7 +933,7 @@ call_connect_status(struct rpc_task *task)
933 struct rpc_clnt *clnt = task->tk_client; 933 struct rpc_clnt *clnt = task->tk_client;
934 int status = task->tk_status; 934 int status = task->tk_status;
935 935
936 dprintk("RPC: %5u call_connect_status (status %d)\n", 936 dprintk("RPC: %5u call_connect_status (status %d)\n",
937 task->tk_pid, task->tk_status); 937 task->tk_pid, task->tk_status);
938 938
939 task->tk_status = 0; 939 task->tk_status = 0;
@@ -966,7 +966,7 @@ call_connect_status(struct rpc_task *task)
966static void 966static void
967call_transmit(struct rpc_task *task) 967call_transmit(struct rpc_task *task)
968{ 968{
969 dprintk("RPC: %4d call_transmit (status %d)\n", 969 dprintk("RPC: %4d call_transmit (status %d)\n",
970 task->tk_pid, task->tk_status); 970 task->tk_pid, task->tk_status);
971 971
972 task->tk_action = call_status; 972 task->tk_action = call_status;
@@ -1028,7 +1028,7 @@ call_status(struct rpc_task *task)
1028 if (req->rq_received > 0 && !req->rq_bytes_sent) 1028 if (req->rq_received > 0 && !req->rq_bytes_sent)
1029 task->tk_status = req->rq_received; 1029 task->tk_status = req->rq_received;
1030 1030
1031 dprintk("RPC: %4d call_status (status %d)\n", 1031 dprintk("RPC: %4d call_status (status %d)\n",
1032 task->tk_pid, task->tk_status); 1032 task->tk_pid, task->tk_status);
1033 1033
1034 status = task->tk_status; 1034 status = task->tk_status;
@@ -1118,7 +1118,7 @@ call_decode(struct rpc_task *task)
1118 kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode; 1118 kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode;
1119 __be32 *p; 1119 __be32 *p;
1120 1120
1121 dprintk("RPC: %4d call_decode (status %d)\n", 1121 dprintk("RPC: %4d call_decode (status %d)\n",
1122 task->tk_pid, task->tk_status); 1122 task->tk_pid, task->tk_status);
1123 1123
1124 if (task->tk_flags & RPC_CALL_MAJORSEEN) { 1124 if (task->tk_flags & RPC_CALL_MAJORSEEN) {
@@ -1196,7 +1196,7 @@ static void
1196call_refreshresult(struct rpc_task *task) 1196call_refreshresult(struct rpc_task *task)
1197{ 1197{
1198 int status = task->tk_status; 1198 int status = task->tk_status;
1199 dprintk("RPC: %4d call_refreshresult (status %d)\n", 1199 dprintk("RPC: %4d call_refreshresult (status %d)\n",
1200 task->tk_pid, task->tk_status); 1200 task->tk_pid, task->tk_status);
1201 1201
1202 task->tk_status = 0; 1202 task->tk_status = 0;
diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
index 3946ec3eb517..f4e1357bc186 100644
--- a/net/sunrpc/pmap_clnt.c
+++ b/net/sunrpc/pmap_clnt.c
@@ -329,7 +329,7 @@ static int xdr_decode_bool(struct rpc_rqst *req, __be32 *p, unsigned int *boolp)
329static struct rpc_procinfo pmap_procedures[] = { 329static struct rpc_procinfo pmap_procedures[] = {
330[PMAP_SET] = { 330[PMAP_SET] = {
331 .p_proc = PMAP_SET, 331 .p_proc = PMAP_SET,
332 .p_encode = (kxdrproc_t) xdr_encode_mapping, 332 .p_encode = (kxdrproc_t) xdr_encode_mapping,
333 .p_decode = (kxdrproc_t) xdr_decode_bool, 333 .p_decode = (kxdrproc_t) xdr_decode_bool,
334 .p_bufsiz = 4, 334 .p_bufsiz = 4,
335 .p_count = 1, 335 .p_count = 1,
@@ -338,7 +338,7 @@ static struct rpc_procinfo pmap_procedures[] = {
338 }, 338 },
339[PMAP_UNSET] = { 339[PMAP_UNSET] = {
340 .p_proc = PMAP_UNSET, 340 .p_proc = PMAP_UNSET,
341 .p_encode = (kxdrproc_t) xdr_encode_mapping, 341 .p_encode = (kxdrproc_t) xdr_encode_mapping,
342 .p_decode = (kxdrproc_t) xdr_decode_bool, 342 .p_decode = (kxdrproc_t) xdr_decode_bool,
343 .p_bufsiz = 4, 343 .p_bufsiz = 4,
344 .p_count = 1, 344 .p_count = 1,
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 89273d35e0cc..e1fad77a2257 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -309,7 +309,7 @@ rpc_pipe_ioctl(struct inode *ino, struct file *filp,
309 } 309 }
310} 310}
311 311
312static struct file_operations rpc_pipe_fops = { 312static const struct file_operations rpc_pipe_fops = {
313 .owner = THIS_MODULE, 313 .owner = THIS_MODULE,
314 .llseek = no_llseek, 314 .llseek = no_llseek,
315 .read = rpc_pipe_read, 315 .read = rpc_pipe_read,
@@ -366,7 +366,7 @@ rpc_info_release(struct inode *inode, struct file *file)
366 return single_release(inode, file); 366 return single_release(inode, file);
367} 367}
368 368
369static struct file_operations rpc_info_operations = { 369static const struct file_operations rpc_info_operations = {
370 .owner = THIS_MODULE, 370 .owner = THIS_MODULE,
371 .open = rpc_info_open, 371 .open = rpc_info_open,
372 .read = seq_read, 372 .read = seq_read,
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index fc083f0b3544..54a6b92525ea 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -4,7 +4,7 @@
4 * Scheduling for synchronous and asynchronous RPC requests. 4 * Scheduling for synchronous and asynchronous RPC requests.
5 * 5 *
6 * Copyright (C) 1996 Olaf Kirch, <okir@monad.swb.de> 6 * Copyright (C) 1996 Olaf Kirch, <okir@monad.swb.de>
7 * 7 *
8 * TCP NFS related read + write fixes 8 * TCP NFS related read + write fixes
9 * (C) 1999 Dave Airlie, University of Limerick, Ireland <airlied@linux.ie> 9 * (C) 1999 Dave Airlie, University of Limerick, Ireland <airlied@linux.ie>
10 */ 10 */
@@ -307,7 +307,7 @@ EXPORT_SYMBOL(__rpc_wait_for_completion_task);
307/* 307/*
308 * Make an RPC task runnable. 308 * Make an RPC task runnable.
309 * 309 *
310 * Note: If the task is ASYNC, this must be called with 310 * Note: If the task is ASYNC, this must be called with
311 * the spinlock held to protect the wait queue operation. 311 * the spinlock held to protect the wait queue operation.
312 */ 312 */
313static void rpc_make_runnable(struct rpc_task *task) 313static void rpc_make_runnable(struct rpc_task *task)
@@ -646,8 +646,8 @@ static int __rpc_execute(struct rpc_task *task)
646 if (RPC_DO_CALLBACK(task)) { 646 if (RPC_DO_CALLBACK(task)) {
647 /* Define a callback save pointer */ 647 /* Define a callback save pointer */
648 void (*save_callback)(struct rpc_task *); 648 void (*save_callback)(struct rpc_task *);
649 649
650 /* 650 /*
651 * If a callback exists, save it, reset it, 651 * If a callback exists, save it, reset it,
652 * call it. 652 * call it.
653 * The save is needed to stop from resetting 653 * The save is needed to stop from resetting
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c
index bd98124c3a64..044d9484bb8c 100644
--- a/net/sunrpc/stats.c
+++ b/net/sunrpc/stats.c
@@ -66,7 +66,7 @@ static int rpc_proc_open(struct inode *inode, struct file *file)
66 return single_open(file, rpc_proc_show, PDE(inode)->data); 66 return single_open(file, rpc_proc_show, PDE(inode)->data);
67} 67}
68 68
69static struct file_operations rpc_proc_fops = { 69static const struct file_operations rpc_proc_fops = {
70 .owner = THIS_MODULE, 70 .owner = THIS_MODULE,
71 .open = rpc_proc_open, 71 .open = rpc_proc_open,
72 .read = seq_read, 72 .read = seq_read,
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index c1f878131ac6..b00511d39b65 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -397,7 +397,7 @@ svc_destroy(struct svc_serv *serv)
397 sk_list); 397 sk_list);
398 svc_close_socket(svsk); 398 svc_close_socket(svsk);
399 } 399 }
400 400
401 cache_clean_deferred(serv); 401 cache_clean_deferred(serv);
402 402
403 /* Unregister service with the portmapper */ 403 /* Unregister service with the portmapper */
@@ -415,7 +415,7 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size)
415{ 415{
416 int pages; 416 int pages;
417 int arghi; 417 int arghi;
418 418
419 pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply. 419 pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply.
420 * We assume one is at most one page 420 * We assume one is at most one page
421 */ 421 */
@@ -514,7 +514,7 @@ choose_pool(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
514 if (pool != NULL) 514 if (pool != NULL)
515 return pool; 515 return pool;
516 516
517 return &serv->sv_pools[(*state)++ % serv->sv_nrpools]; 517 return &serv->sv_pools[(*state)++ % serv->sv_nrpools];
518} 518}
519 519
520/* 520/*
@@ -530,13 +530,13 @@ choose_victim(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
530 spin_lock_bh(&pool->sp_lock); 530 spin_lock_bh(&pool->sp_lock);
531 } else { 531 } else {
532 /* choose a pool in round-robin fashion */ 532 /* choose a pool in round-robin fashion */
533 for (i = 0; i < serv->sv_nrpools; i++) { 533 for (i = 0; i < serv->sv_nrpools; i++) {
534 pool = &serv->sv_pools[--(*state) % serv->sv_nrpools]; 534 pool = &serv->sv_pools[--(*state) % serv->sv_nrpools];
535 spin_lock_bh(&pool->sp_lock); 535 spin_lock_bh(&pool->sp_lock);
536 if (!list_empty(&pool->sp_all_threads)) 536 if (!list_empty(&pool->sp_all_threads))
537 goto found_pool; 537 goto found_pool;
538 spin_unlock_bh(&pool->sp_lock); 538 spin_unlock_bh(&pool->sp_lock);
539 } 539 }
540 return NULL; 540 return NULL;
541 } 541 }
542 542
@@ -551,7 +551,7 @@ found_pool:
551 rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all); 551 rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all);
552 list_del_init(&rqstp->rq_all); 552 list_del_init(&rqstp->rq_all);
553 task = rqstp->rq_task; 553 task = rqstp->rq_task;
554 } 554 }
555 spin_unlock_bh(&pool->sp_lock); 555 spin_unlock_bh(&pool->sp_lock);
556 556
557 return task; 557 return task;
@@ -636,7 +636,7 @@ svc_exit_thread(struct svc_rqst *rqstp)
636 636
637/* 637/*
638 * Register an RPC service with the local portmapper. 638 * Register an RPC service with the local portmapper.
639 * To unregister a service, call this routine with 639 * To unregister a service, call this routine with
640 * proto and port == 0. 640 * proto and port == 0.
641 */ 641 */
642int 642int
@@ -709,7 +709,7 @@ svc_process(struct svc_rqst *rqstp)
709 goto err_short_len; 709 goto err_short_len;
710 710
711 /* setup response xdr_buf. 711 /* setup response xdr_buf.
712 * Initially it has just one page 712 * Initially it has just one page
713 */ 713 */
714 rqstp->rq_resused = 1; 714 rqstp->rq_resused = 1;
715 resv->iov_base = page_address(rqstp->rq_respages[0]); 715 resv->iov_base = page_address(rqstp->rq_respages[0]);
@@ -811,7 +811,7 @@ svc_process(struct svc_rqst *rqstp)
811 memset(rqstp->rq_argp, 0, procp->pc_argsize); 811 memset(rqstp->rq_argp, 0, procp->pc_argsize);
812 memset(rqstp->rq_resp, 0, procp->pc_ressize); 812 memset(rqstp->rq_resp, 0, procp->pc_ressize);
813 813
814 /* un-reserve some of the out-queue now that we have a 814 /* un-reserve some of the out-queue now that we have a
815 * better idea of reply size 815 * better idea of reply size
816 */ 816 */
817 if (procp->pc_xdrressize) 817 if (procp->pc_xdrressize)
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index c7bb5f7f21a5..811a24c83262 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -2,7 +2,7 @@
2 * linux/net/sunrpc/svcauth.c 2 * linux/net/sunrpc/svcauth.c
3 * 3 *
4 * The generic interface for RPC authentication on the server side. 4 * The generic interface for RPC authentication on the server side.
5 * 5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> 6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 * 7 *
8 * CHANGES 8 * CHANGES
@@ -74,7 +74,7 @@ int svc_authorise(struct svc_rqst *rqstp)
74 int rv = 0; 74 int rv = 0;
75 75
76 rqstp->rq_authop = NULL; 76 rqstp->rq_authop = NULL;
77 77
78 if (aops) { 78 if (aops) {
79 rv = aops->release(rqstp); 79 rv = aops->release(rqstp);
80 module_put(aops->owner); 80 module_put(aops->owner);
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 0d1e8fb83b93..4b775dbf580d 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -151,7 +151,7 @@ static void ip_map_request(struct cache_detail *cd,
151 char text_addr[20]; 151 char text_addr[20];
152 struct ip_map *im = container_of(h, struct ip_map, h); 152 struct ip_map *im = container_of(h, struct ip_map, h);
153 __be32 addr = im->m_addr.s_addr; 153 __be32 addr = im->m_addr.s_addr;
154 154
155 snprintf(text_addr, 20, "%u.%u.%u.%u", 155 snprintf(text_addr, 20, "%u.%u.%u.%u",
156 ntohl(addr) >> 24 & 0xff, 156 ntohl(addr) >> 24 & 0xff,
157 ntohl(addr) >> 16 & 0xff, 157 ntohl(addr) >> 16 & 0xff,
@@ -198,7 +198,7 @@ static int ip_map_parse(struct cache_detail *cd,
198 198
199 if (sscanf(buf, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) 199 if (sscanf(buf, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4)
200 return -EINVAL; 200 return -EINVAL;
201 201
202 expiry = get_expiry(&mesg); 202 expiry = get_expiry(&mesg);
203 if (expiry ==0) 203 if (expiry ==0)
204 return -EINVAL; 204 return -EINVAL;
@@ -248,7 +248,7 @@ static int ip_map_show(struct seq_file *m,
248 /* class addr domain */ 248 /* class addr domain */
249 addr = im->m_addr; 249 addr = im->m_addr;
250 250
251 if (test_bit(CACHE_VALID, &h->flags) && 251 if (test_bit(CACHE_VALID, &h->flags) &&
252 !test_bit(CACHE_NEGATIVE, &h->flags)) 252 !test_bit(CACHE_NEGATIVE, &h->flags))
253 dom = im->m_client->h.name; 253 dom = im->m_client->h.name;
254 254
@@ -262,7 +262,7 @@ static int ip_map_show(struct seq_file *m,
262 ); 262 );
263 return 0; 263 return 0;
264} 264}
265 265
266 266
267struct cache_detail ip_map_cache = { 267struct cache_detail ip_map_cache = {
268 .owner = THIS_MODULE, 268 .owner = THIS_MODULE,
@@ -343,7 +343,7 @@ int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom)
343int auth_unix_forget_old(struct auth_domain *dom) 343int auth_unix_forget_old(struct auth_domain *dom)
344{ 344{
345 struct unix_domain *udom; 345 struct unix_domain *udom;
346 346
347 if (dom->flavour != &svcauth_unix) 347 if (dom->flavour != &svcauth_unix)
348 return -EINVAL; 348 return -EINVAL;
349 udom = container_of(dom, struct unix_domain, h); 349 udom = container_of(dom, struct unix_domain, h);
@@ -421,6 +421,7 @@ svcauth_unix_info_release(void *info)
421static int 421static int
422svcauth_unix_set_client(struct svc_rqst *rqstp) 422svcauth_unix_set_client(struct svc_rqst *rqstp)
423{ 423{
424 struct sockaddr_in *sin = svc_addr_in(rqstp);
424 struct ip_map *ipm; 425 struct ip_map *ipm;
425 426
426 rqstp->rq_client = NULL; 427 rqstp->rq_client = NULL;
@@ -430,7 +431,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
430 ipm = ip_map_cached_get(rqstp); 431 ipm = ip_map_cached_get(rqstp);
431 if (ipm == NULL) 432 if (ipm == NULL)
432 ipm = ip_map_lookup(rqstp->rq_server->sv_program->pg_class, 433 ipm = ip_map_lookup(rqstp->rq_server->sv_program->pg_class,
433 rqstp->rq_addr.sin_addr); 434 sin->sin_addr);
434 435
435 if (ipm == NULL) 436 if (ipm == NULL)
436 return SVC_DENIED; 437 return SVC_DENIED;
@@ -465,7 +466,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, __be32 *authp)
465 if (argv->iov_len < 3*4) 466 if (argv->iov_len < 3*4)
466 return SVC_GARBAGE; 467 return SVC_GARBAGE;
467 468
468 if (svc_getu32(argv) != 0) { 469 if (svc_getu32(argv) != 0) {
469 dprintk("svc: bad null cred\n"); 470 dprintk("svc: bad null cred\n");
470 *authp = rpc_autherr_badcred; 471 *authp = rpc_autherr_badcred;
471 return SVC_DENIED; 472 return SVC_DENIED;
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index cf93cd1d857b..63ae94771b8e 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -36,11 +36,13 @@
36#include <net/sock.h> 36#include <net/sock.h>
37#include <net/checksum.h> 37#include <net/checksum.h>
38#include <net/ip.h> 38#include <net/ip.h>
39#include <net/ipv6.h>
39#include <net/tcp_states.h> 40#include <net/tcp_states.h>
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
41#include <asm/ioctls.h> 42#include <asm/ioctls.h>
42 43
43#include <linux/sunrpc/types.h> 44#include <linux/sunrpc/types.h>
45#include <linux/sunrpc/clnt.h>
44#include <linux/sunrpc/xdr.h> 46#include <linux/sunrpc/xdr.h>
45#include <linux/sunrpc/svcsock.h> 47#include <linux/sunrpc/svcsock.h>
46#include <linux/sunrpc/stats.h> 48#include <linux/sunrpc/stats.h>
@@ -58,7 +60,7 @@
58 * providing that certain rules are followed: 60 * providing that certain rules are followed:
59 * 61 *
60 * SK_CONN, SK_DATA, can be set or cleared at any time. 62 * SK_CONN, SK_DATA, can be set or cleared at any time.
61 * after a set, svc_sock_enqueue must be called. 63 * after a set, svc_sock_enqueue must be called.
62 * after a clear, the socket must be read/accepted 64 * after a clear, the socket must be read/accepted
63 * if this succeeds, it must be set again. 65 * if this succeeds, it must be set again.
64 * SK_CLOSE can set at any time. It is never cleared. 66 * SK_CLOSE can set at any time. It is never cleared.
@@ -75,7 +77,7 @@
75 77
76 78
77static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, 79static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
78 int *errp, int pmap_reg); 80 int *errp, int flags);
79static void svc_delete_socket(struct svc_sock *svsk); 81static void svc_delete_socket(struct svc_sock *svsk);
80static void svc_udp_data_ready(struct sock *, int); 82static void svc_udp_data_ready(struct sock *, int);
81static int svc_udp_recvfrom(struct svc_rqst *); 83static int svc_udp_recvfrom(struct svc_rqst *);
@@ -121,6 +123,41 @@ static inline void svc_reclassify_socket(struct socket *sock)
121} 123}
122#endif 124#endif
123 125
126static char *__svc_print_addr(struct sockaddr *addr, char *buf, size_t len)
127{
128 switch (addr->sa_family) {
129 case AF_INET:
130 snprintf(buf, len, "%u.%u.%u.%u, port=%u",
131 NIPQUAD(((struct sockaddr_in *) addr)->sin_addr),
132 htons(((struct sockaddr_in *) addr)->sin_port));
133 break;
134#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
135 case AF_INET6:
136 snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x, port=%u",
137 NIP6(((struct sockaddr_in6 *) addr)->sin6_addr),
138 htons(((struct sockaddr_in6 *) addr)->sin6_port));
139 break;
140#endif
141 default:
142 snprintf(buf, len, "unknown address type: %d", addr->sa_family);
143 break;
144 }
145 return buf;
146}
147
148/**
149 * svc_print_addr - Format rq_addr field for printing
150 * @rqstp: svc_rqst struct containing address to print
151 * @buf: target buffer for formatted address
152 * @len: length of target buffer
153 *
154 */
155char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len)
156{
157 return __svc_print_addr(svc_addr(rqstp), buf, len);
158}
159EXPORT_SYMBOL_GPL(svc_print_addr);
160
124/* 161/*
125 * Queue up an idle server thread. Must have pool->sp_lock held. 162 * Queue up an idle server thread. Must have pool->sp_lock held.
126 * Note: this is really a stack rather than a queue, so that we only 163 * Note: this is really a stack rather than a queue, so that we only
@@ -252,7 +289,7 @@ svc_sock_enqueue(struct svc_sock *svsk)
252 svsk->sk_sk, rqstp); 289 svsk->sk_sk, rqstp);
253 svc_thread_dequeue(pool, rqstp); 290 svc_thread_dequeue(pool, rqstp);
254 if (rqstp->rq_sock) 291 if (rqstp->rq_sock)
255 printk(KERN_ERR 292 printk(KERN_ERR
256 "svc_sock_enqueue: server %p, rq_sock=%p!\n", 293 "svc_sock_enqueue: server %p, rq_sock=%p!\n",
257 rqstp, rqstp->rq_sock); 294 rqstp, rqstp->rq_sock);
258 rqstp->rq_sock = svsk; 295 rqstp->rq_sock = svsk;
@@ -410,6 +447,43 @@ svc_wake_up(struct svc_serv *serv)
410 } 447 }
411} 448}
412 449
450union svc_pktinfo_u {
451 struct in_pktinfo pkti;
452#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
453 struct in6_pktinfo pkti6;
454#endif
455};
456
457static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh)
458{
459 switch (rqstp->rq_sock->sk_sk->sk_family) {
460 case AF_INET: {
461 struct in_pktinfo *pki = CMSG_DATA(cmh);
462
463 cmh->cmsg_level = SOL_IP;
464 cmh->cmsg_type = IP_PKTINFO;
465 pki->ipi_ifindex = 0;
466 pki->ipi_spec_dst.s_addr = rqstp->rq_daddr.addr.s_addr;
467 cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
468 }
469 break;
470#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
471 case AF_INET6: {
472 struct in6_pktinfo *pki = CMSG_DATA(cmh);
473
474 cmh->cmsg_level = SOL_IPV6;
475 cmh->cmsg_type = IPV6_PKTINFO;
476 pki->ipi6_ifindex = 0;
477 ipv6_addr_copy(&pki->ipi6_addr,
478 &rqstp->rq_daddr.addr6);
479 cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
480 }
481 break;
482#endif
483 }
484 return;
485}
486
413/* 487/*
414 * Generic sendto routine 488 * Generic sendto routine
415 */ 489 */
@@ -419,9 +493,8 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
419 struct svc_sock *svsk = rqstp->rq_sock; 493 struct svc_sock *svsk = rqstp->rq_sock;
420 struct socket *sock = svsk->sk_sock; 494 struct socket *sock = svsk->sk_sock;
421 int slen; 495 int slen;
422 char buffer[CMSG_SPACE(sizeof(struct in_pktinfo))]; 496 char buffer[CMSG_SPACE(sizeof(union svc_pktinfo_u))];
423 struct cmsghdr *cmh = (struct cmsghdr *)buffer; 497 struct cmsghdr *cmh = (struct cmsghdr *)buffer;
424 struct in_pktinfo *pki = (struct in_pktinfo *)CMSG_DATA(cmh);
425 int len = 0; 498 int len = 0;
426 int result; 499 int result;
427 int size; 500 int size;
@@ -429,25 +502,20 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
429 size_t base = xdr->page_base; 502 size_t base = xdr->page_base;
430 unsigned int pglen = xdr->page_len; 503 unsigned int pglen = xdr->page_len;
431 unsigned int flags = MSG_MORE; 504 unsigned int flags = MSG_MORE;
505 char buf[RPC_MAX_ADDRBUFLEN];
432 506
433 slen = xdr->len; 507 slen = xdr->len;
434 508
435 if (rqstp->rq_prot == IPPROTO_UDP) { 509 if (rqstp->rq_prot == IPPROTO_UDP) {
436 /* set the source and destination */ 510 struct msghdr msg = {
437 struct msghdr msg; 511 .msg_name = &rqstp->rq_addr,
438 msg.msg_name = &rqstp->rq_addr; 512 .msg_namelen = rqstp->rq_addrlen,
439 msg.msg_namelen = sizeof(rqstp->rq_addr); 513 .msg_control = cmh,
440 msg.msg_iov = NULL; 514 .msg_controllen = sizeof(buffer),
441 msg.msg_iovlen = 0; 515 .msg_flags = MSG_MORE,
442 msg.msg_flags = MSG_MORE; 516 };
443 517
444 msg.msg_control = cmh; 518 svc_set_cmsg_data(rqstp, cmh);
445 msg.msg_controllen = sizeof(buffer);
446 cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
447 cmh->cmsg_level = SOL_IP;
448 cmh->cmsg_type = IP_PKTINFO;
449 pki->ipi_ifindex = 0;
450 pki->ipi_spec_dst.s_addr = rqstp->rq_daddr;
451 519
452 if (sock_sendmsg(sock, &msg, 0) < 0) 520 if (sock_sendmsg(sock, &msg, 0) < 0)
453 goto out; 521 goto out;
@@ -484,16 +552,16 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
484 if (xdr->tail[0].iov_len) { 552 if (xdr->tail[0].iov_len) {
485 result = kernel_sendpage(sock, rqstp->rq_respages[0], 553 result = kernel_sendpage(sock, rqstp->rq_respages[0],
486 ((unsigned long)xdr->tail[0].iov_base) 554 ((unsigned long)xdr->tail[0].iov_base)
487 & (PAGE_SIZE-1), 555 & (PAGE_SIZE-1),
488 xdr->tail[0].iov_len, 0); 556 xdr->tail[0].iov_len, 0);
489 557
490 if (result > 0) 558 if (result > 0)
491 len += result; 559 len += result;
492 } 560 }
493out: 561out:
494 dprintk("svc: socket %p sendto([%p %Zu... ], %d) = %d (addr %x)\n", 562 dprintk("svc: socket %p sendto([%p %Zu... ], %d) = %d (addr %s)\n",
495 rqstp->rq_sock, xdr->head[0].iov_base, xdr->head[0].iov_len, xdr->len, len, 563 rqstp->rq_sock, xdr->head[0].iov_base, xdr->head[0].iov_len,
496 rqstp->rq_addr.sin_addr.s_addr); 564 xdr->len, len, svc_print_addr(rqstp, buf, sizeof(buf)));
497 565
498 return len; 566 return len;
499} 567}
@@ -568,31 +636,22 @@ svc_recv_available(struct svc_sock *svsk)
568static int 636static int
569svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) 637svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen)
570{ 638{
571 struct msghdr msg; 639 struct svc_sock *svsk = rqstp->rq_sock;
572 struct socket *sock; 640 struct msghdr msg = {
573 int len, alen; 641 .msg_flags = MSG_DONTWAIT,
574 642 };
575 rqstp->rq_addrlen = sizeof(rqstp->rq_addr); 643 int len;
576 sock = rqstp->rq_sock->sk_sock;
577
578 msg.msg_name = &rqstp->rq_addr;
579 msg.msg_namelen = sizeof(rqstp->rq_addr);
580 msg.msg_control = NULL;
581 msg.msg_controllen = 0;
582
583 msg.msg_flags = MSG_DONTWAIT;
584 644
585 len = kernel_recvmsg(sock, &msg, iov, nr, buflen, MSG_DONTWAIT); 645 len = kernel_recvmsg(svsk->sk_sock, &msg, iov, nr, buflen,
646 msg.msg_flags);
586 647
587 /* sock_recvmsg doesn't fill in the name/namelen, so we must.. 648 /* sock_recvmsg doesn't fill in the name/namelen, so we must..
588 * possibly we should cache this in the svc_sock structure
589 * at accept time. FIXME
590 */ 649 */
591 alen = sizeof(rqstp->rq_addr); 650 memcpy(&rqstp->rq_addr, &svsk->sk_remote, svsk->sk_remotelen);
592 kernel_getpeername(sock, (struct sockaddr *)&rqstp->rq_addr, &alen); 651 rqstp->rq_addrlen = svsk->sk_remotelen;
593 652
594 dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n", 653 dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
595 rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len); 654 svsk, iov[0].iov_base, iov[0].iov_len, len);
596 655
597 return len; 656 return len;
598} 657}
@@ -662,6 +721,47 @@ svc_write_space(struct sock *sk)
662 } 721 }
663} 722}
664 723
724static void svc_udp_get_sender_address(struct svc_rqst *rqstp,
725 struct sk_buff *skb)
726{
727 switch (rqstp->rq_sock->sk_sk->sk_family) {
728 case AF_INET: {
729 /* this seems to come from net/ipv4/udp.c:udp_recvmsg */
730 struct sockaddr_in *sin = svc_addr_in(rqstp);
731
732 sin->sin_family = AF_INET;
733 sin->sin_port = skb->h.uh->source;
734 sin->sin_addr.s_addr = skb->nh.iph->saddr;
735 rqstp->rq_addrlen = sizeof(struct sockaddr_in);
736 /* Remember which interface received this request */
737 rqstp->rq_daddr.addr.s_addr = skb->nh.iph->daddr;
738 }
739 break;
740#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
741 case AF_INET6: {
742 /* this is derived from net/ipv6/udp.c:udpv6_recvmesg */
743 struct sockaddr_in6 *sin6 = svc_addr_in6(rqstp);
744
745 sin6->sin6_family = AF_INET6;
746 sin6->sin6_port = skb->h.uh->source;
747 sin6->sin6_flowinfo = 0;
748 sin6->sin6_scope_id = 0;
749 if (ipv6_addr_type(&sin6->sin6_addr) &
750 IPV6_ADDR_LINKLOCAL)
751 sin6->sin6_scope_id = IP6CB(skb)->iif;
752 ipv6_addr_copy(&sin6->sin6_addr,
753 &skb->nh.ipv6h->saddr);
754 rqstp->rq_addrlen = sizeof(struct sockaddr_in);
755 /* Remember which interface received this request */
756 ipv6_addr_copy(&rqstp->rq_daddr.addr6,
757 &skb->nh.ipv6h->saddr);
758 }
759 break;
760#endif
761 }
762 return;
763}
764
665/* 765/*
666 * Receive a datagram from a UDP socket. 766 * Receive a datagram from a UDP socket.
667 */ 767 */
@@ -711,7 +811,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
711 tv.tv_sec = xtime.tv_sec; 811 tv.tv_sec = xtime.tv_sec;
712 tv.tv_usec = xtime.tv_nsec / NSEC_PER_USEC; 812 tv.tv_usec = xtime.tv_nsec / NSEC_PER_USEC;
713 skb_set_timestamp(skb, &tv); 813 skb_set_timestamp(skb, &tv);
714 /* Don't enable netstamp, sunrpc doesn't 814 /* Don't enable netstamp, sunrpc doesn't
715 need that much accuracy */ 815 need that much accuracy */
716 } 816 }
717 skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp); 817 skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp);
@@ -725,13 +825,9 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
725 len = skb->len - sizeof(struct udphdr); 825 len = skb->len - sizeof(struct udphdr);
726 rqstp->rq_arg.len = len; 826 rqstp->rq_arg.len = len;
727 827
728 rqstp->rq_prot = IPPROTO_UDP; 828 rqstp->rq_prot = IPPROTO_UDP;
729 829
730 /* Get sender address */ 830 svc_udp_get_sender_address(rqstp, skb);
731 rqstp->rq_addr.sin_family = AF_INET;
732 rqstp->rq_addr.sin_port = skb->h.uh->source;
733 rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr;
734 rqstp->rq_daddr = skb->nh.iph->daddr;
735 831
736 if (skb_is_nonlinear(skb)) { 832 if (skb_is_nonlinear(skb)) {
737 /* we have to copy */ 833 /* we have to copy */
@@ -743,7 +839,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
743 return 0; 839 return 0;
744 } 840 }
745 local_bh_enable(); 841 local_bh_enable();
746 skb_free_datagram(svsk->sk_sk, skb); 842 skb_free_datagram(svsk->sk_sk, skb);
747 } else { 843 } else {
748 /* we can use it in-place */ 844 /* we can use it in-place */
749 rqstp->rq_arg.head[0].iov_base = skb->data + sizeof(struct udphdr); 845 rqstp->rq_arg.head[0].iov_base = skb->data + sizeof(struct udphdr);
@@ -794,7 +890,7 @@ svc_udp_init(struct svc_sock *svsk)
794 svsk->sk_sendto = svc_udp_sendto; 890 svsk->sk_sendto = svc_udp_sendto;
795 891
796 /* initialise setting must have enough space to 892 /* initialise setting must have enough space to
797 * receive and respond to one request. 893 * receive and respond to one request.
798 * svc_udp_recvfrom will re-adjust if necessary 894 * svc_udp_recvfrom will re-adjust if necessary
799 */ 895 */
800 svc_sock_setbufsize(svsk->sk_sock, 896 svc_sock_setbufsize(svsk->sk_sock,
@@ -875,18 +971,36 @@ svc_tcp_data_ready(struct sock *sk, int count)
875 wake_up_interruptible(sk->sk_sleep); 971 wake_up_interruptible(sk->sk_sleep);
876} 972}
877 973
974static inline int svc_port_is_privileged(struct sockaddr *sin)
975{
976 switch (sin->sa_family) {
977 case AF_INET:
978 return ntohs(((struct sockaddr_in *)sin)->sin_port)
979 < PROT_SOCK;
980#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
981 case AF_INET6:
982 return ntohs(((struct sockaddr_in6 *)sin)->sin6_port)
983 < PROT_SOCK;
984#endif
985 default:
986 return 0;
987 }
988}
989
878/* 990/*
879 * Accept a TCP connection 991 * Accept a TCP connection
880 */ 992 */
881static void 993static void
882svc_tcp_accept(struct svc_sock *svsk) 994svc_tcp_accept(struct svc_sock *svsk)
883{ 995{
884 struct sockaddr_in sin; 996 struct sockaddr_storage addr;
997 struct sockaddr *sin = (struct sockaddr *) &addr;
885 struct svc_serv *serv = svsk->sk_server; 998 struct svc_serv *serv = svsk->sk_server;
886 struct socket *sock = svsk->sk_sock; 999 struct socket *sock = svsk->sk_sock;
887 struct socket *newsock; 1000 struct socket *newsock;
888 struct svc_sock *newsvsk; 1001 struct svc_sock *newsvsk;
889 int err, slen; 1002 int err, slen;
1003 char buf[RPC_MAX_ADDRBUFLEN];
890 1004
891 dprintk("svc: tcp_accept %p sock %p\n", svsk, sock); 1005 dprintk("svc: tcp_accept %p sock %p\n", svsk, sock);
892 if (!sock) 1006 if (!sock)
@@ -907,8 +1021,7 @@ svc_tcp_accept(struct svc_sock *svsk)
907 set_bit(SK_CONN, &svsk->sk_flags); 1021 set_bit(SK_CONN, &svsk->sk_flags);
908 svc_sock_enqueue(svsk); 1022 svc_sock_enqueue(svsk);
909 1023
910 slen = sizeof(sin); 1024 err = kernel_getpeername(newsock, sin, &slen);
911 err = kernel_getpeername(newsock, (struct sockaddr *) &sin, &slen);
912 if (err < 0) { 1025 if (err < 0) {
913 if (net_ratelimit()) 1026 if (net_ratelimit())
914 printk(KERN_WARNING "%s: peername failed (err %d)!\n", 1027 printk(KERN_WARNING "%s: peername failed (err %d)!\n",
@@ -917,27 +1030,30 @@ svc_tcp_accept(struct svc_sock *svsk)
917 } 1030 }
918 1031
919 /* Ideally, we would want to reject connections from unauthorized 1032 /* Ideally, we would want to reject connections from unauthorized
920 * hosts here, but when we get encription, the IP of the host won't 1033 * hosts here, but when we get encryption, the IP of the host won't
921 * tell us anything. For now just warn about unpriv connections. 1034 * tell us anything. For now just warn about unpriv connections.
922 */ 1035 */
923 if (ntohs(sin.sin_port) >= 1024) { 1036 if (!svc_port_is_privileged(sin)) {
924 dprintk(KERN_WARNING 1037 dprintk(KERN_WARNING
925 "%s: connect from unprivileged port: %u.%u.%u.%u:%d\n", 1038 "%s: connect from unprivileged port: %s\n",
926 serv->sv_name, 1039 serv->sv_name,
927 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port)); 1040 __svc_print_addr(sin, buf, sizeof(buf)));
928 } 1041 }
929 1042 dprintk("%s: connect from %s\n", serv->sv_name,
930 dprintk("%s: connect from %u.%u.%u.%u:%04x\n", serv->sv_name, 1043 __svc_print_addr(sin, buf, sizeof(buf)));
931 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
932 1044
933 /* make sure that a write doesn't block forever when 1045 /* make sure that a write doesn't block forever when
934 * low on memory 1046 * low on memory
935 */ 1047 */
936 newsock->sk->sk_sndtimeo = HZ*30; 1048 newsock->sk->sk_sndtimeo = HZ*30;
937 1049
938 if (!(newsvsk = svc_setup_socket(serv, newsock, &err, 0))) 1050 if (!(newsvsk = svc_setup_socket(serv, newsock, &err,
1051 (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY))))
939 goto failed; 1052 goto failed;
1053 memcpy(&newsvsk->sk_remote, sin, slen);
1054 newsvsk->sk_remotelen = slen;
940 1055
1056 svc_sock_received(newsvsk);
941 1057
942 /* make sure that we don't have too many active connections. 1058 /* make sure that we don't have too many active connections.
943 * If we have, something must be dropped. 1059 * If we have, something must be dropped.
@@ -960,11 +1076,9 @@ svc_tcp_accept(struct svc_sock *svsk)
960 "sockets, consider increasing the " 1076 "sockets, consider increasing the "
961 "number of nfsd threads\n", 1077 "number of nfsd threads\n",
962 serv->sv_name); 1078 serv->sv_name);
963 printk(KERN_NOTICE "%s: last TCP connect from " 1079 printk(KERN_NOTICE
964 "%u.%u.%u.%u:%d\n", 1080 "%s: last TCP connect from %s\n",
965 serv->sv_name, 1081 serv->sv_name, buf);
966 NIPQUAD(sin.sin_addr.s_addr),
967 ntohs(sin.sin_port));
968 } 1082 }
969 /* 1083 /*
970 * Always select the oldest socket. It's not fair, 1084 * Always select the oldest socket. It's not fair,
@@ -1038,7 +1152,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
1038 * on the number of threads which will access the socket. 1152 * on the number of threads which will access the socket.
1039 * 1153 *
1040 * rcvbuf just needs to be able to hold a few requests. 1154 * rcvbuf just needs to be able to hold a few requests.
1041 * Normally they will be removed from the queue 1155 * Normally they will be removed from the queue
1042 * as soon a a complete request arrives. 1156 * as soon a a complete request arrives.
1043 */ 1157 */
1044 svc_sock_setbufsize(svsk->sk_sock, 1158 svc_sock_setbufsize(svsk->sk_sock,
@@ -1063,7 +1177,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
1063 1177
1064 if (len < want) { 1178 if (len < want) {
1065 dprintk("svc: short recvfrom while reading record length (%d of %lu)\n", 1179 dprintk("svc: short recvfrom while reading record length (%d of %lu)\n",
1066 len, want); 1180 len, want);
1067 svc_sock_received(svsk); 1181 svc_sock_received(svsk);
1068 return -EAGAIN; /* record header not complete */ 1182 return -EAGAIN; /* record header not complete */
1069 } 1183 }
@@ -1221,7 +1335,7 @@ svc_tcp_init(struct svc_sock *svsk)
1221 tp->nonagle = 1; /* disable Nagle's algorithm */ 1335 tp->nonagle = 1; /* disable Nagle's algorithm */
1222 1336
1223 /* initialise setting must have enough space to 1337 /* initialise setting must have enough space to
1224 * receive and respond to one request. 1338 * receive and respond to one request.
1225 * svc_tcp_recvfrom will re-adjust if necessary 1339 * svc_tcp_recvfrom will re-adjust if necessary
1226 */ 1340 */
1227 svc_sock_setbufsize(svsk->sk_sock, 1341 svc_sock_setbufsize(svsk->sk_sock,
@@ -1230,7 +1344,7 @@ svc_tcp_init(struct svc_sock *svsk)
1230 1344
1231 set_bit(SK_CHNGBUF, &svsk->sk_flags); 1345 set_bit(SK_CHNGBUF, &svsk->sk_flags);
1232 set_bit(SK_DATA, &svsk->sk_flags); 1346 set_bit(SK_DATA, &svsk->sk_flags);
1233 if (sk->sk_state != TCP_ESTABLISHED) 1347 if (sk->sk_state != TCP_ESTABLISHED)
1234 set_bit(SK_CLOSE, &svsk->sk_flags); 1348 set_bit(SK_CLOSE, &svsk->sk_flags);
1235 } 1349 }
1236} 1350}
@@ -1246,7 +1360,7 @@ svc_sock_update_bufs(struct svc_serv *serv)
1246 1360
1247 spin_lock_bh(&serv->sv_lock); 1361 spin_lock_bh(&serv->sv_lock);
1248 list_for_each(le, &serv->sv_permsocks) { 1362 list_for_each(le, &serv->sv_permsocks) {
1249 struct svc_sock *svsk = 1363 struct svc_sock *svsk =
1250 list_entry(le, struct svc_sock, sk_list); 1364 list_entry(le, struct svc_sock, sk_list);
1251 set_bit(SK_CHNGBUF, &svsk->sk_flags); 1365 set_bit(SK_CHNGBUF, &svsk->sk_flags);
1252 } 1366 }
@@ -1266,7 +1380,7 @@ svc_sock_update_bufs(struct svc_serv *serv)
1266int 1380int
1267svc_recv(struct svc_rqst *rqstp, long timeout) 1381svc_recv(struct svc_rqst *rqstp, long timeout)
1268{ 1382{
1269 struct svc_sock *svsk =NULL; 1383 struct svc_sock *svsk = NULL;
1270 struct svc_serv *serv = rqstp->rq_server; 1384 struct svc_serv *serv = rqstp->rq_server;
1271 struct svc_pool *pool = rqstp->rq_pool; 1385 struct svc_pool *pool = rqstp->rq_pool;
1272 int len, i; 1386 int len, i;
@@ -1278,11 +1392,11 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
1278 rqstp, timeout); 1392 rqstp, timeout);
1279 1393
1280 if (rqstp->rq_sock) 1394 if (rqstp->rq_sock)
1281 printk(KERN_ERR 1395 printk(KERN_ERR
1282 "svc_recv: service %p, socket not NULL!\n", 1396 "svc_recv: service %p, socket not NULL!\n",
1283 rqstp); 1397 rqstp);
1284 if (waitqueue_active(&rqstp->rq_wait)) 1398 if (waitqueue_active(&rqstp->rq_wait))
1285 printk(KERN_ERR 1399 printk(KERN_ERR
1286 "svc_recv: service %p, wait queue active!\n", 1400 "svc_recv: service %p, wait queue active!\n",
1287 rqstp); 1401 rqstp);
1288 1402
@@ -1363,7 +1477,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
1363 svsk->sk_lastrecv = get_seconds(); 1477 svsk->sk_lastrecv = get_seconds();
1364 clear_bit(SK_OLD, &svsk->sk_flags); 1478 clear_bit(SK_OLD, &svsk->sk_flags);
1365 1479
1366 rqstp->rq_secure = ntohs(rqstp->rq_addr.sin_port) < 1024; 1480 rqstp->rq_secure = svc_port_is_privileged(svc_addr(rqstp));
1367 rqstp->rq_chandle.defer = svc_defer; 1481 rqstp->rq_chandle.defer = svc_defer;
1368 1482
1369 if (serv->sv_stats) 1483 if (serv->sv_stats)
@@ -1371,7 +1485,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
1371 return len; 1485 return len;
1372} 1486}
1373 1487
1374/* 1488/*
1375 * Drop request 1489 * Drop request
1376 */ 1490 */
1377void 1491void
@@ -1476,12 +1590,14 @@ svc_age_temp_sockets(unsigned long closure)
1476 * Initialize socket for RPC use and create svc_sock struct 1590 * Initialize socket for RPC use and create svc_sock struct
1477 * XXX: May want to setsockopt SO_SNDBUF and SO_RCVBUF. 1591 * XXX: May want to setsockopt SO_SNDBUF and SO_RCVBUF.
1478 */ 1592 */
1479static struct svc_sock * 1593static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
1480svc_setup_socket(struct svc_serv *serv, struct socket *sock, 1594 struct socket *sock,
1481 int *errp, int pmap_register) 1595 int *errp, int flags)
1482{ 1596{
1483 struct svc_sock *svsk; 1597 struct svc_sock *svsk;
1484 struct sock *inet; 1598 struct sock *inet;
1599 int pmap_register = !(flags & SVC_SOCK_ANONYMOUS);
1600 int is_temporary = flags & SVC_SOCK_TEMPORARY;
1485 1601
1486 dprintk("svc: svc_setup_socket %p\n", sock); 1602 dprintk("svc: svc_setup_socket %p\n", sock);
1487 if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) { 1603 if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) {
@@ -1523,7 +1639,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock,
1523 svc_tcp_init(svsk); 1639 svc_tcp_init(svsk);
1524 1640
1525 spin_lock_bh(&serv->sv_lock); 1641 spin_lock_bh(&serv->sv_lock);
1526 if (!pmap_register) { 1642 if (is_temporary) {
1527 set_bit(SK_TEMP, &svsk->sk_flags); 1643 set_bit(SK_TEMP, &svsk->sk_flags);
1528 list_add(&svsk->sk_list, &serv->sv_tempsocks); 1644 list_add(&svsk->sk_list, &serv->sv_tempsocks);
1529 serv->sv_tmpcnt++; 1645 serv->sv_tmpcnt++;
@@ -1543,8 +1659,6 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock,
1543 dprintk("svc: svc_setup_socket created %p (inet %p)\n", 1659 dprintk("svc: svc_setup_socket created %p (inet %p)\n",
1544 svsk, svsk->sk_sk); 1660 svsk, svsk->sk_sk);
1545 1661
1546 clear_bit(SK_BUSY, &svsk->sk_flags);
1547 svc_sock_enqueue(svsk);
1548 return svsk; 1662 return svsk;
1549} 1663}
1550 1664
@@ -1567,9 +1681,11 @@ int svc_addsock(struct svc_serv *serv,
1567 else if (so->state > SS_UNCONNECTED) 1681 else if (so->state > SS_UNCONNECTED)
1568 err = -EISCONN; 1682 err = -EISCONN;
1569 else { 1683 else {
1570 svsk = svc_setup_socket(serv, so, &err, 1); 1684 svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS);
1571 if (svsk) 1685 if (svsk) {
1686 svc_sock_received(svsk);
1572 err = 0; 1687 err = 0;
1688 }
1573 } 1689 }
1574 if (err) { 1690 if (err) {
1575 sockfd_put(so); 1691 sockfd_put(so);
@@ -1583,18 +1699,18 @@ EXPORT_SYMBOL_GPL(svc_addsock);
1583/* 1699/*
1584 * Create socket for RPC service. 1700 * Create socket for RPC service.
1585 */ 1701 */
1586static int 1702static int svc_create_socket(struct svc_serv *serv, int protocol,
1587svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin) 1703 struct sockaddr *sin, int len, int flags)
1588{ 1704{
1589 struct svc_sock *svsk; 1705 struct svc_sock *svsk;
1590 struct socket *sock; 1706 struct socket *sock;
1591 int error; 1707 int error;
1592 int type; 1708 int type;
1709 char buf[RPC_MAX_ADDRBUFLEN];
1593 1710
1594 dprintk("svc: svc_create_socket(%s, %d, %u.%u.%u.%u:%d)\n", 1711 dprintk("svc: svc_create_socket(%s, %d, %s)\n",
1595 serv->sv_program->pg_name, protocol, 1712 serv->sv_program->pg_name, protocol,
1596 NIPQUAD(sin->sin_addr.s_addr), 1713 __svc_print_addr(sin, buf, sizeof(buf)));
1597 ntohs(sin->sin_port));
1598 1714
1599 if (protocol != IPPROTO_UDP && protocol != IPPROTO_TCP) { 1715 if (protocol != IPPROTO_UDP && protocol != IPPROTO_TCP) {
1600 printk(KERN_WARNING "svc: only UDP and TCP " 1716 printk(KERN_WARNING "svc: only UDP and TCP "
@@ -1603,15 +1719,15 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
1603 } 1719 }
1604 type = (protocol == IPPROTO_UDP)? SOCK_DGRAM : SOCK_STREAM; 1720 type = (protocol == IPPROTO_UDP)? SOCK_DGRAM : SOCK_STREAM;
1605 1721
1606 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0) 1722 error = sock_create_kern(sin->sa_family, type, protocol, &sock);
1723 if (error < 0)
1607 return error; 1724 return error;
1608 1725
1609 svc_reclassify_socket(sock); 1726 svc_reclassify_socket(sock);
1610 1727
1611 if (type == SOCK_STREAM) 1728 if (type == SOCK_STREAM)
1612 sock->sk->sk_reuse = 1; /* allow address reuse */ 1729 sock->sk->sk_reuse = 1; /* allow address reuse */
1613 error = kernel_bind(sock, (struct sockaddr *) sin, 1730 error = kernel_bind(sock, sin, len);
1614 sizeof(*sin));
1615 if (error < 0) 1731 if (error < 0)
1616 goto bummer; 1732 goto bummer;
1617 1733
@@ -1620,8 +1736,10 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
1620 goto bummer; 1736 goto bummer;
1621 } 1737 }
1622 1738
1623 if ((svsk = svc_setup_socket(serv, sock, &error, 1)) != NULL) 1739 if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) {
1624 return 0; 1740 svc_sock_received(svsk);
1741 return ntohs(inet_sk(svsk->sk_sk)->sport);
1742 }
1625 1743
1626bummer: 1744bummer:
1627 dprintk("svc: svc_create_socket error = %d\n", -error); 1745 dprintk("svc: svc_create_socket error = %d\n", -error);
@@ -1651,7 +1769,7 @@ svc_delete_socket(struct svc_sock *svsk)
1651 1769
1652 if (!test_and_set_bit(SK_DETACHED, &svsk->sk_flags)) 1770 if (!test_and_set_bit(SK_DETACHED, &svsk->sk_flags))
1653 list_del_init(&svsk->sk_list); 1771 list_del_init(&svsk->sk_list);
1654 /* 1772 /*
1655 * We used to delete the svc_sock from whichever list 1773 * We used to delete the svc_sock from whichever list
1656 * it's sk_ready node was on, but we don't actually 1774 * it's sk_ready node was on, but we don't actually
1657 * need to. This is because the only time we're called 1775 * need to. This is because the only time we're called
@@ -1681,23 +1799,30 @@ void svc_close_socket(struct svc_sock *svsk)
1681 svc_sock_put(svsk); 1799 svc_sock_put(svsk);
1682} 1800}
1683 1801
1684/* 1802/**
1685 * Make a socket for nfsd and lockd 1803 * svc_makesock - Make a socket for nfsd and lockd
1804 * @serv: RPC server structure
1805 * @protocol: transport protocol to use
1806 * @port: port to use
1807 * @flags: requested socket characteristics
1808 *
1686 */ 1809 */
1687int 1810int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port,
1688svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) 1811 int flags)
1689{ 1812{
1690 struct sockaddr_in sin; 1813 struct sockaddr_in sin = {
1814 .sin_family = AF_INET,
1815 .sin_addr.s_addr = INADDR_ANY,
1816 .sin_port = htons(port),
1817 };
1691 1818
1692 dprintk("svc: creating socket proto = %d\n", protocol); 1819 dprintk("svc: creating socket proto = %d\n", protocol);
1693 sin.sin_family = AF_INET; 1820 return svc_create_socket(serv, protocol, (struct sockaddr *) &sin,
1694 sin.sin_addr.s_addr = INADDR_ANY; 1821 sizeof(sin), flags);
1695 sin.sin_port = htons(port);
1696 return svc_create_socket(serv, protocol, &sin);
1697} 1822}
1698 1823
1699/* 1824/*
1700 * Handle defer and revisit of requests 1825 * Handle defer and revisit of requests
1701 */ 1826 */
1702 1827
1703static void svc_revisit(struct cache_deferred_req *dreq, int too_many) 1828static void svc_revisit(struct cache_deferred_req *dreq, int too_many)
@@ -1742,7 +1867,8 @@ svc_defer(struct cache_req *req)
1742 1867
1743 dr->handle.owner = rqstp->rq_server; 1868 dr->handle.owner = rqstp->rq_server;
1744 dr->prot = rqstp->rq_prot; 1869 dr->prot = rqstp->rq_prot;
1745 dr->addr = rqstp->rq_addr; 1870 memcpy(&dr->addr, &rqstp->rq_addr, rqstp->rq_addrlen);
1871 dr->addrlen = rqstp->rq_addrlen;
1746 dr->daddr = rqstp->rq_daddr; 1872 dr->daddr = rqstp->rq_daddr;
1747 dr->argslen = rqstp->rq_arg.len >> 2; 1873 dr->argslen = rqstp->rq_arg.len >> 2;
1748 memcpy(dr->args, rqstp->rq_arg.head[0].iov_base-skip, dr->argslen<<2); 1874 memcpy(dr->args, rqstp->rq_arg.head[0].iov_base-skip, dr->argslen<<2);
@@ -1766,7 +1892,8 @@ static int svc_deferred_recv(struct svc_rqst *rqstp)
1766 rqstp->rq_arg.page_len = 0; 1892 rqstp->rq_arg.page_len = 0;
1767 rqstp->rq_arg.len = dr->argslen<<2; 1893 rqstp->rq_arg.len = dr->argslen<<2;
1768 rqstp->rq_prot = dr->prot; 1894 rqstp->rq_prot = dr->prot;
1769 rqstp->rq_addr = dr->addr; 1895 memcpy(&rqstp->rq_addr, &dr->addr, dr->addrlen);
1896 rqstp->rq_addrlen = dr->addrlen;
1770 rqstp->rq_daddr = dr->daddr; 1897 rqstp->rq_daddr = dr->daddr;
1771 rqstp->rq_respages = rqstp->rq_pages; 1898 rqstp->rq_respages = rqstp->rq_pages;
1772 return dr->argslen<<2; 1899 return dr->argslen<<2;
@@ -1776,7 +1903,7 @@ static int svc_deferred_recv(struct svc_rqst *rqstp)
1776static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk) 1903static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk)
1777{ 1904{
1778 struct svc_deferred_req *dr = NULL; 1905 struct svc_deferred_req *dr = NULL;
1779 1906
1780 if (!test_bit(SK_DEFERRED, &svsk->sk_flags)) 1907 if (!test_bit(SK_DEFERRED, &svsk->sk_flags))
1781 return NULL; 1908 return NULL;
1782 spin_lock_bh(&svsk->sk_defer_lock); 1909 spin_lock_bh(&svsk->sk_defer_lock);
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index 82b27528d0c4..47d8df2b5eb2 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -42,7 +42,7 @@ rpc_register_sysctl(void)
42 sunrpc_table[0].de->owner = THIS_MODULE; 42 sunrpc_table[0].de->owner = THIS_MODULE;
43#endif 43#endif
44 } 44 }
45 45
46} 46}
47 47
48void 48void
@@ -126,7 +126,7 @@ static ctl_table debug_table[] = {
126 .maxlen = sizeof(int), 126 .maxlen = sizeof(int),
127 .mode = 0644, 127 .mode = 0644,
128 .proc_handler = &proc_dodebug 128 .proc_handler = &proc_dodebug
129 }, 129 },
130 { 130 {
131 .ctl_name = CTL_NFSDEBUG, 131 .ctl_name = CTL_NFSDEBUG,
132 .procname = "nfs_debug", 132 .procname = "nfs_debug",
@@ -134,7 +134,7 @@ static ctl_table debug_table[] = {
134 .maxlen = sizeof(int), 134 .maxlen = sizeof(int),
135 .mode = 0644, 135 .mode = 0644,
136 .proc_handler = &proc_dodebug 136 .proc_handler = &proc_dodebug
137 }, 137 },
138 { 138 {
139 .ctl_name = CTL_NFSDDEBUG, 139 .ctl_name = CTL_NFSDDEBUG,
140 .procname = "nfsd_debug", 140 .procname = "nfsd_debug",
@@ -142,7 +142,7 @@ static ctl_table debug_table[] = {
142 .maxlen = sizeof(int), 142 .maxlen = sizeof(int),
143 .mode = 0644, 143 .mode = 0644,
144 .proc_handler = &proc_dodebug 144 .proc_handler = &proc_dodebug
145 }, 145 },
146 { 146 {
147 .ctl_name = CTL_NLMDEBUG, 147 .ctl_name = CTL_NLMDEBUG,
148 .procname = "nlm_debug", 148 .procname = "nlm_debug",
@@ -150,7 +150,7 @@ static ctl_table debug_table[] = {
150 .maxlen = sizeof(int), 150 .maxlen = sizeof(int),
151 .mode = 0644, 151 .mode = 0644,
152 .proc_handler = &proc_dodebug 152 .proc_handler = &proc_dodebug
153 }, 153 },
154 { .ctl_name = 0 } 154 { .ctl_name = 0 }
155}; 155};
156 156
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index a0af250ca319..6a59180e1667 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -302,7 +302,7 @@ _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len)
302 * @buf: xdr_buf 302 * @buf: xdr_buf
303 * @len: bytes to remove from buf->head[0] 303 * @len: bytes to remove from buf->head[0]
304 * 304 *
305 * Shrinks XDR buffer's header kvec buf->head[0] by 305 * Shrinks XDR buffer's header kvec buf->head[0] by
306 * 'len' bytes. The extra data is not lost, but is instead 306 * 'len' bytes. The extra data is not lost, but is instead
307 * moved into the inlined pages and/or the tail. 307 * moved into the inlined pages and/or the tail.
308 */ 308 */
@@ -375,7 +375,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len)
375 * @buf: xdr_buf 375 * @buf: xdr_buf
376 * @len: bytes to remove from buf->pages 376 * @len: bytes to remove from buf->pages
377 * 377 *
378 * Shrinks XDR buffer's page array buf->pages by 378 * Shrinks XDR buffer's page array buf->pages by
379 * 'len' bytes. The extra data is not lost, but is instead 379 * 'len' bytes. The extra data is not lost, but is instead
380 * moved into the tail. 380 * moved into the tail.
381 */ 381 */
@@ -1024,7 +1024,7 @@ xdr_encode_array2(struct xdr_buf *buf, unsigned int base,
1024 1024
1025int 1025int
1026xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, 1026xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
1027 int (*actor)(struct scatterlist *, void *), void *data) 1027 int (*actor)(struct scatterlist *, void *), void *data)
1028{ 1028{
1029 int i, ret = 0; 1029 int i, ret = 0;
1030 unsigned page_len, thislen, page_offset; 1030 unsigned page_len, thislen, page_offset;
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 7a3999f0a4a2..e7c71a1ea3d4 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -410,7 +410,7 @@ void xprt_set_retrans_timeout_def(struct rpc_task *task)
410/* 410/*
411 * xprt_set_retrans_timeout_rtt - set a request's retransmit timeout 411 * xprt_set_retrans_timeout_rtt - set a request's retransmit timeout
412 * @task: task whose timeout is to be set 412 * @task: task whose timeout is to be set
413 * 413 *
414 * Set a request's retransmit timeout using the RTT estimator. 414 * Set a request's retransmit timeout using the RTT estimator.
415 */ 415 */
416void xprt_set_retrans_timeout_rtt(struct rpc_task *task) 416void xprt_set_retrans_timeout_rtt(struct rpc_task *task)
@@ -873,7 +873,7 @@ void xprt_release(struct rpc_task *task)
873 */ 873 */
874void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr) 874void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
875{ 875{
876 to->to_initval = 876 to->to_initval =
877 to->to_increment = incr; 877 to->to_increment = incr;
878 to->to_maxval = to->to_initval + (incr * retr); 878 to->to_maxval = to->to_initval + (incr * retr);
879 to->to_retries = retr; 879 to->to_retries = retr;