aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorFrank van Maarseveen <frankvm@frankvm.com>2007-07-08 07:08:54 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-10 23:40:49 -0400
commit96802a095171f5b35cf0e1e0d4be943e6696a253 (patch)
treeedad2ad27532dc7e380ec2fd3854d8c265a004c1 /net/sunrpc/xprtsock.c
parent6f2e64d3e1f661095e274c9d9d47e3f39a6cf1c0 (diff)
SUNRPC: cleanup transport creation argument passing
Cleanup argument passing to functions for creating an RPC transport. Signed-off-by: Frank van Maarseveen <frankvm@frankvm.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index a8f7c5fd752c..6b7cea57651c 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1502,12 +1502,12 @@ static struct rpc_xprt_ops xs_tcp_ops = {
1502 .print_stats = xs_tcp_print_stats, 1502 .print_stats = xs_tcp_print_stats,
1503}; 1503};
1504 1504
1505static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, unsigned int slot_table_size) 1505static struct rpc_xprt *xs_setup_xprt(struct rpc_xprtsock_create *args, unsigned int slot_table_size)
1506{ 1506{
1507 struct rpc_xprt *xprt; 1507 struct rpc_xprt *xprt;
1508 struct sock_xprt *new; 1508 struct sock_xprt *new;
1509 1509
1510 if (addrlen > sizeof(xprt->addr)) { 1510 if (args->addrlen > sizeof(xprt->addr)) {
1511 dprintk("RPC: xs_setup_xprt: address too large\n"); 1511 dprintk("RPC: xs_setup_xprt: address too large\n");
1512 return ERR_PTR(-EBADF); 1512 return ERR_PTR(-EBADF);
1513 } 1513 }
@@ -1529,8 +1529,8 @@ static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, uns
1529 return ERR_PTR(-ENOMEM); 1529 return ERR_PTR(-ENOMEM);
1530 } 1530 }
1531 1531
1532 memcpy(&xprt->addr, addr, addrlen); 1532 memcpy(&xprt->addr, args->dstaddr, args->addrlen);
1533 xprt->addrlen = addrlen; 1533 xprt->addrlen = args->addrlen;
1534 new->port = xs_get_random_port(); 1534 new->port = xs_get_random_port();
1535 1535
1536 return xprt; 1536 return xprt;
@@ -1538,22 +1538,20 @@ static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, uns
1538 1538
1539/** 1539/**
1540 * xs_setup_udp - Set up transport to use a UDP socket 1540 * xs_setup_udp - Set up transport to use a UDP socket
1541 * @addr: address of remote server 1541 * @args: rpc transport creation arguments
1542 * @addrlen: length of address in bytes
1543 * @to: timeout parameters
1544 * 1542 *
1545 */ 1543 */
1546struct rpc_xprt *xs_setup_udp(struct sockaddr *addr, size_t addrlen, struct rpc_timeout *to) 1544struct rpc_xprt *xs_setup_udp(struct rpc_xprtsock_create *args)
1547{ 1545{
1548 struct rpc_xprt *xprt; 1546 struct rpc_xprt *xprt;
1549 struct sock_xprt *transport; 1547 struct sock_xprt *transport;
1550 1548
1551 xprt = xs_setup_xprt(addr, addrlen, xprt_udp_slot_table_entries); 1549 xprt = xs_setup_xprt(args, xprt_udp_slot_table_entries);
1552 if (IS_ERR(xprt)) 1550 if (IS_ERR(xprt))
1553 return xprt; 1551 return xprt;
1554 transport = container_of(xprt, struct sock_xprt, xprt); 1552 transport = container_of(xprt, struct sock_xprt, xprt);
1555 1553
1556 if (ntohs(((struct sockaddr_in *)addr)->sin_port) != 0) 1554 if (ntohs(((struct sockaddr_in *)args->dstaddr)->sin_port) != 0)
1557 xprt_set_bound(xprt); 1555 xprt_set_bound(xprt);
1558 1556
1559 xprt->prot = IPPROTO_UDP; 1557 xprt->prot = IPPROTO_UDP;
@@ -1569,8 +1567,8 @@ struct rpc_xprt *xs_setup_udp(struct sockaddr *addr, size_t addrlen, struct rpc_
1569 1567
1570 xprt->ops = &xs_udp_ops; 1568 xprt->ops = &xs_udp_ops;
1571 1569
1572 if (to) 1570 if (args->timeout)
1573 xprt->timeout = *to; 1571 xprt->timeout = *args->timeout;
1574 else 1572 else
1575 xprt_set_timeout(&xprt->timeout, 5, 5 * HZ); 1573 xprt_set_timeout(&xprt->timeout, 5, 5 * HZ);
1576 1574
@@ -1583,22 +1581,20 @@ struct rpc_xprt *xs_setup_udp(struct sockaddr *addr, size_t addrlen, struct rpc_
1583 1581
1584/** 1582/**
1585 * xs_setup_tcp - Set up transport to use a TCP socket 1583 * xs_setup_tcp - Set up transport to use a TCP socket
1586 * @addr: address of remote server 1584 * @args: rpc transport creation arguments
1587 * @addrlen: length of address in bytes
1588 * @to: timeout parameters
1589 * 1585 *
1590 */ 1586 */
1591struct rpc_xprt *xs_setup_tcp(struct sockaddr *addr, size_t addrlen, struct rpc_timeout *to) 1587struct rpc_xprt *xs_setup_tcp(struct rpc_xprtsock_create *args)
1592{ 1588{
1593 struct rpc_xprt *xprt; 1589 struct rpc_xprt *xprt;
1594 struct sock_xprt *transport; 1590 struct sock_xprt *transport;
1595 1591
1596 xprt = xs_setup_xprt(addr, addrlen, xprt_tcp_slot_table_entries); 1592 xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
1597 if (IS_ERR(xprt)) 1593 if (IS_ERR(xprt))
1598 return xprt; 1594 return xprt;
1599 transport = container_of(xprt, struct sock_xprt, xprt); 1595 transport = container_of(xprt, struct sock_xprt, xprt);
1600 1596
1601 if (ntohs(((struct sockaddr_in *)addr)->sin_port) != 0) 1597 if (ntohs(((struct sockaddr_in *)args->dstaddr)->sin_port) != 0)
1602 xprt_set_bound(xprt); 1598 xprt_set_bound(xprt);
1603 1599
1604 xprt->prot = IPPROTO_TCP; 1600 xprt->prot = IPPROTO_TCP;
@@ -1613,8 +1609,8 @@ struct rpc_xprt *xs_setup_tcp(struct sockaddr *addr, size_t addrlen, struct rpc_
1613 1609
1614 xprt->ops = &xs_tcp_ops; 1610 xprt->ops = &xs_tcp_ops;
1615 1611
1616 if (to) 1612 if (args->timeout)
1617 xprt->timeout = *to; 1613 xprt->timeout = *args->timeout;
1618 else 1614 else
1619 xprt_set_timeout(&xprt->timeout, 2, 60 * HZ); 1615 xprt_set_timeout(&xprt->timeout, 2, 60 * HZ);
1620 1616