staging:lustre: rename tcpip handling functions to lnet_* prefix
With all the TCPIP handling done in the lnet layer we should rename all the functions with the prefix lnet_*. One other change done was changing the remove argument of lnet_sock_getaddr from a int to a bool. Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
45bd3ebe32
commit
1ad6a73ef2
10 changed files with 110 additions and 128 deletions
|
@ -65,21 +65,6 @@ static inline int __is_po2(unsigned long long val)
|
||||||
int libcfs_arch_init(void);
|
int libcfs_arch_init(void);
|
||||||
void libcfs_arch_cleanup(void);
|
void libcfs_arch_cleanup(void);
|
||||||
|
|
||||||
/* libcfs tcpip */
|
|
||||||
int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
|
|
||||||
int libcfs_ipif_enumerate(char ***names);
|
|
||||||
void libcfs_ipif_free_enumeration(char **names, int n);
|
|
||||||
int libcfs_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
|
|
||||||
int libcfs_sock_accept(struct socket **newsockp, struct socket *sock);
|
|
||||||
int libcfs_sock_connect(struct socket **sockp, int *fatal,
|
|
||||||
__u32 local_ip, int local_port,
|
|
||||||
__u32 peer_ip, int peer_port);
|
|
||||||
int libcfs_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
|
|
||||||
int libcfs_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
|
|
||||||
int libcfs_sock_getaddr(struct socket *socket, int remote, __u32 *ip, int *port);
|
|
||||||
int libcfs_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
|
|
||||||
int libcfs_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
|
|
||||||
|
|
||||||
/* need both kernel and user-land acceptor */
|
/* need both kernel and user-land acceptor */
|
||||||
#define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
|
#define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
|
||||||
#define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023
|
#define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023
|
||||||
|
|
|
@ -639,6 +639,22 @@ int lnet_acceptor_port(void);
|
||||||
int lnet_acceptor_start(void);
|
int lnet_acceptor_start(void);
|
||||||
void lnet_acceptor_stop(void);
|
void lnet_acceptor_stop(void);
|
||||||
|
|
||||||
|
int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
|
||||||
|
int lnet_ipif_enumerate(char ***names);
|
||||||
|
void lnet_ipif_free_enumeration(char **names, int n);
|
||||||
|
int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
|
||||||
|
int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
|
||||||
|
int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port);
|
||||||
|
int lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
|
||||||
|
int lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
|
||||||
|
|
||||||
|
int lnet_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
|
||||||
|
int lnet_sock_accept(struct socket **newsockp, struct socket *sock);
|
||||||
|
int lnet_sock_connect(struct socket **sockp, int *fatal,
|
||||||
|
__u32 local_ip, int local_port,
|
||||||
|
__u32 peer_ip, int peer_port);
|
||||||
|
void libcfs_sock_release(struct socket *sock);
|
||||||
|
|
||||||
void lnet_get_tunables(void);
|
void lnet_get_tunables(void);
|
||||||
int lnet_peers_start_down(void);
|
int lnet_peers_start_down(void);
|
||||||
int lnet_peer_buffer_credits(lnet_ni_t *ni);
|
int lnet_peer_buffer_credits(lnet_ni_t *ni);
|
||||||
|
|
|
@ -2617,7 +2617,7 @@ static kib_dev_t *kiblnd_create_dev(char *ifname)
|
||||||
int up;
|
int up;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = libcfs_ipif_query(ifname, &up, &ip, &netmask);
|
rc = lnet_ipif_query(ifname, &up, &ip, &netmask);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Can't query IPoIB interface %s: %d\n",
|
CERROR("Can't query IPoIB interface %s: %d\n",
|
||||||
ifname, rc);
|
ifname, rc);
|
||||||
|
|
|
@ -968,7 +968,7 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
|
||||||
__u32 peer_ip;
|
__u32 peer_ip;
|
||||||
int peer_port;
|
int peer_port;
|
||||||
|
|
||||||
rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
|
rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
|
||||||
LASSERT(rc == 0); /* we succeeded before */
|
LASSERT(rc == 0); /* we succeeded before */
|
||||||
|
|
||||||
LIBCFS_ALLOC(cr, sizeof(*cr));
|
LIBCFS_ALLOC(cr, sizeof(*cr));
|
||||||
|
@ -2594,7 +2594,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
|
||||||
int rc;
|
int rc;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
n = libcfs_ipif_enumerate(&names);
|
n = lnet_ipif_enumerate(&names);
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
CERROR("Can't enumerate interfaces: %d\n", n);
|
CERROR("Can't enumerate interfaces: %d\n", n);
|
||||||
return n;
|
return n;
|
||||||
|
@ -2608,7 +2608,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
|
||||||
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
|
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rc = libcfs_ipif_query(names[i], &up, &ip, &mask);
|
rc = lnet_ipif_query(names[i], &up, &ip, &mask);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CWARN("Can't get interface %s info: %d\n",
|
CWARN("Can't get interface %s info: %d\n",
|
||||||
names[i], rc);
|
names[i], rc);
|
||||||
|
@ -2634,7 +2634,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
libcfs_ipif_free_enumeration(names, n);
|
lnet_ipif_free_enumeration(names, n);
|
||||||
|
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
CERROR("Can't find any usable interfaces\n");
|
CERROR("Can't find any usable interfaces\n");
|
||||||
|
@ -2796,8 +2796,7 @@ ksocknal_startup(lnet_ni_t *ni)
|
||||||
if (ni->ni_interfaces[i] == NULL)
|
if (ni->ni_interfaces[i] == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rc = libcfs_ipif_query(
|
rc = lnet_ipif_query(ni->ni_interfaces[i], &up,
|
||||||
ni->ni_interfaces[i], &up,
|
|
||||||
&net->ksnn_interfaces[i].ksni_ipaddr,
|
&net->ksnn_interfaces[i].ksni_ipaddr,
|
||||||
&net->ksnn_interfaces[i].ksni_netmask);
|
&net->ksnn_interfaces[i].ksni_netmask);
|
||||||
|
|
||||||
|
|
|
@ -1707,7 +1707,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
|
||||||
timeout = active ? *ksocknal_tunables.ksnd_timeout :
|
timeout = active ? *ksocknal_tunables.ksnd_timeout :
|
||||||
lnet_acceptor_timeout();
|
lnet_acceptor_timeout();
|
||||||
|
|
||||||
rc = libcfs_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
|
rc = lnet_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Error %d reading HELLO from %pI4h\n",
|
CERROR("Error %d reading HELLO from %pI4h\n",
|
||||||
rc, &conn->ksnc_ipaddr);
|
rc, &conn->ksnc_ipaddr);
|
||||||
|
@ -1726,7 +1726,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
|
||||||
return -EPROTO;
|
return -EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_read(sock, &hello->kshm_version,
|
rc = lnet_sock_read(sock, &hello->kshm_version,
|
||||||
sizeof(hello->kshm_version), timeout);
|
sizeof(hello->kshm_version), timeout);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Error %d reading HELLO from %pI4h\n",
|
CERROR("Error %d reading HELLO from %pI4h\n",
|
||||||
|
|
|
@ -39,8 +39,7 @@
|
||||||
int
|
int
|
||||||
ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
|
ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
|
||||||
{
|
{
|
||||||
int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1,
|
int rc = lnet_sock_getaddr(conn->ksnc_sock, 1, &conn->ksnc_ipaddr,
|
||||||
&conn->ksnc_ipaddr,
|
|
||||||
&conn->ksnc_port);
|
&conn->ksnc_port);
|
||||||
|
|
||||||
/* Didn't need the {get,put}connsock dance to deref ksnc_sock... */
|
/* Didn't need the {get,put}connsock dance to deref ksnc_sock... */
|
||||||
|
@ -51,8 +50,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
|
rc = lnet_sock_getaddr(conn->ksnc_sock, 0, &conn->ksnc_myipaddr, NULL);
|
||||||
&conn->ksnc_myipaddr, NULL);
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Error %d getting sock local IP\n", rc);
|
CERROR("Error %d getting sock local IP\n", rc);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -436,7 +434,7 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *
|
||||||
return -ESHUTDOWN;
|
return -ESHUTDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_getbuf(sock, txmem, rxmem);
|
rc = lnet_sock_getbuf(sock, txmem, rxmem);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
len = sizeof(*nagle);
|
len = sizeof(*nagle);
|
||||||
rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY,
|
rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY,
|
||||||
|
@ -498,8 +496,7 @@ ksocknal_lib_setup_sock(struct socket *sock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_setbuf(sock,
|
rc = lnet_sock_setbuf(sock, *ksocknal_tunables.ksnd_tx_buffer_size,
|
||||||
*ksocknal_tunables.ksnd_tx_buffer_size,
|
|
||||||
*ksocknal_tunables.ksnd_rx_buffer_size);
|
*ksocknal_tunables.ksnd_rx_buffer_size);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Can't set buffer tx %d, rx %d buffers: %d\n",
|
CERROR("Can't set buffer tx %d, rx %d buffers: %d\n",
|
||||||
|
|
|
@ -495,9 +495,7 @@ 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.type = cpu_to_le32 (hello->kshm_ctype);
|
||||||
hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
|
hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
|
||||||
|
|
||||||
rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),
|
rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
|
||||||
lnet_acceptor_timeout());
|
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
|
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
|
||||||
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
|
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
|
||||||
|
@ -511,7 +509,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
|
||||||
hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]);
|
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),
|
hello->kshm_nips * sizeof(__u32),
|
||||||
lnet_acceptor_timeout());
|
lnet_acceptor_timeout());
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
@ -544,9 +542,8 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
|
||||||
LNET_UNLOCK();
|
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());
|
lnet_acceptor_timeout());
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
|
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
|
||||||
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
|
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
|
||||||
|
@ -556,7 +553,7 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
|
||||||
if (hello->kshm_nips == 0)
|
if (hello->kshm_nips == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rc = libcfs_sock_write(sock, hello->kshm_ips,
|
rc = lnet_sock_write(sock, hello->kshm_ips,
|
||||||
hello->kshm_nips * sizeof(__u32),
|
hello->kshm_nips * sizeof(__u32),
|
||||||
lnet_acceptor_timeout());
|
lnet_acceptor_timeout());
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
@ -583,7 +580,7 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_read(sock, &hdr->src_nid,
|
rc = lnet_sock_read(sock, &hdr->src_nid,
|
||||||
sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
|
sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
|
||||||
timeout);
|
timeout);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
@ -619,7 +616,7 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
|
||||||
if (hello->kshm_nips == 0)
|
if (hello->kshm_nips == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rc = libcfs_sock_read(sock, hello->kshm_ips,
|
rc = lnet_sock_read(sock, hello->kshm_ips,
|
||||||
hello->kshm_nips * sizeof(__u32), timeout);
|
hello->kshm_nips * sizeof(__u32), timeout);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Error %d reading IPs from ip %pI4h\n",
|
CERROR("Error %d reading IPs from ip %pI4h\n",
|
||||||
|
@ -656,7 +653,7 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout
|
||||||
else
|
else
|
||||||
conn->ksnc_flip = 1;
|
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_ips) -
|
||||||
offsetof(ksock_hello_msg_t, kshm_src_nid),
|
offsetof(ksock_hello_msg_t, kshm_src_nid),
|
||||||
timeout);
|
timeout);
|
||||||
|
@ -687,7 +684,7 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout
|
||||||
if (hello->kshm_nips == 0)
|
if (hello->kshm_nips == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rc = libcfs_sock_read(sock, hello->kshm_ips,
|
rc = lnet_sock_read(sock, hello->kshm_ips,
|
||||||
hello->kshm_nips * sizeof(__u32), timeout);
|
hello->kshm_nips * sizeof(__u32), timeout);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Error %d reading IPs from ip %pI4h\n",
|
CERROR("Error %d reading IPs from ip %pI4h\n",
|
||||||
|
|
|
@ -155,9 +155,8 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
|
||||||
--port) {
|
--port) {
|
||||||
/* Iterate through reserved ports. */
|
/* Iterate through reserved ports. */
|
||||||
|
|
||||||
rc = libcfs_sock_connect(&sock, &fatal,
|
rc = lnet_sock_connect(&sock, &fatal, local_ip, port, peer_ip,
|
||||||
local_ip, port,
|
peer_port);
|
||||||
peer_ip, peer_port);
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
if (fatal)
|
if (fatal)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -184,8 +183,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
|
||||||
lnet_net_unlock(LNET_LOCK_EX);
|
lnet_net_unlock(LNET_LOCK_EX);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_write(sock, &cr, sizeof(cr),
|
rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
|
||||||
accept_timeout);
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
goto failed_sock;
|
goto failed_sock;
|
||||||
|
|
||||||
|
@ -220,7 +218,7 @@ lnet_accept(struct socket *sock, __u32 magic)
|
||||||
|
|
||||||
LASSERT(sizeof(cr) <= 16); /* not too big for the stack */
|
LASSERT(sizeof(cr) <= 16); /* not too big for the stack */
|
||||||
|
|
||||||
rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
|
rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
|
||||||
LASSERT(rc == 0); /* we succeeded before */
|
LASSERT(rc == 0); /* we succeeded before */
|
||||||
|
|
||||||
if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) {
|
if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) {
|
||||||
|
@ -234,7 +232,7 @@ lnet_accept(struct socket *sock, __u32 magic)
|
||||||
memset(&cr, 0, sizeof(cr));
|
memset(&cr, 0, sizeof(cr));
|
||||||
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
|
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
|
||||||
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
|
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
|
||||||
rc = libcfs_sock_write(sock, &cr, sizeof(cr),
|
rc = lnet_sock_write(sock, &cr, sizeof(cr),
|
||||||
accept_timeout);
|
accept_timeout);
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
|
@ -257,8 +255,7 @@ lnet_accept(struct socket *sock, __u32 magic)
|
||||||
|
|
||||||
flip = (magic != LNET_PROTO_ACCEPTOR_MAGIC);
|
flip = (magic != LNET_PROTO_ACCEPTOR_MAGIC);
|
||||||
|
|
||||||
rc = libcfs_sock_read(sock, &cr.acr_version,
|
rc = lnet_sock_read(sock, &cr.acr_version, sizeof(cr.acr_version),
|
||||||
sizeof(cr.acr_version),
|
|
||||||
accept_timeout);
|
accept_timeout);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Error %d reading connection request version from %pI4h\n",
|
CERROR("Error %d reading connection request version from %pI4h\n",
|
||||||
|
@ -280,16 +277,14 @@ lnet_accept(struct socket *sock, __u32 magic)
|
||||||
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
|
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
|
||||||
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
|
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
|
||||||
|
|
||||||
rc = libcfs_sock_write(sock, &cr, sizeof(cr),
|
rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
|
||||||
accept_timeout);
|
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
CERROR("Error sending magic+version in response to version %d from %pI4h: %d\n",
|
CERROR("Error sending magic+version in response to version %d from %pI4h: %d\n",
|
||||||
peer_version, &peer_ip, rc);
|
peer_version, &peer_ip, rc);
|
||||||
return -EPROTO;
|
return -EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_read(sock, &cr.acr_nid,
|
rc = lnet_sock_read(sock, &cr.acr_nid,
|
||||||
sizeof(cr) -
|
sizeof(cr) -
|
||||||
offsetof(lnet_acceptor_connreq_t, acr_nid),
|
offsetof(lnet_acceptor_connreq_t, acr_nid),
|
||||||
accept_timeout);
|
accept_timeout);
|
||||||
|
@ -343,8 +338,8 @@ lnet_acceptor(void *arg)
|
||||||
|
|
||||||
cfs_block_allsigs();
|
cfs_block_allsigs();
|
||||||
|
|
||||||
rc = libcfs_sock_listen(&lnet_acceptor_state.pta_sock,
|
rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock, 0, accept_port,
|
||||||
0, accept_port, accept_backlog);
|
accept_backlog);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
if (rc == -EADDRINUSE)
|
if (rc == -EADDRINUSE)
|
||||||
LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port %d: port already in use\n",
|
LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port %d: port already in use\n",
|
||||||
|
@ -367,7 +362,7 @@ lnet_acceptor(void *arg)
|
||||||
|
|
||||||
while (!lnet_acceptor_state.pta_shutdown) {
|
while (!lnet_acceptor_state.pta_shutdown) {
|
||||||
|
|
||||||
rc = libcfs_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
|
rc = lnet_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
if (rc != -EAGAIN) {
|
if (rc != -EAGAIN) {
|
||||||
CWARN("Accept error %d: pausing...\n", rc);
|
CWARN("Accept error %d: pausing...\n", rc);
|
||||||
|
@ -383,7 +378,7 @@ lnet_acceptor(void *arg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
|
rc = lnet_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Can't determine new connection's address\n");
|
CERROR("Can't determine new connection's address\n");
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -395,7 +390,7 @@ lnet_acceptor(void *arg)
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_sock_read(newsock, &magic, sizeof(magic),
|
rc = lnet_sock_read(newsock, &magic, sizeof(magic),
|
||||||
accept_timeout);
|
accept_timeout);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Error %d reading connection request from %pI4h\n",
|
CERROR("Error %d reading connection request from %pI4h\n",
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
|
||||||
__u32 *ipaddrs2;
|
__u32 *ipaddrs2;
|
||||||
int nip;
|
int nip;
|
||||||
char **ifnames;
|
char **ifnames;
|
||||||
int nif = libcfs_ipif_enumerate(&ifnames);
|
int nif = lnet_ipif_enumerate(&ifnames);
|
||||||
int i;
|
int i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -1128,7 +1128,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
|
||||||
LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
|
LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
|
||||||
if (ipaddrs == NULL) {
|
if (ipaddrs == NULL) {
|
||||||
CERROR("Can't allocate ipaddrs[%d]\n", nif);
|
CERROR("Can't allocate ipaddrs[%d]\n", nif);
|
||||||
libcfs_ipif_free_enumeration(ifnames, nif);
|
lnet_ipif_free_enumeration(ifnames, nif);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1136,8 +1136,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
|
||||||
if (!strcmp(ifnames[i], "lo"))
|
if (!strcmp(ifnames[i], "lo"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rc = libcfs_ipif_query(ifnames[i], &up,
|
rc = lnet_ipif_query(ifnames[i], &up, &ipaddrs[nip], &netmask);
|
||||||
&ipaddrs[nip], &netmask);
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CWARN("Can't query interface %s: %d\n",
|
CWARN("Can't query interface %s: %d\n",
|
||||||
ifnames[i], rc);
|
ifnames[i], rc);
|
||||||
|
@ -1153,7 +1152,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
|
||||||
nip++;
|
nip++;
|
||||||
}
|
}
|
||||||
|
|
||||||
libcfs_ipif_free_enumeration(ifnames, nif);
|
lnet_ipif_free_enumeration(ifnames, nif);
|
||||||
|
|
||||||
if (nip == nif) {
|
if (nip == nif) {
|
||||||
*ipaddrsp = ipaddrs;
|
*ipaddrsp = ipaddrs;
|
||||||
|
@ -1237,8 +1236,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libcfs_ipif_query(ni->ni_interfaces[0],
|
rc = lnet_ipif_query(ni->ni_interfaces[0], &up, &ip, &netmask);
|
||||||
&up, &ip, &netmask);
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Net %s can't query interface %s: %d\n",
|
CERROR("Net %s can't query interface %s: %d\n",
|
||||||
libcfs_net2str(net), ni->ni_interfaces[0], rc);
|
libcfs_net2str(net), ni->ni_interfaces[0], rc);
|
||||||
|
@ -1255,7 +1253,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = libcfs_ipif_enumerate(&names);
|
n = lnet_ipif_enumerate(&names);
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
CERROR("Net %s can't enumerate interfaces: %d\n",
|
CERROR("Net %s can't enumerate interfaces: %d\n",
|
||||||
libcfs_net2str(net), n);
|
libcfs_net2str(net), n);
|
||||||
|
@ -1266,8 +1264,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
|
||||||
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
|
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rc = libcfs_ipif_query(names[i], &up, &ip, &netmask);
|
rc = lnet_ipif_query(names[i], &up, &ip, &netmask);
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CWARN("Net %s can't query interface %s: %d\n",
|
CWARN("Net %s can't query interface %s: %d\n",
|
||||||
libcfs_net2str(net), names[i], rc);
|
libcfs_net2str(net), names[i], rc);
|
||||||
|
@ -1280,13 +1277,13 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
libcfs_ipif_free_enumeration(names, n);
|
lnet_ipif_free_enumeration(names, n);
|
||||||
ni->ni_nid = LNET_MKNID(net, ip);
|
ni->ni_nid = LNET_MKNID(net, ip);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CERROR("Net %s can't find any interfaces\n", libcfs_net2str(net));
|
CERROR("Net %s can't find any interfaces\n", libcfs_net2str(net));
|
||||||
libcfs_ipif_free_enumeration(names, n);
|
lnet_ipif_free_enumeration(names, n);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(lnet_set_ip_niaddr);
|
EXPORT_SYMBOL(lnet_set_ip_niaddr);
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include <linux/syscalls.h>
|
#include <linux/syscalls.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libcfs_sock_ioctl(int cmd, unsigned long arg)
|
lnet_sock_ioctl(int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
mm_segment_t oldmm = get_fs();
|
mm_segment_t oldmm = get_fs();
|
||||||
struct socket *sock;
|
struct socket *sock;
|
||||||
|
@ -76,7 +76,7 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
|
lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int nob;
|
int nob;
|
||||||
|
@ -92,8 +92,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
|
||||||
CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
|
CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
|
||||||
|
|
||||||
strcpy(ifr.ifr_name, name);
|
strcpy(ifr.ifr_name, name);
|
||||||
rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
|
rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Can't get flags for interface %s\n", name);
|
CERROR("Can't get flags for interface %s\n", name);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -110,8 +109,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
|
||||||
|
|
||||||
strcpy(ifr.ifr_name, name);
|
strcpy(ifr.ifr_name, name);
|
||||||
ifr.ifr_addr.sa_family = AF_INET;
|
ifr.ifr_addr.sa_family = AF_INET;
|
||||||
rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
|
rc = lnet_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Can't get IP address for interface %s\n", name);
|
CERROR("Can't get IP address for interface %s\n", name);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -122,8 +120,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
|
||||||
|
|
||||||
strcpy(ifr.ifr_name, name);
|
strcpy(ifr.ifr_name, name);
|
||||||
ifr.ifr_addr.sa_family = AF_INET;
|
ifr.ifr_addr.sa_family = AF_INET;
|
||||||
rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
|
rc = lnet_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
CERROR("Can't get netmask for interface %s\n", name);
|
CERROR("Can't get netmask for interface %s\n", name);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -135,10 +132,10 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_ipif_query);
|
EXPORT_SYMBOL(lnet_ipif_query);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_ipif_enumerate (char ***namesp)
|
lnet_ipif_enumerate (char ***namesp)
|
||||||
{
|
{
|
||||||
/* Allocate and fill in 'names', returning # interfaces/error */
|
/* Allocate and fill in 'names', returning # interfaces/error */
|
||||||
char **names;
|
char **names;
|
||||||
|
@ -172,8 +169,7 @@ libcfs_ipif_enumerate (char ***namesp)
|
||||||
ifc.ifc_buf = (char *)ifr;
|
ifc.ifc_buf = (char *)ifr;
|
||||||
ifc.ifc_len = nalloc * sizeof(*ifr);
|
ifc.ifc_len = nalloc * sizeof(*ifr);
|
||||||
|
|
||||||
rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
|
rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
CERROR ("Error %d enumerating interfaces\n", rc);
|
CERROR ("Error %d enumerating interfaces\n", rc);
|
||||||
goto out1;
|
goto out1;
|
||||||
|
@ -226,17 +222,17 @@ libcfs_ipif_enumerate (char ***namesp)
|
||||||
|
|
||||||
out2:
|
out2:
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
libcfs_ipif_free_enumeration(names, nfound);
|
lnet_ipif_free_enumeration(names, nfound);
|
||||||
out1:
|
out1:
|
||||||
LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
|
LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
|
||||||
out0:
|
out0:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_ipif_enumerate);
|
EXPORT_SYMBOL(lnet_ipif_enumerate);
|
||||||
|
|
||||||
void
|
void
|
||||||
libcfs_ipif_free_enumeration (char **names, int n)
|
lnet_ipif_free_enumeration (char **names, int n)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -248,10 +244,10 @@ libcfs_ipif_free_enumeration (char **names, int n)
|
||||||
LIBCFS_FREE(names, n * sizeof(*names));
|
LIBCFS_FREE(names, n * sizeof(*names));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_ipif_free_enumeration);
|
EXPORT_SYMBOL(lnet_ipif_free_enumeration);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
|
lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
long ticks = timeout * HZ;
|
long ticks = timeout * HZ;
|
||||||
|
@ -310,10 +306,10 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(libcfs_sock_write);
|
EXPORT_SYMBOL(lnet_sock_write);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
|
lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
long ticks = timeout * HZ;
|
long ticks = timeout * HZ;
|
||||||
|
@ -366,10 +362,10 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_sock_read);
|
EXPORT_SYMBOL(lnet_sock_read);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libcfs_sock_create (struct socket **sockp, int *fatal,
|
lnet_sock_create (struct socket **sockp, int *fatal,
|
||||||
__u32 local_ip, int local_port)
|
__u32 local_ip, int local_port)
|
||||||
{
|
{
|
||||||
struct sockaddr_in locaddr;
|
struct sockaddr_in locaddr;
|
||||||
|
@ -424,7 +420,7 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
|
lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
|
||||||
{
|
{
|
||||||
int option;
|
int option;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -454,10 +450,10 @@ libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_sock_setbuf);
|
EXPORT_SYMBOL(lnet_sock_setbuf);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
|
lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port)
|
||||||
{
|
{
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
int len = sizeof (sin);
|
int len = sizeof (sin);
|
||||||
|
@ -480,10 +476,10 @@ libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_sock_getaddr);
|
EXPORT_SYMBOL(lnet_sock_getaddr);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
|
lnet_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (txbufsize != NULL) {
|
if (txbufsize != NULL) {
|
||||||
|
@ -497,16 +493,16 @@ libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_sock_getbuf);
|
EXPORT_SYMBOL(lnet_sock_getbuf);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_listen (struct socket **sockp,
|
lnet_sock_listen (struct socket **sockp,
|
||||||
__u32 local_ip, int local_port, int backlog)
|
__u32 local_ip, int local_port, int backlog)
|
||||||
{
|
{
|
||||||
int fatal;
|
int fatal;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port);
|
rc = lnet_sock_create(sockp, &fatal, local_ip, local_port);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
if (!fatal)
|
if (!fatal)
|
||||||
CERROR("Can't create socket: port %d already in use\n",
|
CERROR("Can't create socket: port %d already in use\n",
|
||||||
|
@ -523,10 +519,10 @@ libcfs_sock_listen (struct socket **sockp,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_sock_listen);
|
EXPORT_SYMBOL(lnet_sock_listen);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
|
lnet_sock_accept (struct socket **newsockp, struct socket *sock)
|
||||||
{
|
{
|
||||||
wait_queue_t wait;
|
wait_queue_t wait;
|
||||||
struct socket *newsock;
|
struct socket *newsock;
|
||||||
|
@ -566,17 +562,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_sock_accept);
|
EXPORT_SYMBOL(lnet_sock_accept);
|
||||||
|
|
||||||
int
|
int
|
||||||
libcfs_sock_connect (struct socket **sockp, int *fatal,
|
lnet_sock_connect (struct socket **sockp, int *fatal,
|
||||||
__u32 local_ip, int local_port,
|
__u32 local_ip, int local_port,
|
||||||
__u32 peer_ip, int peer_port)
|
__u32 peer_ip, int peer_port)
|
||||||
{
|
{
|
||||||
struct sockaddr_in srvaddr;
|
struct sockaddr_in srvaddr;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = libcfs_sock_create(sockp, fatal, local_ip, local_port);
|
rc = lnet_sock_create(sockp, fatal, local_ip, local_port);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
@ -605,4 +601,4 @@ libcfs_sock_connect (struct socket **sockp, int *fatal,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(libcfs_sock_connect);
|
EXPORT_SYMBOL(lnet_sock_connect);
|
||||||
|
|
Loading…
Add table
Reference in a new issue