From 8ae40a9153d992b246bcbfe9791a7cda57f4977f Mon Sep 17 00:00:00 2001 From: udippant Date: Wed, 28 Aug 2019 15:44:16 -0700 Subject: [PATCH] allow to specify should unlimited memlock be used or not (#43) Summary: by default katran today requesting (during startup) unlimited amount of locked memory. this is suboptimal for environments where container managment system wants to enforce this number as well. in this diff i'm adding a flag in katran's config, which would allow us to bypas setting memlock limit to unlimited, and hence would rely on external (to katran) managing system to do so this diff wont change defautl behavior - by default we still would try to set limit to RLIM_UNLIMITED Tested By: unittests + katran_tester Pull Request resolved: https://github.com/facebookincubator/katran/pull/43 Pulled By: udippant Reviewed By: sharma95 Differential Revision: D17097200 fbshipit-source-id: aff4f8aa956d24885fcaf911f52a3e17904e15bf --- katran/lib/KatranLb.cpp | 2 +- katran/lib/KatranLbStructs.h | 2 ++ katran/lib/tests/KatranLbTest.cpp | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/katran/lib/KatranLb.cpp b/katran/lib/KatranLb.cpp index 53256468c2..a0ad436569 100644 --- a/katran/lib/KatranLb.cpp +++ b/katran/lib/KatranLb.cpp @@ -43,7 +43,7 @@ constexpr folly::StringPiece kEmptyString = ""; KatranLb::KatranLb(const KatranConfig& config) : config_(config), - bpfAdapter_(!config.testing), + bpfAdapter_(config.memlockUnlimited), ctlValues_(kCtlMapSize), standalone_(true), forwardingCores_(config.forwardingCores), diff --git a/katran/lib/KatranLbStructs.h b/katran/lib/KatranLbStructs.h index b2c4c440e5..58099c1244 100644 --- a/katran/lib/KatranLbStructs.h +++ b/katran/lib/KatranLbStructs.h @@ -132,6 +132,7 @@ struct KatranMonitorConfig { * @param uint32_t maxDecapDst maximum number of destinations for inline decap * @param std::string hcInterface interface where we want to attach hc bpf prog * @param KatranMonitorConfig monitorConfig for katran introspection + * @param memlockUnlimited should katran set memlock to unlimited by default * * note about rootMapPath and rootMapPos: * katran has two modes of operation. @@ -174,6 +175,7 @@ struct KatranConfig { std::string hcInterface = kDefaultHcInterface; uint32_t xdpAttachFlags = kNoFlags; struct KatranMonitorConfig monitorConfig; + bool memlockUnlimited = true; }; /** diff --git a/katran/lib/tests/KatranLbTest.cpp b/katran/lib/tests/KatranLbTest.cpp index e4352f35b0..9d58606eed 100644 --- a/katran/lib/tests/KatranLbTest.cpp +++ b/katran/lib/tests/KatranLbTest.cpp @@ -42,7 +42,11 @@ class KatranLbTest : public ::testing::Test { {}, {}, 10, - 4}){}; + 4, + "eth0", + 0, + {}, + false}){} void SetUp() override { v1.address = "fc01::1";