Skip to content

Commit

Permalink
add support to specify the default vrf name
Browse files Browse the repository at this point in the history
Summary: Adding the option to specify the default VRF Open/R should return to after starting a thrift instance on a non-default VRF.

Reviewed By: xiangxu1121

Differential Revision: D47784714

fbshipit-source-id: 0911f462daa1d416f94c1eb98dc77b41893425b1
  • Loading branch information
Kyle Sugrue authored and facebook-github-bot committed Jul 26, 2023
1 parent 948efe3 commit 866028e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions openr/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ class Config {
return *getThriftServerConfig().vrf_names();
}

const std::string
getDefaultVrfName() const {
return getThriftServerConfig().default_vrf_name().value_or("");
}

const std::string
getSSLCertPath() const {
auto certPath = getThriftServerConfig().x509_cert_path();
Expand Down
26 changes: 26 additions & 0 deletions openr/config/tests/ConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,30 @@ TEST(ConfigTest, NonDefaultVrfConfigGetter) {
EXPECT_EQ(1, vrfs.size());
EXPECT_EQ(mgmtVrf, vrfs.front());
}

TEST(ConfigTest, DefaultVrfConfigGetter) {
std::string defaultVrf{"defaultVrf"};
thrift::ThriftServerConfig thrift_server_config;
thrift_server_config.default_vrf_name() = defaultVrf;

auto tConfig = getBasicOpenrConfig();
tConfig.thrift_server() = thrift_server_config;

// no soft-drained flag
auto config = Config(tConfig);
const auto vrf = config.getDefaultVrfName();
EXPECT_EQ(defaultVrf, vrf);
}

TEST(ConfigTest, DefaultVrfConfigGetterUnsetValue) {
thrift::ThriftServerConfig thrift_server_config;

auto tConfig = getBasicOpenrConfig();
tConfig.thrift_server() = thrift_server_config;

// no soft-drained flag
auto config = Config(tConfig);
const auto vrf = config.getDefaultVrfName();
EXPECT_EQ("", vrf);
}
} // namespace openr
6 changes: 6 additions & 0 deletions openr/if/OpenrConfig.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ struct ThriftServerConfig {
* `enable_non_default_vrf_thrift_server = true`
*/
13: list<string> vrf_names = [];

/**
* User specified default vrf name to pivot the thrift server to.
* This VRF is only used when pivoting back from a non-default VRF
*/
14: optional string default_vrf_name;
}

struct ThriftClientConfig {
Expand Down

0 comments on commit 866028e

Please sign in to comment.