Skip to content

Commit

Permalink
in_forward: Handle handshake states correctly
Browse files Browse the repository at this point in the history
Handshake process on in_forward in Fluent Bit is:

1. send HELO                                    (FW_HANDSHAKE_HELO)
2. check PING                                   (none)
3. send PONG                                    (FW_HANDSHAKE_PINGPONG)
4. Mark a connect as established                (FW_HANDSHAKE_ESTABLISHED)
5. Process retrived records

On waiting the actual records, we just early return from the event
handler to wait the next read event for ingested logs.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Mar 8, 2024
1 parent 5f15f3f commit 5656d84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/in_forward/fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <fluent-bit/flb_log_event_encoder.h>

enum {
FW_HANDSHAKE_HELO = 1,
FW_HANDSHAKE_PINGPONG = 2,
FW_HANDSHAKE_ESTABLISHED = 3,
FW_HANDSHAKE_HELO = 1,
FW_HANDSHAKE_PINGPONG = 2,
FW_HANDSHAKE_ESTABLISHED = 3,
};

struct flb_in_fw_helo {
Expand Down
5 changes: 5 additions & 0 deletions plugins/in_forward/fw_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ int fw_conn_event(void *data)

if (event->mask & MK_EVENT_READ) {
if (conn->handshake_status == FW_HANDSHAKE_PINGPONG) {
flb_plg_trace(ctx->ins, "handshake status = %d", conn->handshake_status);

ret = fw_prot_secure_forward_handshake(ctx->ins, conn);
if (ret == -1) {
return -1;
}

conn->handshake_status = FW_HANDSHAKE_ESTABLISHED;
return 0;
}

flb_plg_trace(ctx->ins, "handshake status = %d", conn->handshake_status);

available = (conn->buf_size - conn->buf_len);
if (available < 1) {
if (conn->buf_size >= ctx->buffer_max_size) {
Expand Down

0 comments on commit 5656d84

Please sign in to comment.