fix: set mtu value regardless of interface state

This PR will fix a bug we encountered in GCE, where the interface was
already up and the MTU value wasn't getting set.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
This commit is contained in:
Spencer Smith 2019-07-31 14:21:47 -04:00 committed by Spencer Smith
parent ac963ad7e1
commit bc5fe085bd

View File

@ -102,21 +102,22 @@ func ifup(ifname string, mtu int) (err error) {
case netlink.OperUnknown:
fallthrough
case netlink.OperDown:
if mtu > 0 {
if err = netlink.LinkSetMTU(link, mtu); err != nil {
return err
}
}
if err = netlink.LinkSetUp(link); err != nil && err != syscall.EEXIST {
log.Printf("im failing here in operdown for %s", ifname)
return err
}
case netlink.OperUp:
return nil
default:
return errors.Errorf("cannot handle current state of %s: %s", ifname, attrs.OperState.String())
}
// Configure MTU if specified
if mtu > 0 {
if err = netlink.LinkSetMTU(link, mtu); err != nil {
return err
}
}
return nil
}