feat(net): Support bridge interfaces (#1528)
Bridge interfaces don't provide linkspeed via ethtool but everything else works the same as with ethernet links. Fixes #1522
This commit is contained in:
parent
d3e37918e5
commit
22af69545a
@ -87,7 +87,7 @@ namespace net {
|
||||
void set_unknown_up(bool unknown = true);
|
||||
|
||||
protected:
|
||||
void check_tuntap();
|
||||
void check_tuntap_or_bridge();
|
||||
bool test_interface() const;
|
||||
string format_speedrate(float bytes_diff, int minwidth) const;
|
||||
void query_ip6();
|
||||
@ -97,6 +97,7 @@ namespace net {
|
||||
link_status m_status{};
|
||||
string m_interface;
|
||||
bool m_tuntap{false};
|
||||
bool m_bridge{false};
|
||||
bool m_unknown_up{false};
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace net {
|
||||
throw network_error("Failed to open socket");
|
||||
}
|
||||
|
||||
check_tuntap();
|
||||
check_tuntap_or_bridge();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,9 +174,9 @@ namespace net {
|
||||
|
||||
/**
|
||||
* Query driver info to check if the
|
||||
* interface is a TUN/TAP device
|
||||
* interface is a TUN/TAP device or BRIDGE
|
||||
*/
|
||||
void network::check_tuntap() {
|
||||
void network::check_tuntap_or_bridge() {
|
||||
struct ethtool_drvinfo driver {};
|
||||
struct ifreq request {};
|
||||
|
||||
@ -204,6 +204,11 @@ namespace net {
|
||||
} else {
|
||||
m_tuntap = false;
|
||||
}
|
||||
|
||||
if (strncmp(driver.driver, "bridge", 6) == 0) {
|
||||
m_bridge = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,6 +253,13 @@ namespace net {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_bridge) {
|
||||
/* If bridge network then link speed cannot be computed
|
||||
* TODO: Identify the physical network in bridge and compute the link speed
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
struct ifreq request {};
|
||||
struct ethtool_cmd data {};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user