Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in/out interfaces in the metadata of dumped packets #94

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build_*
__pycache__
report/
.*
compile_commands.json
26 changes: 26 additions & 0 deletions cli/convert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include "common/icontrolplane.h"
#include "helper.h"

namespace convert
{

inline void logical_module()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.convert("logical_module");

table_t table;
table.insert("id",
"name");

for (const auto& [id, name] : response)
{
table.insert(id, name);
}

table.print();
}

} /* namespace convert */
8 changes: 4 additions & 4 deletions cli/main.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <variant>
#include <vector>

#include "acl.h"
#include "balancer.h"
#include "config.h"
#include "convert.h"
#include "develop.h"
#include "dregress.h"
#include "helper.h"
Expand Down Expand Up @@ -121,7 +119,9 @@ std::vector<std::tuple<std::string,
{"version", "", [](const auto& args) { call(show::version, args); }},
{"latch update dataplane", "<latch name> <state>", [](const auto& args) { call(latch::dataplane_update, args); }},
{"counter", "[counter_name] <core_id>", [](const auto& args) { call(show::counter_by_name, args); }},
{"latch update dataplane", "<latch name> <state>", [](const auto& args) { call(latch::dataplane_update, args); }}};
{"latch update dataplane", "<latch name> <state>", [](const auto& args) { call(latch::dataplane_update, args); }},
{},
{"convert logical_module", "", [](const auto& args) { call(convert::logical_module, args); }}};

void printUsage()
{
Expand Down
52 changes: 26 additions & 26 deletions cli/show.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace show
{

void physicalPort()
inline void physicalPort()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing: Function 'physicalPort' defined in a header file; function definitions in header files can lead to ODR violations

{
interface::controlPlane controlPlane;
const auto response = controlPlane.getPhysicalPorts();
Expand Down Expand Up @@ -49,9 +49,9 @@ void physicalPort()
table.print();
}

void physical_port_dump(const std::string& direction,
const std::string& interface_name,
const std::string& state)
inline void physical_port_dump(const std::string& direction,
const std::string& interface_name,
const std::string& state)
{
interface::dataPlane dataplane;

Expand All @@ -68,7 +68,7 @@ void physical_port_dump(const std::string& direction,
}
}

void logicalPort()
inline void logicalPort()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getLogicalPorts();
Expand Down Expand Up @@ -108,7 +108,7 @@ static inline std::string convertToString(const common::defender::status& status
}
}

void defenders()
inline void defenders()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getDefenders();
Expand All @@ -135,7 +135,7 @@ void defenders()
namespace tun64
{

void summary(std::optional<std::string> module)
inline void summary(std::optional<std::string> module)
{
interface::controlPlane controlPlane;
const auto response = controlPlane.tun64_tunnels();
Expand Down Expand Up @@ -167,7 +167,7 @@ void summary(std::optional<std::string> module)
table.print();
}

void announce(std::optional<std::string> module)
inline void announce(std::optional<std::string> module)
{
interface::controlPlane controlPlane;
const auto response = controlPlane.tun64_prefixes();
Expand All @@ -194,7 +194,7 @@ void announce(std::optional<std::string> module)
table.print();
}

void mappings(std::optional<std::string> module)
inline void mappings(std::optional<std::string> module)
{
interface::controlPlane controlPlane;
const auto response = controlPlane.tun64_mappings();
Expand Down Expand Up @@ -228,7 +228,7 @@ void mappings(std::optional<std::string> module)
namespace decap
{

void summary()
inline void summary()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getDecaps();
Expand Down Expand Up @@ -268,7 +268,7 @@ void summary()
table.print();
}

void announce()
inline void announce()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getDecapPrefixes();
Expand Down Expand Up @@ -296,7 +296,7 @@ void announce()
namespace nat64stateless
{

void summary()
inline void summary()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getNat64statelesses();
Expand All @@ -322,7 +322,7 @@ void summary()
table.print();
}

void translation()
inline void translation()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getNat64statelessTranslations();
Expand Down Expand Up @@ -355,7 +355,7 @@ void translation()
table.print();
}

void announce()
inline void announce()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getNat64statelessPrefixes();
Expand Down Expand Up @@ -384,7 +384,7 @@ void announce()

}

void snmp()
inline void snmp()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getPortStatsEx();
Expand Down Expand Up @@ -589,7 +589,7 @@ static void list_fw_rules(unsigned int mask, bool list)
table.print();
}

