flow: Add helper to determine a flow's protocol
Each flow already has a type field. This implies the protocol the flow represents, but also has more information: we have two ways to represent TCP flows, "tap" and "spliced". In order to generalise some of the flow mechanics, we'll need to determine a flow's protocol in terms of the IP (L4) protocol number. Introduce a constant table and helper macro to derive this from the flow type. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
bb9bf0bb8f
commit
76c7e1dca3
2 changed files with 11 additions and 0 deletions
7
flow.c
7
flow.c
|
@ -25,6 +25,13 @@ const char *flow_type_str[] = {
|
|||
static_assert(ARRAY_SIZE(flow_type_str) == FLOW_NUM_TYPES,
|
||||
"flow_type_str[] doesn't match enum flow_type");
|
||||
|
||||
const uint8_t flow_proto[] = {
|
||||
[FLOW_TCP] = IPPROTO_TCP,
|
||||
[FLOW_TCP_SPLICE] = IPPROTO_TCP,
|
||||
};
|
||||
static_assert(ARRAY_SIZE(flow_proto) == FLOW_NUM_TYPES,
|
||||
"flow_proto[] doesn't match enum flow_type");
|
||||
|
||||
/* Global Flow Table */
|
||||
|
||||
/**
|
||||
|
|
4
flow.h
4
flow.h
|
@ -27,6 +27,10 @@ extern const char *flow_type_str[];
|
|||
#define FLOW_TYPE(f) \
|
||||
((f)->type < FLOW_NUM_TYPES ? flow_type_str[(f)->type] : "?")
|
||||
|
||||
extern const uint8_t flow_proto[];
|
||||
#define FLOW_PROTO(f) \
|
||||
((f)->type < FLOW_NUM_TYPES ? flow_proto[(f)->type] : 0)
|
||||
|
||||
/**
|
||||
* struct flow_common - Common fields for packet flows
|
||||
* @type: Type of packet flow
|
||||
|
|
Loading…
Reference in a new issue