Skip to content

Commit

Permalink
Add ability to specify source of hitcount in cli
Browse files Browse the repository at this point in the history
Right now, only "acl" is supported
  • Loading branch information
ol-imorozko committed Dec 13, 2024
1 parent 234dcfb commit 86b0b54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions autotest/units/001_one_port/078_hitcount_one/autotest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ steps:
# - Payload: 50 bytes
# Total: 14 + 20 + 20 + 50 = 104 bytes
- cli_check: |
hitcount dump
hitcount dump acl
[
c1: 1, 104
]
Expand All @@ -27,7 +27,7 @@ steps:
# Check hitcount dump. Two packets now match "c1".
# Byte count increments by 104 (packet size) for each additional packet.
- cli_check: |
hitcount dump
hitcount dump acl
[
c1: 2, 208
]
Expand All @@ -39,7 +39,7 @@ steps:

# Check hitcount dump. Three packets now match "c1".
- cli_check: |
hitcount dump
hitcount dump acl
[
c1: 3, 312
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ steps:
send: 003-send.pcap
expect: 003-expect.pcap

- cli: "hitcount dump | diff - TESTDIR/hitcount_expected.txt"
- cli: "hitcount dump acl | diff - TESTDIR/hitcount_expected.txt"
2 changes: 1 addition & 1 deletion cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ std::vector<std::tuple<std::string,
{"dontdoit podumoi controlplane rib clear", "[protocol] <peer> <vrf> <priority>", [](const auto& args) { Call(rib::clear, args); }},
{"dontdoit podumoi tsc monitoring", "", [](const auto& args) { Call(develop::dataplane::tsc_monitoring, args); }},
{},
{"hitcount dump", "", [](const auto& args) { Call(show::hitcount_dump, args); }},
{"hitcount dump", "<acl|>", [](const auto& args) { Call(show::hitcount_dump, args); }},
{},
{"telegraf unsafe", "", [](const auto& args) { Call(telegraf::unsafe, args); }},
{"telegraf ports", "", [](const auto& args) { Call(telegraf::ports_stats, args); }},
Expand Down
7 changes: 6 additions & 1 deletion cli/show.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,13 @@ inline void samples_dump()
std::cout << "]\n";
}

inline void hitcount_dump()
inline void hitcount_dump(const std::string& source)
{
if (source != "acl")
{
YANET_THROW("Error: Need to specify source. Right now, only 'acl' is supported.\n");
}

interface::dataPlane dataplane;
const auto& response = dataplane.hitcount_dump();

Expand Down

0 comments on commit 86b0b54

Please sign in to comment.