/* Assume sufficient socket buffering for this message */
rc = syscall(SYS_write, sockfd, &hdr, sizeof(hdr));
if (rc <= 0) {
/* Assume sufficient socket buffering for this message */
rc = syscall(SYS_write, sockfd, &hdr, sizeof(hdr));
if (rc <= 0) {
return (rc);
}
rc = syscall(SYS_read, sockfd, hmv, sizeof(*hmv));
if (rc <= 0) {
return (rc);
}
rc = syscall(SYS_read, sockfd, hmv, sizeof(*hmv));
if (rc <= 0) {
if (hmv->version_major != __cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR) ||
hmv->version_minor != __cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR)) {
CERROR ("Incompatible protocol version %d.%d (%d.%d expected)"
if (hmv->version_major != __cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR) ||
hmv->version_minor != __cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR)) {
CERROR ("Incompatible protocol version %d.%d (%d.%d expected)"
__le16_to_cpu (hmv->version_major),
__le16_to_cpu (hmv->version_minor),
PORTALS_PROTO_VERSION_MAJOR,
__le16_to_cpu (hmv->version_major),
__le16_to_cpu (hmv->version_minor),
PORTALS_PROTO_VERSION_MAJOR,
rc = syscall(SYS_read, sockfd, hmv + 1, sizeof(hdr) - sizeof(*hmv));
if (rc <= 0) {
rc = syscall(SYS_read, sockfd, hmv + 1, sizeof(hdr) - sizeof(*hmv));
if (rc <= 0) {
if (hdr.type != __cpu_to_le32 (PTL_MSG_HELLO) ||
hdr.payload_length != __cpu_to_le32 (0)) {
CERROR ("Expecting a HELLO hdr with 0 payload,"
if (hdr.type != __cpu_to_le32 (PTL_MSG_HELLO) ||
hdr.payload_length != __cpu_to_le32 (0)) {
CERROR ("Expecting a HELLO hdr with 0 payload,"
__le32_to_cpu (hdr.type),
__le32_to_cpu (hdr.payload_length), *nid);
return (-EPROTO);
__le32_to_cpu (hdr.type),
__le32_to_cpu (hdr.payload_length), *nid);
return (-EPROTO);
if (*nid == PTL_NID_ANY) { /* don't know peer's nid yet */
*nid = __le64_to_cpu(hdr.src_nid);
} else if (*nid != __le64_to_cpu (hdr.src_nid)) {
if (*nid == PTL_NID_ANY) { /* don't know peer's nid yet */
*nid = __le64_to_cpu(hdr.src_nid);
} else if (*nid != __le64_to_cpu (hdr.src_nid)) {