Skip to content

Commit

Permalink
Add balancer_prog_with_introspection to KatranConfig
Browse files Browse the repository at this point in the history
Summary:
Follow up on the discussion of loading two versions of the balancer progs, one with no introspection path (and thus no overhead), one with introspection path. This diff adds another flag on katran start path, which sets the path to the balancer prog with introspection enabled.

The use of this flag will come in subsequent diff.
The tw spec will be updated after the pipeline is built.

Reviewed By: udippant

Differential Revision: D22984318

fbshipit-source-id: da5d6fee5f6e0941381891dd4e80b02961398a77
  • Loading branch information
xttjsn authored and facebook-github-bot committed Aug 25, 2020
1 parent 6d462b5 commit ef8a0b3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
3 changes: 3 additions & 0 deletions katran/lib/KatranLbStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ struct KatranMonitorConfig {
* @param string v4TunInterface name for ipip encap (for healtchecks)
* @param string v6TunInterface name for ip(6)ip6 encap (for healthchecks)
* @param string balancerProgPath path to bpf prog for balancer
* @param string balancerProgWithIntrospectionPath path to introspection-enabled
* bpf prog for balancer
* @param string healthcheckingProgPath path to bpf prog for healthchecking
* @param std::vector<uint8_t> defaultMac mac address of default router
* @param uint32_t tc priority of healtchecking task
Expand Down Expand Up @@ -176,6 +178,7 @@ struct KatranConfig {
std::string v4TunInterface;
std::string v6TunInterface;
std::string balancerProgPath;
std::string balancerProgWithIntrospectionPath;
std::string healthcheckingProgPath;
std::vector<uint8_t> defaultMac;
uint32_t priority = kDefaultPriority;
Expand Down
30 changes: 18 additions & 12 deletions katran/lib/testing/katran_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
#include <iostream>
#include <thread>

#include <folly/Conv.h>
#include <folly/File.h>
#include <folly/FileUtil.h>
#include <folly/Range.h>
#include <folly/Conv.h>
#include <gflags/gflags.h>

#include "katran/lib/MonitoringStructs.h"
#include "katran/lib/testing/BpfTester.h"
#include "katran/lib/testing/KatranTestProvision.h"
#include "katran/lib/testing/KatranGueOptionalTestFixtures.h"
#include "katran/lib/testing/KatranGueTestFixtures.h"
#include "katran/lib/testing/KatranHCTestFixtures.h"
#include "katran/lib/testing/KatranOptionalTestFixtures.h"
#include "katran/lib/testing/KatranTestFixtures.h"
#include "katran/lib/MonitoringStructs.h"
#include "katran/lib/testing/KatranTestProvision.h"

using namespace katran::testing;

Expand All @@ -42,18 +42,24 @@ DEFINE_string(
"/tmp/katran_pcap",
"output file for katran monitoring");
DEFINE_string(balancer_prog, "./balancer_kern.o", "path to balancer bpf prog");
DEFINE_string(
balancer_prog_with_introspection,
"./balancer_kern_with_introspection.o",
"path to balancer bpf prog with introspection enabled");
DEFINE_string(healthchecking_prog, "", "path to healthchecking bpf prog");
DEFINE_bool(print_base64, false, "print packets in base64 from pcap file");
DEFINE_bool(test_from_fixtures, false, "run tests on predefined dataset");
DEFINE_bool(perf_testing, false, "run perf tests on predefined dataset");
DEFINE_bool(optional_tests, false, "run optional (kernel specific) tests");
DEFINE_bool(optional_counter_tests, false, "run optional (kernel specific) counter tests");
DEFINE_bool(
optional_counter_tests,
false,
"run optional (kernel specific) counter tests");
DEFINE_bool(gue, false, "run GUE tests instead of IPIP ones");
DEFINE_int32(repeat, 1000000, "perf test runs for single packet");
DEFINE_int32(position, -1, "perf test runs for single packet");
DEFINE_bool(iobuf_storage, false, "test iobuf storage for katran monitor");


void testSimulator(katran::KatranLb& lb) {
// udp, v4 vip v4 real
auto real = lb.getRealForFlow(katran::KatranFlow{
Expand Down Expand Up @@ -145,8 +151,8 @@ void testKatranMonitor(katran::KatranLb& lb) {
lb.stopKatranMonitor();
std::this_thread::sleep_for(std::chrono::seconds(1));
constexpr std::array<katran::monitoring::EventId, 2> events = {
katran::monitoring::EventId::TCP_NONSYN_LRUMISS,
katran::monitoring::EventId::PACKET_TOOBIG,
katran::monitoring::EventId::TCP_NONSYN_LRUMISS,
katran::monitoring::EventId::PACKET_TOOBIG,
};

for (const auto event : events) {
Expand All @@ -155,8 +161,7 @@ void testKatranMonitor(katran::KatranLb& lb) {
folly::toAppend(FLAGS_monitor_output, "_event_", event, &fname);
if (buf != nullptr) {
LOG(INFO) << "buffer length is: " << buf->length();
auto pcap_file =
folly::File(fname.c_str(), O_RDWR | O_CREAT | O_TRUNC);
auto pcap_file = folly::File(fname.c_str(), O_RDWR | O_CREAT | O_TRUNC);
auto res = folly::writeFull(pcap_file.fd(), buf->data(), buf->length());
if (res < 0) {
LOG(ERROR) << "error while trying to write katran monitor output";
Expand Down Expand Up @@ -208,7 +213,7 @@ void validateMapSize(
int expected_max) {
auto map_stats = lb.getBpfMapStats(map_name);
VLOG(3) << map_name << ": " << map_stats.currentEntries << "/"
<< map_stats.maxEntries;
<< map_stats.maxEntries;
if (expected_max != map_stats.maxEntries) {
LOG(INFO) << map_name
<< ": max size is incorrect: " << map_stats.maxEntries;
Expand All @@ -230,7 +235,6 @@ void preTestOptionalLbCounters(katran::KatranLb& lb) {
return;
}


void postTestOptionalLbCounters(katran::KatranLb& lb) {
validateMapSize(lb, "vip_map", 8, katran::kDefaultMaxVips);
validateMapSize(
Expand Down Expand Up @@ -269,7 +273,8 @@ void testLbCounters(katran::KatranLb& lb) {
}
stats = lb.getQuicRoutingStats();
if (stats.v1 != 5 || stats.v2 != 4) {
LOG(INFO) << "Counters for QUIC packets routed with CH: " << stats.v1 << ", with connection-id: " << stats.v2;
LOG(INFO) << "Counters for QUIC packets routed with CH: " << stats.v1
<< ", with connection-id: " << stats.v2;
LOG(INFO) << "Counters for routing of QUIC packets is wrong.";
}
for (int i = 0; i < kReals.size(); i++) {
Expand Down Expand Up @@ -338,6 +343,7 @@ int main(int argc, char** argv) {
kV4TunInterface,
kV6TunInterface,
FLAGS_balancer_prog,
FLAGS_balancer_prog_with_introspection,
FLAGS_healthchecking_prog,
kDefaultMac,
kDefaultPriority,
Expand Down
52 changes: 28 additions & 24 deletions katran/lib/tests/KatranLbTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,34 @@ namespace katran {
class KatranLbTest : public ::testing::Test {
protected:
KatranLbTest()
: lb(KatranConfig{"eth0",
"ipip0",
"ipip60",
"./lb.o",
"./hc.0",
{0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E},
1,
"",
1,
true,
false,
512,
4096,
65537,
true,
1,
{},
{},
10,
4,
"eth0",
0,
{},
false}){}
: lb(KatranConfig{
"eth0", // mainInterface
"ipip0", // v4TunInterface
"ipip60", // v6TunInterface
"./lb.o", // balancerProgPath
"./lb_with_introspection.o", // balancerProgWithIntrospectionPath
"./hc.0", // healthcheckingProgPath
{0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E}, // defaultMac
1, // priority
"", // rootMapPath
1, // rootMapPos
true, // enableHc
false, // disableForwarding
512, // maxVips
4096, // maxReals
65537, // chRingSize
true, // testing
1, // LruSize
{}, // forwardingCores
{}, // numaNodes
10, // maxLpmSrcSize
4, // maxDecapDst
"eth0", // hcInterface
0, // xdpAttachFlags
{}, // monitorConfig
false, // memlockUnlimited
{}, // localMac
}) {}

void SetUp() override {
v1.address = "fc01::1";
Expand Down

0 comments on commit ef8a0b3

Please sign in to comment.