Skip to content

Commit

Permalink
The code was changed considering the review.
Browse files Browse the repository at this point in the history
  • Loading branch information
biathlon3 committed May 20, 2024
1 parent 3f5f9c7 commit 336b43d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
1 change: 0 additions & 1 deletion fw/sock_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ tfw_sk_prepare_xmit(struct sock *sk, struct sk_buff *skb, unsigned int mss_now,
BUG_ON(!conn);

*nskbs = UINT_MAX;

h2_mode = TFW_CONN_PROTO(conn) == TFW_FSM_H2;
if (h2_mode)
r = tfw_h2_sk_prepare_xmit(sk, skb, mss_now, limit, nskbs);
Expand Down
39 changes: 17 additions & 22 deletions fw/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,19 @@ tfw_tls_sni(TlsCtx *ctx, const unsigned char *data, size_t len)
static inline int
tfw_tls_over(TlsCtx *tls, int state)
{
int sk_proto = ((SsProto *)tls->sk->sk_user_data)->type;
TfwConn *conn = (TfwConn*)tls->sk->sk_user_data;

if (state == TTLS_HS_CB_FINISHED_NEW
|| state == TTLS_HS_CB_FINISHED_RESUMED)
TFW_INC_STAT_BH(serv.tls_hs_successful);

if (TFW_FSM_TYPE(sk_proto) == TFW_FSM_H2 &&
tfw_h2_context_init(tfw_h2_context(conn))) {
T_ERR("cannot establish a new h2 connection\n");
return T_DROP;
}

return frang_tls_handler(tls, state);
}

Expand All @@ -975,35 +984,21 @@ tfw_tls_alpn_match(const TlsCtx *tls, const ttls_alpn_proto *alpn)
int sk_proto = ((SsProto *)tls->sk->sk_user_data)->type;
TfwConn *conn = (TfwConn*)tls->sk->sk_user_data;

if (TFW_FSM_TYPE(sk_proto) == TFW_FSM_H2
&& alpn->id == TTLS_ALPN_ID_HTTP2) {
if (tfw_h2_context_init(tfw_h2_context(conn))) {
T_ERR("cannot establish a new h2 connection\n");
return false;
}
/* Downgrade from HTTP2 to HTTP1. */
if (sk_proto & Conn_Negotiable && alpn->id == TTLS_ALPN_ID_HTTP1) {
conn->proto.type = (conn->proto.type & ~TFW_GFSM_FSM_MASK) |
TFW_FSM_HTTPS;
return true;
}

if (TFW_FSM_TYPE(sk_proto) == TFW_FSM_H2
&& alpn->id == TTLS_ALPN_ID_HTTP2)
return true;

if (TFW_FSM_TYPE(sk_proto) == TFW_FSM_HTTPS
&& alpn->id == TTLS_ALPN_ID_HTTP1)
return true;

if ((sk_proto & Conn_Negotiable)) {
if (alpn->id == TTLS_ALPN_ID_HTTP1) {
conn->proto.type = (conn->proto.type &
~TFW_GFSM_FSM_MASK) |
TFW_FSM_HTTPS;
return true;
}
if (alpn->id == TTLS_ALPN_ID_HTTP2) {
if (tfw_h2_context_init(tfw_h2_context(conn))) {
T_ERR("cannot establish a new h2 connection\n");
return false;
}
return true;
}
}

return false;
}

Expand Down

0 comments on commit 336b43d

Please sign in to comment.