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
proposal: net: add FlagRunning to the Flags of struct Interface, to exactly reflect the states of an interface or NIC #53482
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, |
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: