.. | .. |
---|
21 | 21 | static struct rpc_auth * |
---|
22 | 22 | nul_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) |
---|
23 | 23 | { |
---|
24 | | - atomic_inc(&null_auth.au_count); |
---|
| 24 | + refcount_inc(&null_auth.au_count); |
---|
25 | 25 | return &null_auth; |
---|
26 | 26 | } |
---|
27 | 27 | |
---|
.. | .. |
---|
36 | 36 | static struct rpc_cred * |
---|
37 | 37 | nul_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) |
---|
38 | 38 | { |
---|
39 | | - if (flags & RPCAUTH_LOOKUP_RCU) |
---|
40 | | - return &null_cred; |
---|
41 | 39 | return get_rpccred(&null_cred); |
---|
42 | 40 | } |
---|
43 | 41 | |
---|
.. | .. |
---|
61 | 59 | /* |
---|
62 | 60 | * Marshal credential. |
---|
63 | 61 | */ |
---|
64 | | -static __be32 * |
---|
65 | | -nul_marshal(struct rpc_task *task, __be32 *p) |
---|
| 62 | +static int |
---|
| 63 | +nul_marshal(struct rpc_task *task, struct xdr_stream *xdr) |
---|
66 | 64 | { |
---|
67 | | - *p++ = htonl(RPC_AUTH_NULL); |
---|
68 | | - *p++ = 0; |
---|
69 | | - *p++ = htonl(RPC_AUTH_NULL); |
---|
70 | | - *p++ = 0; |
---|
| 65 | + __be32 *p; |
---|
71 | 66 | |
---|
72 | | - return p; |
---|
| 67 | + p = xdr_reserve_space(xdr, 4 * sizeof(*p)); |
---|
| 68 | + if (!p) |
---|
| 69 | + return -EMSGSIZE; |
---|
| 70 | + /* Credential */ |
---|
| 71 | + *p++ = rpc_auth_null; |
---|
| 72 | + *p++ = xdr_zero; |
---|
| 73 | + /* Verifier */ |
---|
| 74 | + *p++ = rpc_auth_null; |
---|
| 75 | + *p = xdr_zero; |
---|
| 76 | + return 0; |
---|
73 | 77 | } |
---|
74 | 78 | |
---|
75 | 79 | /* |
---|
.. | .. |
---|
82 | 86 | return 0; |
---|
83 | 87 | } |
---|
84 | 88 | |
---|
85 | | -static __be32 * |
---|
86 | | -nul_validate(struct rpc_task *task, __be32 *p) |
---|
| 89 | +static int |
---|
| 90 | +nul_validate(struct rpc_task *task, struct xdr_stream *xdr) |
---|
87 | 91 | { |
---|
88 | | - rpc_authflavor_t flavor; |
---|
89 | | - u32 size; |
---|
| 92 | + __be32 *p; |
---|
90 | 93 | |
---|
91 | | - flavor = ntohl(*p++); |
---|
92 | | - if (flavor != RPC_AUTH_NULL) { |
---|
93 | | - printk("RPC: bad verf flavor: %u\n", flavor); |
---|
94 | | - return ERR_PTR(-EIO); |
---|
95 | | - } |
---|
96 | | - |
---|
97 | | - size = ntohl(*p++); |
---|
98 | | - if (size != 0) { |
---|
99 | | - printk("RPC: bad verf size: %u\n", size); |
---|
100 | | - return ERR_PTR(-EIO); |
---|
101 | | - } |
---|
102 | | - |
---|
103 | | - return p; |
---|
| 94 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); |
---|
| 95 | + if (!p) |
---|
| 96 | + return -EIO; |
---|
| 97 | + if (*p++ != rpc_auth_null) |
---|
| 98 | + return -EIO; |
---|
| 99 | + if (*p != xdr_zero) |
---|
| 100 | + return -EIO; |
---|
| 101 | + return 0; |
---|
104 | 102 | } |
---|
105 | 103 | |
---|
106 | 104 | const struct rpc_authops authnull_ops = { |
---|
.. | .. |
---|
116 | 114 | struct rpc_auth null_auth = { |
---|
117 | 115 | .au_cslack = NUL_CALLSLACK, |
---|
118 | 116 | .au_rslack = NUL_REPLYSLACK, |
---|
119 | | - .au_flags = RPCAUTH_AUTH_NO_CRKEY_TIMEOUT, |
---|
| 117 | + .au_verfsize = NUL_REPLYSLACK, |
---|
| 118 | + .au_ralign = NUL_REPLYSLACK, |
---|
120 | 119 | .au_ops = &authnull_ops, |
---|
121 | 120 | .au_flavor = RPC_AUTH_NULL, |
---|
122 | | - .au_count = ATOMIC_INIT(0), |
---|
| 121 | + .au_count = REFCOUNT_INIT(1), |
---|
123 | 122 | }; |
---|
124 | 123 | |
---|
125 | 124 | static |
---|
126 | 125 | const struct rpc_credops null_credops = { |
---|
127 | 126 | .cr_name = "AUTH_NULL", |
---|
128 | 127 | .crdestroy = nul_destroy_cred, |
---|
129 | | - .crbind = rpcauth_generic_bind_cred, |
---|
130 | 128 | .crmatch = nul_match, |
---|
131 | 129 | .crmarshal = nul_marshal, |
---|
| 130 | + .crwrap_req = rpcauth_wrap_req_encode, |
---|
132 | 131 | .crrefresh = nul_refresh, |
---|
133 | 132 | .crvalidate = nul_validate, |
---|
| 133 | + .crunwrap_resp = rpcauth_unwrap_resp_decode, |
---|
134 | 134 | }; |
---|
135 | 135 | |
---|
136 | 136 | static |
---|
.. | .. |
---|
138 | 138 | .cr_lru = LIST_HEAD_INIT(null_cred.cr_lru), |
---|
139 | 139 | .cr_auth = &null_auth, |
---|
140 | 140 | .cr_ops = &null_credops, |
---|
141 | | - .cr_count = ATOMIC_INIT(1), |
---|
| 141 | + .cr_count = REFCOUNT_INIT(2), |
---|
142 | 142 | .cr_flags = 1UL << RPCAUTH_CRED_UPTODATE, |
---|
143 | 143 | }; |
---|