forked from tempesta-tech/tempesta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace GFSM calls with direct calls to TLS and HTTP
Almost literaly follow ak patch from 2eae1da Replace GFSM calls with direct calls to TLS and HTTP handlers on low level networking layers. GFSM was designed to build graphs of network protocols FSMs (this design was inspired by FreeBSD netgraph). However, during the years neither we nor external users have any requirements to introduce any modules which use GFSM to hook TLS or HTTP entry code. There are only 2 users of the mechanism for TLS and HTTP for now: 1. TLS -> HTTP protocols handling 2. HTTP limits (the frang module) This patch replaces GFSM calls with direct calls to tfw_http_req_process(), tfw_tls_msg_process() and frang_tls_handler() in following paths: 1. sync sockets -> TLS 2. sync sockets -> HTTP 3. TLS -> HTTP 4. TLS -> Frang As the result the function tfw_connection_recv() was eliminated. Now the code is simpler and has lower overhead. We still might need GFSM for the user-space requests handling (tempesta-tech#77) and Tempesta Language (tempesta-tech#102). Contributes to tempesta-tech#755 Based-on-patch-by: Alexander K <[email protected]> Signed-off-by: Aleksey Mikhaylov <[email protected]>
- Loading branch information
Showing
14 changed files
with
84 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Generic connection management. | ||
* | ||
* Copyright (C) 2014 NatSys Lab. ([email protected]). | ||
* Copyright (C) 2015-2021 Tempesta Technologies, Inc. | ||
* Copyright (C) 2015-2022 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
|
@@ -24,6 +24,7 @@ | |
#include "gfsm.h" | ||
#include "log.h" | ||
#include "sync_socket.h" | ||
#include "http.h" | ||
|
||
TfwConnHooks *conn_hooks[TFW_CONN_MAX_PROTOS]; | ||
|
||
|
@@ -131,7 +132,7 @@ tfw_connection_recv(void *cdata, struct sk_buff *skb) | |
.skb = skb, | ||
}; | ||
|
||
return tfw_gfsm_dispatch(&conn->state, conn, &fsm_data); | ||
return tfw_http_msg_process(conn, &fsm_data); | ||
} | ||
|
||
void | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Definitions for generic connection management at OSI level 6 (presentation). | ||
* | ||
* Copyright (C) 2014 NatSys Lab. ([email protected]). | ||
* Copyright (C) 2015-2019 Tempesta Technologies, Inc. | ||
* Copyright (C) 2015-2022 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
|
@@ -100,7 +100,7 @@ enum { | |
struct sock *sk; \ | ||
void (*destructor)(void *); | ||
|
||
typedef struct { | ||
typedef struct TfwConn { | ||
TFW_CONN_COMMON; | ||
} TfwConn; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Tempesta FW | ||
* | ||
* Copyright (C) 2014 NatSys Lab. ([email protected]). | ||
* Copyright (C) 2015-2018 Tempesta Technologies, Inc. | ||
* Copyright (C) 2015-2022 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
|
@@ -88,7 +88,6 @@ enum { | |
/* Security rules enforcement. */ | ||
TFW_FSM_FRANG_REQ, | ||
TFW_FSM_FRANG_RESP, | ||
TFW_FSM_FRANG_TLS, | ||
|
||
TFW_FSM_NUM /* Must be <= TFW_GFSM_FSM_N */ | ||
}; | ||
|
@@ -178,11 +177,12 @@ typedef struct { | |
unsigned short states[TFW_GFSM_FSM_NUM]; | ||
} TfwGState; | ||
|
||
#define TFW_GFSM_STATE(s) ((s)->states[(unsigned char)(s)->curr] \ | ||
& ((TFW_GFSM_FSM_MASK << TFW_GFSM_FSM_SHIFT) \ | ||
| TFW_GFSM_STATE_MASK)) | ||
#define TFW_GFSM_STATE(s) ((s)->states[(unsigned char)(s)->curr] \ | ||
& ((TFW_GFSM_FSM_MASK << TFW_GFSM_FSM_SHIFT) \ | ||
| TFW_GFSM_STATE_MASK)) | ||
|
||
typedef int (*tfw_gfsm_handler_t)(void *obj, TfwFsmData *data); | ||
typedef struct TfwConn TfwConn; | ||
typedef int (*tfw_gfsm_handler_t)(TfwConn *conn, TfwFsmData *data); | ||
|
||
void tfw_gfsm_state_init(TfwGState *st, void *obj, int st0); | ||
int tfw_gfsm_dispatch(TfwGState *st, void *obj, TfwFsmData *data); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.