summaryrefslogtreecommitdiff
path: root/netcon/NetconEthernetTap.cpp
diff options
context:
space:
mode:
authorJoseph Henry <joseph.henry@zerotier.com>2015-09-24 17:33:25 -0400
committerJoseph Henry <joseph.henry@zerotier.com>2015-09-24 17:33:25 -0400
commit8a8264bc39b97bcce07933c0a5c3158208efcd6c (patch)
tree1023884026caabe3cac822b96b77b90133af21d5 /netcon/NetconEthernetTap.cpp
parent1119f64a77a39619c8632ca1f6cbf3811edefa55 (diff)
downloadinfinitytier-8a8264bc39b97bcce07933c0a5c3158208efcd6c.tar.gz
infinitytier-8a8264bc39b97bcce07933c0a5c3158208efcd6c.zip
Fixed their_fd closure bug
Diffstat (limited to 'netcon/NetconEthernetTap.cpp')
-rw-r--r--netcon/NetconEthernetTap.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp
index 460dedcb..da8c0c67 100644
--- a/netcon/NetconEthernetTap.cpp
+++ b/netcon/NetconEthernetTap.cpp
@@ -302,9 +302,9 @@ void NetconEthernetTap::closeConnection(NetconConnection *conn)
lwipstack->_tcp_err(conn->pcb, NULL);
lwipstack->_tcp_poll(conn->pcb, NULL, 0);
close(_phy.getDescriptor(conn->sock));
+ close(conn->their_fd);
_phy.close(conn->sock);
lwipstack->_tcp_close(conn->pcb);
- client->removeConnection(conn->sock);
delete conn;
}
@@ -564,6 +564,7 @@ err_t NetconEthernetTap::nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
NetconConnection *new_conn = client->addConnection(BUFFER, tap->_phy.wrapSocket(fds[0], client));
client->connections.push_back(new_conn);
new_conn->pcb = newpcb;
+ new_conn->their_fd = fds[1];
int send_fd = tap->_phy.getDescriptor(client->rpc->sock);
int n = write(larg_fd, "z", 1);
if(n > 0) {
@@ -577,7 +578,7 @@ err_t NetconEthernetTap::nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
}
}
else {
- fprintf(stderr, "nc_accept(%d): error writing signal byte (send_fd = %d, their_fd = %d)\n", larg_fd, send_fd, fds[1]);
+ fprintf(stderr, "nc_accept(%d): error writing signal byte (send_fd = %d, perceived_fd = %d)\n", larg_fd, send_fd, fds[1]);
return -1;
}
tap->lwipstack->_tcp_arg(newpcb, new Larg(tap, new_conn->sock));
@@ -797,8 +798,8 @@ void NetconEthernetTap::handle_listen(NetconClient *client, struct listen_st *li
void NetconEthernetTap::handle_retval(NetconClient *client, unsigned char* buf)
{
if(client->unmapped_conn != NULL) {
- memcpy(&(client->unmapped_conn->their_fd), &buf[1], sizeof(int));
- fprintf(stderr, "handle_retval(): Mapping [our=%d -> their=%d]\n", _phy.getDescriptor(client->unmapped_conn->sock), client->unmapped_conn->their_fd);
+ memcpy(&(client->unmapped_conn->perceived_fd), &buf[1], sizeof(int));
+ fprintf(stderr, "handle_retval(): Mapping [our=%d -> their=%d]\n", _phy.getDescriptor(client->unmapped_conn->sock), client->unmapped_conn->perceived_fd);
client->connections.push_back(client->unmapped_conn);
client->unmapped_conn = NULL;
}
@@ -824,6 +825,7 @@ void NetconEthernetTap::handle_socket(NetconClient *client, struct socket_st* so
socketpair(PF_LOCAL, SOCK_STREAM, 0, fds);
NetconConnection *new_conn = client->addConnection(BUFFER, _phy.wrapSocket(fds[0], client));
new_conn->pcb = pcb;
+ new_conn->their_fd = fds[1];
PhySocket *sock = client->rpc->sock;
sock_fd_write(_phy.getDescriptor(sock), fds[1]);
fprintf(stderr, "handle_socket(): socketpair = { our=%d, their=%d}\n", fds[0], fds[1]);