From 16ae03260800b8044efa541edcf43d4fb83b740d Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 30 Nov 2023 13:02:08 +1100 Subject: flow, tcp: Generalise connection types Currently TCP connections use a 1-bit selector, 'spliced', to determine the rest of the contents of the structure. We want to generalise the TCP connection table to other types of flows in other protocols. Make a start on this by replacing the tcp_conn_common structure with a new flow_common structure with an enum rather than a simple boolean indicating the type of flow. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- flow.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 flow.h (limited to 'flow.h') diff --git a/flow.h b/flow.h new file mode 100644 index 0000000..351837d --- /dev/null +++ b/flow.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright Red Hat + * Author: David Gibson + * + * Tracking for logical "flows" of packets. + */ +#ifndef FLOW_H +#define FLOW_H + +/** + * enum flow_type - Different types of packet flows we track + */ +enum flow_type { + /* Represents an invalid or unused flow */ + FLOW_TYPE_NONE = 0, + /* A TCP connection between a socket and tap interface */ + FLOW_TCP, + /* A TCP connection between a host socket and ns socket */ + FLOW_TCP_SPLICE, + + FLOW_NUM_TYPES, +}; + +extern const char *flow_type_str[]; +#define FLOW_TYPE(f) \ + ((f)->type < FLOW_NUM_TYPES ? flow_type_str[(f)->type] : "?") + +/** + * struct flow_common - Common fields for packet flows + * @type: Type of packet flow + */ +struct flow_common { + uint8_t type; +}; + +#endif /* FLOW_H */ -- cgit v1.2.3