Skip to content

Commit

Permalink
Fix after rebasing on master
Browse files Browse the repository at this point in the history
Now Tempesta FW has ability to accept both HTTP1 and
HTTP2 connections on the same port. When we create
new connection we don't know real connection type,
so we should set `sk_fill_write_queue` callback
for all tls connections and just return 0 in this
callback if it is not HTTP2 later.
  • Loading branch information
EvgeniiMekhanik committed Jun 25, 2024
1 parent 7b820df commit ba856b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fw/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ typedef struct {
*/
#define tfw_h2_context_unsafe(conn) ((TfwH2Ctx *)(&((TfwH2Conn *)conn)->h2))
#define tfw_h2_context_safe(conn) \
ttls_hs_done(tfw_tls_context(conn)) ? tfw_h2_context_unsafe(conn) : NULL;
ttls_hs_done(tfw_tls_context(conn)) ? tfw_h2_context_unsafe(conn) : NULL


/* Callbacks used by l5-l7 protocols to operate on connection level. */
Expand Down
12 changes: 8 additions & 4 deletions fw/sock_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,14 @@ tfw_sk_fill_write_queue(struct sock *sk, unsigned int mss_now, int ss_action)
* set to TCP_CLOSE, so this function will never be called after it.
*/
BUG_ON(!conn);
BUG_ON(TFW_CONN_PROTO(conn) != TFW_FSM_H2);

h2 = tfw_h2_context_safe(conn);
/*
* This function can be called both for HTTP1 and HTTP2 connections.
* Moreover this function can be called when HTTP2 connection is
* shutdowned before TLS hadshake was finished.
*/
h2 = TFW_CONN_PROTO(conn) == TFW_FSM_H2 ?
tfw_h2_context_safe(conn) : NULL;
if (!h2) {
if (ss_action == SS_SHUTDOWN)
tcp_shutdown(sk, SEND_SHUTDOWN);
Expand Down Expand Up @@ -278,9 +283,8 @@ tfw_sock_clnt_new(struct sock *sk)
* find a simple and better solution.
*/
sk->sk_write_xmit = tfw_tls_encrypt;
}
if (TFW_CONN_PROTO(conn) == TFW_FSM_H2)
sk->sk_fill_write_queue = tfw_sk_fill_write_queue;
}

/* Activate keepalive timer. */
mod_timer(&conn->timer,
Expand Down

0 comments on commit ba856b0

Please sign in to comment.