Whamcloud - gitweb
LU-6245 libcfs: remove tcpip abstraction from libcfs
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_proto.c
index 9bfb61a..f4a7d77 100644 (file)
@@ -451,7 +451,7 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
 static int
 ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
 {
-        cfs_socket_t        *sock = conn->ksnc_sock;
+       struct socket        *sock = conn->ksnc_sock;
         lnet_hdr_t          *hdr;
         lnet_magicversion_t *hmv;
         int                  rc;
@@ -494,11 +494,10 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
         hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
         hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
 
-        rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),lnet_acceptor_timeout());
-
+       rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
         if (rc != 0) {
-                CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+               CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
+                       rc, &conn->ksnc_ipaddr, conn->ksnc_port);
                 goto out;
         }
 
@@ -509,13 +508,13 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
                 hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]);
         }
 
-        rc = libcfs_sock_write(sock, hello->kshm_ips,
+       rc = lnet_sock_write(sock, hello->kshm_ips,
                                hello->kshm_nips * sizeof(__u32),
                                lnet_acceptor_timeout());
         if (rc != 0) {
                 CNETERR("Error %d sending HELLO payload (%d)"
-                        " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips,
-                        HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+                       " to %pI4h/%d\n", rc, hello->kshm_nips,
+                       &conn->ksnc_ipaddr, conn->ksnc_port);
         }
 out:
         LIBCFS_FREE(hdr, sizeof(*hdr));
@@ -526,7 +525,7 @@ out:
 static int
 ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
 {
-        cfs_socket_t   *sock = conn->ksnc_sock;
+       struct socket   *sock = conn->ksnc_sock;
         int             rc;
 
         hello->kshm_magic   = LNET_PROTO_MAGIC;
@@ -542,25 +541,25 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
                 LNET_UNLOCK();
         }
 
-        rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
+       rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
                                lnet_acceptor_timeout());
 
         if (rc != 0) {
-                CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+               CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
+                       rc, &conn->ksnc_ipaddr, conn->ksnc_port);
                 return rc;
         }
 
         if (hello->kshm_nips == 0)
                 return 0;
 
-        rc = libcfs_sock_write(sock, hello->kshm_ips,
+       rc = lnet_sock_write(sock, hello->kshm_ips,
                                hello->kshm_nips * sizeof(__u32),
                                lnet_acceptor_timeout());
         if (rc != 0) {
                 CNETERR("Error %d sending HELLO payload (%d)"
-                        " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips,
-                        HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+                       " to %pI4h/%d\n", rc, hello->kshm_nips,
+                       &conn->ksnc_ipaddr, conn->ksnc_port);
         }
 
         return rc;
@@ -569,7 +568,7 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
 static int
 ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout)
 {
-        cfs_socket_t        *sock = conn->ksnc_sock;
+       struct socket        *sock = conn->ksnc_sock;
         lnet_hdr_t          *hdr;
         int                  rc;
         int                  i;
@@ -580,22 +579,22 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout)
                 return -ENOMEM;
         }
 
-        rc = libcfs_sock_read(sock, &hdr->src_nid,
-                              sizeof (*hdr) - offsetof (lnet_hdr_t, src_nid),
-                              timeout);
-        if (rc != 0) {
-                CERROR ("Error %d reading rest of HELLO hdr from %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
-                goto out;
-        }
+       rc = lnet_sock_read(sock, &hdr->src_nid,
+                             sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
+                             timeout);
+       if (rc != 0) {
+               CERROR("Error %d reading rest of HELLO hdr from %pI4h\n",
+                      rc, &conn->ksnc_ipaddr);
+               LASSERT(rc < 0 && rc != -EALREADY);
+               goto out;
+       }
 
         /* ...and check we got what we expected */
         if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) {
                 CERROR ("Expecting a HELLO hdr,"
-                        " but got type %d from %u.%u.%u.%u\n",
+                       " but got type %d from %pI4h\n",
                         le32_to_cpu (hdr->type),
-                        HIPQUAD(conn->ksnc_ipaddr));
+                       &conn->ksnc_ipaddr);
                 rc = -EPROTO;
                 goto out;
         }
