@@ -611,23 +611,19 @@ struct ksock_peer_ni *
}
int
-ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id4,
+ksocknal_add_peer(struct lnet_ni *ni, struct lnet_processid *id,
struct sockaddr *addr)
{
struct ksock_peer_ni *peer_ni;
struct ksock_peer_ni *peer2;
struct ksock_conn_cb *conn_cb;
- struct lnet_processid id;
- if (id4.nid == LNET_NID_ANY ||
- id4.pid == LNET_PID_ANY)
+ if (LNET_NID_IS_ANY(&id->nid) ||
+ id->pid == LNET_PID_ANY)
return -EINVAL;
- id.pid = id4.pid;
- lnet_nid4_to_nid(id4.nid, &id.nid);
-
/* Have a brand new peer_ni ready... */
- peer_ni = ksocknal_create_peer(ni, &id);
+ peer_ni = ksocknal_create_peer(ni, id);
if (IS_ERR(peer_ni))
return PTR_ERR(peer_ni);
@@ -642,14 +638,14 @@ struct ksock_peer_ni *
/* always called with a ref on ni, so shutdown can't have started */
LASSERT(atomic_read(&((struct ksock_net *)ni->ni_data)->ksnn_npeers) >= 0);
- peer2 = ksocknal_find_peer_locked(ni, &id);
+ peer2 = ksocknal_find_peer_locked(ni, id);
if (peer2) {
ksocknal_peer_decref(peer_ni);
peer_ni = peer2;
} else {
/* peer_ni table takes my ref on peer_ni */
hash_add(ksocknal_data.ksnd_peers, &peer_ni->ksnp_list,
- nidhash(&id.nid));
+ nidhash(&id->nid));
}
ksocknal_add_conn_cb_locked(peer_ni, conn_cb);
@@ -1830,11 +1826,11 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_processid *id)
case IOC_LIBCFS_ADD_PEER: {
struct sockaddr_in sa = {.sin_family = AF_INET};
- id4.nid = data->ioc_nid;
- id4.pid = LNET_PID_LUSTRE;
+ id.pid = LNET_PID_LUSTRE;
+ lnet_nid4_to_nid(data->ioc_nid, &id.nid);
sa.sin_addr.s_addr = htonl(data->ioc_u32[0]);
sa.sin_port = htons(data->ioc_u32[1]);
- return ksocknal_add_peer(ni, id4, (struct sockaddr *)&sa);
+ return ksocknal_add_peer(ni, &id, (struct sockaddr *)&sa);
}
case IOC_LIBCFS_DEL_PEER:
id4.nid = data->ioc_nid;
@@ -627,7 +627,7 @@ int ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
int delayed, struct iov_iter *to, unsigned int rlen);
int ksocknal_accept(struct lnet_ni *ni, struct socket *sock);
-int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id,
+int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_processid *id,
struct sockaddr *addr);
struct ksock_peer_ni *ksocknal_find_peer_locked(struct lnet_ni *ni,
struct lnet_processid *id);
@@ -808,7 +808,7 @@ struct ksock_conn_cb *
{
struct ksock_peer_ni *peer_ni;
struct ksock_conn *conn;
- struct sockaddr_in sa;
+ struct sockaddr_storage sa;
rwlock_t *g_lock;
int retry;
int rc;
@@ -859,16 +859,24 @@ struct ksock_conn_cb *
}
memset(&sa, 0, sizeof(sa));
- sa.sin_family = AF_INET;
- sa.sin_addr.s_addr = id->nid.nid_addr[0];
- sa.sin_port = htons(lnet_acceptor_port());
- {
- struct lnet_process_id id4 = {
- .pid = id->pid,
- .nid = lnet_nid_to_nid4(&id->nid),
- };
- rc = ksocknal_add_peer(ni, id4, (struct sockaddr *)&sa);
+ switch (NID_ADDR_BYTES(&id->nid)) {
+ struct sockaddr_in *sin;
+ struct sockaddr_in6 *sin6;
+ case 4:
+ sin = (void *)&sa;
+ sin->sin_family = AF_INET;
+ sin->sin_addr.s_addr = id->nid.nid_addr[0];
+ sin->sin_port = htons(lnet_acceptor_port());
+ break;
+ case 16:
+ sin6 = (void *)&sa;
+ sin6->sin6_family = AF_INET6;
+ memcpy(&sin6->sin6_addr, id->nid.nid_addr,
+ sizeof(sin6->sin6_addr));
+ sin6->sin6_port = htons(lnet_acceptor_port());
+ break;
}
+ rc = ksocknal_add_peer(ni, id, (struct sockaddr *)&sa);
if (rc) {
CERROR("Can't add peer_ni %s: %d\n",
libcfs_idstr(id), rc);