Skip to content

Commit 6f3d772

Browse files
Takuma UmeyaJ. Bruce Fields
authored andcommitted
nfs4: set source address when callback is generated
when callback is generated in NFSv4 server, it doesn't set the source address. When an alias IP is utilized on NFSv4 server and suppose the client is accessing via that alias IP (e.g. eth0:0), the client invokes the callback to the IP address that is set on the original device (e.g. eth0). This behavior results in timeout of xprt. The patch sets the IP address that the client should invoke callback to. Signed-off-by: Takuma Umeya <[email protected]> [[email protected]: Simplify gen_callback arguments, use helper function] Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 3c72602 commit 6f3d772

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

fs/nfsd/nfs4callback.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ static int setup_callback_client(struct nfs4_client *clp,
484484
.net = &init_net,
485485
.address = (struct sockaddr *) &conn->cb_addr,
486486
.addrsize = conn->cb_addrlen,
487+
.saddress = (struct sockaddr *) &conn->cb_saddr,
487488
.timeout = &timeparms,
488489
.program = &cb_program,
489490
.version = 0,

fs/nfsd/nfs4state.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,10 +1163,26 @@ find_unconfirmed_client_by_str(const char *dname, unsigned int hashval)
11631163
return NULL;
11641164
}
11651165

1166+
static void rpc_svcaddr2sockaddr(struct sockaddr *sa, unsigned short family, union svc_addr_u *svcaddr)
1167+
{
1168+
switch (family) {
1169+
case AF_INET:
1170+
((struct sockaddr_in *)sa)->sin_family = AF_INET;
1171+
((struct sockaddr_in *)sa)->sin_addr = svcaddr->addr;
1172+
return;
1173+
case AF_INET6:
1174+
((struct sockaddr_in6 *)sa)->sin6_family = AF_INET6;
1175+
((struct sockaddr_in6 *)sa)->sin6_addr = svcaddr->addr6;
1176+
return;
1177+
}
1178+
}
1179+
11661180
static void
1167-
gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, u32 scopeid)
1181+
gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, struct svc_rqst *rqstp)
11681182
{
11691183
struct nfs4_cb_conn *conn = &clp->cl_cb_conn;
1184+
struct sockaddr *sa = svc_addr(rqstp);
1185+
u32 scopeid = rpc_get_scope_id(sa);
11701186
unsigned short expected_family;
11711187

11721188
/* Currently, we only support tcp and tcp6 for the callback channel */
@@ -1192,6 +1208,7 @@ gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, u32 scopeid)
11921208

11931209
conn->cb_prog = se->se_callback_prog;
11941210
conn->cb_ident = se->se_callback_ident;
1211+
rpc_svcaddr2sockaddr((struct sockaddr *)&conn->cb_saddr, expected_family, &rqstp->rq_daddr);
11951212
return;
11961213
out_err:
11971214
conn->cb_addr.ss_family = AF_UNSPEC;
@@ -1768,7 +1785,6 @@ __be32
17681785
nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
17691786
struct nfsd4_setclientid *setclid)
17701787
{
1771-
struct sockaddr *sa = svc_addr(rqstp);
17721788
struct xdr_netobj clname = {
17731789
.len = setclid->se_namelen,
17741790
.data = setclid->se_name,
@@ -1871,7 +1887,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18711887
* for consistent minorversion use throughout:
18721888
*/
18731889
new->cl_minorversion = 0;
1874-
gen_callback(new, setclid, rpc_get_scope_id(sa));
1890+
gen_callback(new, setclid, rqstp);
18751891
add_to_unconfirmed(new, strhashval);
18761892
setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot;
18771893
setclid->se_clientid.cl_id = new->cl_clientid.cl_id;

fs/nfsd/state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct nfs4_delegation {
9696
struct nfs4_cb_conn {
9797
/* SETCLIENTID info */
9898
struct sockaddr_storage cb_addr;
99+
struct sockaddr_storage cb_saddr;
99100
size_t cb_addrlen;
100101
u32 cb_prog; /* used only in 4.0 case;
101102
per-session otherwise */

0 commit comments

Comments
 (0)