Skip to content

VMNetworkInterface: require both IFF_UP and IFF_RUNNING in isUp() - #78

Open
guillerodriguez wants to merge 1 commit into
masterfrom
fix/vmnetworkinterface-isup-flags
Open

guillerodriguez wants to merge 1 commit into
masterfrom
fix/vmnetworkinterface-isup-flags

Conversation

@guillerodriguez

Copy link
Copy Markdown
Contributor

NetworkInterface.isUp() should return true when the interface is "up and running", so IFF_UP and IFF_RUNNING must both be set. The current implementation returns true when either flag is set. Fix it by requiring both flags, also matching what OpenJDK does.

On Haiku, where there is no IFF_RUNNING, use IFF_LINK instead. Commit c74aac5 avoided this because IFF_LINK can be set even when the interface is down. Now that both flags are required, IFF_UP combined with IFF_LINK means "up and running" as intended.

Fail compilation on other platforms that lack IFF_RUNNING.

Fixes #77 (BZ#42817)

NetworkInterface.isUp() should return true when the interface is
"up and running", so IFF_UP and IFF_RUNNING must both be set. The
current implementation returns true when either flag is set. Fix
it by requiring both flags, also matching what OpenJDK does.

On Haiku, where there is no IFF_RUNNING, use IFF_LINK instead.
Commit c74aac5 avoided this because IFF_LINK can be set even
when the interface is down. Now that both flags are required,
IFF_UP combined with IFF_LINK means "up and running" as intended.

Fail compilation on other platforms that lack IFF_RUNNING.

Fixes #77 (BZ#42817)

Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>
@guillerodriguez

Copy link
Copy Markdown
Contributor Author

@duncanmcqueen if you could re-run the checks from #75 (comment) on Haiku, that would be great.

This should fix the "interface up, cable disconnected" case:

Case IFF_UP only (prev) IFF_UP + IFF_LINK (new)
0. Up and connected up=true up=true
1. Down, cable connected up=false up=false
2. Up, cable disconnected up=true up=false
3. Loopback up=true up=true

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.

NetworkInterface.isUp bug

2 participants