1
1

libfabric: update to 8528d35551a78b5241e615c0e6ac5a711f96a03c

Update to latest from libfabric Github master
ofiwg/libfabric@8528d35551
Этот коммит содержится в:
Jeff Squyres 2015-02-20 12:37:27 -08:00
родитель 15be948d79
Коммит 937bbbac34
59 изменённых файлов: 573 добавлений и 355 удалений

Просмотреть файл

@ -87,11 +87,12 @@ _sockets_files = \
if HAVE_SOCKETS_DL
pkglib_LTLIBRARIES += libsockets-fi.la
libsockets_fi_la_SOURCES = $(_sockets_files) $(common_srcs)
libsockets_fi_la_LIBADD = $(linkback)
libsockets_fi_la_LIBADD = $(linkback) $(sockets_shm_LIBS)
libsockets_fi_la_LDFLAGS = -module -avoid-version -shared -export-dynamic
libsockets_fi_la_DEPENDENCIES = $(linkback)
else !HAVE_SOCKETS_DL
src_libfabric_la_SOURCES += $(_sockets_files)
src_libfabric_la_LIBADD += $(sockets_shm_LIBS)
endif !HAVE_SOCKETS_DL
endif HAVE_SOCKETS
@ -312,6 +313,7 @@ real_man_pages = \
man/fi_av.3 \
man/fi_cm.3 \
man/fi_cntr.3 \
man/fi_control.3 \
man/fi_cq.3 \
man/fi_direct.7 \
man/fi_domain.3 \

Просмотреть файл

@ -1,7 +1,7 @@
This README is for userspace RDMA fabric library.
Version Libfabric v1.0.0rc1
Released on 2015-02-13
Version Libfabric v1.0.0rc3
Released on 2015-02-20
Building
========

Просмотреть файл

@ -70,6 +70,9 @@
/* assembler has .symver support */
#undef HAVE_SYMVER_SUPPORT
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

Просмотреть файл

@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT([libfabric], [1.0.0rc1], [ofiwg@lists.openfabrics.org])
AC_INIT([libfabric], [1.0.0rc3], [ofiwg@lists.openfabrics.org])
AC_CONFIG_SRCDIR([src/fabric.c])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)

Просмотреть файл

@ -1,5 +1,5 @@
Name: libfabric
Version: 1.0.0rc1
Version: 1.0.0rc3
Release: 1%{?dist}
Summary: User-space RDMA Fabric Interfaces
Group: System Environment/Libraries
@ -61,5 +61,5 @@ rm -rf %{buildroot}
%{_mandir}/man7/*
%changelog
* Mon Jan 19 2015 Maintainer Name <email@intel.com> 1.0.0
- TODO: Release manager fill this out for initial release
* Mon Feb 16 2015 Open Fabrics Interfaces Working Group <ofiwg@lists.openfabrics.org> 1.0.0
- Release 1.0.0rc2

Просмотреть файл

@ -61,5 +61,5 @@ rm -rf %{buildroot}
%{_mandir}/man7/*
%changelog
* Mon Jan 19 2015 Maintainer Name <email@intel.com> 1.0.0
- TODO: Release manager fill this out for initial release
* Mon Feb 16 2015 Open Fabrics Interfaces Working Group <ofiwg@lists.openfabrics.org> 1.0.0
- Release 1.0.0rc2

Просмотреть файл

@ -1,4 +1,4 @@
.TH fabric 7 "2014\-12\-15" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fabric 7 "2014\-12\-15" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
Fabric Interface Library

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_av 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_av 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_av - Address vector operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_cm 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_cm 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_cm - Connection management operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_cntr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_cntr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_cntr - Completion and event counter operations

Просмотреть файл

@ -0,0 +1,36 @@
.TH fi_control 3 "2015\-02\-16" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_control - Perform an operation on a fabric resource.
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <rdma/fabric.h>
int\ fi_control(struct\ fid\ *fid,\ int\ command,\ void\ *arg);
\f[]
.fi
.SH ARGUMENTS
.PP
\f[I]fid\f[] : Fabric resource
.PP
\f[I]command\f[] : Operation to perform
.PP
\f[I]arg\f[] : Optional argument to the command
.SH DESCRIPTION
.PP
The fi_control operation is used to perform one or more operations on a
fabric resource.
Conceptually, fi_control is similar to the POSIX fcntl routine.
The exact behavior of using fi_control depends on the fabric resource
being operated on, the specified command, and any provided arguments for
the command.
For specific details, see the fabric resource specific help pages noted
below.
.SH SEE ALSO
.PP
\f[C]fi_endpoint\f[](3), \f[C]fi_cm\f[](3), \f[C]fi_cntr\f[](3),
\f[C]fi_cq\f[](3), \f[C]fi_eq\f[](3),
.SH AUTHORS
OpenFabrics.

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_cq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_cq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_cq - Completion queue operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_direct 7 "2014\-11\-21" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_direct 7 "2014\-11\-21" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
Direct fabric provider access

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_domain 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_domain 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_domain - Open a fabric access domain

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_endpoint 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_endpoint 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_endpoint - Fabric endpoint operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_eq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_eq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_eq - Event queue operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_errno 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_errno 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_errno - fabric errors

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_fabric 3 "2015\-01\-24" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_fabric 3 "2015\-01\-24" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_fabric - Fabric domain operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_getinfo 3 "2015\-02\-11" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_getinfo 3 "2015\-02\-11" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_getinfo / fi_freeinfo - Obtain / free fabric interface information

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_mr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_mr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_mr - Memory region operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_msg 3 "2015\-02\-06" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_msg 3 "2015\-02\-06" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_msg - Message data transfer operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_poll 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_poll 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_poll - Polling and wait set operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_rma 3 "2015\-01\-28" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_rma 3 "2015\-01\-28" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_rma - Remote memory access operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_tagged 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_tagged 3 "2015\-02\-18" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_tagged - Tagged data transfer operations
@ -314,24 +314,6 @@ operations.
the user.
.PP
\f[I]-FI_EOTHER\f[] : Indicates that an unspecified error occurred.
.SH NOTES
.SS Ordering
.PP
The order in which tags are matched is only defined for a pair of
sending and receiving endpoints.
The ordering is defined by the underlying protocol.
If a specific protocol is not selected for an endpoint, the libfabric
implementation will choose a protocol that satisfies the following
requirement from the MPI-3.0 specification (page 41, lines 1-5):
.RS
.PP
If a sender sends two messages in succession to the same destination,
and both match the same receive, then this operation cannot receive the
second message if the first one is still pending.
If a receiver posts two receives in succession, and both match the same
message, then the second receive operation cannot be satisfied by this
message, if the first one is still pending.
.RE
.SH SEE ALSO
.PP
\f[C]fi_getinfo\f[](3), \f[C]fi_endpoint\f[](3), \f[C]fi_domain\f[](3),

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_trigger 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_trigger 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_trigger - Triggered operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_version 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.TH fi_version 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc3"
.SH NAME
.PP
fi_version - Version of the library interfaces

Просмотреть файл

@ -9,11 +9,31 @@ dnl $2: action if not configured successfully
dnl
AC_DEFUN([FI_SOCKETS_CONFIGURE],[
# Determine if we can support the sockets provider
sockets_happy=0
sockets_h_happy=0
sockets_shm_happy=0
AS_IF([test x"$enable_sockets" != x"no"],
[sockets_happy=1
AC_CHECK_HEADER([sys/socket.h], [], [sockets_happy=0])
[AC_CHECK_HEADER([sys/socket.h], [sockets_h_happy=1],
[sockets_h_happy=0])
# check if shm_open is already present
AC_CHECK_FUNC([shm_open],
[sockets_shm_happy=1],
[sockets_shm_happy=0])
# look for shm_open in librt if not already present
AS_IF([test $sockets_shm_happy -eq 0],
[FI_CHECK_PACKAGE([sockets_shm],
[sys/mman.h],
[rt],
[shm_open],
[],
[],
[],
[sockets_shm_happy=1],
[sockets_shm_happy=0])])
])
AS_IF([test $sockets_happy -eq 1], [$1], [$2])
AS_IF([test $sockets_h_happy -eq 1 && \
test $sockets_shm_happy -eq 1], [$1], [$2])
])

Просмотреть файл

@ -715,7 +715,8 @@ struct sock_cq {
struct sock_conn_hdr {
uint8_t type;
uint8_t reserved[7];
uint8_t reserved[3];
int32_t s_port;
fid_t c_fid;
fid_t s_fid;
};

Просмотреть файл

@ -488,6 +488,9 @@ static int sock_ep_atomic_valid(struct fid_ep *ep, enum fi_datatype datatype,
}
datatype_sz = fi_datatype_size(datatype);
if (datatype_sz == 0)
return -FI_ENOENT;
*count = (SOCK_EP_MAX_ATOMIC_SZ/datatype_sz);
return 0;
}

Просмотреть файл

@ -513,6 +513,7 @@ static int sock_verify_av_attr(struct fi_av_attr *attr)
int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
struct fid_av **av, void *context)
{
int ret = 0;
struct sock_domain *dom;
struct sock_av *_av;
size_t table_sz, i;
@ -531,8 +532,8 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
_av->key = calloc(_av->attr.count, sizeof(uint16_t));
if (!_av->key) {
free(_av);
return -FI_ENOMEM;
ret = -FI_ENOMEM;
goto err;
}
table_sz = sizeof(struct sock_av_table_hdr) +
@ -540,9 +541,10 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
if (attr->name) {
_av->name = calloc(1, FI_NAME_MAX);
if(!_av->name)
return -FI_ENOMEM;
if(!_av->name) {
ret = -FI_ENOMEM;
goto err;
}
strcpy(_av->name, attr->name);
if (!(attr->flags & FI_READ))
flags |= O_CREAT;
@ -557,22 +559,24 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
_av->shared_fd = shm_open(_av->name, flags, S_IRUSR | S_IWUSR);
if (_av->shared_fd < 0) {
SOCK_LOG_ERROR("shm_open failed\n");
free(_av);
return -FI_EINVAL;
ret = -FI_EINVAL;
goto err;
}
if (ftruncate(_av->shared_fd, table_sz) == -1) {
SOCK_LOG_ERROR("ftruncate failed\n");
shm_unlink(_av->name);
free(_av);
return -FI_EINVAL;
ret = -FI_EINVAL;
goto err;
}
_av->table_hdr = mmap(NULL, table_sz, PROT_READ | PROT_WRITE,
MAP_SHARED, _av->shared_fd, 0);
if (attr->flags & FI_READ) {
if (_av->table_hdr->size != _av->attr.count)
return -FI_EINVAL;
if (_av->table_hdr->size != _av->attr.count) {
ret = -FI_EINVAL;
goto err;
}
} else {
_av->table_hdr->size = _av->attr.count;
_av->table_hdr->stored = 0;
@ -581,13 +585,15 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
if (_av->table_hdr == MAP_FAILED) {
SOCK_LOG_ERROR("mmap failed\n");
shm_unlink(_av->name);
free(_av);
return -FI_EINVAL;
ret = -FI_EINVAL;
goto err;
}
} else {
_av->table_hdr = calloc(1, table_sz);
if (!_av->table_hdr)
return -FI_ENOMEM;
if (!_av->table_hdr) {
ret = -FI_ENOMEM;
goto err;
}
_av->table_hdr->size = _av->attr.count;
_av->table_hdr->req_sz = attr->count;
}
@ -606,6 +612,7 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
_av->av_fid.ops = &sock_at_ops;
break;
default:
ret = -FI_EINVAL;
goto err;
}
@ -618,6 +625,7 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
break;
default:
SOCK_LOG_ERROR("Invalid address format: only IPv4 supported\n");
ret = -FI_EINVAL;
goto err;
}
_av->rx_ctx_bits = attr->rx_ctx_bits;
@ -627,5 +635,5 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
return 0;
err:
free(_av);
return -EINVAL;
return ret;
}

Просмотреть файл

@ -315,6 +315,9 @@ int sock_cntr_open(struct fid_domain *domain, struct fi_cntr_attr *attr,
break;
case FI_WAIT_SET:
if (!attr)
return -FI_EINVAL;
_cntr->waitset = attr->wait_set;
_cntr->signal = 1;
wait = container_of(attr->wait_set, struct sock_wait, wait_fid);

Просмотреть файл

@ -208,25 +208,29 @@ int sock_comm_buffer_init(struct sock_conn *conn)
socklen_t optlen = sizeof(socklen_t);
optval = 1;
setsockopt(conn->sock_fd, IPPROTO_TCP, TCP_NODELAY,
&optval, sizeof optval);
if (setsockopt(conn->sock_fd, IPPROTO_TCP, TCP_NODELAY,
&optval, sizeof optval))
SOCK_LOG_ERROR("setsockopt failed\n");
flags = fcntl(conn->sock_fd, F_GETFL, 0);
fcntl(conn->sock_fd, F_SETFL, flags | O_NONBLOCK);
if (fcntl(conn->sock_fd, F_SETFL, flags | O_NONBLOCK))
SOCK_LOG_ERROR("fcntl failed\n");
rbinit(&conn->inbuf, SOCK_COMM_BUF_SZ);
rbinit(&conn->outbuf, SOCK_COMM_BUF_SZ);
setsockopt(conn->sock_fd, SOL_SOCKET, SO_RCVBUF, &size, optlen);
setsockopt(conn->sock_fd, SOL_SOCKET, SO_SNDBUF, &size, optlen);
if (setsockopt(conn->sock_fd, SOL_SOCKET, SO_RCVBUF, &size, optlen))
SOCK_LOG_ERROR("setsockopt failed\n");
getsockopt(conn->sock_fd, SOL_SOCKET, SO_RCVBUF, &size, &optlen);
SOCK_LOG_INFO("SO_RCVBUF: %d\n", size);
if (setsockopt(conn->sock_fd, SOL_SOCKET, SO_SNDBUF, &size, optlen))
SOCK_LOG_ERROR("setsockopt failed\n");
if (!getsockopt(conn->sock_fd, SOL_SOCKET, SO_RCVBUF, &size, &optlen))
SOCK_LOG_INFO("SO_RCVBUF: %d\n", size);
optlen = sizeof(socklen_t);
getsockopt(conn->sock_fd, SOL_SOCKET, SO_SNDBUF, &size, &optlen);
SOCK_LOG_INFO("SO_SNDBUF: %d\n", size);
if (!getsockopt(conn->sock_fd, SOL_SOCKET, SO_SNDBUF, &size, &optlen))
SOCK_LOG_INFO("SO_SNDBUF: %d\n", size);
return 0;
}

Просмотреть файл

@ -164,14 +164,16 @@ uint16_t sock_conn_map_connect(struct sock_domain *dom,
}
optval = 1;
setsockopt(conn_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval);
if (setsockopt(conn_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval))
SOCK_LOG_ERROR("setsockopt failed\n");
memcpy(sa_ip, inet_ntoa(addr->sin_addr), INET_ADDRSTRLEN);
SOCK_LOG_INFO("Connecting to: %s:%d\n",
sa_ip, ntohs(((struct sockaddr_in*)addr)->sin_port));
flags = fcntl(conn_fd, F_GETFL, 0);
fcntl(conn_fd, F_SETFL, flags | O_NONBLOCK);
if (fcntl(conn_fd, F_SETFL, flags | O_NONBLOCK))
SOCK_LOG_ERROR("fcntl failed\n");
fastlock_acquire(&map->lock);
memcpy(&map->curr_addr, addr, sizeof(struct sockaddr_in));
@ -191,40 +193,43 @@ uint16_t sock_conn_map_connect(struct sock_domain *dom,
if (optval) {
SOCK_LOG_ERROR("failed to connect %d - %s\n", optval,
strerror(optval));
close(conn_fd);
return 0;
ret = 0;
goto err;
}
} else {
SOCK_LOG_ERROR("Timeout or error to connect %d - %s\n", optval,
strerror(optval));
close(conn_fd);
return 0;
ret = 0;
goto err;
}
} else {
SOCK_LOG_ERROR("Error connecting %d - %s\n", errno,
strerror(errno));
close(conn_fd);
return 0;
ret = 0;
goto err;
}
}
flags = fcntl(conn_fd, F_GETFL, 0);
flags &= (~O_NONBLOCK);
fcntl(conn_fd, F_SETFL, flags);
if (fcntl(conn_fd, F_SETFL, flags))
SOCK_LOG_ERROR("fcntl failed\n");
ret = send(conn_fd,
&((struct sockaddr_in*)&dom->src_addr)->sin_port,
sizeof(unsigned short), 0);
if (ret != sizeof(unsigned short)) {
SOCK_LOG_ERROR("Cannot exchange port\n");
return 0;
ret = 0;
goto err;
}
ret = recv(conn_fd,
&reply, sizeof(unsigned short), 0);
if (ret != sizeof(unsigned short)) {
SOCK_LOG_ERROR("Cannot exchange port: %d\n", ret);
return 0;
ret = 0;
goto err;
}
reply = ntohs(reply);
@ -248,6 +253,10 @@ uint16_t sock_conn_map_connect(struct sock_domain *dom,
}
return ret;
err:
close(conn_fd);
return ret;
}
uint16_t sock_conn_map_match_or_connect(struct sock_domain *dom,
@ -270,13 +279,13 @@ static void *_sock_conn_listen(void *arg)
struct sock_conn_map *map = &domain->r_cmap;
struct addrinfo *s_res = NULL, *p;
struct addrinfo hints;
int optval, flags, tmp;
int optval, flags;
int listen_fd = 0, conn_fd, ret;
struct sockaddr_in remote;
socklen_t addr_size;
struct pollfd poll_fds[2];
struct sockaddr_in addr;
char sa_ip[INET_ADDRSTRLEN];
char sa_ip[INET_ADDRSTRLEN], tmp;
unsigned short port, response;
uint16_t index;
@ -297,11 +306,13 @@ static void *_sock_conn_listen(void *arg)
listen_fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
if (listen_fd >= 0) {
flags = fcntl(listen_fd, F_GETFL, 0);
fcntl(listen_fd, F_SETFL, flags | O_NONBLOCK);
if (fcntl(listen_fd, F_SETFL, flags | O_NONBLOCK))
SOCK_LOG_ERROR("fcntl failed\n");
optval = 1;
setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval);
if (setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval))
SOCK_LOG_ERROR("setsockopt failed\n");
if (!bind(listen_fd, s_res->ai_addr, s_res->ai_addrlen))
break;
@ -340,7 +351,11 @@ static void *_sock_conn_listen(void *arg)
while(domain->listening) {
if (poll(poll_fds, 2, -1) > 0) {
if (poll_fds[1].revents & POLLIN) {
read(domain->signal_fds[1], &tmp, 1);
ret = read(domain->signal_fds[1], &tmp, 1);
if (ret != 1) {
SOCK_LOG_ERROR("Invalid signal\n");
goto err;
}
continue;
}
} else
@ -355,7 +370,11 @@ static void *_sock_conn_listen(void *arg)
}
addr_size = sizeof(struct sockaddr_in);
getpeername(conn_fd, (struct sockaddr *) &remote, &addr_size);
if (getpeername(conn_fd, (struct sockaddr *) &remote, &addr_size)) {
SOCK_LOG_ERROR("Failed to do getpeername\n");
goto err;
}
memcpy(sa_ip, inet_ntoa(remote.sin_addr), INET_ADDRSTRLEN);
SOCK_LOG_INFO("ACCEPT: %s, %d\n", sa_ip, ntohs(remote.sin_port));
@ -400,7 +419,8 @@ static void *_sock_conn_listen(void *arg)
return NULL;
err:
close(listen_fd);
if (listen_fd > 0)
close(listen_fd);
perror("listening thread failed");
return NULL;
}

Просмотреть файл

@ -556,6 +556,9 @@ int sock_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
break;
case FI_WAIT_SET:
if (!attr)
return -FI_EINVAL;
sock_cq->waitset = attr->wait_set;
sock_cq->signal = 1;
wait = container_of(attr->wait_set, struct sock_wait, wait_fid);

Просмотреть файл

@ -118,7 +118,8 @@ static int sock_dom_close(struct fid *fid)
{
struct sock_domain *dom;
void *res;
int c;
int ret;
char c = 0;
dom = container_of(fid, struct sock_domain, dom_fid.fid);
if (atomic_get(&dom->ref)) {
@ -126,7 +127,12 @@ static int sock_dom_close(struct fid *fid)
}
dom->listening = 0;
write(dom->signal_fds[0], &c, 1);
ret = write(dom->signal_fds[0], &c, 1);
if (ret != 1) {
SOCK_LOG_ERROR("Failed to signal\n");
return -FI_EINVAL;
}
if (pthread_join(dom->listen_thread, &res)) {
SOCK_LOG_ERROR("could not join listener thread, errno = %d\n", errno);
return -FI_EBUSY;
@ -462,7 +468,9 @@ int sock_domain(struct fid_fabric *fabric, struct fi_info *info,
goto err;
flags = fcntl(sock_domain->signal_fds[1], F_GETFL, 0);
fcntl(sock_domain->signal_fds[1], F_SETFL, flags | O_NONBLOCK);
if (fcntl(sock_domain->signal_fds[1], F_SETFL, flags | O_NONBLOCK))
SOCK_LOG_ERROR("fcntl failed\n");
sock_conn_listen(sock_domain);
while(!(volatile int)sock_domain->listening)

Просмотреть файл

@ -1252,7 +1252,9 @@ int sock_alloc_endpoint(struct fid_domain *domain, struct fi_info *info,
/* default config */
sock_ep->min_multi_recv = SOCK_EP_MIN_MULTI_RECV;
memcpy(&sock_ep->info, info, sizeof(struct fi_info));
if (info) {
memcpy(&sock_ep->info, info, sizeof(struct fi_info));
}
sock_ep->domain = sock_dom;
atomic_inc(&sock_dom->ref);
return 0;

