@@ -759,27 +759,6 @@ expire_client(struct nfs4_client *clp)
759759 put_nfs4_client (clp );
760760}
761761
762- static struct nfs4_client * create_client (struct xdr_netobj name , char * recdir )
763- {
764- struct nfs4_client * clp ;
765-
766- clp = alloc_client (name );
767- if (clp == NULL )
768- return NULL ;
769- memcpy (clp -> cl_recdir , recdir , HEXDIR_LEN );
770- atomic_set (& clp -> cl_count , 1 );
771- atomic_set (& clp -> cl_cb_conn .cb_set , 0 );
772- INIT_LIST_HEAD (& clp -> cl_idhash );
773- INIT_LIST_HEAD (& clp -> cl_strhash );
774- INIT_LIST_HEAD (& clp -> cl_openowners );
775- INIT_LIST_HEAD (& clp -> cl_delegations );
776- INIT_LIST_HEAD (& clp -> cl_sessions );
777- INIT_LIST_HEAD (& clp -> cl_lru );
778- clear_bit (0 , & clp -> cl_cb_slot_busy );
779- rpc_init_wait_queue (& clp -> cl_cb_waitq , "Backchannel slot table" );
780- return clp ;
781- }
782-
783762static void copy_verf (struct nfs4_client * target , nfs4_verifier * source )
784763{
785764 memcpy (target -> cl_verifier .data , source -> data ,
@@ -842,6 +821,46 @@ static void gen_confirm(struct nfs4_client *clp)
842821 * p ++ = i ++ ;
843822}
844823
824+ static struct nfs4_client * create_client (struct xdr_netobj name , char * recdir ,
825+ struct svc_rqst * rqstp , nfs4_verifier * verf )
826+ {
827+ struct nfs4_client * clp ;
828+ struct sockaddr * sa = svc_addr (rqstp );
829+ char * princ ;
830+
831+ clp = alloc_client (name );
832+ if (clp == NULL )
833+ return NULL ;
834+
835+ princ = svc_gss_principal (rqstp );
836+ if (princ ) {
837+ clp -> cl_principal = kstrdup (princ , GFP_KERNEL );
838+ if (clp -> cl_principal == NULL ) {
839+ free_client (clp );
840+ return NULL ;
841+ }
842+ }
843+
844+ memcpy (clp -> cl_recdir , recdir , HEXDIR_LEN );
845+ atomic_set (& clp -> cl_count , 1 );
846+ atomic_set (& clp -> cl_cb_conn .cb_set , 0 );
847+ INIT_LIST_HEAD (& clp -> cl_idhash );
848+ INIT_LIST_HEAD (& clp -> cl_strhash );
849+ INIT_LIST_HEAD (& clp -> cl_openowners );
850+ INIT_LIST_HEAD (& clp -> cl_delegations );
851+ INIT_LIST_HEAD (& clp -> cl_sessions );
852+ INIT_LIST_HEAD (& clp -> cl_lru );
853+ clear_bit (0 , & clp -> cl_cb_slot_busy );
854+ rpc_init_wait_queue (& clp -> cl_cb_waitq , "Backchannel slot table" );
855+ copy_verf (clp , verf );
856+ rpc_copy_addr ((struct sockaddr * ) & clp -> cl_addr , sa );
857+ clp -> cl_flavor = rqstp -> rq_flavor ;
858+ copy_cred (& clp -> cl_cred , & rqstp -> rq_cred );
859+ gen_confirm (clp );
860+
861+ return clp ;
862+ }
863+
845864static int check_name (struct xdr_netobj name )
846865{
847866 if (name .len == 0 )
@@ -1189,17 +1208,13 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
11891208
11901209out_new :
11911210 /* Normal case */
1192- new = create_client (exid -> clname , dname );
1211+ new = create_client (exid -> clname , dname , rqstp , & verf );
11931212 if (new == NULL ) {
11941213 status = nfserr_serverfault ;
11951214 goto out ;
11961215 }
11971216
1198- copy_verf (new , & verf );
1199- copy_cred (& new -> cl_cred , & rqstp -> rq_cred );
1200- rpc_copy_addr ((struct sockaddr * ) & new -> cl_addr , sa );
12011217 gen_clid (new );
1202- gen_confirm (new );
12031218 add_to_unconfirmed (new , strhashval );
12041219out_copy :
12051220 exid -> clientid .cl_boot = new -> cl_clientid .cl_boot ;
@@ -1473,7 +1488,6 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
14731488 unsigned int strhashval ;
14741489 struct nfs4_client * conf , * unconf , * new ;
14751490 __be32 status ;
1476- char * princ ;
14771491 char dname [HEXDIR_LEN ];
14781492
14791493 if (!check_name (clname ))
@@ -1518,7 +1532,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
15181532 */
15191533 if (unconf )
15201534 expire_client (unconf );
1521- new = create_client (clname , dname );
1535+ new = create_client (clname , dname , rqstp , & clverifier );
15221536 if (new == NULL )
15231537 goto out ;
15241538 gen_clid (new );
@@ -1535,7 +1549,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
15351549 */
15361550 expire_client (unconf );
15371551 }
1538- new = create_client (clname , dname );
1552+ new = create_client (clname , dname , rqstp , & clverifier );
15391553 if (new == NULL )
15401554 goto out ;
15411555 copy_clid (new , conf );
@@ -1545,7 +1559,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
15451559 * probable client reboot; state will be removed if
15461560 * confirmed.
15471561 */
1548- new = create_client (clname , dname );
1562+ new = create_client (clname , dname , rqstp , & clverifier );
15491563 if (new == NULL )
15501564 goto out ;
15511565 gen_clid (new );
@@ -1556,24 +1570,11 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
15561570 * confirmed.
15571571 */
15581572 expire_client (unconf );
1559- new = create_client (clname , dname );
1573+ new = create_client (clname , dname , rqstp , & clverifier );
15601574 if (new == NULL )
15611575 goto out ;
15621576 gen_clid (new );
15631577 }
1564- copy_verf (new , & clverifier );
1565- rpc_copy_addr ((struct sockaddr * ) & new -> cl_addr , sa );
1566- new -> cl_flavor = rqstp -> rq_flavor ;
1567- princ = svc_gss_principal (rqstp );
1568- if (princ ) {
1569- new -> cl_principal = kstrdup (princ , GFP_KERNEL );
1570- if (new -> cl_principal == NULL ) {
1571- free_client (new );
1572- goto out ;
1573- }
1574- }
1575- copy_cred (& new -> cl_cred , & rqstp -> rq_cred );
1576- gen_confirm (new );
15771578 gen_callback (new , setclid , rpc_get_scope_id (sa ));
15781579 add_to_unconfirmed (new , strhashval );
15791580 setclid -> se_clientid .cl_boot = new -> cl_clientid .cl_boot ;
0 commit comments