mirror of
https://github.com/clearml/dropbear
synced 2025-02-26 05:38:53 +00:00
In theory TFO should work. Needs platform cleanup and testing
--HG-- branch : fastopen
This commit is contained in:
parent
5f0cc969a0
commit
76a3eb393c
@ -47,6 +47,7 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
int sock_in, sock_out;
|
int sock_in, sock_out;
|
||||||
char* error = NULL;
|
char* error = NULL;
|
||||||
|
struct dropbear_progress_connection *progress = NULL;
|
||||||
|
|
||||||
_dropbear_exit = cli_dropbear_exit;
|
_dropbear_exit = cli_dropbear_exit;
|
||||||
_dropbear_log = cli_dropbear_log;
|
_dropbear_log = cli_dropbear_log;
|
||||||
@ -72,11 +73,11 @@ int main(int argc, char ** argv) {
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
connect_remote(cli_opts.remotehost, cli_opts.remoteport, cli_connected, NULL);
|
progress = connect_remote(cli_opts.remotehost, cli_opts.remoteport, cli_connected, NULL);
|
||||||
sock_in = sock_out = -1;
|
sock_in = sock_out = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cli_session(sock_in, sock_out);
|
cli_session(sock_in, sock_out, progress);
|
||||||
|
|
||||||
/* not reached */
|
/* not reached */
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -102,15 +102,20 @@ void cli_connected(int result, int sock, void* userdata, const char *errstring)
|
|||||||
ses.sock_in = ses.sock_out = sock;
|
ses.sock_in = ses.sock_out = sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cli_session(int sock_in, int sock_out) {
|
void cli_session(int sock_in, int sock_out, struct dropbear_progress_connection *progress) {
|
||||||
|
|
||||||
common_session_init(sock_in, sock_out);
|
common_session_init(sock_in, sock_out);
|
||||||
|
|
||||||
|
if (progress) {
|
||||||
|
connect_set_writequeue(progress, &ses.writequeue);
|
||||||
|
}
|
||||||
|
|
||||||
chaninitialise(cli_chantypes);
|
chaninitialise(cli_chantypes);
|
||||||
|
|
||||||
/* Set up cli_ses vars */
|
/* Set up cli_ses vars */
|
||||||
cli_session_init();
|
cli_session_init();
|
||||||
|
|
||||||
|
|
||||||
/* Ready to go */
|
/* Ready to go */
|
||||||
sessinitdone = 1;
|
sessinitdone = 1;
|
||||||
|
|
||||||
|
46
dbutil.c
46
dbutil.c
@ -1049,9 +1049,11 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
|
|||||||
setnonblocking(c->sock);
|
setnonblocking(c->sock);
|
||||||
|
|
||||||
#if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
|
#if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
|
||||||
set_piggyback_ack(sock);
|
//set_piggyback_ack(c->sock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PROGRESS_CONNECT_FALLBACK
|
||||||
|
#if 0
|
||||||
if (connect(c->sock, r->ai_addr, r->ai_addrlen) < 0) {
|
if (connect(c->sock, r->ai_addr, r->ai_addrlen) < 0) {
|
||||||
if (errno == EINPROGRESS) {
|
if (errno == EINPROGRESS) {
|
||||||
TRACE(("Connect in progress"))
|
TRACE(("Connect in progress"))
|
||||||
@ -1065,7 +1067,42 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break; /* Success. Treated the same as EINPROGRESS */
|
break; /* Success. Treated the same as EINPROGRESS */
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
struct msghdr message = {0};
|
||||||
|
int flags;
|
||||||
|
int res;
|
||||||
|
message.msg_name = r->ai_addr;
|
||||||
|
message.msg_namelen = r->ai_addrlen;
|
||||||
|
|
||||||
|
if (c->writequeue) {
|
||||||
|
int iovlen; /* Linux msg_iovlen is a size_t */
|
||||||
|
message.msg_iov = packet_queue_to_iovec(c->writequeue, &iovlen);
|
||||||
|
message.msg_iovlen = iovlen;
|
||||||
|
res = sendmsg(c->sock, &message, MSG_FASTOPEN);
|
||||||
|
if (res < 0 && errno == EOPNOTSUPP) {
|
||||||
|
TRACE(("Fastopen not supported"));
|
||||||
|
/* No kernel MSG_FASTOPEN support. Fall back below */
|
||||||
|
c->writequeue = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!c->writequeue) {
|
||||||
|
res = connect(c->sock, r->ai_addr, r->ai_addrlen);
|
||||||
|
}
|
||||||
|
if (res < 0 && errno != EINPROGRESS) {
|
||||||
|
err = errno;
|
||||||
|
close(c->sock);
|
||||||
|
c->sock = -1;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
c->res_iter = r->ai_next;
|
c->res_iter = r->ai_next;
|
||||||
@ -1130,9 +1167,6 @@ struct dropbear_progress_connection *connect_remote(const char* remotehost, cons
|
|||||||
|
|
||||||
c->res_iter = c->res;
|
c->res_iter = c->res;
|
||||||
|
|
||||||
/* Set one going */
|
|
||||||
connect_try_next(c);
|
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,3 +1236,7 @@ void handle_connect_fds(fd_set *writefd) {
|
|||||||
}
|
}
|
||||||
TRACE(("leave handle_connect_fds - end iter"))
|
TRACE(("leave handle_connect_fds - end iter"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue) {
|
||||||
|
c->writequeue = writequeue;
|
||||||
|
}
|
||||||
|
3
dbutil.h
3
dbutil.h
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "queue.h"
|
||||||
|
|
||||||
#ifndef DISABLE_SYSLOG
|
#ifndef DISABLE_SYSLOG
|
||||||
void startsyslog();
|
void startsyslog();
|
||||||
@ -132,4 +133,6 @@ void handle_connect_fds(fd_set *writefd);
|
|||||||
/* Doesn't actually stop the connect, but adds a dummy callback instead */
|
/* Doesn't actually stop the connect, but adds a dummy callback instead */
|
||||||
void cancel_connect(struct dropbear_progress_connection *c);
|
void cancel_connect(struct dropbear_progress_connection *c);
|
||||||
|
|
||||||
|
void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue);
|
||||||
|
|
||||||
#endif /* _DBUTIL_H_ */
|
#endif /* _DBUTIL_H_ */
|
||||||
|
2
packet.c
2
packet.c
@ -108,8 +108,6 @@ void write_packet() {
|
|||||||
unsigned packet_type;
|
unsigned packet_type;
|
||||||
#ifdef HAVE_WRITEV
|
#ifdef HAVE_WRITEV
|
||||||
struct iovec *iov = NULL;
|
struct iovec *iov = NULL;
|
||||||
int i;
|
|
||||||
struct Link *l;
|
|
||||||
int iov_count;
|
int iov_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
5
packet.h
5
packet.h
@ -27,6 +27,7 @@
|
|||||||
#define _PACKET_H_
|
#define _PACKET_H_
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
#include "queue.h"
|
||||||
|
|
||||||
void write_packet();
|
void write_packet();
|
||||||
void read_packet();
|
void read_packet();
|
||||||
@ -46,4 +47,8 @@ typedef struct PacketType {
|
|||||||
|
|
||||||
#define INIT_READBUF 128
|
#define INIT_READBUF 128
|
||||||
|
|
||||||
|
/* TODO: writev #ifdef guard */
|
||||||
|
struct iovec * packet_queue_to_iovec(struct Queue *queue, int *ret_iov_count);
|
||||||
|
void packet_queue_consume(struct Queue *queue, ssize_t written);
|
||||||
|
|
||||||
#endif /* _PACKET_H_ */
|
#endif /* _PACKET_H_ */
|
||||||
|
@ -60,7 +60,7 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) ATTRIB_N
|
|||||||
void svr_dropbear_log(int priority, const char* format, va_list param);
|
void svr_dropbear_log(int priority, const char* format, va_list param);
|
||||||
|
|
||||||
/* Client */
|
/* Client */
|
||||||
void cli_session(int sock_in, int sock_out);
|
void cli_session(int sock_in, int sock_out, struct dropbear_progress_connection *progress);
|
||||||
void cli_connected(int result, int sock, void* userdata, const char *errstring);
|
void cli_connected(int result, int sock, void* userdata, const char *errstring);
|
||||||
void cleantext(unsigned char* dirtytext);
|
void cleantext(unsigned char* dirtytext);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user