From a2d2e6e7cb12c57cd8f5af64909882bab1dbca19 Mon Sep 17 00:00:00 2001 From: Jianwei Mao Date: Fri, 26 Aug 2022 08:45:23 +0000 Subject: net: add FlagRunning to exactly reflect the states of an interface. 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 #53482 Change-Id: I43796bea1a7f72d1fddfef914efe603c81995e1b GitHub-Last-Rev: 686b5d888e97e9b90cf36ac0c15943eb97e125d4 GitHub-Pull-Request: golang/go#53484 Reviewed-on: https://go-review.googlesource.com/c/go/+/413454 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Ryan Schuster Reviewed-by: Jianwei Mao Reviewed-by: Damien Neil --- src/net/interface_linux.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/net/interface_linux.go') diff --git a/src/net/interface_linux.go b/src/net/interface_linux.go index 441ab2f880..9112ecc854 100644 --- a/src/net/interface_linux.go +++ b/src/net/interface_linux.go @@ -99,6 +99,9 @@ func linkFlags(rawFlags uint32) Flags { if rawFlags&syscall.IFF_UP != 0 { f |= FlagUp } + if rawFlags&syscall.IFF_RUNNING != 0 { + f |= FlagRunning + } if rawFlags&syscall.IFF_BROADCAST != 0 { f |= FlagBroadcast } -- cgit v1.3