fix_scope_shadowing_err_in_netboot_ConfigureInterface #538
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here is my long story:
I find that netlink doesn't allow to add the same address to one dev multiple time.
TestConfigureInterface
should fail to add10.20.30.40
toeth0
in second time/second test case ,but it dosen't.So,I think there is a bug in the func
TestConfigureInterface
located in netboot/netconf_integ_test.goAnd the reason
TestConfigureInterface
dosen't fail is that anonther bug located in funcConfigureInterface
To prove that, i use iproute2 tools in debian12 to illustrate the problem as follow:
ip address flush dev enp0s8
To clean all address attached to dev enp0s8
ip address add 10.20.30.40 dev enp0s8
First time,to add 10.20.30.40 succesfully
ip address add 10.20.30.40 dev enp0s8
Second time, an error return and terminal display
RTNETLINK answers: File exists
from iproute2.Same reuslt in my test code which use
rt.AddrAdd(iface,&addr)
twice.After a further reaserch, i believe that the func
netboot.ConfigureInterface
has a bug, too.to be briefly,ConfigureInterface always return nil.
When
line2
return err which is not nil ,the defer closure check theerr != nil
inline1
, then reassign the err to cerr.But
cerr := rt.Close()
is nil in most case ,which means that ConfigureInterface nearly always return nil
even if
line2
return err != nil inside the function .I think we should only reassign
reutrn err
to cerr,whenreturn err
is nil.