Use net.InterfaceByName to retrieve runsc DUT's device ID.

PiperOrigin-RevId: 413941742
This commit is contained in:
Zeling Feng
2021-12-03 08:31:34 -08:00
committed by gVisor bot
parent 74536aba2c
commit 791b9428a6
2 changed files with 4 additions and 6 deletions
-1
View File
@@ -29,5 +29,4 @@ go_binary(
name = "devid",
testonly = True,
srcs = ["devid.go"],
deps = ["@com_github_vishvananda_netlink//:go_default_library"],
)
+4 -5
View File
@@ -21,15 +21,14 @@ package main
import (
"fmt"
"log"
"net"
"os"
"github.com/vishvananda/netlink"
)
func main() {
link, err := netlink.LinkByName(os.Args[1])
iface, err := net.InterfaceByName(os.Args[1])
if err != nil {
log.Fatalf("could not find the link: %s", err)
log.Fatalf("could not find link %s: %s", os.Args[1], err)
}
fmt.Printf("%d", link.Attrs().Index)
fmt.Printf("%d", iface.Index)
}