comparison netio.c @ 1136:a7c4a70ae495

Don't try to send data on first ack packet of 3way handshake. Cisco SSH on 15.4(3)M2 or similar can't handle it.
author Matt Johnston <matt@ucc.asn.au>
date Mon, 03 Aug 2015 20:53:37 +0800
parents bb3a03feb31f
children 57d09741d46d
comparison
equal deleted inserted replaced
1135:be862d101766 1136:a7c4a70ae495
18 18
19 int sock; 19 int sock;
20 20
21 char* errstring; 21 char* errstring;
22 }; 22 };
23
24 #if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
25 static void set_piggyback_ack(int sock) {
26 /* Undocumented Linux feature - set TCP_DEFER_ACCEPT and data will be piggybacked
27 on the 3rd packet (ack) of the TCP handshake. Saves a IP packet.
28 http://thread.gmane.org/gmane.linux.network/224627/focus=224727
29 "Piggyback the final ACK of the three way TCP connection establishment with the data" */
30 int val = 1;
31 /* No error checking, this is opportunistic */
32 int err = setsockopt(sock, IPPROTO_TCP, TCP_DEFER_ACCEPT, (void*)&val, sizeof(val));
33 if (err)
34 {
35 TRACE(("Failed setsockopt TCP_DEFER_ACCEPT: %s", strerror(errno)))
36 }
37 }
38 #endif
39
40 23
41 /* Deallocate a progress connection. Removes from the pending list if iter!=NULL. 24 /* Deallocate a progress connection. Removes from the pending list if iter!=NULL.
42 Does not close sockets */ 25 Does not close sockets */
43 static void remove_connect(struct dropbear_progress_connection *c, m_list_elem *iter) { 26 static void remove_connect(struct dropbear_progress_connection *c, m_list_elem *iter) {
44 if (c->res) { 27 if (c->res) {
84 } 67 }
85 68
86 ses.maxfd = MAX(ses.maxfd, c->sock); 69 ses.maxfd = MAX(ses.maxfd, c->sock);
87 set_sock_nodelay(c->sock); 70 set_sock_nodelay(c->sock);
88 setnonblocking(c->sock); 71 setnonblocking(c->sock);
89
90 #if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
91 set_piggyback_ack(c->sock);
92 #endif
93 72
94 #ifdef DROPBEAR_CLIENT_TCP_FAST_OPEN 73 #ifdef DROPBEAR_CLIENT_TCP_FAST_OPEN
95 fastopen = (c->writequeue != NULL); 74 fastopen = (c->writequeue != NULL);
96 75
97 if (fastopen) { 76 if (fastopen) {