Просмотреть файл

@ -213,11 +213,11 @@ int sock_dgram_getinfo(uint32_t version, const char *node, const char *service,
uint64_t flags, struct fi_info *hints, struct fi_info **info)
{
int ret;
int udp_sock;
int udp_sock = 0;
socklen_t len;
struct fi_info *_info;
struct addrinfo sock_hints;
struct addrinfo *result = NULL;
struct addrinfo *result = NULL, *result_ptr = NULL;
struct sockaddr_in *src_addr = NULL, *dest_addr = NULL;
char sa_ip[INET_ADDRSTRLEN];
char hostname[HOST_NAME_MAX];
@ -264,13 +264,14 @@ int sock_dgram_getinfo(uint32_t version, const char *node, const char *service,
}
ret = getaddrinfo(node ? node : hostname, service,
&sock_hints, &result);
&sock_hints, &result_ptr);
if (ret != 0) {
ret = FI_ENODATA;
SOCK_LOG_INFO("getaddrinfo failed!\n");
goto err;
}
result = result_ptr;
while (result) {
if (result->ai_family == AF_INET &&
result->ai_addrlen == sizeof(struct sockaddr_in))
@ -290,16 +291,18 @@ int sock_dgram_getinfo(uint32_t version, const char *node, const char *service,
goto err;
}
memcpy(src_addr, result->ai_addr, result->ai_addrlen);
freeaddrinfo(result);
} else if (node || service) {
freeaddrinfo(result_ptr);
result_ptr = NULL;
} else {
ret = getaddrinfo(node, service, &sock_hints, &result);
ret = getaddrinfo(node, service, &sock_hints, &result_ptr);
if (ret != 0) {
ret = FI_ENODATA;
SOCK_LOG_INFO("getaddrinfo failed!\n");
goto err;
}
result = result_ptr;
while (result) {
if (result->ai_family == AF_INET &&
result->ai_addrlen == sizeof(struct sockaddr_in))
@ -321,6 +324,11 @@ int sock_dgram_getinfo(uint32_t version, const char *node, const char *service,
memcpy(dest_addr, result->ai_addr, result->ai_addrlen);
udp_sock = socket(AF_INET, SOCK_DGRAM, 0);
if (udp_sock < 0) {
ret = -FI_ENOMEM;
goto err;
}
ret = connect(udp_sock, result->ai_addr,
result->ai_addrlen);
if ( ret != 0) {
@ -338,15 +346,16 @@ int sock_dgram_getinfo(uint32_t version, const char *node, const char *service,
ret = getsockname(udp_sock, (struct sockaddr*)src_addr, &len);
if (ret != 0) {
SOCK_LOG_ERROR("getsockname failed\n");
close(udp_sock);
ret = FI_ENODATA;
goto err;
}
close(udp_sock);
freeaddrinfo(result);
udp_sock = 0;
freeaddrinfo(result_ptr);
result_ptr = NULL;
}
if (hints->src_addr) {
if (hints && hints->src_addr) {
if (!src_addr) {
src_addr = calloc(1, sizeof(struct sockaddr_in));
if (!src_addr) {
@ -358,7 +367,7 @@ int sock_dgram_getinfo(uint32_t version, const char *node, const char *service,
memcpy(src_addr, hints->src_addr, hints->src_addrlen);
}
if (hints->dest_addr) {
if (hints && hints->dest_addr) {
if (!dest_addr) {
dest_addr = calloc(1, sizeof(struct sockaddr_in));
if (!dest_addr) {
@ -396,10 +405,15 @@ int sock_dgram_getinfo(uint32_t version, const char *node, const char *service,
return 0;
err:
if (udp_sock > 0)
close(udp_sock);
if (src_addr)
free(src_addr);
if (dest_addr)
free(dest_addr);
if (result_ptr)
freeaddrinfo(result_ptr);
SOCK_LOG_ERROR("fi_getinfo failed\n");
return ret;
}

Просмотреть файл

@ -214,11 +214,11 @@ int sock_msg_getinfo(uint32_t version, const char *node, const char *service,
uint64_t flags, struct fi_info *hints, struct fi_info **info)
{
int ret;
int udp_sock;
int udp_sock = 0;
socklen_t len;
struct fi_info *_info;
struct addrinfo sock_hints;
struct addrinfo *result = NULL;
struct addrinfo *result = NULL, *result_ptr = NULL;
struct sockaddr_in *src_addr = NULL, *dest_addr = NULL;
char sa_ip[INET_ADDRSTRLEN];
char hostname[HOST_NAME_MAX];
@ -265,13 +265,14 @@ int sock_msg_getinfo(uint32_t version, const char *node, const char *service,
}
ret = getaddrinfo(node ? node : hostname, service,
&sock_hints, &result);
&sock_hints, &result_ptr);
if (ret != 0) {
ret = FI_ENODATA;
SOCK_LOG_INFO("getaddrinfo failed!\n");
goto err;
}
result = result_ptr;
while (result) {
if (result->ai_family == AF_INET &&
result->ai_addrlen == sizeof(struct sockaddr_in))
@ -291,16 +292,18 @@ int sock_msg_getinfo(uint32_t version, const char *node, const char *service,
goto err;
}
memcpy(src_addr, result->ai_addr, result->ai_addrlen);
freeaddrinfo(result);
} else if (node || service) {
freeaddrinfo(result_ptr);
result_ptr = NULL;
} else {
ret = getaddrinfo(node, service, &sock_hints, &result);
ret = getaddrinfo(node, service, &sock_hints, &result_ptr);
if (ret != 0) {
ret = FI_ENODATA;
SOCK_LOG_INFO("getaddrinfo failed!\n");
goto err;
}
result = result_ptr;
while (result) {
if (result->ai_family == AF_INET &&
result->ai_addrlen == sizeof(struct sockaddr_in))
@ -322,6 +325,11 @@ int sock_msg_getinfo(uint32_t version, const char *node, const char *service,
memcpy(dest_addr, result->ai_addr, result->ai_addrlen);
udp_sock = socket(AF_INET, SOCK_DGRAM, 0);
if (udp_sock < 0) {
ret = -FI_ENOMEM;
goto err;
}
ret = connect(udp_sock, result->ai_addr,
result->ai_addrlen);
if ( ret != 0) {
@ -339,20 +347,28 @@ int sock_msg_getinfo(uint32_t version, const char *node, const char *service,
ret = getsockname(udp_sock, (struct sockaddr*)src_addr, &len);
if (ret != 0) {
SOCK_LOG_ERROR("getsockname failed\n");
close(udp_sock);
ret = FI_ENODATA;
goto err;
}
close(udp_sock);
freeaddrinfo(result);
udp_sock = 0;
freeaddrinfo(result_ptr);
result_ptr = NULL;
}
if (hints->src_addr) {
if (hints && hints->src_addr) {
if (!src_addr) {
src_addr = calloc(1, sizeof(struct sockaddr_in));
if (!src_addr) {
ret = -FI_ENOMEM;
goto err;
}
}
assert(hints->src_addrlen == sizeof(struct sockaddr_in));
memcpy(src_addr, hints->src_addr, hints->src_addrlen);
}
if (hints->dest_addr) {
if (hints && hints->dest_addr) {
if (!dest_addr) {
dest_addr = calloc(1, sizeof(struct sockaddr_in));
if (!dest_addr) {
@ -365,26 +381,12 @@ int sock_msg_getinfo(uint32_t version, const char *node, const char *service,
}
if (dest_addr) {
if (!dest_addr) {
dest_addr = calloc(1, sizeof(struct sockaddr_in));
if (!dest_addr) {
ret = -FI_ENOMEM;
goto err;
}
}
memcpy(sa_ip, inet_ntoa(dest_addr->sin_addr), INET_ADDRSTRLEN);
SOCK_LOG_INFO("dest_addr: family: %d, IP is %s\n",
((struct sockaddr_in*)dest_addr)->sin_family, sa_ip);
}
if (src_addr) {
if (!src_addr) {
src_addr = calloc(1, sizeof(struct sockaddr_in));
if (!src_addr) {
ret = -FI_ENOMEM;
goto err;
}
}
memcpy(sa_ip, inet_ntoa(src_addr->sin_addr), INET_ADDRSTRLEN);
SOCK_LOG_INFO("src_addr: family: %d, IP is %s\n",
((struct sockaddr_in*)src_addr)->sin_family, sa_ip);
@ -404,25 +406,47 @@ int sock_msg_getinfo(uint32_t version, const char *node, const char *service,
return 0;
err:
if (udp_sock > 0)
close(udp_sock);
if (src_addr)
free(src_addr);
if (dest_addr)
free(dest_addr);
if (result_ptr)
freeaddrinfo(result_ptr);
SOCK_LOG_ERROR("fi_getinfo failed\n");
return ret;
}
static int sock_ep_cm_getname(fid_t fid, void *addr, size_t *addrlen)
{
struct sock_ep *sock_ep;
struct sock_ep *sock_ep = NULL;
struct sock_pep *sock_pep = NULL;
if (*addrlen == 0) {
*addrlen = sizeof(struct sockaddr_in);
return -FI_ETOOSMALL;
}
sock_ep = container_of(fid, struct sock_ep, ep.fid);
*addrlen = MIN(*addrlen, sizeof(struct sockaddr_in));
memcpy(addr, sock_ep->src_addr, *addrlen);
switch(fid->fclass) {
case FI_CLASS_EP:
sock_ep = container_of(fid, struct sock_ep, ep.fid);
memcpy(addr, sock_ep->src_addr, *addrlen);
break;
case FI_CLASS_PEP:
sock_pep = container_of(fid, struct sock_pep, pep.fid);
memcpy(addr, &sock_pep->src_addr, *addrlen);
break;
default:
SOCK_LOG_ERROR("Invalid argument\n");
return -FI_EINVAL;
}
return 0;
}
@ -449,8 +473,9 @@ static int sock_ep_cm_create_socket()
return 0;
optval = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
&optval, sizeof optval);
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
&optval, sizeof optval))
SOCK_LOG_ERROR("setsockopt failed\n");
return sock;
}
@ -459,7 +484,7 @@ static int sock_ep_cm_send_msg(int sock_fd,
const struct sockaddr_in *addr, void *msg, size_t len)
{
int ret, retry = 0;
unsigned char response;
unsigned char response = 0;
struct sockaddr_in from_addr;
socklen_t addr_len;
char sa_ip[INET_ADDRSTRLEN] = {0};
@ -516,19 +541,25 @@ static int sock_ep_cm_send_ack(int sock_fd, struct sockaddr_in *addr)
static void *sock_msg_ep_listener_thread (void *data)
{
struct sock_ep *ep = (struct sock_ep *)data;
struct sock_conn_response *conn_response = NULL;
struct fi_eq_cm_entry cm_entry;
struct sock_ep *ep = data;
struct sock_conn_response *conn_response;
struct fi_eq_cm_entry *cm_entry;
struct fi_eq_err_entry cm_err_entry;
struct sockaddr_in from_addr;
socklen_t addr_len;
int ret, user_data_sz;
int ret, user_data_sz, entry_sz;
struct fid_ep *fid_ep;
struct sock_ep *sock_ep;
SOCK_LOG_INFO("Starting listener thread for EP: %p\n", ep);
conn_response = malloc(sizeof(*conn_response) + SOCK_EP_MAX_CM_DATA_SZ);
cm_entry = malloc(sizeof(*cm_entry) + SOCK_EP_MAX_CM_DATA_SZ);
if (!conn_response || !cm_entry) {
SOCK_LOG_ERROR("cannot allocate\n");
return NULL;
}
ep->do_listen = 1;
while((volatile int)ep->do_listen) {
@ -536,16 +567,6 @@ static void *sock_msg_ep_listener_thread (void *data)
if (ret <= 0)
continue;
if (conn_response == NULL) {
conn_response = (struct sock_conn_response*)
calloc(1, sizeof(*conn_response) +
SOCK_EP_MAX_CM_DATA_SZ);
if (!conn_response) {
SOCK_LOG_ERROR("cannot allocate\n");
return NULL;
}
}
addr_len = sizeof(struct sockaddr_in);
ret = recvfrom(ep->socket, (char*)conn_response,
sizeof(*conn_response) + SOCK_EP_MAX_CM_DATA_SZ,
@ -559,56 +580,44 @@ static void *sock_msg_ep_listener_thread (void *data)
!sock_ep_cm_send_ack(ep->socket, &from_addr))
continue;
user_data_sz = 0;
user_data_sz = ret - sizeof(*conn_response);
switch (conn_response->hdr.type) {
case SOCK_CONN_ACCEPT:
SOCK_LOG_INFO("Received SOCK_CONN_ACCEPT\n");
memset(&cm_entry, 0, sizeof(cm_entry));
cm_entry.fid = conn_response->hdr.c_fid;
entry_sz = sizeof(*cm_entry) + user_data_sz;
memset(cm_entry, 0, sizeof *cm_entry);
cm_entry->fid = conn_response->hdr.c_fid;
if (ret > sizeof(struct sock_conn_response)) {
user_data_sz = ret -
sizeof(struct sock_conn_response);
memcpy(&cm_entry.data,
(char *)conn_response +
sizeof(struct sock_conn_response),
user_data_sz);
}
memcpy(&cm_entry->data, &conn_response->user_data,
user_data_sz);
fid_ep = container_of(conn_response->hdr.c_fid,
struct fid_ep, fid);
sock_ep = container_of(fid_ep, struct sock_ep, ep);
sock_ep->connected = 1;
((struct sockaddr_in*)sock_ep->dest_addr)->sin_port =
conn_response->hdr.s_port;
sock_ep_enable(&ep->ep);
if (sock_eq_report_event(ep->eq, FI_CONNECTED, &cm_entry,
sizeof(cm_entry) + user_data_sz, 0))
if (sock_eq_report_event(ep->eq, FI_CONNECTED, cm_entry,
entry_sz, 0))
SOCK_LOG_ERROR("Error in writing to EQ\n");
break;
case SOCK_CONN_REJECT:
SOCK_LOG_INFO("Received SOCK_CONN_REJECT\n");
memset(&cm_err_entry, 0, sizeof(cm_err_entry));
memset(&cm_err_entry, 0, sizeof cm_err_entry);
cm_err_entry.fid = conn_response->hdr.c_fid;
cm_err_entry.context = NULL;
cm_err_entry.data = 0;
cm_err_entry.err = -FI_ECONNREFUSED;
cm_err_entry.prov_errno = 0;
cm_err_entry.err_data = NULL;
if (ret > sizeof(struct sock_conn_response)) {
user_data_sz = ret -
sizeof(struct sock_conn_response);
memcpy(&cm_entry.data,
(char *)conn_response +
sizeof(struct sock_conn_response),
user_data_sz);
}
/* TODO: Fix reporting err_data */
//cm_err_entry->err_data = &conn_response->user_data;
if (sock_eq_report_event(ep->eq, FI_ECONNREFUSED,
&cm_err_entry,
sizeof (cm_err_entry) +
user_data_sz, 0))
sizeof cm_err_entry, 0))
SOCK_LOG_ERROR("Error in writing to EQ\n");
goto out;
@ -616,12 +625,11 @@ static void *sock_msg_ep_listener_thread (void *data)
SOCK_LOG_ERROR("Invalid event\n");
break;
}
conn_response = NULL;
}
out:
if (conn_response)
free(conn_response);
free(conn_response);
free(cm_entry);
close(ep->socket);
ep->socket = 0;
return NULL;
@ -644,6 +652,9 @@ static int sock_ep_cm_connect(struct fid_ep *ep, const void *addr,
return -FI_ENOMEM;
_ep->rem_ep_id = ((struct sockaddr *)addr)->sa_family;
((struct sockaddr_in*)_ep->src_addr)->sin_port =
htons(atoi(_ep->domain->service));
((struct sockaddr *)addr)->sa_family = AF_INET;
req->hdr.type = SOCK_CONN_REQ;
@ -651,7 +662,7 @@ static int sock_ep_cm_connect(struct fid_ep *ep, const void *addr,
req->hdr.c_fid = &ep->fid;
req->hdr.s_fid = 0;
memcpy(&req->info, &_ep->info, sizeof(struct fi_info));
memcpy(&req->src_addr, _ep->info.src_addr, sizeof(struct sockaddr_in));
memcpy(&req->src_addr, _ep->src_addr, sizeof(struct sockaddr_in));
memcpy(&req->dest_addr, _ep->info.dest_addr, sizeof(struct sockaddr_in));
memcpy(&req->tx_attr, _ep->info.tx_attr, sizeof(struct fi_tx_attr));
memcpy(&req->rx_attr, _ep->info.rx_attr, sizeof(struct fi_rx_attr));
@ -717,6 +728,7 @@ static int sock_ep_cm_accept(struct fid_ep *ep, const void *param, size_t paraml
_ep->rem_ep_id = req->ep_id;
response->hdr.type = SOCK_CONN_ACCEPT;
response->hdr.s_fid = &ep->fid;
response->hdr.s_port = htons(atoi(_ep->domain->service));
_ep->socket = sock_ep_cm_create_socket();
if (!_ep->socket) {
@ -833,12 +845,16 @@ static int sock_pep_fi_bind(fid_t fid, struct fid *bfid, uint64_t flags)
static int sock_pep_fi_close(fid_t fid)
{
int c;
int ret;
char c = 0;
struct sock_pep *pep;
pep = container_of(fid, struct sock_pep, pep.fid);
pep->do_listen = 0;
write(pep->signal_fds[0], &c, 1);
ret = write(pep->signal_fds[0], &c, 1);
if (ret != 1)
SOCK_LOG_ERROR("Failed to signal\n");
pthread_join(pep->listener_thread, NULL);
free(pep);
return 0;
@ -878,14 +894,19 @@ static void *sock_pep_listener_thread (void *data)
{
struct sock_pep *pep = (struct sock_pep *)data;
struct sock_conn_req *conn_req = NULL;
struct fi_eq_cm_entry cm_entry;
struct fi_eq_cm_entry *cm_entry;
struct sockaddr_in from_addr;
struct pollfd poll_fds[2];
socklen_t addr_len;
int ret, user_data_sz, tmp;
int ret, user_data_sz, entry_sz, tmp;
SOCK_LOG_INFO("Starting listener thread for PEP: %p\n", pep);
cm_entry = malloc(sizeof(*cm_entry) + SOCK_EP_MAX_CM_DATA_SZ);
if (!cm_entry) {
SOCK_LOG_ERROR("cannot allocate\n");
return NULL;
}
poll_fds[0].fd = pep->socket;
poll_fds[1].fd = pep->signal_fds[1];
@ -896,19 +917,18 @@ static void *sock_pep_listener_thread (void *data)
read(pep->signal_fds[1], &tmp, 1);
continue;
}
} else
return NULL;
if (conn_req == NULL) {
conn_req = (struct sock_conn_req*)calloc(1,
sizeof(*conn_req) +
SOCK_EP_MAX_CM_DATA_SZ);
if (!conn_req) {
SOCK_LOG_ERROR("cannot allocate\n");
return NULL;
}
} else {
break;
}
if (conn_req == NULL) {
conn_req = malloc(sizeof(*conn_req) + SOCK_EP_MAX_CM_DATA_SZ);
if (!conn_req) {
SOCK_LOG_ERROR("cannot allocate\n");
break;
}
}
addr_len = sizeof(struct sockaddr_in);
ret = recvfrom(pep->socket, (char*)conn_req,
sizeof(*conn_req) + SOCK_EP_MAX_CM_DATA_SZ, 0,
@ -918,8 +938,10 @@ static void *sock_pep_listener_thread (void *data)
memcpy(&conn_req->from_addr, &from_addr, sizeof(struct sockaddr_in));
SOCK_LOG_INFO("Msg received: %d\n", ret);
memset(&cm_entry, 0, sizeof(cm_entry));
user_data_sz = 0;
user_data_sz = ret - sizeof(*conn_req);
entry_sz = sizeof(*cm_entry) + user_data_sz;
memset(cm_entry, 0, sizeof *cm_entry);
if (conn_req->hdr.type == SOCK_CONN_REQ) {
SOCK_LOG_INFO("Received SOCK_CONN_REQ\n");
@ -929,26 +951,24 @@ static void *sock_pep_listener_thread (void *data)
break;
}
cm_entry.info = sock_ep_msg_process_info(conn_req);
cm_entry.info->connreq = (fi_connreq_t)conn_req;
if (ret > sizeof(struct sock_conn_req)) {
user_data_sz = ret - sizeof(struct sock_conn_req);
memcpy(&cm_entry.data,
(char *)conn_req + sizeof(struct sock_conn_req),
user_data_sz);
}
cm_entry->info = sock_ep_msg_process_info(conn_req);
cm_entry->info->connreq = (fi_connreq_t) conn_req;
memcpy(&cm_entry->data, &conn_req->user_data,
user_data_sz);
conn_req = NULL;
if (sock_eq_report_event(pep->eq, FI_CONNREQ, &cm_entry,
sizeof(cm_entry) + user_data_sz, 0))
if (sock_eq_report_event(pep->eq, FI_CONNREQ, cm_entry,
entry_sz, 0))
SOCK_LOG_ERROR("Error in writing to EQ\n");
} else {
SOCK_LOG_ERROR("Invalid event\n");
}
conn_req = NULL;
}
if (conn_req)
free(conn_req);
free(cm_entry);
close(pep->socket);
pep->socket = 0;
return NULL;
@ -987,8 +1007,10 @@ static int sock_pep_create_listener_thread(struct sock_pep *pep)
p->ai_protocol);
if (pep->socket >= 0) {
optval = 1;
setsockopt(pep->socket, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval);
if (setsockopt(pep->socket, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval))
SOCK_LOG_ERROR("setsockopt failed\n");
if (!bind(pep->socket, s_res->ai_addr, s_res->ai_addrlen))
break;
close(pep->socket);
@ -1001,8 +1023,9 @@ static int sock_pep_create_listener_thread(struct sock_pep *pep)
return -FI_EIO;
optval = 1;
setsockopt(pep->socket, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval);
if (setsockopt(pep->socket, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval))
SOCK_LOG_ERROR("setsockopt failed\n");
if (pep->src_addr.sin_port == 0) {
addr_size = sizeof(addr);
@ -1084,7 +1107,7 @@ out:
static struct fi_ops_cm sock_pep_cm_ops = {
.size = sizeof(struct fi_ops_cm),
.getname = fi_no_getname,
.getname = sock_ep_cm_getname,
.getpeer = fi_no_getpeer,
.connect = fi_no_connect,
.listen = sock_pep_listen,
@ -1146,6 +1169,8 @@ int sock_msg_passive_ep(struct fid_fabric *fabric, struct fi_info *info,
goto err;
}
memcpy(&_pep->src_addr, result->ai_addr, result->ai_addrlen);
freeaddrinfo(result);
result = NULL;
}
_pep->info = *info;
} else {
@ -1157,7 +1182,8 @@ int sock_msg_passive_ep(struct fid_fabric *fabric, struct fi_info *info,
goto err;
flags = fcntl(_pep->signal_fds[1], F_GETFL, 0);
fcntl(_pep->signal_fds[1], F_SETFL, flags | O_NONBLOCK);
if (fcntl(_pep->signal_fds[1], F_SETFL, flags | O_NONBLOCK))
SOCK_LOG_ERROR("fcntl failed");
_pep->pep.fid.fclass = FI_CLASS_PEP;
_pep->pep.fid.context = context;
@ -1169,6 +1195,8 @@ int sock_msg_passive_ep(struct fid_fabric *fabric, struct fi_info *info,
*pep = &_pep->pep;
return 0;
err:
if (result)
freeaddrinfo(result);
free(_pep);
return ret;
}

Просмотреть файл

@ -215,11 +215,11 @@ int sock_rdm_getinfo(uint32_t version, const char *node, const char *service,
uint64_t flags, struct fi_info *hints, struct fi_info **info)
{
int ret;
int udp_sock;
int udp_sock = 0;
socklen_t len;
struct fi_info *_info;
struct addrinfo sock_hints;
struct addrinfo *result = NULL;
struct addrinfo *result = NULL, *result_ptr = NULL;
struct sockaddr_in *src_addr = NULL, *dest_addr = NULL;
char sa_ip[INET_ADDRSTRLEN];
char hostname[HOST_NAME_MAX];
@ -262,13 +262,14 @@ int sock_rdm_getinfo(uint32_t version, const char *node, const char *service,
}
ret = getaddrinfo(node ? node : hostname, service,
&sock_hints, &result);
&sock_hints, &result_ptr);
if (ret != 0) {
ret = FI_ENODATA;
SOCK_LOG_INFO("getaddrinfo failed!\n");
goto err;
}
result = result_ptr;
while (result) {
if (result->ai_family == AF_INET &&
result->ai_addrlen == sizeof(struct sockaddr_in))
@ -288,16 +289,18 @@ int sock_rdm_getinfo(uint32_t version, const char *node, const char *service,
goto err;
}
memcpy(src_addr, result->ai_addr, result->ai_addrlen);
freeaddrinfo(result);
} else if (node || service) {
freeaddrinfo(result_ptr);
result_ptr = NULL;
} else {
ret = getaddrinfo(node, service, &sock_hints, &result);
ret = getaddrinfo(node, service, &sock_hints, &result_ptr);
if (ret != 0) {
ret = FI_ENODATA;
SOCK_LOG_INFO("getaddrinfo failed!\n");
goto err;
}
result = result_ptr;
while (result) {
if (result->ai_family == AF_INET &&
result->ai_addrlen == sizeof(struct sockaddr_in))
@ -319,6 +322,11 @@ int sock_rdm_getinfo(uint32_t version, const char *node, const char *service,
memcpy(dest_addr, result->ai_addr, result->ai_addrlen);
udp_sock = socket(AF_INET, SOCK_DGRAM, 0);
if (udp_sock < 0) {
ret = -FI_ENOMEM;
goto err;
}
ret = connect(udp_sock, result->ai_addr,
result->ai_addrlen);
if ( ret != 0) {
@ -336,15 +344,16 @@ int sock_rdm_getinfo(uint32_t version, const char *node, const char *service,
ret = getsockname(udp_sock, (struct sockaddr*)src_addr, &len);
if (ret != 0) {
SOCK_LOG_ERROR("getsockname failed\n");
close(udp_sock);
ret = FI_ENODATA;
goto err;
}
close(udp_sock);
freeaddrinfo(result);
udp_sock = 0;
freeaddrinfo(result_ptr);
result_ptr = NULL;
}
if (hints->src_addr) {
if (hints && hints->src_addr) {
if (!src_addr) {
src_addr = calloc(1, sizeof(struct sockaddr_in));
if (!src_addr) {
@ -356,7 +365,7 @@ int sock_rdm_getinfo(uint32_t version, const char *node, const char *service,
memcpy(src_addr, hints->src_addr, hints->src_addrlen);
}
if (hints->dest_addr) {
if (hints && hints->dest_addr) {
if (!dest_addr) {
dest_addr = calloc(1, sizeof(struct sockaddr_in));
if (!dest_addr) {
@ -394,10 +403,15 @@ int sock_rdm_getinfo(uint32_t version, const char *node, const char *service,
return 0;
err:
if (udp_sock > 0)
close(udp_sock);
if (src_addr)
free(src_addr);
if (dest_addr)
free(dest_addr);
if (result_ptr)
freeaddrinfo(result_ptr);
SOCK_LOG_ERROR("fi_getinfo failed\n");
return ret;
}

Просмотреть файл

@ -329,8 +329,10 @@ int sock_eq_openwait(struct sock_eq *eq, const char *service)
p->ai_protocol);
if (eq->wait_fd >= 0) {
optval = 1;
setsockopt(eq->wait_fd, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval);
if (setsockopt(eq->wait_fd, SOL_SOCKET, SO_REUSEADDR, &optval,
sizeof optval))
SOCK_LOG_ERROR("setsockopt failed\n");
if (!bind(eq->wait_fd, s_res->ai_addr, s_res->ai_addrlen))
break;
close(eq->wait_fd);
@ -344,7 +346,9 @@ int sock_eq_openwait(struct sock_eq *eq, const char *service)
return -FI_EINVAL;
}
fcntl(eq->wait_fd, F_SETFL, O_NONBLOCK);
if (fcntl(eq->wait_fd, F_SETFL, O_NONBLOCK))
SOCK_LOG_ERROR("fcntl failed");
memcpy(&eq->service, service, NI_MAXSERV);
SOCK_LOG_INFO("open udp successfully\n");
@ -410,6 +414,9 @@ int sock_eq_open(struct fid_fabric *fabric, struct fi_eq_attr *attr,
break;
case FI_WAIT_SET:
if (!attr)
return -FI_EINVAL;
sock_eq->waitset = attr->wait_set;
sock_eq->signal = 1;
break;

Просмотреть файл

@ -127,7 +127,7 @@ static ssize_t sock_ep_recv(struct fid_ep *ep, void *buf, size_t len, void *desc
msg.iov_count = 1;
msg.addr = src_addr;
msg.context = context;
msg.data = 0;
return sock_ep_recvmsg(ep, &msg, 0);
}
@ -142,6 +142,7 @@ static ssize_t sock_ep_recvv(struct fid_ep *ep, const struct iovec *iov,
msg.iov_count = count;
msg.addr = src_addr;
msg.context = context;
msg.data = 0;
return sock_ep_recvmsg(ep, &msg, 0);
}
@ -392,7 +393,7 @@ static ssize_t sock_ep_trecv(struct fid_ep *ep, void *buf, size_t len, void *des
msg.context = context;
msg.tag = tag;
msg.ignore = ignore;
msg.data = 0;
return sock_ep_trecvmsg(ep, &msg, 0);
}
@ -409,6 +410,7 @@ static ssize_t sock_ep_trecvv(struct fid_ep *ep, const struct iovec *iov,
msg.context = context;
msg.tag = tag;
msg.ignore = ignore;
msg.data = 0;
return sock_ep_trecvmsg(ep, &msg, 0);
}
@ -448,14 +450,19 @@ static ssize_t sock_ep_tsendmsg(struct fid_ep *ep,
if (!conn)
return -FI_EAGAIN;
memset(&tx_op, 0, sizeof(struct sock_op));
tx_op.op = SOCK_OP_TSEND;
total_len = 0;
if (SOCK_INJECT_OK(flags)) {
for (i=0; i< msg->iov_count; i++) {
total_len += msg->msg_iov[i].iov_len;
}
tx_op.src_iov_len = total_len;
assert(total_len <= SOCK_EP_MAX_INJECT_SZ);
} else {
total_len = msg->iov_count * sizeof(union sock_iov);
tx_op.src_iov_len = msg->iov_count;
}
total_len += sizeof(struct sock_op_tsend);
@ -469,10 +476,6 @@ static ssize_t sock_ep_tsendmsg(struct fid_ep *ep,
}
flags |= tx_ctx->attr.op_flags;
memset(&tx_op, 0, sizeof(struct sock_op));
tx_op.op = SOCK_OP_TSEND;
tx_op.src_iov_len = msg->iov_count;
sock_tx_ctx_write(tx_ctx, &tx_op, sizeof(struct sock_op));
sock_tx_ctx_write(tx_ctx, &flags, sizeof(uint64_t));
sock_tx_ctx_write(tx_ctx, &msg->context, sizeof(uint64_t));

Просмотреть файл

@ -1409,7 +1409,6 @@ static int sock_pe_peek_hdr(struct sock_pe *pe,
return -1;
msg_hdr->msg_len = ntohll(msg_hdr->msg_len);
msg_hdr->rx_id = msg_hdr->rx_id;
msg_hdr->flags = ntohll(msg_hdr->flags);
msg_hdr->pe_entry_id = ntohs(msg_hdr->pe_entry_id);
msg_hdr->ep_id = ntohs(msg_hdr->ep_id);
@ -1462,8 +1461,11 @@ static int sock_pe_read_hdr(struct sock_pe *pe, struct sock_rx_ctx *rx_ctx,
}
}
sock_pe_recv_field(pe_entry, (void*)msg_hdr,
sizeof(struct sock_msg_hdr), 0);
if (sock_pe_recv_field(pe_entry, (void*)msg_hdr,
sizeof(struct sock_msg_hdr), 0)) {
SOCK_LOG_ERROR("Failed to recv header\n");
return -1;
}
msg_hdr->msg_len = ntohll(msg_hdr->msg_len);
msg_hdr->rx_id = msg_hdr->rx_id;
@ -2020,7 +2022,7 @@ static int sock_pe_new_tx_entry(struct sock_pe *pe, struct sock_tx_ctx *tx_ctx)
msg_hdr->ep_id = sock_av_lookup_ep_id(tx_ctx->av, pe_entry->addr);
} else {
msg_hdr->rx_id = 0;
msg_hdr->ep_id = ep->rem_ep_id;
msg_hdr->ep_id = ((ep != NULL) ? ep->rem_ep_id : 0);
}
msg_hdr->dest_iov_len = pe_entry->pe.tx.tx_op.dest_iov_len;
@ -2074,8 +2076,6 @@ int sock_pe_progress_rx_ep(struct sock_pe *pe, struct sock_ep *ep,
for (i=0; i<map->used; i++) {
conn = &map->table[i];
if (!conn)
continue;
if (rbused(&conn->outbuf))
sock_comm_flush(conn);

Просмотреть файл

@ -189,16 +189,21 @@ static ssize_t sock_ep_rma_readv(struct fid_ep *ep, const struct iovec *iov,
void **desc, size_t count, fi_addr_t src_addr,
uint64_t addr, uint64_t key, void *context)
{
size_t len, i;
struct fi_msg_rma msg;
struct fi_rma_iov rma_iov;
msg.msg_iov = iov;
msg.desc = desc;
msg.iov_count = count;
msg.rma_iov_count = 1;
rma_iov.addr = addr;
rma_iov.key = key;
rma_iov.len = 1;
for (i = 0, len = 0; i < count; i++)
len += iov[i].iov_len;
rma_iov.len = len;
msg.rma_iov = &rma_iov;
msg.addr = src_addr;
@ -371,7 +376,7 @@ static ssize_t sock_ep_rma_writev(struct fid_ep *ep,
for (i = 0, len = 0; i < count; i++)
len += iov[i].iov_len;
rma_iov.addr = addr;
rma_iov.key = key;
rma_iov.len = len;

Просмотреть файл

@ -82,7 +82,7 @@ static int sock_wait_init(struct sock_wait *wait, enum fi_wait_obj type)
if (socketpair(AF_UNIX, SOCK_STREAM, 0, wait->wobj.fd))
return -errno;
fcntl(wait->wobj.fd[WAIT_READ_FD], F_GETFL, &flags);
flags = fcntl(wait->wobj.fd[WAIT_READ_FD], F_GETFL, 0);
if (fcntl(wait->wobj.fd[WAIT_READ_FD], F_SETFL, flags | O_NONBLOCK)) {
close(wait->wobj.fd[WAIT_READ_FD]);
close(wait->wobj.fd[WAIT_WRITE_FD]);
@ -273,6 +273,8 @@ int sock_wait_open(struct fid_fabric *fabric, struct fi_wait_attr *attr,
fab = container_of(fabric, struct sock_fabric, fab_fid);
if (!attr || attr->wait_obj == FI_WAIT_UNSPEC)
wait_obj_type = FI_WAIT_FD;
else
wait_obj_type = attr->wait_obj;
wait = calloc(1, sizeof(*wait));
if (!wait)

Просмотреть файл

@ -81,14 +81,16 @@ usdf_av_insert_async_complete(struct usdf_av_insert *insert)
pthread_spin_lock(&av->av_lock);
usdf_timer_free(av->av_domain->dom_fabric, insert->avi_timer);
atomic_dec(&av->av_active_inserts);
if (atomic_get(&av->av_active_inserts) == 0 && av->av_closing) {
pthread_spin_destroy(&av->av_lock);
free(av);
} else {
pthread_spin_unlock(&av->av_lock);
}
usdf_timer_free(av->av_domain->dom_fabric, insert->avi_timer);
free(insert);
}
@ -328,7 +330,7 @@ usdf_am_insert_sync(struct fid_av *fav, const void *addr, size_t count,
const struct sockaddr_in *sin;
struct usdf_av *av;
struct usd_dest *u_dest;
struct usdf_dest *dest = dest; // supress uninit
struct usdf_dest *dest;
int ret_count;
int ret;
int i;
@ -344,6 +346,8 @@ usdf_am_insert_sync(struct fid_av *fav, const void *addr, size_t count,
/* XXX parallelize, this will also eliminate u_dest silliness */
for (i = 0; i < count; i++) {
dest = NULL;
u_dest = NULL;
ret = usdf_av_alloc_dest(&dest);
if (ret == 0) {
ret = usd_create_dest(av->av_domain->dom_dev,
@ -352,12 +356,13 @@ usdf_am_insert_sync(struct fid_av *fav, const void *addr, size_t count,
}
if (ret == 0) {
dest->ds_dest = *u_dest;
free(u_dest);
fi_addr[i] = (fi_addr_t)dest;
++ret_count;
} else {
fi_addr[i] = FI_ADDR_NOTAVAIL;
free(dest);
}
free(u_dest);
++sin;
}
@ -389,7 +394,7 @@ usdf_am_lookup(struct fid_av *av, fi_addr_t fi_addr, void *addr,
size_t *addrlen)
{
struct usdf_dest *dest;
struct sockaddr_in sin;
struct sockaddr_in sin = { 0 };
size_t copylen;
dest = (struct usdf_dest *)(uintptr_t)fi_addr;
@ -467,6 +472,7 @@ usdf_av_close(struct fid *fid)
av->av_closing = 1;
pthread_spin_unlock(&av->av_lock);
} else {
pthread_spin_destroy(&av->av_lock);
free(av);
}
return 0;

Просмотреть файл

@ -81,7 +81,7 @@ usdf_cm_msg_connreq_cleanup(struct usdf_connreq *crp)
}
if (crp->cr_pollitem.pi_rtn != NULL) {
epoll_ctl(fp->fab_epollfd, EPOLL_CTL_DEL, crp->cr_sockfd, NULL);
(void) epoll_ctl(fp->fab_epollfd, EPOLL_CTL_DEL, crp->cr_sockfd, NULL);
crp->cr_pollitem.pi_rtn = NULL;
}
if (crp->cr_sockfd != -1) {

Просмотреть файл

@ -715,6 +715,9 @@ usdf_ep_msg_open(struct fid_domain *domain, struct fi_info *info,
tx->tx_attr = *info->tx_attr;
} else {
ret = usdf_msg_fill_tx_attr(&tx->tx_attr);
if (ret != 0) {
goto fail;
}
}
TAILQ_INIT(&tx->t.msg.tx_free_wqe);
TAILQ_INIT(&tx->t.msg.tx_ep_ready);

Просмотреть файл

@ -760,6 +760,9 @@ usdf_ep_rdm_open(struct fid_domain *domain, struct fi_info *info,
tx->tx_attr = *info->tx_attr;
} else {
ret = usdf_rdm_fill_tx_attr(&tx->tx_attr);
if (ret != 0) {
goto fail;
}
}
TAILQ_INIT(&tx->t.rdm.tx_free_wqe);
TAILQ_INIT(&tx->t.rdm.tx_rdc_ready);
@ -798,6 +801,9 @@ usdf_ep_rdm_open(struct fid_domain *domain, struct fi_info *info,
rx->rx_attr = *info->rx_attr;
} else {
ret = usdf_rdm_fill_rx_attr(&rx->rx_attr);
if (ret != 0) {
goto fail;
}
}
TAILQ_INIT(&rx->r.rdm.rx_free_rqe);
TAILQ_INIT(&rx->r.rdm.rx_posted_rqe);
@ -823,5 +829,8 @@ fail:
free(tx);
atomic_dec(&udp->dom_refcnt);
}
if (ep != NULL) {
free(ep);
}
return ret;
}

Просмотреть файл

@ -298,6 +298,7 @@ usdf_eq_read_fd(struct fid_eq *feq, uint32_t *event, void *buf, size_t len,
ret = read(eq->eq_fd, &val, sizeof(val));
if (ret != sizeof(val)) {
ret = -FI_EIO;
goto done;
}
}
@ -588,10 +589,10 @@ usdf_eq_open(struct fid_fabric *fabric, struct fi_eq_attr *attr,
fail:
if (eq != NULL) {
free(eq);
if (eq->eq_ev_ring != NULL) {
free(eq->eq_ev_ring);
}
free(eq);
}
return ret;
}

Просмотреть файл

@ -201,16 +201,6 @@ usdf_fill_info_dgram(
size_t entries;
int ret;
/* check that we are capable of what's requested */
if ((hints->caps & ~USDF_DGRAM_CAPS) != 0) {
return -FI_ENODATA;
}
/* app must support these modes */
if ((hints->mode & USDF_DGRAM_REQ_MODE) != USDF_DGRAM_REQ_MODE) {
return -FI_ENODATA;
}
fi = fi_allocinfo_internal();
if (fi == NULL) {
ret = -FI_ENOMEM;
@ -222,6 +212,18 @@ usdf_fill_info_dgram(
if (hints != NULL) {
fi->mode = hints->mode & USDF_DGRAM_SUPP_MODE;
addr_format = hints->addr_format;
/* check that we are capable of what's requested */
if ((hints->caps & ~USDF_DGRAM_CAPS) != 0) {
ret = -FI_ENODATA;
goto fail;
}
/* app must support these modes */
if ((hints->mode & USDF_DGRAM_REQ_MODE) != USDF_DGRAM_REQ_MODE) {
ret = -FI_ENODATA;
goto fail;
}
} else {
fi->mode = USDF_DGRAM_SUPP_MODE;
addr_format = FI_FORMAT_UNSPEC;
@ -363,16 +365,6 @@ usdf_fill_info_msg(
uint32_t addr_format;
int ret;
/* check that we are capable of what's requested */
if ((hints->caps & ~USDF_MSG_CAPS) != 0) {
return -FI_ENODATA;
}
/* app must support these modes */
if ((hints->mode & USDF_MSG_REQ_MODE) != USDF_MSG_REQ_MODE) {
return -FI_ENODATA;
}
fi = fi_allocinfo_internal();
if (fi == NULL) {
ret = -FI_ENOMEM;
@ -384,6 +376,18 @@ usdf_fill_info_msg(
if (hints != NULL) {
fi->mode = hints->mode & USDF_MSG_SUPP_MODE;
addr_format = hints->addr_format;
/* check that we are capable of what's requested */
if ((hints->caps & ~USDF_MSG_CAPS) != 0) {
ret = -FI_ENODATA;
goto fail;
}
/* app must support these modes */
if ((hints->mode & USDF_MSG_REQ_MODE) != USDF_MSG_REQ_MODE) {
ret = -FI_ENODATA;
goto fail;
}
} else {
fi->mode = USDF_MSG_SUPP_MODE;
addr_format = FI_FORMAT_UNSPEC;
@ -466,16 +470,6 @@ usdf_fill_info_rdm(
uint32_t addr_format;
int ret;
/* check that we are capable of what's requested */
if ((hints->caps & ~USDF_RDM_CAPS) != 0) {
return -FI_ENODATA;
}
/* app must support these modes */
if ((hints->mode & USDF_RDM_REQ_MODE) != USDF_RDM_REQ_MODE) {
return -FI_ENODATA;
}
fi = fi_allocinfo_internal();
if (fi == NULL) {
ret = -FI_ENOMEM;
@ -487,6 +481,17 @@ usdf_fill_info_rdm(
if (hints != NULL) {
fi->mode = hints->mode & USDF_RDM_SUPP_MODE;
addr_format = hints->addr_format;
/* check that we are capable of what's requested */
if ((hints->caps & ~USDF_RDM_CAPS) != 0) {
ret = -FI_ENODATA;
goto fail;
}
/* app must support these modes */
if ((hints->mode & USDF_RDM_REQ_MODE) != USDF_RDM_REQ_MODE) {
ret = -FI_ENODATA;
goto fail;
}
} else {
fi->mode = USDF_RDM_SUPP_MODE;
addr_format = FI_FORMAT_UNSPEC;

Просмотреть файл

@ -425,12 +425,12 @@ usdf_msg_send_segment(struct usdf_tx *tx, struct usdf_ep *ep)
(sizeof(struct rudp_pkt) -
sizeof(struct ether_header) -
sizeof(struct iphdr)) + sent);
if (0) {
#if 0
if ((random() % 177) == 0 && resid == 0) {
hdr->hdr.uh_eth.ether_type = 0;
//printf("BORK seq %u\n", ep->e.msg.ep_next_tx_seq);
}
}
#endif
if (resid == 0) {
hdr->msg.opcode = htons(RUDP_OP_LAST);

Просмотреть файл

@ -149,10 +149,14 @@ usdf_pep_conn_info(struct usdf_connreq *crp)
/* fill in dest addr */
ip->dest_addrlen = ip->src_addrlen;
sin = calloc(1, ip->dest_addrlen);
if (sin == NULL) {
goto fail;
}
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = reqp->creq_ipaddr;
sin->sin_port = reqp->creq_port;
ip->dest_addr = sin;
ip->connreq = crp;
return ip;
fail:
@ -322,7 +326,7 @@ usdf_pep_listen(struct fid_pep *fpep)
ret = listen(pep->pep_sock, pep->pep_backlog);
if (ret != 0) {
ret = -errno;
return -errno;
}
pep->pep_pollitem.pi_rtn = usdf_pep_listen_cb;
@ -334,7 +338,7 @@ usdf_pep_listen(struct fid_pep *fpep)
return -errno;
}
return ret;
return 0;
}
ssize_t

Просмотреть файл

@ -706,12 +706,12 @@ PRINTF("TX 1seg=%lu, s/i = %u/%u\n", sent, ntohs(hdr->msg.m.rc_data.seqno), ntoh
(sizeof(struct rudp_pkt) -
sizeof(struct ether_header) -
sizeof(struct iphdr)) + sent);
if (0) {
#if 0
if ((random() % 177) == 0 && resid == 0) {
hdr->hdr.uh_eth.ether_type = 0;
//printf("BORK seq %u, ID %u\n", rdc->dc_next_tx_seq, ntohl(wqe->rd_msg_id_be));
}
}
#endif
if (resid == 0) {
opcode |= RUDP_OP_LAST;

Просмотреть файл

@ -121,7 +121,8 @@ usd_ib_get_devlist(
rc = -errno;
goto out;
}
n = read(fd, ibdev_buf, sizeof(ibdev_buf));
memset(ibdev_buf, 0, sizeof(ibdev_buf));
n = read(fd, ibdev_buf, sizeof(ibdev_buf) - 1);
if (n == -1) {
usd_perror("reading ibdev");
rc = -errno;
@ -141,12 +142,12 @@ usd_ib_get_devlist(
rc = -errno;
goto out;
}
strncpy(idp->id_name, dent->d_name, sizeof(idp->id_name));
strncpy(idp->id_name, dent->d_name, sizeof(idp->id_name) - 1);
strncpy(idp->id_usnic_name, ibdev_buf,
sizeof(idp->id_usnic_name));
snprintf(idp->id_dev_path, sizeof(idp->id_dev_path),
sizeof(idp->id_usnic_name) - 1);
snprintf(idp->id_dev_path, sizeof(idp->id_dev_path) - 1,
"/dev/infiniband/%s", idp->id_name);
snprintf(idp->id_class_path, sizeof(idp->id_class_path),
snprintf(idp->id_class_path, sizeof(idp->id_class_path) - 1,
"%s/device/infiniband/%s", dev_path, ibdev_buf);
if (last_idp == NULL) {
@ -254,11 +255,7 @@ usd_get_iface(
return -errno;
}
/* allow for trailing newline */
if (dev->ud_attrs.uda_ifname[n - 1] == '\n')
dev->ud_attrs.uda_ifname[n - 1] = '\0';
else
dev->ud_attrs.uda_ifname[n] = '\0';
dev->ud_attrs.uda_ifname[n - 1] = '\0';
return 0;
}
@ -355,11 +352,7 @@ usd_get_firmware(
usd_perror("reading fw_ver");
return -errno;
}
/* allow for trailing newline */
if (fw[n - 1] == '\n')
fw[n - 1] = '\0';
else
fw[n] = '\0';
fw[n - 1] = '\0';
return 0;
}

Просмотреть файл

@ -110,6 +110,8 @@ usd_get_dev_if_info(
if (ret == -1)
goto out;
dev->ud_arp_sockfd = s;
} else {
close(s);
}
return 0;

Просмотреть файл

@ -65,7 +65,7 @@ int usnic_arp_lookup(char *ifname, uint32_t ipaddr, int sockfd, uint8_t *macaddr
int status;
memset(&req, 0, sizeof req);
strcpy(req.arp_dev, ifname);
strncpy(req.arp_dev, ifname, sizeof(req.arp_dev) - 1);
memset(&sinp, 0, sizeof(sinp));
sinp.sin_family = AF_INET;
sinp.sin_addr.s_addr = ipaddr;

Просмотреть файл

@ -65,6 +65,8 @@
#define VERBS_PROV_VERS FI_VERSION(1,0)
#define VERBS_WARN(...) FI_WARN(VERBS_PROV_NAME, __VA_ARGS__)
#define VERBS_INFO(...) FI_LOG(2, VERBS_PROV_NAME, __VA_ARGS__)
#define VERBS_DEBUG(...) FI_DEBUG(VERBS_PROV_NAME, __VA_ARGS__)
#define VERBS_MSG_SIZE (1ULL << 31)
#define VERBS_IB_PREFIX "IB-0x"
@ -222,7 +224,7 @@ static int fi_ibv_check_domain_attr(struct fi_domain_attr *attr)
case FI_THREAD_COMPLETION:
break;
default:
VERBS_WARN("Invalid threading model\n");
VERBS_INFO("Invalid threading model\n");
return -FI_ENODATA;
}
@ -232,7 +234,7 @@ static int fi_ibv_check_domain_attr(struct fi_domain_attr *attr)
case FI_PROGRESS_MANUAL:
break;
default:
VERBS_WARN("Given control progress mode not supported\n");
VERBS_INFO("Given control progress mode not supported\n");
return -FI_ENODATA;
}
@ -242,7 +244,7 @@ static int fi_ibv_check_domain_attr(struct fi_domain_attr *attr)
case FI_PROGRESS_MANUAL:
break;
default:
VERBS_WARN("Given data progress mode not supported!\n");
VERBS_INFO("Given data progress mode not supported!\n");
return -FI_ENODATA;
}
@ -274,37 +276,37 @@ static int fi_ibv_check_ep_attr(struct fi_ep_attr *attr)
return -FI_ENODATA;
if (attr->total_buffered_recv) {
VERBS_WARN("Buffered Recv not supported\n");
VERBS_INFO("Buffered Recv not supported\n");
return -FI_ENODATA;
}
if (attr->max_order_raw_size > verbs_ep_attr.max_order_raw_size) {
VERBS_WARN("max_order_raw_size exceeds supported size\n");
VERBS_INFO("max_order_raw_size exceeds supported size\n");
return -FI_ENODATA;
}
if (attr->max_order_war_size) {
VERBS_WARN("max_order_war_size exceeds supported size\n");
VERBS_INFO("max_order_war_size exceeds supported size\n");
return -FI_ENODATA;
}
if (attr->max_order_waw_size > verbs_ep_attr.max_order_waw_size) {
VERBS_WARN("max_order_waw_size exceeds supported size\n");
VERBS_INFO("max_order_waw_size exceeds supported size\n");
return -FI_ENODATA;
}
if (attr->msg_order & ~(verbs_ep_attr.msg_order)) {
VERBS_WARN("Given msg ordering not supported\n");
VERBS_INFO("Given msg ordering not supported\n");
return -FI_ENODATA;
}
if (attr->tx_ctx_cnt > verbs_ep_attr.tx_ctx_cnt) {
VERBS_WARN("tx_ctx_cnt exceeds supported size\n");
VERBS_INFO("tx_ctx_cnt exceeds supported size\n");
return -FI_ENODATA;
}
if (attr->rx_ctx_cnt > verbs_ep_attr.rx_ctx_cnt) {
VERBS_WARN("rx_ctx_cnt exceeds supported size\n");
VERBS_INFO("rx_ctx_cnt exceeds supported size\n");
return -FI_ENODATA;
}
@ -314,22 +316,22 @@ static int fi_ibv_check_ep_attr(struct fi_ep_attr *attr)
static int fi_ibv_check_rx_attr(struct fi_rx_attr *attr)
{
if (attr->caps & ~(verbs_rx_attr.caps)) {
VERBS_WARN("Given rx_attr->caps not supported\n");
VERBS_INFO("Given rx_attr->caps not supported\n");
return -FI_ENODATA;
}
if ((attr->mode & verbs_rx_attr.mode) != verbs_rx_attr.mode) {
VERBS_WARN("Given rx_attr->mode not supported\n");
VERBS_INFO("Given rx_attr->mode not supported\n");
return -FI_ENODATA;
}
if (attr->msg_order & ~(verbs_rx_attr.msg_order)) {
VERBS_WARN("Given rx_attr->msg_order not supported\n");
VERBS_INFO("Given rx_attr->msg_order not supported\n");
return -FI_ENODATA;
}
if (attr->total_buffered_recv > verbs_rx_attr.total_buffered_recv) {
VERBS_WARN("Given rx_attr->total_buffered_recv exceeds supported size\n");
VERBS_INFO("Given rx_attr->total_buffered_recv exceeds supported size\n");
return -FI_ENODATA;
}
@ -339,22 +341,22 @@ static int fi_ibv_check_rx_attr(struct fi_rx_attr *attr)
static int fi_ibv_check_tx_attr(struct fi_tx_attr *attr)
{
if (attr->caps & ~(verbs_tx_attr.caps)) {
VERBS_WARN("Given tx_attr->caps not supported\n");
VERBS_INFO("Given tx_attr->caps not supported\n");
return -FI_ENODATA;
}
if ((attr->mode & verbs_tx_attr.mode) != verbs_tx_attr.mode) {
VERBS_WARN("Given tx_attr->mode not supported\n");
VERBS_INFO("Given tx_attr->mode not supported\n");
return -FI_ENODATA;
}
if (attr->msg_order & ~(verbs_tx_attr.msg_order)) {
VERBS_WARN("Given tx_attr->msg_order not supported\n");
VERBS_INFO("Given tx_attr->msg_order not supported\n");
return -FI_ENODATA;
}
if (attr->inject_size > verbs_tx_attr.inject_size) {
VERBS_WARN("Given tx_attr->inject_size exceeds supported size\n");
VERBS_INFO("Given tx_attr->inject_size exceeds supported size\n");
return -FI_ENODATA;
}
@ -416,22 +418,22 @@ static int fi_ibv_check_dev_limits(struct fi_domain_attr *domain_attr,
struct ibv_device_attr *device_attr)
{
if (domain_attr->cq_cnt > device_attr->max_cq) {
VERBS_WARN("cq_cnt exceeds supported size\n");
VERBS_INFO("cq_cnt exceeds supported size\n");
return -FI_ENODATA;
}
if (domain_attr->ep_cnt > device_attr->max_qp) {
VERBS_WARN("ep_cnt exceeds supported size\n");
VERBS_INFO("ep_cnt exceeds supported size\n");
return -FI_ENODATA;
}
if (domain_attr->tx_ctx_cnt > device_attr->max_qp) {
VERBS_WARN("domain_attr: tx_ctx_cnt exceeds supported size\n");
VERBS_INFO("domain_attr: tx_ctx_cnt exceeds supported size\n");
return -FI_ENODATA;
}
if (domain_attr->rx_ctx_cnt > device_attr->max_qp) {
VERBS_WARN("domain_attr: rx_ctx_cnt exceeds supported size\n");
VERBS_INFO("domain_attr: rx_ctx_cnt exceeds supported size\n");
return -FI_ENODATA;
}
@ -543,7 +545,7 @@ static int fi_ibv_fill_info_attr(struct ibv_context *ctx, struct fi_info *hints,
fi->fabric_attr->name = strdup(VERBS_IWARP_FABRIC);
break;
default:
VERBS_WARN("Unknown transport type");
VERBS_INFO("Unknown transport type");
return -FI_ENODATA;
}
@ -2103,7 +2105,11 @@ fi_ibv_eq_open(struct fid_fabric *fabric, struct fi_eq_attr *attr,
ret = -errno;
goto err1;
}
fcntl(_eq->channel->fd, F_GETFL, &flags);
flags = fcntl(_eq->channel->fd, F_GETFL);
if (flags < 0) {
ret = -errno;
goto err2;
}
ret = fcntl(_eq->channel->fd, F_SETFL, flags | O_NONBLOCK);
if (ret) {
ret = -errno;
@ -2113,7 +2119,8 @@ fi_ibv_eq_open(struct fid_fabric *fabric, struct fi_eq_attr *attr,
case FI_WAIT_NONE:
break;
default:
return -ENOSYS;
ret = -FI_ENOSYS;
goto err1;
}
_eq->flags = attr->flags;
@ -2418,17 +2425,22 @@ fi_ibv_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
goto err1;
}
fcntl(_cq->channel->fd, F_GETFL, &flags);
flags = fcntl(_cq->channel->fd, F_GETFL);
if (flags < 0) {
ret = -errno;
goto err2;
}
ret = fcntl(_cq->channel->fd, F_SETFL, flags | O_NONBLOCK);
if (ret) {
ret = -errno;
goto err1;
goto err2;
}
break;
case FI_WAIT_NONE:
break;
default:
return -FI_ENOSYS;
ret = -FI_ENOSYS;
goto err1;
}
_cq->cq = ibv_create_cq(_cq->domain->verbs, attr->size, _cq,

Просмотреть файл

@ -140,7 +140,6 @@ static int fi_register_provider(struct fi_provider *provider, void *dlhandle)
cleanup:
cleanup_provider(provider, dlhandle);
return ret;
}
@ -171,47 +170,53 @@ static void fi_ini(void)
fi_log_init();
#ifdef HAVE_LIBDL
struct dirent **liblist;
int n;
struct dirent **liblist = NULL;
int n = 0;
char *lib, *provdir;
void *dlhandle;
struct fi_provider* (*inif)(void);
/* If dlopen fails, assume static linking and just return
without error */
if (dlopen(NULL, RTLD_NOW) == NULL) {
goto done;
dlhandle = dlopen(NULL, RTLD_NOW);
if (dlhandle == NULL) {
goto libdl_done;
}
dlclose(dlhandle);
provdir = PROVDLDIR;
n = scandir(provdir, &liblist, lib_filter, NULL);
if (n < 0)
goto done;
goto libdl_done;
while (n--) {
if (asprintf(&lib, "%s/%s", provdir, liblist[n]->d_name) < 0) {
FI_WARN(NULL, "asprintf failed to allocate memory\n");
free(liblist[n]);
goto done;
goto libdl_done;
}
FI_DEBUG(NULL, "opening provider lib %s\n", lib);
dlhandle = dlopen(lib, RTLD_NOW);
if (dlhandle == NULL)
FI_WARN(NULL, "dlopen(%s): %s\n", lib, dlerror());
free(liblist[n]);
if (dlhandle == NULL) {
FI_WARN(NULL, "dlopen(%s): %s\n", lib, dlerror());
free(lib);
continue;
}
free(lib);
inif = dlsym(dlhandle, "fi_prov_ini");
if (inif == NULL)
if (inif == NULL) {
FI_WARN(NULL, "dlsym: %s\n", dlerror());
else
dlclose(dlhandle);
} else
fi_register_provider((inif)(), dlhandle);
}
libdl_done:
while (n-- > 0)
free(liblist[n]);
free(liblist);
done:
#endif
fi_register_provider(PSM_INIT, NULL);
@ -227,8 +232,14 @@ unlock:
static void __attribute__((destructor)) fi_fini(void)
{
for (struct fi_prov *prov = prov_head; prov; prov = prov->next)
struct fi_prov *prov;
while (prov_head) {
prov = prov_head;
prov_head = prov->next;
cleanup_provider(prov->provider, prov->dlhandle);
free(prov);
}
}
static struct fi_prov *fi_getprov(const char *prov_name)

Просмотреть файл

@ -496,13 +496,17 @@ __attribute__((visibility ("default")))
char *DEFAULT_SYMVER_PRE(fi_tostr)(const void *data, enum fi_type datatype)
{
static char *buf = NULL;
uint64_t val64 = *(const uint64_t *) data;
uint32_t val32 = *(const uint32_t *) data;
int enumval = *(const int *) data;
uint64_t val64;
uint32_t val32;
int enumval;
if (!data)
return NULL;
val64 = *(const uint64_t *) data;
val32 = *(const uint32_t *) data;
enumval = *(const int *) data;
if (!buf) {
buf = calloc(BUFSIZ, 1);
if (!buf)