From 961a741d5d554f7a2d7017947db8e71be526809d Mon Sep 17 00:00:00 2001 From: youngifif Date: Mon, 3 Jun 2024 15:22:39 +0800 Subject: [PATCH 1/2] In ConfigureInterface(),the defer closure misuse outter 'err' to check nil ,not 'cerr' inside the closure. Signed-off-by: youngifif --- netboot/netconf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netboot/netconf.go b/netboot/netconf.go index 6370b5dc..80933044 100644 --- a/netboot/netconf.go +++ b/netboot/netconf.go @@ -192,7 +192,7 @@ func ConfigureInterface(ifname string, netconf *NetConf) (err error) { return err } defer func() { - if cerr := rt.Close(); err != nil { + if cerr := rt.Close(); cerr != nil { err = cerr } }() From 96ec2a8971fb57fcf47ccd03f56131ee09cda4ee Mon Sep 17 00:00:00 2001 From: youngifif Date: Mon, 3 Jun 2024 21:52:14 +0800 Subject: [PATCH 2/2] fix testCase in TestConfigureInterface() when netlink return 'file exists' error Signed-off-by: youngifif --- netboot/netconf_integ_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netboot/netconf_integ_test.go b/netboot/netconf_integ_test.go index a0af291c..d537f920 100644 --- a/netboot/netconf_integ_test.go +++ b/netboot/netconf_integ_test.go @@ -55,7 +55,7 @@ func TestConfigureInterface(t *testing.T) { Name: "IP addr, DNS, and routers", NetConf: &NetConf{ Addresses: []AddrConf{ - AddrConf{IPNet: net.IPNet{IP: net.ParseIP("10.20.30.40")}}, + AddrConf{IPNet: net.IPNet{IP: net.ParseIP("10.20.30.41")}}, }, DNSServers: []net.IP{net.ParseIP("8.8.8.8")}, DNSSearchList: []string{"slackware.it"},