mirror of https://github.com/jetkvm/kvm.git
Bring up loopback interface via Netlink
This commit is contained in:
parent
63b3ef0151
commit
f29017b7f4
20
network.go
20
network.go
|
@ -25,6 +25,23 @@ type LocalIpInfo struct {
|
|||
MAC string
|
||||
}
|
||||
|
||||
func checkLoopback() {
|
||||
iface, err := netlink.LinkByName("lo")
|
||||
if err != nil {
|
||||
fmt.Printf("failed to get lo interface: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
if iface.Attrs().OperState != netlink.OperUp {
|
||||
fmt.Printf("lo is not up, bringing it up\n")
|
||||
err = netlink.LinkSetUp(iface)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to bring lo up: %v\n", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkNetworkState() {
|
||||
iface, err := netlink.LinkByName("eth0")
|
||||
if err != nil {
|
||||
|
@ -102,6 +119,9 @@ func init() {
|
|||
return
|
||||
}
|
||||
|
||||
//Start loopback before launching network task
|
||||
checkLoopback()
|
||||
|
||||
go func() {
|
||||
waitCtrlClientConnected()
|
||||
checkNetworkState()
|
||||
|
|
Loading…
Reference in New Issue