Skip to content

Commit

Permalink
Update error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Mar 14, 2024
1 parent 429b5d6 commit 4bac83a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cpp/devices/tap_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,13 @@ string TapDriver::DeleteBridge(int fd) const
string TapDriver::IpLink(bool up)
{
const int fd = socket(PF_INET, SOCK_DGRAM, 0);
if (fd == -1) {
return fmt::format("Can't create socket: {}", strerror(errno));
}

trace(string(">ip link set " + BRIDGE_INTERFACE_NAME + " ") + (up ? "up" : "down"));
const string result = IpLink(fd, BRIDGE_INTERFACE_NAME, up);

close(fd);

return result;
Expand Down

0 comments on commit 4bac83a

Please sign in to comment.