pping: Replace boolean connection state flags with enum

The connection state had 3 boolean flags related to what state it was
in (is_empty, has_opened and has_closed). Only specific combinations
of these flags really made sense (has_opened/has_closed didn't really
mean anything if is_empty, and if has_closed one would expect is_empty
to be false and has_opened to be true etc.). Therefore, replace these
combinations of boolean values with a singular enum which is used to
check if the flow is empty, waiting to open (seen outgoing packet but
no response), is open or has closed.

Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
This commit is contained in:
Simon Sundberg
2022-03-30 17:40:54 +02:00
parent 4fb1f6de64
commit 2e7595b3ca
2 changed files with 22 additions and 15 deletions

View File

@@ -50,6 +50,13 @@ enum __attribute__((__packed__)) pping_map {
PPING_MAP_PACKETTS
};
enum __attribute__((__packed__)) connection_state {
CONNECTION_STATE_EMPTY,
CONNECTION_STATE_WAITOPEN,
CONNECTION_STATE_OPEN,
CONNECTION_STATE_CLOSED
};
struct bpf_config {
__u64 rate_limit;
fixpoint64 rtt_rate;
@@ -96,11 +103,9 @@ struct flow_state {
__u64 rec_bytes;
__u32 last_id;
__u32 outstanding_timestamps;
bool has_opened;
enum connection_state conn_state;
enum flow_event_reason opening_reason;
bool is_empty;
bool has_closed;
__u32 reserved;
__u8 reserved[6];
};
/*