-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NetworkInterface.Linux: take into account physical link status for OperationalStatus and GetIsNetworkAvailable #44867
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,12 +68,9 @@ static NetworkChangeKind ReadNewLinkMessage(struct nlmsghdr* hdr) | |
assert(hdr != NULL); | ||
struct ifinfomsg* ifimsg; | ||
ifimsg = (struct ifinfomsg*)NLMSG_DATA(hdr); | ||
if (ifimsg->ifi_family == AF_INET) | ||
if (ifimsg->ifi_family == AF_UNSPEC) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking for AF_INET was simply wrong before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and on the managed side There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My guess that in the past presence of IPv4 address was considered as "available". Perhaps pre-dates IPv6 |
||
{ | ||
if ((ifimsg->ifi_flags & IFF_UP) != 0) | ||
{ | ||
return LinkAdded; | ||
} | ||
return AvailabilityChanged; | ||
} | ||
|
||
return None; | ||
|
@@ -111,9 +108,6 @@ void SystemNative_ReadEvents(int32_t sock, NetworkChangeEvent onNetworkChange) | |
case RTM_NEWLINK: | ||
onNetworkChange(sock, ReadNewLinkMessage(hdr)); | ||
break; | ||
case RTM_DELLINK: | ||
onNetworkChange(sock, LinkRemoved); | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is handling for RTM_DELLINK no longer needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar |
||
case RTM_NEWROUTE: | ||
case RTM_DELROUTE: | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the IFF_RUNNING reliable? e.g. would it also work for bridges, VPNs and interface types other than ethernet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I think so because they have the UP and RUNNING flags set on my system:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be. for me it looks like:
but I don't know how to reliably tell if the bride is up or now.
Also for you if tun0 and virbr0 is up & running. can you really send traffic to it?
I think I'm ok claiming they are up if Linux claim them as such regardless of that the actual ability to communicate. That still seems like improvement over just using IFF_UP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
RUNNING
forvirbr0
seems appropriate. When I shut down all VMs, status forvirbr0
changes to: