Skip to content

Commit

Permalink
Fix overwritten error var in getMTUByName
Browse files Browse the repository at this point in the history
this prevents the error to be lost which was causing the
panic while accesing a nil var.

Fix #830
  • Loading branch information
mlguerrero12 committed Feb 16, 2023
1 parent fb92605 commit 02adbbb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion plugins/main/macvlan/macvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ func getMTUByName(ifName string, namespace string, inContainer bool) (int, error
var link netlink.Link
var err error
if inContainer {
netns, err := ns.GetNS(namespace)
var netns ns.NetNS
netns, err = ns.GetNS(namespace)
if err != nil {
return 0, fmt.Errorf("failed to open netns %q: %v", netns, err)
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/main/vlan/vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ func getMTUByName(ifName string, namespace string, inContainer bool) (int, error
var link netlink.Link
var err error
if inContainer {
netns, err := ns.GetNS(namespace)
var netns ns.NetNS
netns, err = ns.GetNS(namespace)
if err != nil {
return 0, fmt.Errorf("failed to open netns %q: %v", netns, err)
}
Expand Down

0 comments on commit 02adbbb

Please sign in to comment.