insomniacslk / dhcp

DHCPv6 and DHCPv4 packet library, client and server written in Go
BSD 3-Clause "New" or "Revised" License
685 stars 168 forks source link

misuse of 'err' to check nil #537

Closed youngifif closed 1 month ago

youngifif commented 1 month ago

In ConfigureInterface(),the defer closure misuse outter 'err' to check nil ,not 'cerr' inside the closure.

pmazzini commented 1 month ago

Integration tests look to be constantly failing now.

youngifif commented 1 month ago

Integration tests look to be constantly failing now.

I think the testCase in TestConfigureInterface is not correct.

I use Debian12 official iproute2 tools to input command as follow: sudo ip addr add 10.20.30.40 dev eth0 sudo ip addr add 10.20.30.40 dev eth0

then i got: RTNETLINK answers: File exists apparently netlink doesn't allow add the same address to one dev multiple times.

Inside TestConfigureInterface(), the func ConfigureInterface(ifname string, netconf *NetConf) calls rt.AddrAdd(iface, &addr.IPNet) with same addr and same iface. So, the last call expects a error of 'file exits'.

youngifif commented 1 month ago

I was misleading by cerr, the original one is correct. I gonna issue a new issue PR about test case