Skip to content

Commit 9120bc7

Browse files
author
Damir Zainullin
committed
CTT - Inroduce FlowRecordCtt structure
1 parent 183884e commit 9120bc7

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* \file
3+
* \author Damir Zainullin <[email protected]>
4+
* \brief FlowRecord implementation.
5+
*/
6+
/*
7+
* Copyright (C) 2023 CESNET
8+
*
9+
* LICENSE TERMS
10+
*
11+
* Redistribution and use in source and binary forms, with or without
12+
* modification, are permitted provided that the following conditions
13+
* are met:
14+
* 1. Redistributions of source code must retain the above copyright
15+
* notice, this list of conditions and the following disclaimer.
16+
* 2. Redistributions in binary form must reproduce the above copyright
17+
* notice, this list of conditions and the following disclaimer in
18+
* the documentation and/or other materials provided with the
19+
* distribution.
20+
* 3. Neither the name of the Company nor the names of its contributors
21+
* may be used to endorse or promote products derived from this
22+
* software without specific prior written permission.
23+
*/
24+
25+
#include "flowRecordCtt.hpp"
26+
27+
#include <ipfixprobe/flowifc.hpp>
28+
#include <ipfixprobe/packet.hpp>
29+
#include <cstring>
30+
31+
namespace ipxp {
32+
33+
void FlowRecordCtt::erase()
34+
{
35+
FlowRecord::erase();
36+
last_request_time.reset();
37+
can_be_offloaded = false;
38+
offload_mode.reset();
39+
}
40+
41+
void FlowRecordCtt::create(const Packet &pkt, uint64_t hash)
42+
{
43+
FlowRecord::create(pkt, hash);
44+
can_be_offloaded = true;
45+
last_request_time.reset();
46+
}
47+
48+
} // ipxp
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* \file
3+
* \author Damir Zainullin <[email protected]>
4+
* \brief FlowRecord declaration.
5+
*/
6+
/*
7+
* Copyright (C) 2023 CESNET
8+
*
9+
* LICENSE TERMS
10+
*
11+
* Redistribution and use in source and binary forms, with or without
12+
* modification, are permitted provided that the following conditions
13+
* are met:
14+
* 1. Redistributions of source code must retain the above copyright
15+
* notice, this list of conditions and the following disclaimer.
16+
* 2. Redistributions in binary form must reproduce the above copyright
17+
* notice, this list of conditions and the following disclaimer in
18+
* the documentation and/or other materials provided with the
19+
* distribution.
20+
* 3. Neither the name of the Company nor the names of its contributors
21+
* may be used to endorse or promote products derived from this
22+
* software without specific prior written permission.
23+
*/
24+
25+
#pragma once
26+
27+
#include <ipfixprobe/packet.hpp>
28+
#include <ipfixprobe/flowifc.hpp>
29+
#include <cstdint>
30+
#include <optional>
31+
#include <ipfixprobe/cttmeta.hpp>
32+
33+
#include "../../cache/src/flowRecord.hpp"
34+
35+
namespace ipxp {
36+
37+
struct alignas(64) FlowRecordCtt : public FlowRecord
38+
{
39+
bool can_be_offloaded; /**< No flow collision in CTT */
40+
std::optional<timeval> last_request_time; /**< Time point when the last not processed request was sent to CTT. */
41+
std::optional<feta::OffloadMode> offload_mode; /**< Offload mode of the flow. Nullopt if not offloaded*/
42+
43+
void erase() override;
44+
45+
void create(const Packet &pkt, uint64_t pkt_hash) override;
46+
47+
__attribute__((always_inline)) bool is_in_ctt() const noexcept
48+
{
49+
return offload_mode.has_value();
50+
}
51+
52+
__attribute__((always_inline)) bool is_waiting_ctt_response() const noexcept
53+
{
54+
return is_in_ctt() && last_request_time.has_value();
55+
}
56+
57+
};
58+
59+
} // ipxp

0 commit comments

Comments
 (0)