xprtsock.c (fb9a90f7c674f3ddef6baf55cb1612dadd8ea752) xprtsock.c (5d4ec932972a0dd5486c59909e62dc62105d065c)
1/*
2 * linux/net/sunrpc/xprtsock.c
3 *
4 * Client-side transport implementation for sockets.
5 *
6 * TCP callback races fixes (C) 1998 Red Hat
7 * TCP send fixes (C) 1998 Red Hat
8 * TCP NFS related read + write fixes

--- 760 unchanged lines hidden (view full) ---

769 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
770
771 dprintk("RPC: xs_destroy xprt %p\n", xprt);
772
773 cancel_rearming_delayed_work(&transport->connect_worker);
774
775 xs_close(xprt);
776 xs_free_peer_addresses(xprt);
1/*
2 * linux/net/sunrpc/xprtsock.c
3 *
4 * Client-side transport implementation for sockets.
5 *
6 * TCP callback races fixes (C) 1998 Red Hat
7 * TCP send fixes (C) 1998 Red Hat
8 * TCP NFS related read + write fixes

--- 760 unchanged lines hidden (view full) ---

769 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
770
771 dprintk("RPC: xs_destroy xprt %p\n", xprt);
772
773 cancel_rearming_delayed_work(&transport->connect_worker);
774
775 xs_close(xprt);
776 xs_free_peer_addresses(xprt);
777 kfree(xprt->slot);
778 kfree(xprt);
777 xprt_free(xprt);
779 module_put(THIS_MODULE);
780}
781
782static inline struct rpc_xprt *xprt_from_sock(struct sock *sk)
783{
784 return (struct rpc_xprt *) sk->sk_user_data;
785}
786

--- 8 unchanged lines hidden (view full) ---

795 struct rpc_task *task;
796 struct rpc_xprt *xprt;
797 struct rpc_rqst *rovr;
798 struct sk_buff *skb;
799 int err, repsize, copied;
800 u32 _xid;
801 __be32 *xp;
802
778 module_put(THIS_MODULE);
779}
780
781static inline struct rpc_xprt *xprt_from_sock(struct sock *sk)
782{
783 return (struct rpc_xprt *) sk->sk_user_data;
784}
785

--- 8 unchanged lines hidden (view full) ---

794 struct rpc_task *task;
795 struct rpc_xprt *xprt;
796 struct rpc_rqst *rovr;
797 struct sk_buff *skb;
798 int err, repsize, copied;
799 u32 _xid;
800 __be32 *xp;
801
803 read_lock_bh(&sk->sk_callback_lock);
802 read_lock(&sk->sk_callback_lock);
804 dprintk("RPC: xs_udp_data_ready...\n");
805 if (!(xprt = xprt_from_sock(sk)))
806 goto out;
807
808 if ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL)
809 goto out;
810
811 if (xprt->shutdown)

--- 35 unchanged lines hidden (view full) ---

847 xprt_adjust_cwnd(task, copied);
848 xprt_complete_rqst(task, copied);
849
850 out_unlock:
851 spin_unlock(&xprt->transport_lock);
852 dropit:
853 skb_free_datagram(sk, skb);
854 out:
803 dprintk("RPC: xs_udp_data_ready...\n");
804 if (!(xprt = xprt_from_sock(sk)))
805 goto out;
806
807 if ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL)
808 goto out;
809
810 if (xprt->shutdown)

--- 35 unchanged lines hidden (view full) ---

846 xprt_adjust_cwnd(task, copied);
847 xprt_complete_rqst(task, copied);
848
849 out_unlock:
850 spin_unlock(&xprt->transport_lock);
851 dropit:
852 skb_free_datagram(sk, skb);
853 out:
855 read_unlock_bh(&sk->sk_callback_lock);
854 read_unlock(&sk->sk_callback_lock);
856}
857
858static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_reader *desc)
859{
860 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
861 size_t len, used;
862 char *p;
863

--- 360 unchanged lines hidden (view full) ---

1224static void xs_tcp_data_ready(struct sock *sk, int bytes)
1225{
1226 struct rpc_xprt *xprt;
1227 read_descriptor_t rd_desc;
1228 int read;
1229
1230 dprintk("RPC: xs_tcp_data_ready...\n");
1231
855}
856
857static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_reader *desc)
858{
859 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
860 size_t len, used;
861 char *p;
862

--- 360 unchanged lines hidden (view full) ---

1223static void xs_tcp_data_ready(struct sock *sk, int bytes)
1224{
1225 struct rpc_xprt *xprt;
1226 read_descriptor_t rd_desc;
1227 int read;
1228
1229 dprintk("RPC: xs_tcp_data_ready...\n");
1230
1232 read_lock_bh(&sk->sk_callback_lock);
1231 read_lock(&sk->sk_callback_lock);
1233 if (!(xprt = xprt_from_sock(sk)))
1234 goto out;
1235 if (xprt->shutdown)
1236 goto out;
1237
1238 /* Any data means we had a useful conversation, so
1239 * the we don't need to delay the next reconnect
1240 */
1241 if (xprt->reestablish_timeout)
1242 xprt->reestablish_timeout = 0;
1243
1244 /* We use rd_desc to pass struct xprt to xs_tcp_data_recv */
1245 rd_desc.arg.data = xprt;
1246 do {
1247 rd_desc.count = 65536;
1248 read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv);
1249 } while (read > 0);
1250out:
1232 if (!(xprt = xprt_from_sock(sk)))
1233 goto out;
1234 if (xprt->shutdown)
1235 goto out;
1236
1237 /* Any data means we had a useful conversation, so
1238 * the we don't need to delay the next reconnect
1239 */
1240 if (xprt->reestablish_timeout)
1241 xprt->reestablish_timeout = 0;
1242
1243 /* We use rd_desc to pass struct xprt to xs_tcp_data_recv */
1244 rd_desc.arg.data = xprt;
1245 do {
1246 rd_desc.count = 65536;
1247 read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv);
1248 } while (read > 0);
1249out:
1251 read_unlock_bh(&sk->sk_callback_lock);
1250 read_unlock(&sk->sk_callback_lock);
1252}
1253
1254/*
1255 * Do the equivalent of linger/linger2 handling for dealing with
1256 * broken servers that don't close the socket in a timely
1257 * fashion
1258 */
1259static void xs_tcp_schedule_linger_timeout(struct rpc_xprt *xprt,

--- 36 unchanged lines hidden (view full) ---

1296 * xs_tcp_state_change - callback to handle TCP socket state changes
1297 * @sk: socket whose state has changed
1298 *
1299 */
1300static void xs_tcp_state_change(struct sock *sk)
1301{
1302 struct rpc_xprt *xprt;
1303
1251}
1252
1253/*
1254 * Do the equivalent of linger/linger2 handling for dealing with
1255 * broken servers that don't close the socket in a timely
1256 * fashion
1257 */
1258static void xs_tcp_schedule_linger_timeout(struct rpc_xprt *xprt,

--- 36 unchanged lines hidden (view full) ---

1295 * xs_tcp_state_change - callback to handle TCP socket state changes
1296 * @sk: socket whose state has changed
1297 *
1298 */
1299static void xs_tcp_state_change(struct sock *sk)
1300{
1301 struct rpc_xprt *xprt;
1302
1304 read_lock_bh(&sk->sk_callback_lock);
1303 read_lock(&sk->sk_callback_lock);
1305 if (!(xprt = xprt_from_sock(sk)))
1306 goto out;
1307 dprintk("RPC: xs_tcp_state_change client %p...\n", xprt);
1308 dprintk("RPC: state %x conn %d dead %d zapped %d sk_shutdown %d\n",
1309 sk->sk_state, xprt_connected(xprt),
1310 sock_flag(sk, SOCK_DEAD),
1311 sock_flag(sk, SOCK_ZAPPED),
1312 sk->sk_shutdown);
1313
1314 switch (sk->sk_state) {
1315 case TCP_ESTABLISHED:
1304 if (!(xprt = xprt_from_sock(sk)))
1305 goto out;
1306 dprintk("RPC: xs_tcp_state_change client %p...\n", xprt);
1307 dprintk("RPC: state %x conn %d dead %d zapped %d sk_shutdown %d\n",
1308 sk->sk_state, xprt_connected(xprt),
1309 sock_flag(sk, SOCK_DEAD),
1310 sock_flag(sk, SOCK_ZAPPED),
1311 sk->sk_shutdown);
1312
1313 switch (sk->sk_state) {
1314 case TCP_ESTABLISHED:
1316 spin_lock(&xprt->transport_lock);
1315 spin_lock_bh(&xprt->transport_lock);
1317 if (!xprt_test_and_set_connected(xprt)) {
1318 struct sock_xprt *transport = container_of(xprt,
1319 struct sock_xprt, xprt);
1320
1321 /* Reset TCP record info */
1322 transport->tcp_offset = 0;
1323 transport->tcp_reclen = 0;
1324 transport->tcp_copied = 0;
1325 transport->tcp_flags =
1326 TCP_RCV_COPY_FRAGHDR | TCP_RCV_COPY_XID;
1327
1328 xprt_wake_pending_tasks(xprt, -EAGAIN);
1329 }
1316 if (!xprt_test_and_set_connected(xprt)) {
1317 struct sock_xprt *transport = container_of(xprt,
1318 struct sock_xprt, xprt);
1319
1320 /* Reset TCP record info */
1321 transport->tcp_offset = 0;
1322 transport->tcp_reclen = 0;
1323 transport->tcp_copied = 0;
1324 transport->tcp_flags =
1325 TCP_RCV_COPY_FRAGHDR | TCP_RCV_COPY_XID;
1326
1327 xprt_wake_pending_tasks(xprt, -EAGAIN);
1328 }
1330 spin_unlock(&xprt->transport_lock);
1329 spin_unlock_bh(&xprt->transport_lock);
1331 break;
1332 case TCP_FIN_WAIT1:
1333 /* The client initiated a shutdown of the socket */
1334 xprt->connect_cookie++;
1335 xprt->reestablish_timeout = 0;
1336 set_bit(XPRT_CLOSING, &xprt->state);
1337 smp_mb__before_clear_bit();
1338 clear_bit(XPRT_CONNECTED, &xprt->state);

--- 21 unchanged lines hidden (view full) ---

1360 clear_bit(XPRT_CONNECTED, &xprt->state);
1361 smp_mb__after_clear_bit();
1362 break;
1363 case TCP_CLOSE:
1364 xs_tcp_cancel_linger_timeout(xprt);
1365 xs_sock_mark_closed(xprt);
1366 }
1367 out:
1330 break;
1331 case TCP_FIN_WAIT1:
1332 /* The client initiated a shutdown of the socket */
1333 xprt->connect_cookie++;
1334 xprt->reestablish_timeout = 0;
1335 set_bit(XPRT_CLOSING, &xprt->state);
1336 smp_mb__before_clear_bit();
1337 clear_bit(XPRT_CONNECTED, &xprt->state);

--- 21 unchanged lines hidden (view full) ---

1359 clear_bit(XPRT_CONNECTED, &xprt->state);
1360 smp_mb__after_clear_bit();
1361 break;
1362 case TCP_CLOSE:
1363 xs_tcp_cancel_linger_timeout(xprt);
1364 xs_sock_mark_closed(xprt);
1365 }
1366 out:
1368 read_unlock_bh(&sk->sk_callback_lock);
1367 read_unlock(&sk->sk_callback_lock);
1369}
1370
1371/**
1372 * xs_error_report - callback mainly for catching socket errors
1373 * @sk: socket
1374 */
1375static void xs_error_report(struct sock *sk)
1376{
1377 struct rpc_xprt *xprt;
1378
1368}
1369
1370/**
1371 * xs_error_report - callback mainly for catching socket errors
1372 * @sk: socket
1373 */
1374static void xs_error_report(struct sock *sk)
1375{
1376 struct rpc_xprt *xprt;
1377
1379 read_lock_bh(&sk->sk_callback_lock);
1378 read_lock(&sk->sk_callback_lock);
1380 if (!(xprt = xprt_from_sock(sk)))
1381 goto out;
1382 dprintk("RPC: %s client %p...\n"
1383 "RPC: error %d\n",
1384 __func__, xprt, sk->sk_err);
1385 xprt_wake_pending_tasks(xprt, -EAGAIN);
1386out:
1379 if (!(xprt = xprt_from_sock(sk)))
1380 goto out;
1381 dprintk("RPC: %s client %p...\n"
1382 "RPC: error %d\n",
1383 __func__, xprt, sk->sk_err);
1384 xprt_wake_pending_tasks(xprt, -EAGAIN);
1385out:
1387 read_unlock_bh(&sk->sk_callback_lock);
1386 read_unlock(&sk->sk_callback_lock);
1388}
1389
1390static void xs_write_space(struct sock *sk)
1391{
1392 struct socket *sock;
1393 struct rpc_xprt *xprt;
1394
1395 if (unlikely(!(sock = sk->sk_socket)))

--- 15 unchanged lines hidden (view full) ---

1411 *
1412 * Called when more output buffer space is available for this socket.
1413 * We try not to wake our writers until they can make "significant"
1414 * progress, otherwise we'll waste resources thrashing kernel_sendmsg
1415 * with a bunch of small requests.
1416 */
1417static void xs_udp_write_space(struct sock *sk)
1418{
1387}
1388
1389static void xs_write_space(struct sock *sk)
1390{
1391 struct socket *sock;
1392 struct rpc_xprt *xprt;
1393
1394 if (unlikely(!(sock = sk->sk_socket)))

--- 15 unchanged lines hidden (view full) ---

1410 *
1411 * Called when more output buffer space is available for this socket.
1412 * We try not to wake our writers until they can make "significant"
1413 * progress, otherwise we'll waste resources thrashing kernel_sendmsg
1414 * with a bunch of small requests.
1415 */
1416static void xs_udp_write_space(struct sock *sk)
1417{
1419 read_lock_bh(&sk->sk_callback_lock);
1418 read_lock(&sk->sk_callback_lock);
1420
1421 /* from net/core/sock.c:sock_def_write_space */
1422 if (sock_writeable(sk))
1423 xs_write_space(sk);
1424
1419
1420 /* from net/core/sock.c:sock_def_write_space */
1421 if (sock_writeable(sk))
1422 xs_write_space(sk);
1423
1425 read_unlock_bh(&sk->sk_callback_lock);
1424 read_unlock(&sk->sk_callback_lock);
1426}
1427
1428/**
1429 * xs_tcp_write_space - callback invoked when socket buffer space
1430 * becomes available
1431 * @sk: socket whose state has changed
1432 *
1433 * Called when more output buffer space is available for this socket.
1434 * We try not to wake our writers until they can make "significant"
1435 * progress, otherwise we'll waste resources thrashing kernel_sendmsg
1436 * with a bunch of small requests.
1437 */
1438static void xs_tcp_write_space(struct sock *sk)
1439{
1425}
1426
1427/**
1428 * xs_tcp_write_space - callback invoked when socket buffer space
1429 * becomes available
1430 * @sk: socket whose state has changed
1431 *
1432 * Called when more output buffer space is available for this socket.
1433 * We try not to wake our writers until they can make "significant"
1434 * progress, otherwise we'll waste resources thrashing kernel_sendmsg
1435 * with a bunch of small requests.
1436 */
1437static void xs_tcp_write_space(struct sock *sk)
1438{
1440 read_lock_bh(&sk->sk_callback_lock);
1439 read_lock(&sk->sk_callback_lock);
1441
1442 /* from net/core/stream.c:sk_stream_write_space */
1443 if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
1444 xs_write_space(sk);
1445
1440
1441 /* from net/core/stream.c:sk_stream_write_space */
1442 if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
1443 xs_write_space(sk);
1444
1446 read_unlock_bh(&sk->sk_callback_lock);
1445 read_unlock(&sk->sk_callback_lock);
1447}
1448
1449static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)
1450{
1451 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
1452 struct sock *sk = transport->inet;
1453
1454 if (transport->rcvsize) {

--- 56 unchanged lines hidden (view full) ---

1511static void xs_set_port(struct rpc_xprt *xprt, unsigned short port)
1512{
1513 dprintk("RPC: setting port for xprt %p to %u\n", xprt, port);
1514
1515 rpc_set_port(xs_addr(xprt), port);
1516 xs_update_peer_port(xprt);
1517}
1518
1446}
1447
1448static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)
1449{
1450 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
1451 struct sock *sk = transport->inet;
1452
1453 if (transport->rcvsize) {

--- 56 unchanged lines hidden (view full) ---

1510static void xs_set_port(struct rpc_xprt *xprt, unsigned short port)
1511{
1512 dprintk("RPC: setting port for xprt %p to %u\n", xprt, port);
1513
1514 rpc_set_port(xs_addr(xprt), port);
1515 xs_update_peer_port(xprt);
1516}
1517
1519static unsigned short xs_get_srcport(struct sock_xprt *transport, struct socket *sock)
1518static unsigned short xs_get_srcport(struct sock_xprt *transport)
1520{
1521 unsigned short port = transport->srcport;
1522
1523 if (port == 0 && transport->xprt.resvport)
1524 port = xs_get_random_port();
1525 return port;
1526}
1527

--- 10 unchanged lines hidden (view full) ---

1538
1539static int xs_bind4(struct sock_xprt *transport, struct socket *sock)
1540{
1541 struct sockaddr_in myaddr = {
1542 .sin_family = AF_INET,
1543 };
1544 struct sockaddr_in *sa;
1545 int err, nloop = 0;
1519{
1520 unsigned short port = transport->srcport;
1521
1522 if (port == 0 && transport->xprt.resvport)
1523 port = xs_get_random_port();
1524 return port;
1525}
1526

--- 10 unchanged lines hidden (view full) ---

1537
1538static int xs_bind4(struct sock_xprt *transport, struct socket *sock)
1539{
1540 struct sockaddr_in myaddr = {
1541 .sin_family = AF_INET,
1542 };
1543 struct sockaddr_in *sa;
1544 int err, nloop = 0;
1546 unsigned short port = xs_get_srcport(transport, sock);
1545 unsigned short port = xs_get_srcport(transport);
1547 unsigned short last;
1548
1549 sa = (struct sockaddr_in *)&transport->srcaddr;
1550 myaddr.sin_addr = sa->sin_addr;
1551 do {
1552 myaddr.sin_port = htons(port);
1553 err = kernel_bind(sock, (struct sockaddr *) &myaddr,
1554 sizeof(myaddr));

--- 16 unchanged lines hidden (view full) ---

1571
1572static int xs_bind6(struct sock_xprt *transport, struct socket *sock)
1573{
1574 struct sockaddr_in6 myaddr = {
1575 .sin6_family = AF_INET6,
1576 };
1577 struct sockaddr_in6 *sa;
1578 int err, nloop = 0;
1546 unsigned short last;
1547
1548 sa = (struct sockaddr_in *)&transport->srcaddr;
1549 myaddr.sin_addr = sa->sin_addr;
1550 do {
1551 myaddr.sin_port = htons(port);
1552 err = kernel_bind(sock, (struct sockaddr *) &myaddr,
1553 sizeof(myaddr));

--- 16 unchanged lines hidden (view full) ---

1570
1571static int xs_bind6(struct sock_xprt *transport, struct socket *sock)
1572{
1573 struct sockaddr_in6 myaddr = {
1574 .sin6_family = AF_INET6,
1575 };
1576 struct sockaddr_in6 *sa;
1577 int err, nloop = 0;
1579 unsigned short port = xs_get_srcport(transport, sock);
1578 unsigned short port = xs_get_srcport(transport);
1580 unsigned short last;
1581
1582 sa = (struct sockaddr_in6 *)&transport->srcaddr;
1583 myaddr.sin6_addr = sa->sin6_addr;
1584 do {
1585 myaddr.sin6_port = htons(port);
1586 err = kernel_bind(sock, (struct sockaddr *) &myaddr,
1587 sizeof(myaddr));

--- 88 unchanged lines hidden (view full) ---

1676 int err, status = -EIO;
1677
1678 if (xprt->shutdown)
1679 goto out;
1680
1681 /* Start by resetting any existing state */
1682 xs_reset_transport(transport);
1683
1579 unsigned short last;
1580
1581 sa = (struct sockaddr_in6 *)&transport->srcaddr;
1582 myaddr.sin6_addr = sa->sin6_addr;
1583 do {
1584 myaddr.sin6_port = htons(port);
1585 err = kernel_bind(sock, (struct sockaddr *) &myaddr,
1586 sizeof(myaddr));

--- 88 unchanged lines hidden (view full) ---

1675 int err, status = -EIO;
1676
1677 if (xprt->shutdown)
1678 goto out;
1679
1680 /* Start by resetting any existing state */
1681 xs_reset_transport(transport);
1682
1684 err = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
1683 err = __sock_create(xprt->xprt_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
1685 if (err < 0) {
1686 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1687 goto out;
1688 }
1689 xs_reclassify_socket4(sock);
1690
1691 if (xs_bind4(transport, sock)) {
1692 sock_release(sock);

--- 28 unchanged lines hidden (view full) ---

1721 int err, status = -EIO;
1722
1723 if (xprt->shutdown)
1724 goto out;
1725
1726 /* Start by resetting any existing state */
1727 xs_reset_transport(transport);
1728
1684 if (err < 0) {
1685 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1686 goto out;
1687 }
1688 xs_reclassify_socket4(sock);
1689
1690 if (xs_bind4(transport, sock)) {
1691 sock_release(sock);

--- 28 unchanged lines hidden (view full) ---

1720 int err, status = -EIO;
1721
1722 if (xprt->shutdown)
1723 goto out;
1724
1725 /* Start by resetting any existing state */
1726 xs_reset_transport(transport);
1727
1729 err = sock_create_kern(PF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock);
1728 err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
1730 if (err < 0) {
1731 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1732 goto out;
1733 }
1734 xs_reclassify_socket6(sock);
1735
1736 if (xs_bind6(transport, sock) < 0) {
1737 sock_release(sock);

--- 189 unchanged lines hidden (view full) ---

1927
1928static struct socket *xs_create_tcp_sock4(struct rpc_xprt *xprt,
1929 struct sock_xprt *transport)
1930{
1931 struct socket *sock;
1932 int err;
1933
1934 /* start from scratch */
1729 if (err < 0) {
1730 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1731 goto out;
1732 }
1733 xs_reclassify_socket6(sock);
1734
1735 if (xs_bind6(transport, sock) < 0) {
1736 sock_release(sock);

--- 189 unchanged lines hidden (view full) ---

1926
1927static struct socket *xs_create_tcp_sock4(struct rpc_xprt *xprt,
1928 struct sock_xprt *transport)
1929{
1930 struct socket *sock;
1931 int err;
1932
1933 /* start from scratch */
1935 err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
1934 err = __sock_create(xprt->xprt_net, PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock, 1);
1936 if (err < 0) {
1937 dprintk("RPC: can't create TCP transport socket (%d).\n",
1938 -err);
1939 goto out_err;
1940 }
1941 xs_reclassify_socket4(sock);
1942
1943 if (xs_bind4(transport, sock) < 0) {

--- 22 unchanged lines hidden (view full) ---

1966
1967static struct socket *xs_create_tcp_sock6(struct rpc_xprt *xprt,
1968 struct sock_xprt *transport)
1969{
1970 struct socket *sock;
1971 int err;
1972
1973 /* start from scratch */
1935 if (err < 0) {
1936 dprintk("RPC: can't create TCP transport socket (%d).\n",
1937 -err);
1938 goto out_err;
1939 }
1940 xs_reclassify_socket4(sock);
1941
1942 if (xs_bind4(transport, sock) < 0) {

--- 22 unchanged lines hidden (view full) ---

1965
1966static struct socket *xs_create_tcp_sock6(struct rpc_xprt *xprt,
1967 struct sock_xprt *transport)
1968{
1969 struct socket *sock;
1970 int err;
1971
1972 /* start from scratch */
1974 err = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, &sock);
1973 err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_STREAM, IPPROTO_TCP, &sock, 1);
1975 if (err < 0) {
1976 dprintk("RPC: can't create TCP transport socket (%d).\n",
1977 -err);
1978 goto out_err;
1979 }
1980 xs_reclassify_socket6(sock);
1981
1982 if (xs_bind6(transport, sock) < 0) {

--- 285 unchanged lines hidden (view full) ---

2268 struct rpc_xprt *xprt;
2269 struct sock_xprt *new;
2270
2271 if (args->addrlen > sizeof(xprt->addr)) {
2272 dprintk("RPC: xs_setup_xprt: address too large\n");
2273 return ERR_PTR(-EBADF);
2274 }
2275
1974 if (err < 0) {
1975 dprintk("RPC: can't create TCP transport socket (%d).\n",
1976 -err);
1977 goto out_err;
1978 }
1979 xs_reclassify_socket6(sock);
1980
1981 if (xs_bind6(transport, sock) < 0) {

--- 285 unchanged lines hidden (view full) ---

2267 struct rpc_xprt *xprt;
2268 struct sock_xprt *new;
2269
2270 if (args->addrlen > sizeof(xprt->addr)) {
2271 dprintk("RPC: xs_setup_xprt: address too large\n");
2272 return ERR_PTR(-EBADF);
2273 }
2274
2276 new = kzalloc(sizeof(*new), GFP_KERNEL);
2277 if (new == NULL) {
2275 xprt = xprt_alloc(args->net, sizeof(*new), slot_table_size);
2276 if (xprt == NULL) {
2278 dprintk("RPC: xs_setup_xprt: couldn't allocate "
2279 "rpc_xprt\n");
2280 return ERR_PTR(-ENOMEM);
2281 }
2277 dprintk("RPC: xs_setup_xprt: couldn't allocate "
2278 "rpc_xprt\n");
2279 return ERR_PTR(-ENOMEM);
2280 }
2282 xprt = &new->xprt;
2283
2281
2284 xprt->max_reqs = slot_table_size;
2285 xprt->slot = kcalloc(xprt->max_reqs, sizeof(struct rpc_rqst), GFP_KERNEL);
2286 if (xprt->slot == NULL) {
2287 kfree(xprt);
2288 dprintk("RPC: xs_setup_xprt: couldn't allocate slot "
2289 "table\n");
2290 return ERR_PTR(-ENOMEM);
2291 }
2292
2282 new = container_of(xprt, struct sock_xprt, xprt);
2293 memcpy(&xprt->addr, args->dstaddr, args->addrlen);
2294 xprt->addrlen = args->addrlen;
2295 if (args->srcaddr)
2296 memcpy(&new->srcaddr, args->srcaddr, args->addrlen);
2297
2298 return xprt;
2299}
2300

--- 65 unchanged lines hidden (view full) ---

2366 dprintk("RPC: set up xprt to %s (autobind) via %s\n",
2367 xprt->address_strings[RPC_DISPLAY_ADDR],
2368 xprt->address_strings[RPC_DISPLAY_PROTO]);
2369
2370 if (try_module_get(THIS_MODULE))
2371 return xprt;
2372 ret = ERR_PTR(-EINVAL);
2373out_err:
2283 memcpy(&xprt->addr, args->dstaddr, args->addrlen);
2284 xprt->addrlen = args->addrlen;
2285 if (args->srcaddr)
2286 memcpy(&new->srcaddr, args->srcaddr, args->addrlen);
2287
2288 return xprt;
2289}
2290

--- 65 unchanged lines hidden (view full) ---

2356 dprintk("RPC: set up xprt to %s (autobind) via %s\n",
2357 xprt->address_strings[RPC_DISPLAY_ADDR],
2358 xprt->address_strings[RPC_DISPLAY_PROTO]);
2359
2360 if (try_module_get(THIS_MODULE))
2361 return xprt;
2362 ret = ERR_PTR(-EINVAL);
2363out_err:
2374 kfree(xprt->slot);
2375 kfree(xprt);
2364 xprt_free(xprt);
2376 return ret;
2377}
2378
2379static const struct rpc_timeout xs_tcp_default_timeout = {
2380 .to_initval = 60 * HZ,
2381 .to_maxval = 60 * HZ,
2382 .to_retries = 2,
2383};

--- 58 unchanged lines hidden (view full) ---

2442 xprt->address_strings[RPC_DISPLAY_ADDR],
2443 xprt->address_strings[RPC_DISPLAY_PROTO]);
2444
2445
2446 if (try_module_get(THIS_MODULE))
2447 return xprt;
2448 ret = ERR_PTR(-EINVAL);
2449out_err:
2365 return ret;
2366}
2367
2368static const struct rpc_timeout xs_tcp_default_timeout = {
2369 .to_initval = 60 * HZ,
2370 .to_maxval = 60 * HZ,
2371 .to_retries = 2,
2372};

--- 58 unchanged lines hidden (view full) ---

2431 xprt->address_strings[RPC_DISPLAY_ADDR],
2432 xprt->address_strings[RPC_DISPLAY_PROTO]);
2433
2434
2435 if (try_module_get(THIS_MODULE))
2436 return xprt;
2437 ret = ERR_PTR(-EINVAL);
2438out_err:
2450 kfree(xprt->slot);
2451 kfree(xprt);
2439 xprt_free(xprt);
2452 return ret;
2453}
2454
2455/**
2456 * xs_setup_bc_tcp - Set up transport to use a TCP backchannel socket
2457 * @args: rpc transport creation arguments
2458 *
2459 */

--- 63 unchanged lines hidden (view full) ---

2523 */
2524 xprt_set_connected(xprt);
2525
2526
2527 if (try_module_get(THIS_MODULE))
2528 return xprt;
2529 ret = ERR_PTR(-EINVAL);
2530out_err:
2440 return ret;
2441}
2442
2443/**
2444 * xs_setup_bc_tcp - Set up transport to use a TCP backchannel socket
2445 * @args: rpc transport creation arguments
2446 *
2447 */

--- 63 unchanged lines hidden (view full) ---

2511 */
2512 xprt_set_connected(xprt);
2513
2514
2515 if (try_module_get(THIS_MODULE))
2516 return xprt;
2517 ret = ERR_PTR(-EINVAL);
2518out_err:
2531 kfree(xprt->slot);
2532 kfree(xprt);
2519 xprt_free(xprt);
2533 return ret;
2534}
2535
2536static struct xprt_class xs_udp_transport = {
2537 .list = LIST_HEAD_INIT(xs_udp_transport.list),
2538 .name = "udp",
2539 .owner = THIS_MODULE,
2540 .ident = XPRT_TRANSPORT_UDP,

--- 110 unchanged lines hidden ---
2520 return ret;
2521}
2522
2523static struct xprt_class xs_udp_transport = {
2524 .list = LIST_HEAD_INIT(xs_udp_transport.list),
2525 .name = "udp",
2526 .owner = THIS_MODULE,
2527 .ident = XPRT_TRANSPORT_UDP,

--- 110 unchanged lines hidden ---