void fw(std::optional<std::string> str)
inline void fw(std::optional<std::string> str)
{
const auto type = str.value_or("original");

Expand All @@ -605,7 +605,7 @@ void fw(std::optional<std::string> str)
}
}

void fwlist(std::optional<std::string> str)
inline void fwlist(std::optional<std::string> str)
{
const auto type = str.value_or("generated");

Expand All @@ -621,7 +621,7 @@ void fwlist(std::optional<std::string> str)
}
}

void errors()
inline void errors()
{
table_t table;
table.insert("name", "counter");
Expand All @@ -637,7 +637,7 @@ void errors()
table.print();
}

void samples()
inline void samples()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getSamples();
Expand Down Expand Up @@ -675,7 +675,7 @@ void samples()
table.print();
}

void samples_dump()
inline void samples_dump()
{
interface::controlPlane controlPlane;
const auto response = controlPlane.getSamples();
Expand Down Expand Up @@ -703,7 +703,7 @@ void samples_dump()
std::cout << "]\n";
}

void values()
inline void values()
{
interface::controlPlane controlplane;
const auto controlplane_values = controlplane.controlplane_values();
Expand All @@ -723,7 +723,7 @@ void values()
table.print();
}

void durations()
inline void durations()
{
interface::controlPlane controlplane;
const auto controlplane_durations = controlplane.controlplane_durations();
Expand All @@ -743,7 +743,7 @@ void durations()
table.print();
}

void version()
inline void version()
{
table_t table;
table.insert("application",
Expand Down Expand Up @@ -796,8 +796,8 @@ void version()
table.print();
}

void counter_by_name(std::string counter_name,
const std::optional<tCoreId>& core_id)
inline void counter_by_name(std::string counter_name,
const std::optional<tCoreId>& core_id)
{
interface::dataPlane dataplane;

Expand Down Expand Up @@ -827,7 +827,7 @@ void counter_by_name(std::string counter_name,
table.print();
}

void shm_info()
inline void shm_info()
{
interface::dataPlane dataplane;
const auto response = dataplane.get_shm_info();
Expand Down
5 changes: 4 additions & 1 deletion common/bufferring.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <inttypes.h>
#include <cstdint>

namespace common
{
Expand Down Expand Up @@ -47,6 +47,9 @@ class bufferring
{
uint32_t size;
uint32_t tag;
uint32_t in_logicalport_id;
uint32_t out_logicalport_id;
uint8_t flow_type;
} __attribute__((__aligned__(64)));

struct item_t
Expand Down
5 changes: 5 additions & 0 deletions common/icontrolplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ class controlPlane
return get<common::icp::requestType::nat46clat_stats, common::icp::nat46clat_stats::response>();
}

auto convert(const common::icp::convert::request& request) const
{
return get<common::icp::requestType::convert, common::icp::convert::response>(request);
}

protected:
void connectToControlPlane() const
{
Expand Down
21 changes: 16 additions & 5 deletions common/icp.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <inttypes.h>

#include <array>
#include <map>
#include <optional>
Expand Down Expand Up @@ -88,7 +86,8 @@ enum class requestType : uint32_t
nat46clat_config,
nat46clat_announce,
nat46clat_stats,
size
convert,
size // size should always be at the bottom of the list, this enum allows us to find out the size of the enum list
};

inline const char* requestType_toString(requestType t)
Expand Down Expand Up @@ -219,6 +218,8 @@ inline const char* requestType_toString(requestType t)
return "nat46clat_announce";
case requestType::nat46clat_stats:
return "nat46clat_stats";
case requestType::convert:
return "convert";
case requestType::size:
return "unknown";
}
Expand Down Expand Up @@ -898,6 +899,14 @@ using response = std::tuple<unsigned int, ///< major
std::string>; ///< custom
}

namespace convert
{
using request = std::string; // module

using response = std::vector<std::tuple<unsigned int, ///< id
std::string>>; ///< name
}

using request = std::tuple<requestType,
std::variant<std::tuple<>,
acl_unwind::request,
Expand All @@ -912,7 +921,8 @@ using request = std::tuple<requestType,
resolve_fqdn_to_ip::request,
getAclConfig::request,
getFwList::request,
loadConfig::request>>;
loadConfig::request,
convert::request>>;

using response = std::variant<std::tuple<>,
telegraf_unsafe::response,
Expand Down Expand Up @@ -963,7 +973,8 @@ using response = std::variant<std::tuple<>,
loadConfig::response,
nat46clat_config::response,
nat46clat_announce::response,
nat46clat_stats::response>;
nat46clat_stats::response,
convert::response>;
}

}
Loading