switch (rc) {
/* "normal" errors */
case -ECONNREFUSED:
- CDEBUG(D_NETERROR, "Connection to %s at host %u.%u.%u.%u "
- "on port %d was refused: "
- "check that Lustre is running on that node.\n",
- libcfs_nid2str(peer_nid),
- HIPQUAD(peer_ip), peer_port);
+ CNETERR("Connection to %s at host %u.%u.%u.%u on port %d was "
+ "refused: check that Lustre is running on that node.\n",
+ libcfs_nid2str(peer_nid),
+ HIPQUAD(peer_ip), peer_port);
break;
case -EHOSTUNREACH:
case -ENETUNREACH:
- CDEBUG(D_NETERROR, "Connection to %s at host %u.%u.%u.%u "
- "was unreachable: the network or that node may "
- "be down, or Lustre may be misconfigured.\n",
- libcfs_nid2str(peer_nid), HIPQUAD(peer_ip));
+ CNETERR("Connection to %s at host %u.%u.%u.%u "
+ "was unreachable: the network or that node may "
+ "be down, or Lustre may be misconfigured.\n",
+ libcfs_nid2str(peer_nid), HIPQUAD(peer_ip));
break;
case -ETIMEDOUT:
- CDEBUG(D_NETERROR, "Connection to %s at host %u.%u.%u.%u on "
- "port %d took too long: that node may be hung "
- "or experiencing high load.\n",
- libcfs_nid2str(peer_nid),
- HIPQUAD(peer_ip), peer_port);
+ CNETERR("Connection to %s at host %u.%u.%u.%u on "
+ "port %d took too long: that node may be hung "
+ "or experiencing high load.\n",
+ libcfs_nid2str(peer_nid),
+ HIPQUAD(peer_ip), peer_port);
break;
case -ECONNRESET:
LCONSOLE_ERROR_MSG(0x11b, "Connection to %s at host %u.%u.%u.%u"
CLASSERT (LNET_PROTO_ACCEPTOR_VERSION == 1);
- cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
- cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
- cr.acr_nid = peer_nid;
-
- if (the_lnet.ln_testprotocompat != 0) {
- /* single-shot proto check */
- LNET_LOCK();
- if ((the_lnet.ln_testprotocompat & 4) != 0) {
- cr.acr_version++;
- the_lnet.ln_testprotocompat &= ~4;
- }
- if ((the_lnet.ln_testprotocompat & 8) != 0) {
- cr.acr_magic = LNET_PROTO_MAGIC;
- the_lnet.ln_testprotocompat &= ~8;
+ if (the_lnet.ln_ptlcompat != 2) {
+ /* When portals compatibility is "strong", simply
+ * connect (i.e. send no acceptor connection request).
+ * Othewise send an acceptor connection request. I can
+ * have no portals peers so everyone else should
+ * understand my protocol. */
+ cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
+ cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
+ cr.acr_nid = peer_nid;
+
+ if (the_lnet.ln_testprotocompat != 0) {
+ /* single-shot proto check */
+ LNET_LOCK();
+ if ((the_lnet.ln_testprotocompat & 4) != 0) {
+ cr.acr_version++;
+ the_lnet.ln_testprotocompat &= ~4;
+ }
+ if ((the_lnet.ln_testprotocompat & 8) != 0) {
+ cr.acr_magic = LNET_PROTO_MAGIC;
+ the_lnet.ln_testprotocompat &= ~8;
+ }
+ LNET_UNLOCK();
}
- LNET_UNLOCK();
- }
- rc = libcfs_sock_write(sock, &cr, sizeof(cr),
- accept_timeout);
- if (rc != 0)
- goto failed_sock;
+ rc = libcfs_sock_write(sock, &cr, sizeof(cr),
+ accept_timeout);
+ if (rc != 0)
+ goto failed_sock;
+ }
*sockp = sock;
return 0;
}
int
-lnet_accept(cfs_socket_t *sock, __u32 magic)
+lnet_accept(lnet_ni_t *blind_ni, cfs_socket_t *sock, __u32 magic)
{
lnet_acceptor_connreq_t cr;
__u32 peer_ip;
lnet_ni_t *ni;
char *str;
+ /* CAVEAT EMPTOR: I may be called by an LND in any thread's context if
+ * I passed the new socket "blindly" to the single NI that needed an
+ * acceptor. If so, blind_ni != NULL... */
+
LASSERT (sizeof(cr) <= 16); /* not too big for the stack */
rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
return -EPERM;
}
- CDEBUG(D_NET, "Accept %s from %u.%u.%u.%u\n",
- libcfs_nid2str(cr.acr_nid), HIPQUAD(peer_ip));
+ CDEBUG(D_NET, "Accept %s from %u.%u.%u.%u%s\n",
+ libcfs_nid2str(cr.acr_nid), HIPQUAD(peer_ip),
+ blind_ni == NULL ? "" : " (blind)");
+
+ if (blind_ni == NULL) {
+ /* called by the acceptor: call into the requested NI... */
+ rc = ni->ni_lnd->lnd_accept(ni, sock);
+ } else {
+ /* portals_compatible set and the (only) NI called me to verify
+ * and skip the connection request... */
+ LASSERT (the_lnet.ln_ptlcompat != 0);
+ LASSERT (ni == blind_ni);
+ rc = 0;
+ }
- rc = ni->ni_lnd->lnd_accept(ni, sock);
lnet_ni_decref(ni);
return rc;
}
+EXPORT_SYMBOL(lnet_accept);
int
lnet_acceptor(void *arg)
char name[16];
cfs_socket_t *newsock;
int rc;
+ int n_acceptor_nis;
__u32 magic;
__u32 peer_ip;
int peer_port;
- int secure = (int)((long_ptr_t)arg);
+ lnet_ni_t *blind_ni = NULL;
+ int secure = (int)((unsigned long)arg);
LASSERT (lnet_acceptor_state.pta_sock == NULL);
+ if (the_lnet.ln_ptlcompat != 0) {
+ /* When portals_compatibility is enabled, peers may connect
+ * without sending an acceptor connection request. There is no
+ * ambiguity about which network the peer wants to connect to
+ * since there can only be 1 network, so I pass connections
+ * "blindly" to it. */
+ n_acceptor_nis = lnet_count_acceptor_nis(&blind_ni);
+ LASSERT (n_acceptor_nis == 1);
+ LASSERT (blind_ni != NULL);
+ }
+
snprintf(name, sizeof(name), "acceptor_%03d", accept_port);
cfs_daemonize(name);
cfs_block_allsigs();
lnet_acceptor_state.pta_sock = NULL;
} else {
- LCONSOLE(0, "Accept %s, port %d\n", accept, accept_port);
+ LCONSOLE(0, "Accept %s, port %d%s\n",
+ accept, accept_port,
+ blind_ni == NULL ? "" : " (proto compatible)");
}
/* set init status and unblock parent */
goto failed;
}
+ if (blind_ni != NULL) {
+ rc = blind_ni->ni_lnd->lnd_accept(blind_ni, newsock);
+ if (rc != 0) {
+ CERROR("NI %s refused 'blind' connection from "
+ "%u.%u.%u.%u\n",
+ libcfs_nid2str(blind_ni->ni_nid),
+ HIPQUAD(peer_ip));
+ goto failed;
+ }
+ continue;
+ }
+
rc = libcfs_sock_read(newsock, &magic, sizeof(magic),
accept_timeout);
if (rc != 0) {
goto failed;
}
- rc = lnet_accept(newsock, magic);
+ rc = lnet_accept(NULL, newsock, magic);
if (rc != 0)
goto failed;
libcfs_sock_release(lnet_acceptor_state.pta_sock);
lnet_acceptor_state.pta_sock = NULL;
- LCONSOLE(0, "Acceptor stopping\n");
+ if (blind_ni != NULL)
+ lnet_ni_decref(blind_ni);
+
+ LCONSOLE(0,"Acceptor stopping\n");
/* unblock lnet_acceptor_stop() */
mutex_up(&lnet_acceptor_state.pta_signal);
return -EINVAL;
}
- if (lnet_count_acceptor_nis() == 0) /* not required */
+ if (lnet_count_acceptor_nis(NULL) == 0) /* not required */
return 0;
- pid = cfs_kernel_thread(lnet_acceptor, (void *)(ulong_ptr_t)secure, 0);
+ pid = cfs_kernel_thread(lnet_acceptor, (void *)secure, 0);
if (pid < 0) {
CERROR("Can't start acceptor thread: %ld\n", pid);
return -ESRCH;
/* maybe we're waken up with libcfs_sock_abort_accept() */
if (lnet_acceptor_state.pta_shutdown) {
- libcfs_sock_release(newsock);
+ close(newsock);
break;
}
continue;
failed:
- libcfs_sock_release(newsock);
+ close(newsock);
}
- libcfs_sock_release(lnet_acceptor_state.pta_sock);
+ close(lnet_acceptor_state.pta_sock);
LCONSOLE(0,"Acceptor stopping\n");
/* unblock lnet_acceptor_stop() */
return -EINVAL;
}
- if (lnet_count_acceptor_nis() == 0) { /* not required */
+ if (lnet_count_acceptor_nis(NULL) == 0) { /* not required */
skip_waiting_for_completion = 1;
return 0;
}