summaryrefslogtreecommitdiffhomepage
path: root/netboot/rtnetlink_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'netboot/rtnetlink_linux.go')
-rw-r--r--netboot/rtnetlink_linux.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/netboot/rtnetlink_linux.go b/netboot/rtnetlink_linux.go
index 41f5b3e..f6886f8 100644
--- a/netboot/rtnetlink_linux.go
+++ b/netboot/rtnetlink_linux.go
@@ -1,6 +1,10 @@
package netboot
-import "github.com/jsimonetti/rtnetlink"
+import (
+ "log"
+
+ "github.com/jsimonetti/rtnetlink"
+)
// getOperState returns the operational state for the given interface index.
func getOperState(iface int) (rtnetlink.OperationalState, error) {
@@ -8,6 +12,13 @@ func getOperState(iface int) (rtnetlink.OperationalState, error) {
if err != nil {
return 0, err
}
+ defer func() {
+ err := conn.Close()
+ if err != nil {
+ log.Printf("failed to close rtnetlink connection: %v", err)
+ }
+ }()
+
msg, err := conn.Link.Get(uint32(iface))
if err != nil {
return 0, err