aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/lockd/svc.c16
-rw-r--r--include/linux/sunrpc/svc_xprt.h1
-rw-r--r--net/sunrpc/svc_xprt.c35
3 files changed, 38 insertions, 14 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index a8e79a907202..470af0138bb5 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -219,18 +219,6 @@ lockd(struct svc_rqst *rqstp)
219 module_put_and_exit(0); 219 module_put_and_exit(0);
220} 220}
221 221
222static int find_xprt(struct svc_serv *serv, char *proto)
223{
224 struct svc_xprt *xprt;
225 int found = 0;
226 list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list)
227 if (strcmp(xprt->xpt_class->xcl_name, proto) == 0) {
228 found = 1;
229 break;
230 }
231 return found;
232}
233
234/* 222/*
235 * Make any sockets that are needed but not present. 223 * Make any sockets that are needed but not present.
236 * If nlm_udpport or nlm_tcpport were set as module 224 * If nlm_udpport or nlm_tcpport were set as module
@@ -242,11 +230,11 @@ static int make_socks(struct svc_serv *serv, int proto)
242 int err = 0; 230 int err = 0;
243 231
244 if (proto == IPPROTO_UDP || nlm_udpport) 232 if (proto == IPPROTO_UDP || nlm_udpport)
245 if (!find_xprt(serv, "udp")) 233 if (!svc_find_xprt(serv, "udp", 0, 0))
246 err = svc_create_xprt(serv, "udp", nlm_udpport, 234 err = svc_create_xprt(serv, "udp", nlm_udpport,
247 SVC_SOCK_DEFAULTS); 235 SVC_SOCK_DEFAULTS);
248 if (err >= 0 && (proto == IPPROTO_TCP || nlm_tcpport)) 236 if (err >= 0 && (proto == IPPROTO_TCP || nlm_tcpport))
249 if (!find_xprt(serv, "tcp")) 237 if (!svc_find_xprt(serv, "tcp", 0, 0))
250 err = svc_create_xprt(serv, "tcp", nlm_tcpport, 238 err = svc_create_xprt(serv, "tcp", nlm_tcpport,
251 SVC_SOCK_DEFAULTS); 239 SVC_SOCK_DEFAULTS);
252 240
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
index 01e71b7a2e20..68862d51bb36 100644
--- a/include/linux/sunrpc/svc_xprt.h
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -80,6 +80,7 @@ void svc_close_xprt(struct svc_xprt *xprt);
80void svc_delete_xprt(struct svc_xprt *xprt); 80void svc_delete_xprt(struct svc_xprt *xprt);
81int svc_port_is_privileged(struct sockaddr *sin); 81int svc_port_is_privileged(struct sockaddr *sin);
82int svc_print_xprts(char *buf, int maxlen); 82int svc_print_xprts(char *buf, int maxlen);
83struct svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int);
83 84
84static inline void svc_xprt_get(struct svc_xprt *xprt) 85static inline void svc_xprt_get(struct svc_xprt *xprt)
85{ 86{
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 2e5b92ae24ed..512c10fc1a9f 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -977,3 +977,38 @@ static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt)
977 spin_unlock(&xprt->xpt_lock); 977 spin_unlock(&xprt->xpt_lock);
978 return dr; 978 return dr;
979} 979}
980
981/*
982 * Return the transport instance pointer for the endpoint accepting
983 * connections/peer traffic from the specified transport class,
984 * address family and port.
985 *
986 * Specifying 0 for the address family or port is effectively a
987 * wild-card, and will result in matching the first transport in the
988 * service's list that has a matching class name.
989 */
990struct svc_xprt *svc_find_xprt(struct svc_serv *serv, char *xcl_name,
991 int af, int port)
992{
993 struct svc_xprt *xprt;
994 struct svc_xprt *found = NULL;
995
996 /* Sanity check the args */
997 if (!serv || !xcl_name)
998 return found;
999
1000 spin_lock_bh(&serv->sv_lock);
1001 list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list) {
1002 if (strcmp(xprt->xpt_class->xcl_name, xcl_name))
1003 continue;
1004 if (af != AF_UNSPEC && af != xprt->xpt_local.ss_family)
1005 continue;
1006 if (port && port != svc_xprt_local_port(xprt))
1007 continue;
1008 found = xprt;
1009 break;
1010 }
1011 spin_unlock_bh(&serv->sv_lock);
1012 return found;
1013}
1014EXPORT_SYMBOL_GPL(svc_find_xprt);