Skip to content

Commit

Permalink
Simplify interface search
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Sep 7, 2023
1 parent 8b108c4 commit 852f7ae
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions cpp/devices/ctapdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,15 @@ bool CTapDriver::Init(const unordered_map<string, string>& const_params)
if (access(string("/sys/class/net/" + BRIDGE_NAME).c_str(), F_OK)) {
spdlog::trace("Checking which interface is available for creating the bridge " + BRIDGE_NAME);

string bridge_interface;
for (const string& iface : interfaces) {
if (IsInterfaceUp(iface)) {
spdlog::trace("Interface " + iface + " is up");

bridge_interface = iface;
break;
}
else {
spdlog::trace("Interface " + iface + " is not available or is not up");
}
}

if (bridge_interface.empty()) {
const auto& it = find_if(interfaces.begin(), interfaces.end(), [] (const string& interface)
{ return IsInterfaceUp(interface); } );
if (it == interfaces.end()) {
spdlog::error("No interface is up, not creating bridge " + BRIDGE_NAME);
return false;
}

const string bridge_interface = *it;

spdlog::info("Creating " + BRIDGE_NAME + " for interface " + bridge_interface);

if (bridge_interface == "eth0") {
Expand Down

0 comments on commit 852f7ae

Please sign in to comment.