aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2012-08-14 15:50:34 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-08-21 17:07:48 -0400
commit39b553013719fe6495cf5e496b827b2d712e4265 (patch)
tree27e4c71fa94f08e19b4709c25a81b5eecf23c5ba /net/sunrpc
parentc3341966943284ab3618a1814cefd693ad9aa736 (diff)
svcrpc: share some setup of listening sockets
There's some duplicate code here. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/svc_xprt.c16
-rw-r--r--net/sunrpc/svcsock.c6
2 files changed, 11 insertions, 11 deletions
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 4801fdac2c9d..ee15663798b3 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -208,6 +208,15 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl,
208 return xcl->xcl_ops->xpo_create(serv, net, sap, len, flags); 208 return xcl->xcl_ops->xpo_create(serv, net, sap, len, flags);
209} 209}
210 210
211void svc_add_new_perm_xprt(struct svc_serv *serv, struct svc_xprt *new)
212{
213 clear_bit(XPT_TEMP, &new->xpt_flags);
214 spin_lock_bh(&serv->sv_lock);
215 list_add(&new->xpt_list, &serv->sv_permsocks);
216 spin_unlock_bh(&serv->sv_lock);
217 svc_xprt_received(new);
218}
219
211int svc_create_xprt(struct svc_serv *serv, const char *xprt_name, 220int svc_create_xprt(struct svc_serv *serv, const char *xprt_name,
212 struct net *net, const int family, 221 struct net *net, const int family,
213 const unsigned short port, int flags) 222 const unsigned short port, int flags)
@@ -232,13 +241,8 @@ int svc_create_xprt(struct svc_serv *serv, const char *xprt_name,
232 module_put(xcl->xcl_owner); 241 module_put(xcl->xcl_owner);
233 return PTR_ERR(newxprt); 242 return PTR_ERR(newxprt);
234 } 243 }
235 244 svc_add_new_perm_xprt(serv, newxprt);
236 clear_bit(XPT_TEMP, &newxprt->xpt_flags);
237 spin_lock_bh(&serv->sv_lock);
238 list_add(&newxprt->xpt_list, &serv->sv_permsocks);
239 spin_unlock_bh(&serv->sv_lock);
240 newport = svc_xprt_local_port(newxprt); 245 newport = svc_xprt_local_port(newxprt);
241 svc_xprt_received(newxprt);
242 return newport; 246 return newport;
243 } 247 }
244 err: 248 err:
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index bf10b723f429..c7a7b14f54ed 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1478,11 +1478,7 @@ int svc_addsock(struct svc_serv *serv, const int fd, char *name_return,
1478 } 1478 }
1479 if (kernel_getsockname(svsk->sk_sock, sin, &salen) == 0) 1479 if (kernel_getsockname(svsk->sk_sock, sin, &salen) == 0)
1480 svc_xprt_set_local(&svsk->sk_xprt, sin, salen); 1480 svc_xprt_set_local(&svsk->sk_xprt, sin, salen);
1481 clear_bit(XPT_TEMP, &svsk->sk_xprt.xpt_flags); 1481 svc_add_new_perm_xprt(serv, &svsk->sk_xprt);
1482 spin_lock_bh(&serv->sv_lock);
1483 list_add(&svsk->sk_xprt.xpt_list, &serv->sv_permsocks);
1484 spin_unlock_bh(&serv->sv_lock);
1485 svc_xprt_received(&svsk->sk_xprt);
1486 return svc_one_sock_name(svsk, name_return, len); 1482 return svc_one_sock_name(svsk, name_return, len);
1487out: 1483out:
1488 sockfd_put(so); 1484 sockfd_put(so);