diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-02-28 22:25:07 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-02-29 09:47:45 +0100 |
commit | 76c7e1dca3c933bded7984e19322fa75d2ad3c28 (patch) | |
tree | b360c400f0e09aaadf7c419a1ce4741f77642152 /flow.c | |
parent | bb9bf0bb8f576186b62af5c8506741a7bc545f3e (diff) | |
download | passt-76c7e1dca3c933bded7984e19322fa75d2ad3c28.tar passt-76c7e1dca3c933bded7984e19322fa75d2ad3c28.tar.gz passt-76c7e1dca3c933bded7984e19322fa75d2ad3c28.tar.bz2 passt-76c7e1dca3c933bded7984e19322fa75d2ad3c28.tar.lz passt-76c7e1dca3c933bded7984e19322fa75d2ad3c28.tar.xz passt-76c7e1dca3c933bded7984e19322fa75d2ad3c28.tar.zst passt-76c7e1dca3c933bded7984e19322fa75d2ad3c28.zip |
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>
Diffstat (limited to 'flow.c')
-rw-r--r-- | flow.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 */ /** |