@@ -608,8 +607,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout)
                                          sizeof (__u32);
 
         if (hello->kshm_nips > LNET_MAX_INTERFACES) {
-                CERROR("Bad nips %d from ip %u.%u.%u.%u\n",
-                       hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr));
+               CERROR("Bad nips %d from ip %pI4h\n",
+                      hello->kshm_nips, &conn->ksnc_ipaddr);
                 rc = -EPROTO;
                 goto out;
         }
@@ -617,12 +616,12 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout)
         if (hello->kshm_nips == 0)
                 goto out;
 
-        rc = libcfs_sock_read(sock, hello->kshm_ips,
+       rc = lnet_sock_read(sock, hello->kshm_ips,
                               hello->kshm_nips * sizeof(__u32), timeout);
         if (rc != 0) {
-                CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
+               CERROR("Error %d reading IPs from ip %pI4h\n",
+                      rc, &conn->ksnc_ipaddr);
+               LASSERT(rc < 0 && rc != -EALREADY);
                 goto out;
         }
 
@@ -630,8 +629,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout)
                 hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]);
 
                 if (hello->kshm_ips[i] == 0) {
-                        CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n",
-                               i, HIPQUAD(conn->ksnc_ipaddr));
+                       CERROR("Zero IP[%d] from ip %pI4h\n",
+                              i, &conn->ksnc_ipaddr);
                         rc = -EPROTO;
                         break;
                 }
@@ -643,9 +642,10 @@ out:
 }
 
 static int
-ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout)
+ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello,
+                      int timeout)
 {
-        cfs_socket_t      *sock = conn->ksnc_sock;
+       struct socket     *sock = conn->ksnc_sock;
         int                rc;
         int                i;
 
@@ -654,14 +654,14 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou
         else
                 conn->ksnc_flip = 1;
 
-        rc = libcfs_sock_read(sock, &hello->kshm_src_nid,
+       rc = lnet_sock_read(sock, &hello->kshm_src_nid,
                               offsetof(ksock_hello_msg_t, kshm_ips) -
                                        offsetof(ksock_hello_msg_t, kshm_src_nid),
                               timeout);
         if (rc != 0) {
-                CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
+               CERROR("Error %d reading HELLO from %pI4h\n",
+                      rc, &conn->ksnc_ipaddr);
+               LASSERT(rc < 0 && rc != -EALREADY);
                 return rc;
         }
 
@@ -677,20 +677,20 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou
         }
 
         if (hello->kshm_nips > LNET_MAX_INTERFACES) {
-                CERROR("Bad nips %d from ip %u.%u.%u.%u\n",
-                       hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr));
+               CERROR("Bad nips %d from ip %pI4h\n",
+                      hello->kshm_nips, &conn->ksnc_ipaddr);
                 return -EPROTO;
         }
 
         if (hello->kshm_nips == 0)
                 return 0;
 
-        rc = libcfs_sock_read(sock, hello->kshm_ips,
-                              hello->kshm_nips * sizeof(__u32), timeout);
+       rc = lnet_sock_read(sock, hello->kshm_ips,
+                           hello->kshm_nips * sizeof(__u32), timeout);
         if (rc != 0) {
-                CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
+               CERROR("Error %d reading IPs from ip %pI4h\n",
+                      rc, &conn->ksnc_ipaddr);
+               LASSERT(rc < 0 && rc != -EALREADY);
                 return rc;
         }
 
@@ -699,8 +699,8 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou
                         __swab32s(&hello->kshm_ips[i]);
 
                 if (hello->kshm_ips[i] == 0) {
-                        CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n",
-                               i, HIPQUAD(conn->ksnc_ipaddr));
+                       CERROR("Zero IP[%d] from ip %pI4h\n",
+                              i, &conn->ksnc_ipaddr);
                         return -EPROTO;
                 }
         }