-
Notifications
You must be signed in to change notification settings - Fork 18k
net: add FlagRunning to the Flags of struct Interface, to exactly reflect the states of an interface or NIC #53482
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
Comments
…lect the states of an interface or NIC. And a new flag(FlagRunning), and correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC through the FlagUp flag only. Fixes golang#53482 Signed-off-by: Jianwei Mao <maojianwei2012@126.com>
Change https://go.dev/cl/413454 mentions this issue: |
…lect the states of an interface or NIC. And a new flag(FlagRunning), and correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC through the FlagUp flag only. Fixes golang#53482 Signed-off-by: Jianwei Mao <maojianwei2012@126.com>
Turning this issue into a proposal. |
I see you have marked the issue as a proposal, thanks @ianlancetaylor . |
I'm a little confused about inventing a new flag that does not appear in the
The problem seems to be that we want to distinguish eno3 and eno4, where both have the UP flag set but one is 'state DOWN' and the other is 'state UP'. So the suggestion is to add a new flag RUNNING that means 'state UP'. Is 'RUNNING' the right name for that? Is there a RUNNING bit on other systems that it might collide with? |
Hi, @rsc , You get the core problem correctly, thanks :) There are three reasons to choose the 'RUNNING' name:
linkFlags() function:
'IFF_RUNNING' flag, constant:
'IFF_DRV_RUNNING' flag, the meaning is same as 'IFF_RUNNING':
So, in my opinion, it is good to choose the Thanks, |
Just to confirm: it sounds like the What bit is it reporting when it says 'state UNKNOWN' like in the very first comment's:
? Also, looking at PR #53484, does Windows ever distinguish UP from RUNNING? Do we need to do something more precise there? |
Hi, @rsc Yes, that is correct and reasonable.
For the lo(loopback) interface, it report
Windows doesn't distinguish UP from RUNNING, so we don't need to do more things, it is ok to sync the UP & RUNNING state.
Thanks, |
This proposal has been added to the active column of the proposals project |
Sounds like the bit exists and is called Running, so adding it here should be uncontroversial. |
Based on the discussion above, this proposal seems like a likely accept. |
Yes, the bit is right here, and we want to provide it to everyone for using :) Thanks, |
No change in consensus, so accepted. 🎉 |
Many thanks, wish the code will continue to be reviewed :) https://go-review.googlesource.com/c/go/+/413454 Github pull request: #53484 |
Correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC through the FlagUp flag only. Fixes golang#53482 Signed-off-by: Jianwei Mao <maojianwei2012@126.com>
Correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC through the FlagUp flag only. Fixes golang#53482 Signed-off-by: Jianwei Mao <maojianwei2012@126.com>
Correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC through the FlagUp flag only. Fixes golang#53482 Signed-off-by: Jianwei Mao <maojianwei2012@126.com>
Correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC by the FlagUp flag alone. Fixes golang#53482 Signed-off-by: Jianwei Mao <maojianwei2012@126.com>
Correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC by the FlagUp flag alone. Fixes golang#53482
Correctly set this flag while parsing the syscall result. The FlagUp flag can not distinguish the following situations: 1. interface is plugged, automatically up, and in running(UP) state 2. interface is not plugged, administratively or manually set to up, but in DOWN state So, We can't distinguish the state of a NIC by the FlagUp flag alone. Fixes golang#53482
Hi, @ianlancetaylor and @rsc , many thanks for your help, this PR has finally merged :) Will this commit be automatically released in Go 1.20 ? Cheers, |
yes, everything in master goes into the next release |
Thanks, @seankhliao :) |
Change https://go.dev/cl/451420 mentions this issue: |
For #50101 For #51152 For #53482 For #55301 For #56515 Change-Id: I11edeb4be0a7f80fb72fd7680a3407d081f83b8b Reviewed-on: https://go-review.googlesource.com/c/go/+/451420 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Hi, team,
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, it is.
What operating system and processor architecture are you using (
go env
)?Ubuntu 20.04
What did you do?
I inspect the flags of an Interface object to check if this NIC is up and in running state.
But, althought some NIC(s) have the FlagUp flag, when I check again by
ip addr | grep state
, I found they are in DOWN state actually.The situation is: there is no fiber or twisted-pair cable plugged in the NIC, and I run
ip link set XXX up
to set it up administratively and manually.Environment:
The output of
ip addr | grep state
, please pay attention to thestate DOWN
words:What did you expect to see?
I expect to see NICs(ens1f0/eno1/ens1f1/eno2/eno3) and NICs(ens2f0,ens2f1) are all down, and only NIC(eno4) is up.
What did you see instead?
I actually see NICs(ens1f0/eno1/ens1f1/eno2/eno3) and NIC(eno4) are up, and NICs(ens2f0,ens2f1) are down, the output of the above snippet program is as follow:
Please pay attention to the
flags: up
words.In conclusion
We can't distinguish the state of a NIC through only the FlagUp flag in the following situations:
I have fixed this bug, and will send a pull request soon :)
I add a new flag to exactly reflect the states of an interface or NIC, as the title says.
And I get the right and exact report as the follow output, you can see only NIC(lo/eno4) are reported in running state:
Please pay attention to the tailing
running
word.In another words, the NIC(s) which only have up flag but no running flag, are set up administratively or manually.
Thanks,
Mao
The text was updated successfully, but these errors were encountered: