From 22e9a84152a082586a20fa10f5d22b4b074478dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Bj=C3=B6rklund?= Date: Tue, 9 Dec 2025 08:53:57 +0000 Subject: [PATCH 1/3] Added source optimization --- init/config2args.py | 3 ++ init/schema.json | 3 ++ src/plugins/storage/cache/src/cache.cpp | 38 +++++++++++++++++++++---- src/plugins/storage/cache/src/cache.hpp | 18 ++++++++++++ 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/init/config2args.py b/init/config2args.py index 9789b0c2d..d169da70d 100755 --- a/init/config2args.py +++ b/init/config2args.py @@ -333,6 +333,9 @@ def process_storage(config): cache_params.append(f"s={cache['size_exponent']}") if "line_size_exponent" in cache: cache_params.append(f"l={cache['line_size_exponent']}") + if "source_optimization" in cache: + so_value = "true" if cache['source_optimization'] else "false" + cache_params.append(f"so={so_value}") if cache_params: params.append(f"{';'.join(cache_params)}") diff --git a/init/schema.json b/init/schema.json index 3d2f9e9f7..9662c6ea7 100644 --- a/init/schema.json +++ b/init/schema.json @@ -406,6 +406,9 @@ "line_size_exponent": { "type": "integer", "minimum": 1 + }, + "source_optimization": { + "type": "boolean" } }, "additionalProperties": false diff --git a/src/plugins/storage/cache/src/cache.cpp b/src/plugins/storage/cache/src/cache.cpp index bda8bb4ac..83295362e 100644 --- a/src/plugins/storage/cache/src/cache.cpp +++ b/src/plugins/storage/cache/src/cache.cpp @@ -163,6 +163,7 @@ NHTFlowCache::NHTFlowCache(const std::string& params, ipx_ring_t* queue) , m_inactive(0) , m_split_biflow(false) , m_enable_fragmentation_cache(true) + , m_source_optimization_enabled(false) , m_keylen(0) , m_key() , m_key_inv() @@ -220,7 +221,7 @@ void NHTFlowCache::init(const char* params) m_split_biflow = parser.m_split_biflow; m_enable_fragmentation_cache = parser.m_enable_fragmentation_cache; - + m_source_optimization_enabled = parser.m_source_optimization_enabled; if (m_enable_fragmentation_cache) { try { m_fragmentation_cache @@ -367,7 +368,15 @@ int NHTFlowCache::put_pkt(Packet& pkt) } } } - + // Set all source/destination ports to 0 for source optimization based on flow direction + // this will consolidate more flows into single flow record + if (m_source_optimization_enabled) { + if( source_flow ) { + pkt.src_port = 0; + } else { + pkt.dst_port = 0; + } + } if (found) { /* Existing flow record was found, put flow record at the first index of flow line. */ #ifdef FLOW_CACHE_STATS @@ -436,6 +445,7 @@ int NHTFlowCache::put_pkt(Packet& pkt) if (flow->is_empty()) { m_flows_in_cache++; flow->create(pkt, hashval); + ret = plugins_post_create(flow->m_flow, pkt); if (ret & FLOW_FLUSH) { @@ -526,7 +536,11 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) key_v4->proto = pkt.ip_proto; key_v4->ip_version = IP::v4; - key_v4->src_port = pkt.src_port; + if (m_source_optimization_enabled) { + key_v4->src_port = 0; + } else { + key_v4->src_port = pkt.src_port; + } key_v4->dst_port = pkt.dst_port; key_v4->src_ip = pkt.src_ip.v4; key_v4->dst_ip = pkt.dst_ip.v4; @@ -534,7 +548,11 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) key_v4_inv->proto = pkt.ip_proto; key_v4_inv->ip_version = IP::v4; - key_v4_inv->src_port = pkt.dst_port; + if (m_source_optimization_enabled) { + key_v4_inv->src_port = 0; + } else { + key_v4_inv->src_port = pkt.dst_port; + } key_v4_inv->dst_port = pkt.src_port; key_v4_inv->src_ip = pkt.dst_ip.v4; key_v4_inv->dst_ip = pkt.src_ip.v4; @@ -548,7 +566,11 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) key_v6->proto = pkt.ip_proto; key_v6->ip_version = IP::v6; - key_v6->src_port = pkt.src_port; + if (m_source_optimization_enabled) { + key_v6->src_port = 0; + } else { + key_v6->src_port = pkt.src_port; + } key_v6->dst_port = pkt.dst_port; memcpy(key_v6->src_ip, pkt.src_ip.v6, sizeof(pkt.src_ip.v6)); memcpy(key_v6->dst_ip, pkt.dst_ip.v6, sizeof(pkt.dst_ip.v6)); @@ -556,7 +578,11 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) key_v6_inv->proto = pkt.ip_proto; key_v6_inv->ip_version = IP::v6; - key_v6_inv->src_port = pkt.dst_port; + if (m_source_optimization_enabled) { + key_v6_inv->src_port = 0; + } else { + key_v6_inv->src_port = pkt.dst_port; + } key_v6_inv->dst_port = pkt.src_port; memcpy(key_v6_inv->src_ip, pkt.dst_ip.v6, sizeof(pkt.dst_ip.v6)); memcpy(key_v6_inv->dst_ip, pkt.src_ip.v6, sizeof(pkt.src_ip.v6)); diff --git a/src/plugins/storage/cache/src/cache.hpp b/src/plugins/storage/cache/src/cache.hpp index 704d6e402..ec97a7dcb 100644 --- a/src/plugins/storage/cache/src/cache.hpp +++ b/src/plugins/storage/cache/src/cache.hpp @@ -86,6 +86,7 @@ class CacheOptParser : public OptionsParser { uint32_t m_inactive; bool m_split_biflow; bool m_enable_fragmentation_cache; + bool m_source_optimization_enabled; std::size_t m_frag_cache_size; time_t m_frag_cache_timeout; @@ -97,6 +98,7 @@ class CacheOptParser : public OptionsParser { , m_inactive(DEFAULT_INACTIVE_TIMEOUT) , m_split_biflow(false) , m_enable_fragmentation_cache(true) + , m_source_optimization_enabled(false) , m_frag_cache_size(10007) , // Prime for better distribution in hash table m_frag_cache_timeout(3) @@ -217,6 +219,21 @@ class CacheOptParser : public OptionsParser { } return true; }); + register_option( + "so", + "source_optimization", + "true|false", + "Enable/disable source optimization e.g sets all source ports to 0. Disabled (false) by default.", + [this](const char* arg) { + if (strcmp(arg, "true") == 0) { + m_source_optimization_enabled = true; + } else if (strcmp(arg, "false") == 0) { + m_source_optimization_enabled = false; + } else { + return false; + } + return true; + }); } }; @@ -298,6 +315,7 @@ class NHTFlowCache uint32_t m_inactive; bool m_split_biflow; bool m_enable_fragmentation_cache; + bool m_source_optimization_enabled; uint8_t m_keylen; char m_key[MAX_KEY_LENGTH]; char m_key_inv[MAX_KEY_LENGTH]; From c506fc69ab86c8961dbeb0e5f83023993a9f8347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Bj=C3=B6rklund?= <9413089+JimmyBjorklund@users.noreply.github.com> Date: Wed, 10 Dec 2025 09:18:48 +0100 Subject: [PATCH 2/3] This QinQ extension handels both the inner an outer vlan tags This QinQ extension handels both the inner an outer vlan tags and exports them as: ``` DOT1Q_VLAN_ID DOT1Q_CUSTOMER_VLAN_ID ``` --- http-test2.pcap | Bin 0 -> 1342 bytes include/ipfixprobe/ipfix-elements.hpp | 7 ++ include/ipfixprobe/packet.hpp | 2 + qinq.pcap | Bin 0 -> 1244 bytes src/plugins/input/parser/parser.cpp | 11 +- src/plugins/process/CMakeLists.txt | 1 + src/plugins/process/qinq/CMakeLists.txt | 27 +++++ src/plugins/process/qinq/README.md | 0 src/plugins/process/qinq/src/qinq.cpp | 56 ++++++++++ src/plugins/process/qinq/src/qinq.hpp | 104 ++++++++++++++++++ src/plugins/process/vlan/src/vlan.hpp | 6 +- src/plugins/storage/cache/src/cache.cpp | 4 + src/plugins/storage/cache/src/cache.hpp | 2 + .../fragmentationKeyData.hpp | 2 + 14 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 http-test2.pcap create mode 100644 qinq.pcap create mode 100644 src/plugins/process/qinq/CMakeLists.txt create mode 100644 src/plugins/process/qinq/README.md create mode 100644 src/plugins/process/qinq/src/qinq.cpp create mode 100644 src/plugins/process/qinq/src/qinq.hpp diff --git a/http-test2.pcap b/http-test2.pcap new file mode 100644 index 0000000000000000000000000000000000000000..c206fb72d179d0a0e7a31a307ab2aa14de10ee3e GIT binary patch literal 1342 zcmbW1O=#0#7{}jsU02@`*hJWFzVxU~lXmMmv$i_jm+q6bQxPv&@~(}vNll`-gD?l8 zOz<+qc@W$|Q1Kwe%Pun1i{cyuMTUrbIgJtth`n(838ueEtceci;gQWkk2@#Z-h5k1p;=taq)> zEo~6pjJRGV35z1>@8)ouY*UH!8hU_;&7_Sguo8}ta7YrPQiDi3ds7@vQu91DCDNLg zl?>%@k8Ig|uc2xq8dW87f~o-$imbmKBH{rl+$@P9=k4~CoR)|`O8JP|5FVzAI1-JH zsQ&c^@`JLTrj|s8M{R0x_=us~&}+Vj>S;S8kx;ma!^dTF6aFHd&G&A;OTI3<-IIyXE$3FdJ# z<6Qpy-^5xVc5Ejmzi$%DtcXzKR8z^^##Srdr~`8+#%f)wUyp8B(F<0bWEu;95z9_8 W5O@AJEGMAq`cl>L4UIRUYVRK)(Wheo literal 0 HcmV?d00001 diff --git a/include/ipfixprobe/ipfix-elements.hpp b/include/ipfixprobe/ipfix-elements.hpp index 76c15adf3..0a8322867 100644 --- a/include/ipfixprobe/ipfix-elements.hpp +++ b/include/ipfixprobe/ipfix-elements.hpp @@ -93,6 +93,8 @@ namespace ipxp { #define ETHERTYPE(F) F(0, 256, 2, nullptr) #define VLAN_ID(F) F(0, 58, 2, nullptr) +#define DOT1Q_VLAN_ID(F) F(0, 243, 2, nullptr) +#define DOT1Q_CUSTOMER_VLAN_ID(F) F(0, 245, 2, nullptr) #define L2_SRC_MAC(F) F(0, 56, 6, flow.src_mac) #define L2_DST_MAC(F) F(0, 80, 6, flow.dst_mac) @@ -564,6 +566,10 @@ namespace ipxp { #define IPFIX_VLAN_TEMPLATE(F) F(VLAN_ID) +#define IPFIX_QINQ_TEMPLATE(F) \ + F(DOT1Q_VLAN_ID) \ + F(DOT1Q_CUSTOMER_VLAN_ID) + #define IPFIX_NETTISA_TEMPLATE(F) \ F(NTS_MEAN) \ F(NTS_MIN) \ @@ -615,6 +621,7 @@ namespace ipxp { IPFIX_SSADETECTOR_TEMPLATE(F) \ IPFIX_ICMP_TEMPLATE(F) \ IPFIX_VLAN_TEMPLATE(F) \ + IPFIX_QINQ_TEMPLATE(F) \ IPFIX_NETTISA_TEMPLATE(F) \ IPFIX_FLOW_HASH_TEMPLATE(F) diff --git a/include/ipfixprobe/packet.hpp b/include/ipfixprobe/packet.hpp index c84baa534..9e69d4b9d 100644 --- a/include/ipfixprobe/packet.hpp +++ b/include/ipfixprobe/packet.hpp @@ -60,6 +60,7 @@ struct Packet : public Record { ipaddr_t src_ip; ipaddr_t dst_ip; uint32_t vlan_id; + uint32_t vlan_id2; uint32_t frag_id; uint16_t frag_off; bool more_fragments; @@ -119,6 +120,7 @@ struct Packet : public Record { , src_ip({0}) , dst_ip({0}) , vlan_id(0) + , vlan_id2(0) , frag_id(0) , frag_off(0) , more_fragments(false) diff --git a/qinq.pcap b/qinq.pcap new file mode 100644 index 0000000000000000000000000000000000000000..708c99bd4d0b027d74a088aee07282d616bd9f7f GIT binary patch literal 1244 zcmb8vJ4ixN7zgm9Tum!Tds*4T(%zO<)`cdQ8iGV3t3j8BA}50+Y_g%HDYb`MOVD7r zq-77VrN^iuNC`oMQ$b_VW9s`PI8$)$g>%n+@IOD!e>l0@_@S6^gkBsG!HfT!Uy3C- z;)G`$Nu84On&575JJtyi!{B6OjF9QnvzeGhb2p{%1%^aMBp(4kIoX00aMhGwjuTNR zE32w&YE^ah4eG|G<`zwBn^xD}(b?7A)2r|6Hy8&7hfKpGd;oHGm4rb~hl{e5%631< zG2fr;eitThL(a3zB4>;!&$_4_;z5pMYq(e50)OCQ-SZCQUehdcR)ez5OXWfy<^0mASC+0oxK`y$h!K{CEjN+xdl}JWAy|2gn!L8p;xFIZn)N zhau;QFv-U#PkvH4_yh7KwuYi%Lzuh|xg$6goRG!w|4H(cMR_7aW!C}7SJ)cLGX-Jt EFa6r^>Hq)$ literal 0 HcmV?d00001 diff --git a/src/plugins/input/parser/parser.cpp b/src/plugins/input/parser/parser.cpp index d2a731cea..9564b22ff 100644 --- a/src/plugins/input/parser/parser.cpp +++ b/src/plugins/input/parser/parser.cpp @@ -113,7 +113,7 @@ inline uint16_t parse_eth_hdr(const u_char* data_ptr, uint16_t data_len, Packet* // set the default value in case there is no VLAN ID pkt->vlan_id = 0; - + pkt->vlan_id2 = 0; if (ethertype == ETH_P_8021AD || ethertype == ETH_P_8021Q) { if (4 > data_len - hdr_len) { throw "Parser detected malformed packet"; @@ -137,7 +137,8 @@ inline uint16_t parse_eth_hdr(const u_char* data_ptr, uint16_t data_len, Packet* if (4 > data_len - hdr_len) { throw "Parser detected malformed packet"; } - DEBUG_CODE(uint16_t vlan = ntohs(*(uint16_t*) (data_ptr + hdr_len))); + uint16_t vlan = ntohs(*(uint16_t*) (data_ptr + hdr_len)); + pkt->vlan_id2 = vlan & 0x0FFF; DEBUG_MSG("\t802.1q field:\n"); DEBUG_MSG("\t\tPriority:\t%u\n", ((vlan & 0xE000) >> 12)); DEBUG_MSG("\t\tCFI:\t\t%u\n", ((vlan & 0x1000) >> 11)); @@ -771,6 +772,9 @@ void parse_packet( if (pkt->vlan_id) { stats.vlan_packets++; } + if( pkt->vlan_id2) { + stats.vlan_packets++; + } if (pkt->ethertype == ETH_P_IP) { stats.ipv4_packets++; @@ -802,6 +806,9 @@ void parse_packet( pkt->payload = pkt->packet + data_offset; stats.vlan_stats[pkt->vlan_id].update(*pkt); + if( pkt->vlan_id2) { + stats.vlan_stats[pkt->vlan_id2].update(*pkt); + } DEBUG_MSG("Payload length:\t%u\n", pkt->payload_len); DEBUG_MSG("Packet parser exits: packet parsed\n"); diff --git a/src/plugins/process/CMakeLists.txt b/src/plugins/process/CMakeLists.txt index a47322075..54197e5c5 100644 --- a/src/plugins/process/CMakeLists.txt +++ b/src/plugins/process/CMakeLists.txt @@ -21,6 +21,7 @@ add_subdirectory(smtp) add_subdirectory(quic) add_subdirectory(tls) add_subdirectory(http) +add_subdirectory(qinq) if (ENABLE_PROCESS_EXPERIMENTAL) add_subdirectory(sip) diff --git a/src/plugins/process/qinq/CMakeLists.txt b/src/plugins/process/qinq/CMakeLists.txt new file mode 100644 index 000000000..50dd2f6e0 --- /dev/null +++ b/src/plugins/process/qinq/CMakeLists.txt @@ -0,0 +1,27 @@ +project(ipfixprobe-process-qinq VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-qinq plugin") + +add_library(ipfixprobe-process-qinq MODULE + src/qinq.cpp + src/qinq.hpp +) + +set_target_properties(ipfixprobe-process-qinq PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN YES +) + +target_include_directories(ipfixprobe-process-qinq PRIVATE + ${CMAKE_SOURCE_DIR}/include/ +) + +if(ENABLE_NEMEA) + target_link_libraries(ipfixprobe-process-qinq PRIVATE + -Wl,--whole-archive ipfixprobe-nemea-fields -Wl,--no-whole-archive + unirec::unirec + trap::trap + ) +endif() + +install(TARGETS ipfixprobe-process-qinq + LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/" +) diff --git a/src/plugins/process/qinq/README.md b/src/plugins/process/qinq/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/src/plugins/process/qinq/src/qinq.cpp b/src/plugins/process/qinq/src/qinq.cpp new file mode 100644 index 000000000..4d8370f76 --- /dev/null +++ b/src/plugins/process/qinq/src/qinq.cpp @@ -0,0 +1,56 @@ +/** + * @file + * @brief Plugin for parsing basicplus traffic. + * @author Jakub Antonín Štigler xstigl00@xstigl00@stud.fit.vut.cz + * @author Pavel Siska + * @date 2025 + * + * Copyright (c) 2025 CESNET + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "qinq.hpp" + +#include + +#include +#include + +namespace ipxp { + +static const PluginManifest qinqPluginManifest = { + .name = "qinq", + .description = "QinQ process plugin for parsing QinQ traffic, outputs outer and inner VLAN IDs.", + .pluginVersion = "1.0.0", + .apiVersion = "1.0.0", + .usage = + []() { + OptionsParser parser("qinq", "Parse qinq traffic"); + parser.usage(std::cout); + }, +}; + +QinQPlugin::QinQPlugin(const std::string& params, int pluginID) + : ProcessPlugin(pluginID) +{ + init(params.c_str()); +} + +ProcessPlugin* QinQPlugin::copy() +{ + return new QinQPlugin(*this); +} + +int QinQPlugin::post_create(Flow& rec, const Packet& pkt) +{ + auto ext = new RecordExtQinQ(m_pluginID); + ext->vlan_id = pkt.vlan_id; + ext->vlan_id2 = pkt.vlan_id2; + rec.add_extension(ext); + return 0; +} + +static const PluginRegistrar qinqRegistrar(qinqPluginManifest); + +} // namespace ipxp diff --git a/src/plugins/process/qinq/src/qinq.hpp b/src/plugins/process/qinq/src/qinq.hpp new file mode 100644 index 000000000..ae59fa731 --- /dev/null +++ b/src/plugins/process/qinq/src/qinq.hpp @@ -0,0 +1,104 @@ +/** + * @file + * @brief Plugin for parsing basicplus traffic. + * @author Jakub Antonín Štigler xstigl00@xstigl00@stud.fit.vut.cz + * @author Pavel Siska + * @date 2025 + * + * Copyright (c) 2025 CESNET + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#pragma once + +#include + +#ifdef WITH_NEMEA +#include "fields.h" +#endif + +#include +#include +#include + +#include +#include +#include +#include + +namespace ipxp { + +#define QINQ_UNIREC_TEMPLATE "DOT1Q_VLAN_ID,DOT1Q_CUSTOMER_VLAN_ID" + +UR_FIELDS( + uint16 VLAN_ID; + uint16 VLAN_ID2; +) + + +/** + * \brief Flow record extension header for storing parsed QinQ data. + */ +struct RecordExtQinQ : public RecordExt { + // vlan id is in the host byte order + uint16_t vlan_id; + uint16_t vlan_id2; + RecordExtQinQ(int pluginID) + : RecordExt(pluginID) + , vlan_id(0) + , vlan_id2(0) + { + } + +#ifdef WITH_NEMEA + virtual void fill_unirec(ur_template_t* tmplt, void* record) + { + ur_set(tmplt, record, F_VLAN_ID, vlan_id); + ur_set(tmplt, record, F_VLAN_ID2, vlan_id2); + } + + const char* get_unirec_tmplt() const { return QINQ_UNIREC_TEMPLATE; } +#endif + + virtual int fill_ipfix(uint8_t* buffer, int size) + { + const int LEN = sizeof(vlan_id); + const int LEN2 = sizeof(vlan_id2); + if( size < (LEN + LEN2) ) { + return LEN; + } + *reinterpret_cast(buffer) = htons(vlan_id); + *reinterpret_cast(buffer + LEN) = htons(vlan_id2); + return (LEN + LEN2); + } + + const char** get_ipfix_tmplt() const + { + static const char* ipfix_qinq_template[] = {IPFIX_QINQ_TEMPLATE(IPFIX_FIELD_NAMES) NULL}; + return ipfix_qinq_template; + } + + std::string get_text() const + { + std::ostringstream out; + out << "DOT1Q_VLAN_ID=\"" << vlan_id << "\", DOT1Q_CUSTOMER_VLAN_ID=\"" << vlan_id2 << "\""; + return out.str(); + } +}; + +/** + * \brief Process plugin for parsing VLAN packets. + */ +class QinQPlugin : public ProcessPlugin { +public: + QinQPlugin(const std::string& params, int pluginID); + OptionsParser* get_parser() const { return new OptionsParser("qinq", "Parse QinQ traffic"); } + std::string get_name() const { return "qinq"; } + RecordExt* get_ext() const { return new RecordExtQinQ(m_pluginID); } + ProcessPlugin* copy(); + + int post_create(Flow& rec, const Packet& pkt); +}; + +} // namespace ipxp diff --git a/src/plugins/process/vlan/src/vlan.hpp b/src/plugins/process/vlan/src/vlan.hpp index f12abfd14..adf651039 100644 --- a/src/plugins/process/vlan/src/vlan.hpp +++ b/src/plugins/process/vlan/src/vlan.hpp @@ -39,7 +39,7 @@ UR_FIELDS(uint16 VLAN_ID) struct RecordExtVLAN : public RecordExt { // vlan id is in the host byte order uint16_t vlan_id; - + uint16_t vlan_id2; RecordExtVLAN(int pluginID) : RecordExt(pluginID) , vlan_id(0) @@ -69,8 +69,8 @@ struct RecordExtVLAN : public RecordExt { const char** get_ipfix_tmplt() const { - static const char* ipfix_template[] = {IPFIX_VLAN_TEMPLATE(IPFIX_FIELD_NAMES) NULL}; - return ipfix_template; + static const char* ipfix_vlan_template[] = {IPFIX_VLAN_TEMPLATE(IPFIX_FIELD_NAMES) NULL}; + return ipfix_vlan_template; } std::string get_text() const diff --git a/src/plugins/storage/cache/src/cache.cpp b/src/plugins/storage/cache/src/cache.cpp index 83295362e..04893f9a6 100644 --- a/src/plugins/storage/cache/src/cache.cpp +++ b/src/plugins/storage/cache/src/cache.cpp @@ -545,6 +545,7 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) key_v4->src_ip = pkt.src_ip.v4; key_v4->dst_ip = pkt.dst_ip.v4; key_v4->vlan_id = pkt.vlan_id; + key_v4->vlan_id2 = pkt.vlan_id2; key_v4_inv->proto = pkt.ip_proto; key_v4_inv->ip_version = IP::v4; @@ -557,6 +558,7 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) key_v4_inv->src_ip = pkt.dst_ip.v4; key_v4_inv->dst_ip = pkt.src_ip.v4; key_v4_inv->vlan_id = pkt.vlan_id; + key_v4_inv->vlan_id2 = pkt.vlan_id2; m_keylen = sizeof(flow_key_v4_t); return true; @@ -575,6 +577,7 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) memcpy(key_v6->src_ip, pkt.src_ip.v6, sizeof(pkt.src_ip.v6)); memcpy(key_v6->dst_ip, pkt.dst_ip.v6, sizeof(pkt.dst_ip.v6)); key_v6->vlan_id = pkt.vlan_id; + key_v6->vlan_id2 = pkt.vlan_id2; key_v6_inv->proto = pkt.ip_proto; key_v6_inv->ip_version = IP::v6; @@ -587,6 +590,7 @@ bool NHTFlowCache::create_hash_key(Packet& pkt) memcpy(key_v6_inv->src_ip, pkt.dst_ip.v6, sizeof(pkt.dst_ip.v6)); memcpy(key_v6_inv->dst_ip, pkt.src_ip.v6, sizeof(pkt.src_ip.v6)); key_v6_inv->vlan_id = pkt.vlan_id; + key_v6_inv->vlan_id2 = pkt.vlan_id2; m_keylen = sizeof(flow_key_v6_t); return true; diff --git a/src/plugins/storage/cache/src/cache.hpp b/src/plugins/storage/cache/src/cache.hpp index ec97a7dcb..09f1b6462 100644 --- a/src/plugins/storage/cache/src/cache.hpp +++ b/src/plugins/storage/cache/src/cache.hpp @@ -34,6 +34,7 @@ struct __attribute__((packed)) flow_key_v4_t { uint32_t src_ip; uint32_t dst_ip; uint16_t vlan_id; + uint16_t vlan_id2; }; struct __attribute__((packed)) flow_key_v6_t { @@ -44,6 +45,7 @@ struct __attribute__((packed)) flow_key_v6_t { uint8_t src_ip[16]; uint8_t dst_ip[16]; uint16_t vlan_id; + uint16_t vlan_id2; }; #define MAX_KEY_LENGTH (max(sizeof(flow_key_v4_t), sizeof(flow_key_v6_t))) diff --git a/src/plugins/storage/cache/src/fragmentationCache/fragmentationKeyData.hpp b/src/plugins/storage/cache/src/fragmentationCache/fragmentationKeyData.hpp index 726764026..f0302e312 100644 --- a/src/plugins/storage/cache/src/fragmentationCache/fragmentationKeyData.hpp +++ b/src/plugins/storage/cache/src/fragmentationCache/fragmentationKeyData.hpp @@ -58,6 +58,7 @@ struct FragmentationKey { , destination_ip(packet.dst_ip) , fragmentation_id(packet.frag_id) , vlan_id(packet.vlan_id) + , vlan_id2(packet.vlan_id2) { } @@ -76,6 +77,7 @@ struct FragmentationKey { ipaddr_t destination_ip; ///< Destination IP address of the packet. uint32_t fragmentation_id; ///< Fragmentation ID of the packet. uint16_t vlan_id; ///< VLAN ID of the packet. + uint16_t vlan_id2; ///< Second VLAN ID of the packet. } __attribute__((packed)); /** From 912d60a7c12bb7aeedbcff17dac0ea650ced048e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Bj=C3=B6rklund?= Date: Mon, 22 Dec 2025 08:07:12 +0000 Subject: [PATCH 3/3] Removed pcap files --- http-test2.pcap | Bin 1342 -> 0 bytes qinq.pcap | Bin 1244 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 http-test2.pcap delete mode 100644 qinq.pcap diff --git a/http-test2.pcap b/http-test2.pcap deleted file mode 100644 index c206fb72d179d0a0e7a31a307ab2aa14de10ee3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1342 zcmbW1O=#0#7{}jsU02@`*hJWFzVxU~lXmMmv$i_jm+q6bQxPv&@~(}vNll`-gD?l8 zOz<+qc@W$|Q1Kwe%Pun1i{cyuMTUrbIgJtth`n(838ueEtceci;gQWkk2@#Z-h5k1p;=taq)> zEo~6pjJRGV35z1>@8)ouY*UH!8hU_;&7_Sguo8}ta7YrPQiDi3ds7@vQu91DCDNLg zl?>%@k8Ig|uc2xq8dW87f~o-$imbmKBH{rl+$@P9=k4~CoR)|`O8JP|5FVzAI1-JH zsQ&c^@`JLTrj|s8M{R0x_=us~&}+Vj>S;S8kx;ma!^dTF6aFHd&G&A;OTI3<-IIyXE$3FdJ# z<6Qpy-^5xVc5Ejmzi$%DtcXzKR8z^^##Srdr~`8+#%f)wUyp8B(F<0bWEu;95z9_8 W5O@AJEGMAq`cl>L4UIRUYVRK)(Wheo diff --git a/qinq.pcap b/qinq.pcap deleted file mode 100644 index 708c99bd4d0b027d74a088aee07282d616bd9f7f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1244 zcmb8vJ4ixN7zgm9Tum!Tds*4T(%zO<)`cdQ8iGV3t3j8BA}50+Y_g%HDYb`MOVD7r zq-77VrN^iuNC`oMQ$b_VW9s`PI8$)$g>%n+@IOD!e>l0@_@S6^gkBsG!HfT!Uy3C- z;)G`$Nu84On&575JJtyi!{B6OjF9QnvzeGhb2p{%1%^aMBp(4kIoX00aMhGwjuTNR zE32w&YE^ah4eG|G<`zwBn^xD}(b?7A)2r|6Hy8&7hfKpGd;oHGm4rb~hl{e5%631< zG2fr;eitThL(a3zB4>;!&$_4_;z5pMYq(e50)OCQ-SZCQUehdcR)ez5OXWfy<^0mASC+0oxK`y$h!K{CEjN+xdl}JWAy|2gn!L8p;xFIZn)N zhau;QFv-U#PkvH4_yh7KwuYi%Lzuh|xg$6goRG!w|4H(cMR_7aW!C}7SJ)cLGX-Jt EFa6r^>Hq)$