Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate synclink code? #166

Open
uhthomas opened this issue May 9, 2024 · 0 comments · May be fixed by #174
Open

duplicate synclink code? #166

uhthomas opened this issue May 9, 2024 · 0 comments · May be fixed by #174

Comments

@uhthomas
Copy link
Collaborator

uhthomas commented May 9, 2024

Describe the bug

Whilst looking at the SyncLink function, I noticed there may be some duplicated code:

link, err := netlink.LinkByName(iface)
if err != nil {
return err
}
if err := netlink.LinkSetUp(link); err != nil {
return err
}

It looks like we already get the link and set it to up later in the function.

link, err := netlink.LinkByName(iface)
if err != nil {
if _, ok := err.(netlink.LinkNotFoundError); !ok {
return err
}
}

if err := netlink.LinkSetUp(link); err != nil {
return err
}

I didn't remove it at the time because I don't know if this is deliberate, or if it can just be removed. I also wonder if the check for whether or not the link exists a second time makes sense? How could it possibly not exist if we just created it? I wonder if this function should be reworked a bit to simply call itself again after the link is created rather than getting the link multiple times.

To Reproduce

N/A

Expected behavior

N/A

Screenshots

N/A

Additional context

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant