Skip to content

Commit

Permalink
rte_kni is deprecated. migrate to virtio_user.
Browse files Browse the repository at this point in the history
rte_eth_promiscuous_get() - not work with virtio. therefore i had to add command to cli 'yanet-cli dump' for start/stop dumping traffic to spec.interfaces in.X/out.X/drop.X.
rte_eth_dev_set_link_up() - not work too. use ioctl() instead

issue #43
  • Loading branch information
Timur Aitov authored and GeorgyKirichenko committed Oct 6, 2023
1 parent 203e9d0 commit b926f3f
Show file tree
Hide file tree
Showing 16 changed files with 419 additions and 392 deletions.
2 changes: 1 addition & 1 deletion cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ std::vector<std::tuple<std::string,
commands = {{"help", "", [](const auto& args) { call(help, args); }},
{},
{"physicalPort", "", [](const auto& args) { call(show::physicalPort, args); }},
/// @todo: {"physicalPort dump", "[physicalPort_name] [in|out]", [](const auto& args){call(physicalPort::dump, args);}},
{"logicalPort", "", [](const auto& args) { call(show::logicalPort, args); }},
{"acl unwind", "[module] <direction{any|in|out}> <network_source> <network_destination> <fragment{any|frag}> <protocol> <transport_source> <transport_destination> <transport_flags> <keepstate{any|true|false}>", [](const auto& args) { call(acl::unwind, args); }},
{"acl lookup", "<module> <any|in|out> <network_source> <network_destination> <protocol> <transport_source> <transport_destination>", [](const auto& args) { call(acl::lookup, args); }},
Expand Down Expand Up @@ -86,6 +85,7 @@ std::vector<std::tuple<std::string,
{"limit", "", [](const auto& args) { call(limit::summary, args); }},
{"values", "", [](const auto& args) { call(show::values, args); }},
{"durations", "", [](const auto& args) { call(show::durations, args); }},
{"dump", "[in|out|drop] [interface_name] [enable|disable]", [](const auto& args) { call(show::physical_port_dump, args); }},
{},
{"show errors", "", [](const auto& args) { call(show::errors, args); }},
{},
Expand Down
19 changes: 19 additions & 0 deletions cli/show.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ void physicalPort()
table.print();
}

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

bool bool_state = false;
if (state == "enable")
{
bool_state = true;
}

const auto result = dataplane.dump_physical_port({interface_name, direction, bool_state});
if (result != eResult::success)
{
throw std::string(common::result_to_c_str(result));
}
}

void logicalPort()
{
interface::controlPlane controlPlane;
Expand Down
1 change: 1 addition & 0 deletions common/config.release.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@
#define YANET_CONFIG_DUMP_ID_TO_TAG_SIZE (1024 * 1024)
#define YANET_CONFIG_SHARED_RINGS_NUMBER (32)
#define YANET_DEFAULT_IPC_SHMKEY (12345)
#define YANET_CONFIG_KERNEL_INTERFACE_QUEUE_SIZE (4096)
5 changes: 5 additions & 0 deletions common/idataplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ class dataPlane
return get<common::idp::requestType::get_shm_info, common::idp::get_shm_info::response>();
}

auto dump_physical_port(const common::idp::dump_physical_port::request& request) const
{
return get<common::idp::requestType::dump_physical_port, eResult>(request);
}

protected:
void connectToDataPlane() const
{
Expand Down
11 changes: 10 additions & 1 deletion common/idp.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum class requestType : uint32_t
version,
get_counter_by_name,
get_shm_info,
dump_physical_port,
size, // size should always be at the bottom of the list, this enum allows us to find out the size of the enum list
};

Expand Down Expand Up @@ -848,6 +849,13 @@ using dump_meta = std::tuple<std::string, ///< ring name
using response = std::vector<dump_meta>;
}

namespace dump_physical_port
{
using request = std::tuple<std::string, ///< interface_name
std::string, ///< direction (in/out/drop)
bool>; ///< state
}

namespace limits
{
using limit = std::tuple<std::string, ///< name
Expand Down Expand Up @@ -904,7 +912,8 @@ using request = std::tuple<requestType,
debug_latch_update::request,
unrdup_vip_to_balancers::request,
update_vip_vport_proto::request,
get_counter_by_name::request>>;
get_counter_by_name::request,
dump_physical_port::request>>;

using response = std::variant<std::tuple<>,
updateGlobalBase::response, ///< + others which have eResult as response
Expand Down
6 changes: 3 additions & 3 deletions common/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum class result_e : uint32_t
{
success,
errorAllocatingMemory,
errorAllocatingKNI,
errorAllocatingKernelInterface,
errorInitEal,
errorInitBarrier,
errorInitMempool,
Expand Down Expand Up @@ -73,8 +73,8 @@ static constexpr const char* result_to_c_str(common::result_e e)
return "success";
case result_e::errorAllocatingMemory:
return "errorAllocatingMemory";
case result_e::errorAllocatingKNI:
return "errorAllocatingKNI";
case result_e::errorAllocatingKernelInterface:
return "errorAllocatingKernelInterface";
case result_e::errorInitEal:
return "errorInitEal";
case result_e::errorInitBarrier:
Expand Down
5 changes: 5 additions & 0 deletions common/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ class mac_address_t
{
}

mac_address_t(const uint8_t* address)
{
memcpy(this->address.data(), address, this->address.size());
}

mac_address_t(const std::string& string)
{
unsigned int bytes[6];
Expand Down
4 changes: 4 additions & 0 deletions dataplane/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ void cBus::clientThread(int clientSocket)
{
response = callWithResponse(&cControlPlane::get_shm_info, request);
}
else if (type == common::idp::requestType::dump_physical_port)
{
response = callWithResponse(&cControlPlane::dump_physical_port, request);
}
else
{
stats.errors[(uint32_t)common::idp::errorType::busParse]++;
Expand Down
4 changes: 2 additions & 2 deletions dataplane/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#define YADECAP_ETHER_TYPE_MPLS (0x8847)
#define YADECAP_MPLS_HEADER_SIZE 4

#define YANET_PHYSICALPORT_FLAG_INGRESS_DUMP ((uint8_t)(1u << 0))
#define YANET_PHYSICALPORT_FLAG_EGRESS_DUMP ((uint8_t)(1u << 1))
#define YANET_PHYSICALPORT_FLAG_IN_DUMP ((uint8_t)(1u << 0))
#define YANET_PHYSICALPORT_FLAG_OUT_DUMP ((uint8_t)(1u << 1))
#define YANET_PHYSICALPORT_FLAG_DROP_DUMP ((uint8_t)(1u << 2))

#define YANET_LOGICALPORT_FLAG_PROMISCUOUSMODE ((uint8_t)(1u << 0))
Expand Down
Loading

0 comments on commit b926f3f

Please sign in to comment.