xprtsock.c (18dca02aeb3c49dfce87c76be643b139d05cf647) xprtsock.c (f4a2e418bfd03a1f25f515e8a92ecd584d96cfc1)
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

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

265
266/*
267 * TCP receive state flags
268 */
269#define TCP_RCV_LAST_FRAG (1UL << 0)
270#define TCP_RCV_COPY_FRAGHDR (1UL << 1)
271#define TCP_RCV_COPY_XID (1UL << 2)
272#define TCP_RCV_COPY_DATA (1UL << 3)
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

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

265
266/*
267 * TCP receive state flags
268 */
269#define TCP_RCV_LAST_FRAG (1UL << 0)
270#define TCP_RCV_COPY_FRAGHDR (1UL << 1)
271#define TCP_RCV_COPY_XID (1UL << 2)
272#define TCP_RCV_COPY_DATA (1UL << 3)
273#define TCP_RCV_COPY_CALLDIR (1UL << 4)
273#define TCP_RCV_READ_CALLDIR (1UL << 4)
274#define TCP_RCV_COPY_CALLDIR (1UL << 5)
274
275/*
276 * TCP RPC flags
277 */
275
276/*
277 * TCP RPC flags
278 */
278#define TCP_RPC_REPLY (1UL << 5)
279#define TCP_RPC_REPLY (1UL << 6)
279
280static inline struct sockaddr *xs_addr(struct rpc_xprt *xprt)
281{
282 return (struct sockaddr *) &xprt->addr;
283}
284
285static inline struct sockaddr_in *xs_addr_in(struct rpc_xprt *xprt)
286{

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

992 len = sizeof(transport->tcp_xid) - transport->tcp_offset;
993 dprintk("RPC: reading XID (%Zu bytes)\n", len);
994 p = ((char *) &transport->tcp_xid) + transport->tcp_offset;
995 used = xdr_skb_read_bits(desc, p, len);
996 transport->tcp_offset += used;
997 if (used != len)
998 return;
999 transport->tcp_flags &= ~TCP_RCV_COPY_XID;
280
281static inline struct sockaddr *xs_addr(struct rpc_xprt *xprt)
282{
283 return (struct sockaddr *) &xprt->addr;
284}
285
286static inline struct sockaddr_in *xs_addr_in(struct rpc_xprt *xprt)
287{

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

993 len = sizeof(transport->tcp_xid) - transport->tcp_offset;
994 dprintk("RPC: reading XID (%Zu bytes)\n", len);
995 p = ((char *) &transport->tcp_xid) + transport->tcp_offset;
996 used = xdr_skb_read_bits(desc, p, len);
997 transport->tcp_offset += used;
998 if (used != len)
999 return;
1000 transport->tcp_flags &= ~TCP_RCV_COPY_XID;
1000 transport->tcp_flags |= TCP_RCV_COPY_CALLDIR;
1001 transport->tcp_flags |= TCP_RCV_READ_CALLDIR;
1001 transport->tcp_copied = 4;
1002 dprintk("RPC: reading %s XID %08x\n",
1003 (transport->tcp_flags & TCP_RPC_REPLY) ? "reply for"
1004 : "request with",
1005 ntohl(transport->tcp_xid));
1006 xs_tcp_check_fraghdr(transport);
1007}
1008

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

1021 */
1022 offset = transport->tcp_offset - sizeof(transport->tcp_xid);
1023 len = sizeof(calldir) - offset;
1024 dprintk("RPC: reading CALL/REPLY flag (%Zu bytes)\n", len);
1025 used = xdr_skb_read_bits(desc, &calldir, len);
1026 transport->tcp_offset += used;
1027 if (used != len)
1028 return;
1002 transport->tcp_copied = 4;
1003 dprintk("RPC: reading %s XID %08x\n",
1004 (transport->tcp_flags & TCP_RPC_REPLY) ? "reply for"
1005 : "request with",
1006 ntohl(transport->tcp_xid));
1007 xs_tcp_check_fraghdr(transport);
1008}
1009

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

