sunrpc: Factor out udp sockets creation
Make it look like the TCP sockets creation. Unfortunately the git diff made the patch look messy :( Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
58dddac9c5
commit
b65c031061
1 changed files with 59 additions and 43 deletions
|
@ -1660,37 +1660,22 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
|
||||||
xs_udp_do_set_buffer_size(xprt);
|
xs_udp_do_set_buffer_size(xprt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static void xs_udp_setup_socket(struct sock_xprt *transport,
|
||||||
* xs_udp_connect_worker4 - set up a UDP socket
|
struct socket *(*create_sock)(struct rpc_xprt *,
|
||||||
* @work: RPC transport to connect
|
struct sock_xprt *))
|
||||||
*
|
|
||||||
* Invoked by a work queue tasklet.
|
|
||||||
*/
|
|
||||||
static void xs_udp_connect_worker4(struct work_struct *work)
|
|
||||||
{
|
{
|
||||||
struct sock_xprt *transport =
|
|
||||||
container_of(work, struct sock_xprt, connect_worker.work);
|
|
||||||
struct rpc_xprt *xprt = &transport->xprt;
|
struct rpc_xprt *xprt = &transport->xprt;
|
||||||
struct socket *sock = transport->sock;
|
struct socket *sock = transport->sock;
|
||||||
int err, status = -EIO;
|
int status = -EIO;
|
||||||
|
|
||||||
if (xprt->shutdown)
|
if (xprt->shutdown)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Start by resetting any existing state */
|
/* Start by resetting any existing state */
|
||||||
xs_reset_transport(transport);
|
xs_reset_transport(transport);
|
||||||
|
sock = create_sock(xprt, transport);
|
||||||
err = __sock_create(xprt->xprt_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
|
if (IS_ERR(sock))
|
||||||
if (err < 0) {
|
|
||||||
dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
xs_reclassify_socket4(sock);
|
|
||||||
|
|
||||||
if (xs_bind4(transport, sock)) {
|
|
||||||
sock_release(sock);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
dprintk("RPC: worker connecting xprt %p via %s to "
|
dprintk("RPC: worker connecting xprt %p via %s to "
|
||||||
"%s (port %s)\n", xprt,
|
"%s (port %s)\n", xprt,
|
||||||
|
@ -1705,25 +1690,56 @@ static void xs_udp_connect_worker4(struct work_struct *work)
|
||||||
xprt_wake_pending_tasks(xprt, status);
|
xprt_wake_pending_tasks(xprt, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xs_udp_connect_worker4 - set up a UDP socket
|
||||||
|
* @work: RPC transport to connect
|
||||||
|
*
|
||||||
|
* Invoked by a work queue tasklet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static struct socket *xs_create_udp_sock4(struct rpc_xprt *xprt,
|
||||||
|
struct sock_xprt *transport)
|
||||||
|
{
|
||||||
|
struct socket *sock;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = __sock_create(xprt->xprt_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
|
||||||
|
if (err < 0) {
|
||||||
|
dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
xs_reclassify_socket4(sock);
|
||||||
|
|
||||||
|
if (xs_bind4(transport, sock)) {
|
||||||
|
sock_release(sock);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sock;
|
||||||
|
out:
|
||||||
|
return ERR_PTR(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xs_udp_connect_worker4(struct work_struct *work)
|
||||||
|
{
|
||||||
|
struct sock_xprt *transport =
|
||||||
|
container_of(work, struct sock_xprt, connect_worker.work);
|
||||||
|
|
||||||
|
xs_udp_setup_socket(transport, xs_create_udp_sock4);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xs_udp_connect_worker6 - set up a UDP socket
|
* xs_udp_connect_worker6 - set up a UDP socket
|
||||||
* @work: RPC transport to connect
|
* @work: RPC transport to connect
|
||||||
*
|
*
|
||||||
* Invoked by a work queue tasklet.
|
* Invoked by a work queue tasklet.
|
||||||
*/
|
*/
|
||||||
static void xs_udp_connect_worker6(struct work_struct *work)
|
|
||||||
|
static struct socket *xs_create_udp_sock6(struct rpc_xprt *xprt,
|
||||||
|
struct sock_xprt *transport)
|
||||||
{
|
{
|
||||||
struct sock_xprt *transport =
|
struct socket *sock;
|
||||||
container_of(work, struct sock_xprt, connect_worker.work);
|
int err;
|
||||||
struct rpc_xprt *xprt = &transport->xprt;
|
|
||||||
struct socket *sock = transport->sock;
|
|
||||||
int err, status = -EIO;
|
|
||||||
|
|
||||||
if (xprt->shutdown)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* Start by resetting any existing state */
|
|
||||||
xs_reset_transport(transport);
|
|
||||||
|
|
||||||
err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
|
err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
@ -1737,17 +1753,17 @@ static void xs_udp_connect_worker6(struct work_struct *work)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintk("RPC: worker connecting xprt %p via %s to "
|
return sock;
|
||||||
"%s (port %s)\n", xprt,
|
|
||||||
xprt->address_strings[RPC_DISPLAY_PROTO],
|
|
||||||
xprt->address_strings[RPC_DISPLAY_ADDR],
|
|
||||||
xprt->address_strings[RPC_DISPLAY_PORT]);
|
|
||||||
|
|
||||||
xs_udp_finish_connecting(xprt, sock);
|
|
||||||
status = 0;
|
|
||||||
out:
|
out:
|
||||||
xprt_clear_connecting(xprt);
|
return ERR_PTR(err);
|
||||||
xprt_wake_pending_tasks(xprt, status);
|
}
|
||||||
|
|
||||||
|
static void xs_udp_connect_worker6(struct work_struct *work)
|
||||||
|
{
|
||||||
|
struct sock_xprt *transport =
|
||||||
|
container_of(work, struct sock_xprt, connect_worker.work);
|
||||||
|
|
||||||
|
xs_udp_setup_socket(transport, xs_create_udp_sock6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue