History

SUNRPC: Add rpc_auth::au_ralign field

Currently rpc_inline_rcv_pages() uses au_rslack to estimate the size of the upper layer reply header. This is fine for auth flavors where au_verfsize == au_rslack. However, some auth flavors have more going on. krb5i for example has two more words after the verifier, and another blob following the RPC message. The calculation involving au_rslack pushes the upper layer reply header too far into the rcv_buf. au_rslack is still valuable: it's the amount of buffer space needed for the reply, and is used when allocating the reply buffer. We'll keep that. But, add a new field that can be used to properly estimate the location of the upper layer header in each RPC reply, based on the auth flavor in use.

Chuck Lever committed 7 years ago

Commit 35e77d21 parent a00275b5 files · +20 −11Browse files

Unified · Split

5 files
  1. include/linux/sunrpc/auth.h +4 −5
  2. net/sunrpc/auth_gss/auth_gss.c +13 −5
  3. net/sunrpc/auth_null.c +1 −0
  4. net/sunrpc/auth_unix.c +1 −0
  5. net/sunrpc/clnt.c +1 −1
include/linux/sunrpc/auth.h+4−5
@@ -74,13 +74,12 @@ struct rpc_cred_cache; · 73 unmodified lines
7474 struct rpc_authops;
7575 struct rpc_auth {
7676 unsigned int au_cslack; /* call cred size estimate */
77− /* guess at number of u32's auth adds before
78− * reply data; normally the verifier size: */
79− unsigned int au_rslack;
77+ unsigned int au_rslack; /* reply cred size estimate */
8078 unsigned int au_verfsize; /* size of reply verifier */
79+ unsigned int au_ralign; /* words before UL header */
8180
82− unsigned int au_flags; /* various flags */
83− const struct rpc_authops *au_ops; /* operations */
81+ unsigned int au_flags;
82+ const struct rpc_authops *au_ops;
8483 rpc_authflavor_t au_flavor; /* pseudoflavor (note may
8584 * differ from the flavor in
8685 * au_ops->au_flavor in gss
net/sunrpc/auth_gss/auth_gss.c+13−5
@@ -1017,6 +1017,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 1016 unmodified lines
10171017 auth->au_cslack = GSS_CRED_SLACK >> 2;
10181018 auth->au_rslack = GSS_VERF_SLACK >> 2;
10191019 auth->au_verfsize = GSS_VERF_SLACK >> 2;
1020+ auth->au_ralign = GSS_VERF_SLACK >> 2;
10201021 auth->au_flags = 0;
10211022 auth->au_ops = &authgss_ops;
10221023 auth->au_flavor = flavor;
@@ -1891,7 +1892,10 @@ out: · 868 unmodified lines
18911892 static int
18921893 gss_unwrap_resp_auth(struct rpc_cred *cred)
18931894 {
1894− cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize;
1895+ struct rpc_auth *auth = cred->cr_auth;
1896+
1897+ auth->au_rslack = auth->au_verfsize;
1898+ auth->au_ralign = auth->au_verfsize;
18951899 return 0;
18961900 }
18971901
@@ -1902,6 +1906,7 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, · 4 unmodified lines
19021906 {
19031907 struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf;
19041908 u32 data_offset, mic_offset, integ_len, maj_stat;
1909+ struct rpc_auth *auth = cred->cr_auth;
19051910 struct xdr_netobj mic;
19061911 __be32 *p;
19071912
@@ -1928,8 +1933,8 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, · 20 unmodified lines
19281933 if (maj_stat != GSS_S_COMPLETE)
19291934 goto bad_mic;
19301935
1931− cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 +
1932− 1 + XDR_QUADLEN(mic.len);
1936+ auth->au_rslack = auth->au_verfsize + 2 + 1 + XDR_QUADLEN(mic.len);
1937+ auth->au_ralign = auth->au_verfsize + 2;
19331938 return 0;
19341939 unwrap_failed:
19351940 trace_rpcgss_unwrap_failed(task);
@@ -1949,6 +1954,7 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, · 13 unmodified lines
19491954 {
19501955 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;
19511956 struct kvec *head = rqstp->rq_rcv_buf.head;
1957+ struct rpc_auth *auth = cred->cr_auth;
19521958 unsigned int savedlen = rcv_buf->len;
19531959 u32 offset, opaque_len, maj_stat;
19541960 __be32 *p;
@@ -1976,8 +1982,10 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, · 21 unmodified lines
19761982 */
19771983 xdr_init_decode(xdr, rcv_buf, p, rqstp);
19781984
1979− cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 +
1980− XDR_QUADLEN(savedlen - rcv_buf->len);
1985+ auth->au_rslack = auth->au_verfsize + 2 +
1986+ XDR_QUADLEN(savedlen - rcv_buf->len);
1987+ auth->au_ralign = auth->au_verfsize + 2 +
1988+ XDR_QUADLEN(savedlen - rcv_buf->len);
19811989 return 0;
19821990 unwrap_failed:
19831991 trace_rpcgss_unwrap_failed(task);
net/sunrpc/auth_null.c+1−0
@@ -115,6 +115,7 @@ struct rpc_auth null_auth = { · 114 unmodified lines
115115 .au_cslack = NUL_CALLSLACK,
116116 .au_rslack = NUL_REPLYSLACK,
117117 .au_verfsize = NUL_REPLYSLACK,
118+ .au_ralign = NUL_REPLYSLACK,
118119 .au_ops = &authnull_ops,
119120 .au_flavor = RPC_AUTH_NULL,
120121 .au_count = REFCOUNT_INIT(1),
net/sunrpc/auth_unix.c+1−0
@@ -187,6 +187,7 @@ unx_validate(struct rpc_task *task, struct xdr_stream *xdr) · 186 unmodified lines
187187
188188 auth->au_verfsize = XDR_QUADLEN(size) + 2;
189189 auth->au_rslack = XDR_QUADLEN(size) + 2;
190+ auth->au_ralign = XDR_QUADLEN(size) + 2;
190191 return 0;
191192 }
192193
net/sunrpc/clnt.c+1−1
@@ -1180,7 +1180,7 @@ void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages, · 1179 unmodified lines
11801180 /* Subtract one to force an extra word of buffer space for the
11811181 * payload's XDR pad to fall into the rcv_buf's tail iovec.
11821182 */
1183− hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_rslack - 1;
1183+ hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_ralign - 1;
11841184
11851185 xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len);
11861186 trace_rpc_reply_pages(req);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t