Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added support for bridge interface#1528

Merged
patrick96 merged 6 commits into
polybar:masterfrom
spsarolkar:master
Nov 28, 2018
Merged

Added support for bridge interface#1528
patrick96 merged 6 commits into
polybar:masterfrom
spsarolkar:master

Conversation

@spsarolkar

@spsarolkar spsarolkar commented Nov 25, 2018

Copy link
Copy Markdown
Contributor

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

@patrick96 patrick96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/adapters/net.cpp Outdated
@spsarolkar

Copy link
Copy Markdown
Contributor Author

@patrick96 I have made the changes as per your review comments, also please find the output to command ethtool -i br0

▶ ethtool -i br0
driver: bridge
version: 2.3
firmware-version: N/A
expansion-rom-version:
bus-info: N/A
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

Let me know changes required if any

@patrick96 patrick96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done, just a few more changes

Comment thread src/adapters/net.cpp Outdated
m_tuntap = false;
}

if (strncmp(driver.driver, "bridge", 3) == 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (strncmp(driver.driver, "bridge", 3) == 0) {
if (strncmp(driver.driver, "bridge", 6) == 0) {

Otherwise this only compares the first three bytes

Comment thread src/adapters/net.cpp Outdated
Comment thread src/adapters/net.cpp Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@spsarolkar spsarolkar Nov 27, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to the "if-else-if" block at the beginning.

Suggested change
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
*/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @patrick96 , I am not sure if you mean this

Suggested change
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;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find contents of cat /sys/class/net/br0/speed

$ cat /sys/class/net/br0/speed
cat: /sys/class/net/br0/speed: Invalid argument

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ you're right. I knew there was some flaw in my logic ^^

But please put the comment on a separate line

Comment thread src/adapters/net.cpp Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to the "if-else-if" block at the beginning.

Suggested change
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
*/

Comment thread src/adapters/net.cpp Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 patrick96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Looks good now. Thank you very much!

@patrick96 patrick96 merged commit 22af695 into polybar:master Nov 28, 2018
patrick96 added a commit that referenced this pull request Dec 23, 2018
### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants