Skip to content

Commit

Permalink
Use uint64_t for exchanging source/target ids.
Browse files Browse the repository at this point in the history
    -Fixes ofiwg#725

Signed-off-by: Jithin Jose <jithin.jose@intel.com>
  • Loading branch information
jithinjose committed Mar 18, 2015
1 parent 036116d commit 90e6711
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions prov/sockets/src/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ struct sock_ep {
struct sockaddr_in *dest_addr;

struct sockaddr_in cm_addr;
fid_t peer_fid;
uint64_t peer_fid;
uint16_t key;
int is_disabled;
struct sock_cm_entry cm;
Expand Down Expand Up @@ -729,8 +729,8 @@ struct sock_conn_hdr {
uint8_t type;
uint8_t reserved[3];
int32_t s_port;
fid_t c_fid;
fid_t s_fid;
uint64_t source_id;
uint64_t target_id;
};

struct sock_conn_req {
Expand Down
34 changes: 17 additions & 17 deletions prov/sockets/src/sock_ep_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,20 +451,20 @@ static void *sock_msg_ep_listener_thread(void *data)

entry_sz = sizeof(*cm_entry) + user_data_sz;
memset(cm_entry, 0, sizeof *cm_entry);
cm_entry->fid = conn_response->hdr.c_fid;
cm_entry->fid = (fid_t)conn_response->hdr.source_id;

memcpy(&cm_entry->data, &conn_response->user_data,
user_data_sz);

fid_ep = container_of(conn_response->hdr.c_fid,
fid_ep = container_of(conn_response->hdr.source_id,
struct fid_ep, fid);
sock_ep = container_of(fid_ep, struct sock_ep, ep);

if (sock_ep->is_disabled ||
sock_ep->cm.shutdown_received)
break;

sock_ep->peer_fid = conn_response->hdr.s_fid;
sock_ep->peer_fid = conn_response->hdr.target_id;
sock_ep->connected = 1;

((struct sockaddr_in*) sock_ep->dest_addr)->sin_port =
Expand All @@ -478,7 +478,7 @@ static void *sock_msg_ep_listener_thread(void *data)
case SOCK_CONN_REJECT:
SOCK_LOG_INFO("Received SOCK_CONN_REJECT\n");

fid_ep = container_of(conn_response->hdr.c_fid,
fid_ep = container_of(conn_response->hdr.source_id,
struct fid_ep, fid);
sock_ep = container_of(fid_ep, struct sock_ep, ep);

Expand All @@ -493,7 +493,7 @@ static void *sock_msg_ep_listener_thread(void *data)
}

memset(cm_err_entry, 0, sizeof(*cm_err_entry) + user_data_sz);
cm_err_entry->fid = conn_response->hdr.c_fid;
cm_err_entry->fid = (fid_t)conn_response->hdr.source_id;
cm_err_entry->err = -FI_ECONNREFUSED;

if (user_data_sz > 0)
Expand All @@ -513,12 +513,12 @@ static void *sock_msg_ep_listener_thread(void *data)

entry_sz = sizeof(*cm_entry) + user_data_sz;
memset(cm_entry, 0, sizeof *cm_entry);
cm_entry->fid = conn_response->hdr.c_fid;
cm_entry->fid = (fid_t)conn_response->hdr.source_id;

memcpy(&cm_entry->data, &conn_response->user_data,
user_data_sz);

fid_ep = container_of(conn_response->hdr.c_fid,
fid_ep = container_of(conn_response->hdr.source_id,
struct fid_ep, fid);
sock_ep = container_of(fid_ep, struct sock_ep, ep);
if (sock_ep->cm.shutdown_received)
Expand Down Expand Up @@ -568,8 +568,8 @@ static int sock_ep_cm_connect(struct fid_ep *ep, const void *addr,

req->hdr.type = SOCK_CONN_REQ;
req->ep_id = _ep->ep_id;
req->hdr.c_fid = &ep->fid;
req->hdr.s_fid = 0;
req->hdr.source_id = (uint64_t)&ep->fid;

This comment has been minimized.

Copy link
@shefty

shefty Mar 19, 2015

Use (uintptr_t) to cast from an address/pointer to an integer.

This comment has been minimized.

Copy link
@jithinjosepkl

jithinjosepkl Mar 19, 2015

Owner

I have a following commit, with removes the exchange of source/target id.

req->hdr.target_id = 0;
req->info = _ep->info;
memcpy(&req->src_addr, _ep->src_addr, sizeof(req->src_addr));
memcpy(&req->dest_addr, _ep->info.dest_addr, sizeof(req->dest_addr));
Expand Down Expand Up @@ -632,11 +632,11 @@ static int sock_ep_cm_accept(struct fid_ep *ep, const void *param, size_t paraml

addr = &req->from_addr;
memcpy(&_ep->cm_addr, addr, sizeof(*addr));
_ep->peer_fid = req->hdr.c_fid;
_ep->peer_fid = req->hdr.source_id;

_ep->rem_ep_id = req->ep_id;
response->hdr.type = SOCK_CONN_ACCEPT;
response->hdr.s_fid = &ep->fid;
response->hdr.target_id = (uint64_t)&ep->fid;
response->hdr.s_port = htons(atoi(_ep->domain->service));

if (sock_ep_cm_enqueue_msg(&_ep->cm, addr, response,
Expand Down Expand Up @@ -666,8 +666,8 @@ int sock_ep_cm_shutdown(struct fid_ep *ep, uint64_t flags)
_ep = container_of(ep, struct sock_ep, ep);
memset(&response, 0, sizeof(response));

response.hdr.c_fid = _ep->peer_fid;
response.hdr.s_fid = &ep->fid;
response.hdr.source_id = (uint64_t)_ep->peer_fid;
response.hdr.target_id = (uint64_t)&ep->fid;
response.hdr.type = SOCK_CONN_SHUTDOWN;

if (sock_ep_cm_enqueue_msg(&_ep->cm, &_ep->cm_addr, &response,
Expand Down Expand Up @@ -914,8 +914,8 @@ static void *sock_pep_listener_thread (void *data)
conn_response = (struct sock_conn_response*)conn_req;

entry_sz = sizeof(*cm_entry);
cm_entry->fid = conn_response->hdr.c_fid;
fid_ep = container_of(conn_response->hdr.c_fid,
cm_entry->fid = (fid_t)conn_response->hdr.source_id;
fid_ep = container_of(conn_response->hdr.source_id,
struct fid_ep, fid);
sock_ep = container_of(fid_ep, struct sock_ep, ep);
if (sock_ep->cm.shutdown_received)
Expand Down Expand Up @@ -1044,10 +1044,10 @@ static int sock_pep_reject(struct fid_pep *pep, fi_connreq_t connreq,

addr = &req->from_addr;
response->hdr.type = SOCK_CONN_REJECT;
response->hdr.s_fid = NULL;
response->hdr.target_id = 0;

if (sock_ep_cm_enqueue_msg(&_pep->cm, addr, req,
sizeof(struct sock_conn_response))) {
sizeof(struct sock_conn_response))) {
ret = -FI_EIO;
goto out;
}
Expand Down

0 comments on commit 90e6711

Please sign in to comment.