hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/sunrpc/auth_null.c
....@@ -21,7 +21,7 @@
2121 static struct rpc_auth *
2222 nul_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
2323 {
24
- atomic_inc(&null_auth.au_count);
24
+ refcount_inc(&null_auth.au_count);
2525 return &null_auth;
2626 }
2727
....@@ -36,8 +36,6 @@
3636 static struct rpc_cred *
3737 nul_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
3838 {
39
- if (flags & RPCAUTH_LOOKUP_RCU)
40
- return &null_cred;
4139 return get_rpccred(&null_cred);
4240 }
4341
....@@ -61,15 +59,21 @@
6159 /*
6260 * Marshal credential.
6361 */
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)
6664 {
67
- *p++ = htonl(RPC_AUTH_NULL);
68
- *p++ = 0;
69
- *p++ = htonl(RPC_AUTH_NULL);
70
- *p++ = 0;
65
+ __be32 *p;
7166
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;
7377 }
7478
7579 /*
....@@ -82,25 +86,19 @@
8286 return 0;
8387 }
8488
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)
8791 {
88
- rpc_authflavor_t flavor;
89
- u32 size;
92
+ __be32 *p;
9093
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;
104102 }
105103
106104 const struct rpc_authops authnull_ops = {
....@@ -116,21 +114,23 @@
116114 struct rpc_auth null_auth = {
117115 .au_cslack = NUL_CALLSLACK,
118116 .au_rslack = NUL_REPLYSLACK,
119
- .au_flags = RPCAUTH_AUTH_NO_CRKEY_TIMEOUT,
117
+ .au_verfsize = NUL_REPLYSLACK,
118
+ .au_ralign = NUL_REPLYSLACK,
120119 .au_ops = &authnull_ops,
121120 .au_flavor = RPC_AUTH_NULL,
122
- .au_count = ATOMIC_INIT(0),
121
+ .au_count = REFCOUNT_INIT(1),
123122 };
124123
125124 static
126125 const struct rpc_credops null_credops = {
127126 .cr_name = "AUTH_NULL",
128127 .crdestroy = nul_destroy_cred,
129
- .crbind = rpcauth_generic_bind_cred,
130128 .crmatch = nul_match,
131129 .crmarshal = nul_marshal,
130
+ .crwrap_req = rpcauth_wrap_req_encode,
132131 .crrefresh = nul_refresh,
133132 .crvalidate = nul_validate,
133
+ .crunwrap_resp = rpcauth_unwrap_resp_decode,
134134 };
135135
136136 static
....@@ -138,6 +138,6 @@
138138 .cr_lru = LIST_HEAD_INIT(null_cred.cr_lru),
139139 .cr_auth = &null_auth,
140140 .cr_ops = &null_credops,
141
- .cr_count = ATOMIC_INIT(1),
141
+ .cr_count = REFCOUNT_INIT(2),
142142 .cr_flags = 1UL << RPCAUTH_CRED_UPTODATE,
143143 };