Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/netlink/knet_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int knet_manager::create_portdev(uint32_t port_id, const std::string &port_name,
if (r != 0)
LOG(FATAL) << __FUNCTION__
<< ": failed to create knet netif for port_id " << port_id;
change_port_status(port_name, false);
change_port_status_unlocked(port_name, false);
}

} catch (std::exception &e) {
Expand Down Expand Up @@ -231,6 +231,19 @@ bool knet_manager::portdev_removed(rtnl_link *link) {
return true;
}

int knet_manager::change_port_status_unlocked(const std::string name,
bool status) {
std::ofstream file("/proc/bcm/knet/link");

if (file.is_open()) {
file << (name + "=" + (status ? "up" : "down"));
file.close();
return 0;
}

return 1;
}

/*
* set netif link state according to open flow link state
* Status is determined via the portstatus/port_desc_reply message
Expand All @@ -249,15 +262,7 @@ int knet_manager::change_port_status(const std::string name, bool status) {
}
}

std::ofstream file("/proc/bcm/knet/link");

if (file.is_open()) {
file << (name + "=" + (status ? "up" : "down"));
file.close();
return 0;
}

return 1;
return change_port_status_unlocked(name, status);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/netlink/knet_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class knet_manager final : public port_manager {
knet_manager(const knet_manager &other) = delete; // non construction-copyable
knet_manager &operator=(const knet_manager &) = delete; // non copyable

int change_port_status_unlocked(const std::string name, bool status);

std::bitset<128> netif_ids_in_use;
int get_next_netif_id();

Expand Down