Added support for bridge interface#1528
Conversation
patrick96
left a comment
There was a problem hiding this comment.
That was fast, awesome!
I think this is ready to merge after the requested changes but I will do a more thourough review as well.
Could you please also give me the output of ethtool -i br0 on your system, I'm curious what kind of info the interface exposes.
|
@patrick96 I have made the changes as per your review comments, also please find the output to command ▶ ethtool -i br0 Let me know changes required if any |
patrick96
left a comment
There was a problem hiding this comment.
Almost done, just a few more changes
| m_tuntap = false; | ||
| } | ||
|
|
||
| if (strncmp(driver.driver, "bridge", 3) == 0) { |
There was a problem hiding this comment.
| if (strncmp(driver.driver, "bridge", 3) == 0) { | |
| if (strncmp(driver.driver, "bridge", 6) == 0) { |
Otherwise this only compares the first three bytes
| 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 |
There was a problem hiding this comment.
This is not what I meant. We still need to query the interface with ioctl, but we only set m_linkspeed if we are not using a bridge.
There was a problem hiding this comment.
We are already checking the connected status as a part of the call to update
m_connected = network->connected();
And above call makes use of ioctl call to check the status and it works perfectly fine in case of bridge interface.
If we compute the link speed on bridge interface the call fails and false is returned
if (ioctl(*m_socketfd, SIOCETHTOOL, &request) == -1) { return false; }
Do you mean to return true from above if block in case of bridge interface?
There was a problem hiding this comment.
Ah, I see, I though we needed that ioctl to also check if the interface works properly not just to get the linkspeed.
Say, what is the content of /sys/class/net/br0/speed on your system?
There was a problem hiding this comment.
Please add this to the "if-else-if" block at the beginning.
| if(m_bridge) { // If bridge network then link speed cannot be computed TODO: Identify the physical network in bridge and compute the link speed | |
| } else if (m_bridge) { | |
| /* If bridge network then link speed cannot be computed | |
| * TODO: Identify the physical network in bridge and compute the link speed | |
| */ |
There was a problem hiding this comment.
Hi @patrick96 , I am not sure if you mean this
| if(m_bridge) { // If bridge network then link speed cannot be computed TODO: Identify the physical network in bridge and compute the link speed | |
| if (m_tuntap) { | |
| return true; | |
| } else 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; | |
| } else if (!network::query(accumulate)) { | |
| return false; | |
| } |
If we insert if-else-if as above network::query(accumulate) would never get executed. This call calculates the real time upload and download speed for the interface and it works fine for bridge interface.
We need network::query(accumulate) to be executed because this gives some additional information about the current network activity. That's why I have kept below if statement separate after we execute this call.
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;
}
There was a problem hiding this comment.
Please find contents of cat /sys/class/net/br0/speed
$ cat /sys/class/net/br0/speed
cat: /sys/class/net/br0/speed: Invalid argument
There was a problem hiding this comment.
cat: /sys/class/net/br0/speed: Invalid argument
Seems this is consistent with ethtool
If we insert if-else-if as above network::query(accumulate)
No, I meant
if m_tuntap
elseif !network::query
elseif m_bridge
There was a problem hiding this comment.
If I add above if-else-if block, the second if block ‘!network::query’ succeeds and it stops returning true in case of bridge interface. Which proceeds with link speed computation using ‘ioctl’ and fails returning false.
Thats why I have added it as a separate if statement to return true and stop link speed computation
There was a problem hiding this comment.
🤦♂️ you're right. I knew there was some flaw in my logic ^^
But please put the comment on a separate line
| 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 |
There was a problem hiding this comment.
Please add this to the "if-else-if" block at the beginning.
| if(m_bridge) { // If bridge network then link speed cannot be computed TODO: Identify the physical network in bridge and compute the link speed | |
| } else 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 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 |
There was a problem hiding this comment.
| if(m_bridge) { // If bridge network then link speed cannot be computed TODO: Identify the physical network in bridge and compute the link speed | |
| if(m_bridge) { | |
| /* If bridge network then link speed cannot be computed | |
| * TODO: Identify the physical network in bridge and compute the link speed | |
| */ |
patrick96
left a comment
There was a problem hiding this comment.
Alright. Looks good now. Thank you very much!
### Breaking Changes: None ### Changelog **New Config Options** The following config options were added In the `[settings]` section: * `pseudo-transparency` In `internal/cpu`: * `ramp-coreload-spacing`, spacing between elements in `<ramp-coreload>` elements * `%percentage-sum%` in `label`. Shows sum of all percentages In `custom/script`: * `double-click-left` * `double-click-middle` * `double-click-right` In `internal/pulseaudio`: * `interval`, volume increase and decrease steps in percentage points In `internal/memory`: * `bar-swap-used` * `bar-swap-free` * `ramp-swap-used` * `ramp-swap-free` **Deprecations** * `tray-transparent` in the bar section is no longer used. The tray now always uses pseudo-transparency **Features** * volume: adjustable volume steps (#1364), see #1361 * memory: Add progress bars and ramps for swap (#1325) * render: pseudo-transparency (always used in the tray) (#595) * cpu: * Configurable spacing in between coreloads (#1472), see #1389 * Non-normalized cpu load (#1517), see #1516 * script: Double click actions (#1442) * net: Support for bridge interfaces (#1528), see #1522 * token: zero pad tokens when min-width value starts with a `0` (#1341), see #1332 **Fixes** * config: Use font patterns detected on system in sample config (#1350) * net: Disconnected module when SSID is only an emoji (#1371), see #1367 * tray: Tray overlapping with bar (#1392), see #591 * build: Several build errors (#1395, #1454, #1470, polybar/xpp#12, #1493), see #1447, #1469, #750, #1492 * mpd: format-online-prefix not working (#1402), see #1399 * font: Crash for some font-patterns (#1451), see #1435 * script: * Only `%counter%` or `%pid%` token usable, never both (#1456) * click actions with colons in them (#1457), see #984 * renderer: Bar locks up when xorg composite extension is disabled (#1430), see #1425
Currently the polybar fails to detect bridge interface, Issue reference :- #1522.
I have updated the code to add the support for bridge interface
EDIT: Fixes #1522