1022 */
1023 offset = transport->tcp_offset - sizeof(transport->tcp_xid);
1024 len = sizeof(calldir) - offset;
1025 dprintk("RPC: reading CALL/REPLY flag (%Zu bytes)\n", len);
1026 used = xdr_skb_read_bits(desc, &calldir, len);
1027 transport->tcp_offset += used;
1028 if (used != len)
1029 return;
1029 transport->tcp_flags &= ~TCP_RCV_COPY_CALLDIR;
1030 transport->tcp_flags &= ~TCP_RCV_READ_CALLDIR;
1031 transport->tcp_flags |= TCP_RCV_COPY_CALLDIR;
1030 transport->tcp_flags |= TCP_RCV_COPY_DATA;
1032 transport->tcp_flags |= TCP_RCV_COPY_DATA;
1031 transport->tcp_copied += 4;
1033 /*
1034 * We don't yet have the XDR buffer, so we will write the calldir
1035 * out after we get the buffer from the 'struct rpc_rqst'
1036 */
1032 if (ntohl(calldir) == RPC_REPLY)
1033 transport->tcp_flags |= TCP_RPC_REPLY;
1034 else
1035 transport->tcp_flags &= ~TCP_RPC_REPLY;
1036 dprintk("RPC: reading %s CALL/REPLY flag %08x\n",
1037 (transport->tcp_flags & TCP_RPC_REPLY) ?
1038 "reply for" : "request with", calldir);
1039 xs_tcp_check_fraghdr(transport);

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

1054 transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
1055 dprintk("RPC: XID %08x request not found!\n",
1056 ntohl(transport->tcp_xid));
1057 spin_unlock(&xprt->transport_lock);
1058 return;
1059 }
1060
1061 rcvbuf = &req->rq_private_buf;
1037 if (ntohl(calldir) == RPC_REPLY)
1038 transport->tcp_flags |= TCP_RPC_REPLY;
1039 else
1040 transport->tcp_flags &= ~TCP_RPC_REPLY;
1041 dprintk("RPC: reading %s CALL/REPLY flag %08x\n",
1042 (transport->tcp_flags & TCP_RPC_REPLY) ?
1043 "reply for" : "request with", calldir);
1044 xs_tcp_check_fraghdr(transport);

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

1059 transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
1060 dprintk("RPC: XID %08x request not found!\n",
1061 ntohl(transport->tcp_xid));
1062 spin_unlock(&xprt->transport_lock);
1063 return;
1064 }
1065
1066 rcvbuf = &req->rq_private_buf;
1067
1068 if (transport->tcp_flags & TCP_RCV_COPY_CALLDIR) {
1069 /*
1070 * Save the RPC direction in the XDR buffer
1071 */
1072 __be32 calldir = transport->tcp_flags & TCP_RPC_REPLY ?
1073 htonl(RPC_REPLY) : 0;
1074
1075 memcpy(rcvbuf->head[0].iov_base + transport->tcp_copied,
1076 &calldir, sizeof(calldir));
1077 transport->tcp_copied += sizeof(calldir);
1078 transport->tcp_flags &= ~TCP_RCV_COPY_CALLDIR;
1079 }
1080
1062 len = desc->count;
1063 if (len > transport->tcp_reclen - transport->tcp_offset) {
1064 struct xdr_skb_reader my_desc;
1065
1066 len = transport->tcp_reclen - transport->tcp_offset;
1067 memcpy(&my_desc, desc, sizeof(my_desc));
1068 my_desc.count = len;
1069 r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied,

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

1151 continue;
1152 }
1153 /* Read in the xid if necessary */
1154 if (transport->tcp_flags & TCP_RCV_COPY_XID) {
1155 xs_tcp_read_xid(transport, &desc);
1156 continue;
1157 }
1158 /* Read in the call/reply flag */
1081 len = desc->count;
1082 if (len > transport->tcp_reclen - transport->tcp_offset) {
1083 struct xdr_skb_reader my_desc;
1084
1085 len = transport->tcp_reclen - transport->tcp_offset;
1086 memcpy(&my_desc, desc, sizeof(my_desc));
1087 my_desc.count = len;
1088 r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied,

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

1170 continue;
1171 }
1172 /* Read in the xid if necessary */
1173 if (transport->tcp_flags & TCP_RCV_COPY_XID) {
1174 xs_tcp_read_xid(transport, &desc);
1175 continue;
1176 }
1177 /* Read in the call/reply flag */
1159 if (transport->tcp_flags & TCP_RCV_COPY_CALLDIR) {
1178 if (transport->tcp_flags & TCP_RCV_READ_CALLDIR) {
1160 xs_tcp_read_calldir(transport, &desc);
1161 continue;
1162 }
1163 /* Read in the request data */
1164 if (transport->tcp_flags & TCP_RCV_COPY_DATA) {
1165 xs_tcp_read_request(xprt, &desc);
1166 continue;
1167 }

--- 1116 unchanged lines hidden ---
1179 xs_tcp_read_calldir(transport, &desc);
1180 continue;
1181 }
1182 /* Read in the request data */
1183 if (transport->tcp_flags & TCP_RCV_COPY_DATA) {
1184 xs_tcp_read_request(xprt, &desc);
1185 continue;
1186 }

--- 1116 unchanged lines hidden ---