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
74struct rpc_authops;74struct rpc_authops;
75struct rpc_auth {75struct rpc_auth {
76 unsigned int au_cslack; /* call cred size estimate */76 unsigned int au_cslack; /* call cred size estimate */
77 /* guess at number of u32's auth adds before77 unsigned int au_rslack; /* reply cred size estimate */
78 * reply data; normally the verifier size: */
79 unsigned int au_rslack;
80 unsigned int au_verfsize; /* size of reply verifier */78 unsigned int au_verfsize; /* size of reply verifier */
79 unsigned int au_ralign; /* words before UL header */
81 80
82 unsigned int au_flags; /* various flags */81 unsigned int au_flags;
83 const struct rpc_authops *au_ops; /* operations */82 const struct rpc_authops *au_ops;
84 rpc_authflavor_t au_flavor; /* pseudoflavor (note may83 rpc_authflavor_t au_flavor; /* pseudoflavor (note may
85 * differ from the flavor in84 * differ from the flavor in
86 * au_ops->au_flavor in gss85 * 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
1017 auth->au_cslack = GSS_CRED_SLACK >> 2;1017 auth->au_cslack = GSS_CRED_SLACK >> 2;
1018 auth->au_rslack = GSS_VERF_SLACK >> 2;1018 auth->au_rslack = GSS_VERF_SLACK >> 2;
1019 auth->au_verfsize = GSS_VERF_SLACK >> 2;1019 auth->au_verfsize = GSS_VERF_SLACK >> 2;
1020 auth->au_ralign = GSS_VERF_SLACK >> 2;
1020 auth->au_flags = 0;1021 auth->au_flags = 0;
1021 auth->au_ops = &authgss_ops;1022 auth->au_ops = &authgss_ops;
1022 auth->au_flavor = flavor;1023 auth->au_flavor = flavor;
@@ -1891,7 +1892,10 @@ out: · 868 unmodified lines
1891static int1892static int
1892gss_unwrap_resp_auth(struct rpc_cred *cred)1893gss_unwrap_resp_auth(struct rpc_cred *cred)
1893{1894{
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;
1895 return 0;1899 return 0;
1896}1900}
1897 1901
@@ -1902,6 +1906,7 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, · 4 unmodified lines
1902{1906{
1903 struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf;1907 struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf;
1904 u32 data_offset, mic_offset, integ_len, maj_stat;1908 u32 data_offset, mic_offset, integ_len, maj_stat;
1909 struct rpc_auth *auth = cred->cr_auth;
1905 struct xdr_netobj mic;1910 struct xdr_netobj mic;
1906 __be32 *p;1911 __be32 *p;
1907 1912
@@ -1928,8 +1933,8 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, · 20 unmodified lines
1928 if (maj_stat != GSS_S_COMPLETE)1933 if (maj_stat != GSS_S_COMPLETE)
1929 goto bad_mic;1934 goto bad_mic;
1930 1935
1931 cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 +1936 auth->au_rslack = auth->au_verfsize + 2 + 1 + XDR_QUADLEN(mic.len);
1932 1 + XDR_QUADLEN(mic.len);1937 auth->au_ralign = auth->au_verfsize + 2;
1933 return 0;1938 return 0;
1934unwrap_failed:1939unwrap_failed:
1935 trace_rpcgss_unwrap_failed(task);1940 trace_rpcgss_unwrap_failed(task);
@@ -1949,6 +1954,7 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, · 13 unmodified lines
1949{1954{
1950 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;1955 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;
1951 struct kvec *head = rqstp->rq_rcv_buf.head;1956 struct kvec *head = rqstp->rq_rcv_buf.head;
1957 struct rpc_auth *auth = cred->cr_auth;
1952 unsigned int savedlen = rcv_buf->len;1958 unsigned int savedlen = rcv_buf->len;
1953 u32 offset, opaque_len, maj_stat;1959 u32 offset, opaque_len, maj_stat;
1954 __be32 *p;1960 __be32 *p;
@@ -1976,8 +1982,10 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, · 21 unmodified lines
1976 */1982 */
1977 xdr_init_decode(xdr, rcv_buf, p, rqstp);1983 xdr_init_decode(xdr, rcv_buf, p, rqstp);
1978 1984
1979 cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 +1985 auth->au_rslack = auth->au_verfsize + 2 +
1980 XDR_QUADLEN(savedlen - rcv_buf->len);1986 XDR_QUADLEN(savedlen - rcv_buf->len);
1987 auth->au_ralign = auth->au_verfsize + 2 +
1988 XDR_QUADLEN(savedlen - rcv_buf->len);
1981 return 0;1989 return 0;
1982unwrap_failed:1990unwrap_failed:
1983 trace_rpcgss_unwrap_failed(task);1991 trace_rpcgss_unwrap_failed(task);
net/sunrpc/auth_null.c+1−0
@@ -115,6 +115,7 @@ struct rpc_auth null_auth = { · 114 unmodified lines
115 .au_cslack = NUL_CALLSLACK,115 .au_cslack = NUL_CALLSLACK,
116 .au_rslack = NUL_REPLYSLACK,116 .au_rslack = NUL_REPLYSLACK,
117 .au_verfsize = NUL_REPLYSLACK,117 .au_verfsize = NUL_REPLYSLACK,
118 .au_ralign = NUL_REPLYSLACK,
118 .au_ops = &authnull_ops,119 .au_ops = &authnull_ops,
119 .au_flavor = RPC_AUTH_NULL,120 .au_flavor = RPC_AUTH_NULL,
120 .au_count = REFCOUNT_INIT(1),121 .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
187 187
188 auth->au_verfsize = XDR_QUADLEN(size) + 2;188 auth->au_verfsize = XDR_QUADLEN(size) + 2;
189 auth->au_rslack = XDR_QUADLEN(size) + 2;189 auth->au_rslack = XDR_QUADLEN(size) + 2;
190 auth->au_ralign = XDR_QUADLEN(size) + 2;
190 return 0;191 return 0;
191}192}
192 193
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
1180 /* Subtract one to force an extra word of buffer space for the1180 /* Subtract one to force an extra word of buffer space for the
1181 * payload's XDR pad to fall into the rcv_buf's tail iovec.1181 * payload's XDR pad to fall into the rcv_buf's tail iovec.
1182 */1182 */
1183 hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_rslack - 1;1183 hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_ralign - 1;
1184 1184
1185 xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len);1185 xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len);
1186 trace_rpc_reply_pages(req);1186 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