MCPcopy Create free account
hub / github.com/apache/mesos / VEthFilter

Method VEthFilter

src/tests/environment.cpp:1030–1087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1028{
1029public:
1030 VEthFilter()
1031 {
1032#ifdef __linux__
1033 vector<string> messages;
1034
1035 // Checking if it runs as root.
1036 Result<string> user = os::user();
1037 CHECK_SOME(user);
1038
1039 if (user.get() != "root") {
1040 messages.emplace_back("non-root user");
1041 }
1042
1043 // This command returns `ip utility, iproute2-YYMMDD` where
1044 // `YYMMDD` is a release (snapshot) date of iproute2.
1045 Try<string> ipVersion = os::shell("ip -Version");
1046
1047 // Checking if iproute2 exists.
1048 if (ipVersion.isError()) {
1049 messages.emplace_back("iproute2 not found");
1050 } else {
1051 // Checking if it supports `ip link set ... netns ...`.
1052 const string version = strings::trim(ipVersion.get());
1053 if (version.size() < 6) {
1054 messages.emplace_back("unexpected version");
1055 } else {
1056 Try<int> snapshot = numify<int>(version.substr(version.size() - 6));
1057 if (snapshot.isError()) {
1058 messages.emplace_back("iproute2 version is not an integer");
1059 } else if (snapshot.get() < 100224) {
1060 // Support for `netns` was added to iproute2 in v2.6.33.
1061 messages.emplace_back("iproute2 doesn't support network namespaces");
1062 }
1063 }
1064 }
1065
1066 // Checking if libprocess is bound on loopback address, in that
1067 // case network namespace with veth network won't be able to
1068 // connect to parent process on host network namespace.
1069 // TODO(urbanserj): Improve the network connectivity check.
1070 process::network::inet::Address address = process::address();
1071 if (address.ip.isLoopback()) {
1072 messages.emplace_back("libprocess is bound on loopback address");
1073 }
1074
1075 disabled = !messages.empty();
1076 if (disabled) {
1077 std::cerr
1078 << "-------------------------------------------------------------\n"
1079 << "We can't run any VETH tests:\n"
1080 << strings::join("\n", messages) << "\n"
1081 << "-------------------------------------------------------------"
1082 << std::endl;
1083 }
1084#else
1085 disabled = true;
1086#endif // __linux__
1087 }

Callers

nothing calls this directly

Calls 10

trimFunction · 0.85
isLoopbackMethod · 0.80
userFunction · 0.50
shellFunction · 0.50
addressFunction · 0.50
joinFunction · 0.50
getMethod · 0.45
isErrorMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected