Skip to content

Commit

Permalink
enable keepalives for all intercepted connections
Browse files Browse the repository at this point in the history
  • Loading branch information
scareything committed Jun 23, 2023
1 parent 8fbc2c9 commit 4cb75a1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/ziti-tunnel/tunnel_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ static struct tcp_pcb *new_tcp_pcb(ip_addr_t src, ip_addr_t dest, struct tcp_hdr
/* allocate a listener and set accept fn to appease lwip */
npcb->listener = phony_listener;
npcb->netif_idx = netif_get_index(netif_default);
// tell lwip to send tcp keepalive acks when the connection is established
ip_set_option(npcb, SOF_KEEPALIVE);

/* Register the new PCB so that we can begin receiving segments for it. */
TCP_REG_ACTIVE(npcb);
Expand Down Expand Up @@ -241,12 +243,6 @@ int tunneler_tcp_close_write(struct tcp_pcb *pcb) {
tcp_abandon(pcb, 1);
return -1;
}
/* don't let lwip send TCP_MAXRTX FIN segments before clearing the connection if the client never acknowledges,
* enable keepalive instead.
* - https://savannah.nongnu.org/bugs/?31487
* - https://savannah.nongnu.org/bugs/?44092
*/
ip_set_option(pcb, SOF_KEEPALIVE);
LOG_STATE(DEBUG, "closed write", pcb);

return 0;
Expand Down Expand Up @@ -274,12 +270,6 @@ int tunneler_tcp_close(struct tcp_pcb *pcb) {
}
tcp_arg(pcb, NULL);
tcp_recv(pcb, NULL);
/* don't let lwip send TCP_MAXRTX FIN segments before clearing the connection if the client never acknowledges,
* enable keepalive instead
* - https://savannah.nongnu.org/bugs/?31487
* - https://savannah.nongnu.org/bugs/?44092
*/
ip_set_option(pcb, SOF_KEEPALIVE);
LOG_STATE(DEBUG, "closed", pcb);
return 0;
}
Expand Down

0 comments on commit 4cb75a1

Please sign in to comment.