mirror of https://github.com/jetkvm/kvm.git
fix mtu
This commit is contained in:
parent
b3ce961b79
commit
e47442d701
|
|
@ -444,12 +444,22 @@ func (nm *NetlinkManager) ReconcileLink(link *Link, expected []types.IPAddress,
|
||||||
|
|
||||||
expectedGateways := make(map[string]net.IP)
|
expectedGateways := make(map[string]net.IP)
|
||||||
|
|
||||||
|
mtu := link.Attrs().MTU
|
||||||
|
expectedMTU := mtu
|
||||||
// add all expected addresses to the map
|
// add all expected addresses to the map
|
||||||
for _, addr := range expected {
|
for _, addr := range expected {
|
||||||
expectedAddrs[addr.String()] = &addr
|
expectedAddrs[addr.String()] = &addr
|
||||||
if addr.Gateway != nil {
|
if addr.Gateway != nil {
|
||||||
expectedGateways[addr.String()] = addr.Gateway
|
expectedGateways[addr.String()] = addr.Gateway
|
||||||
}
|
}
|
||||||
|
if addr.MTU != 0 {
|
||||||
|
mtu = addr.MTU
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if expectedMTU != mtu {
|
||||||
|
if err := link.SetMTU(expectedMTU); err != nil {
|
||||||
|
nm.logger.Warn().Err(err).Int("expected_mtu", expectedMTU).Int("mtu", mtu).Msg("failed to set MTU")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addrs, err := nm.AddrList(link, family)
|
addrs, err := nm.AddrList(link, family)
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,13 @@ func (l *Link) AddrList(family int) ([]netlink.Addr, error) {
|
||||||
return netlink.AddrList(l.Link, family)
|
return netlink.AddrList(l.Link, family)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Link) SetMTU(mtu int) error {
|
||||||
|
l.mu.Lock()
|
||||||
|
defer l.mu.Unlock()
|
||||||
|
|
||||||
|
return netlink.LinkSetMTU(l.Link, mtu)
|
||||||
|
}
|
||||||
|
|
||||||
// HasGlobalUnicastAddress returns true if the link has a global unicast address
|
// HasGlobalUnicastAddress returns true if the link has a global unicast address
|
||||||
func (l *Link) HasGlobalUnicastAddress() bool {
|
func (l *Link) HasGlobalUnicastAddress() bool {
|
||||||
addrs, err := l.AddrList(AfUnspec)
|
addrs, err := l.AddrList(AfUnspec)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue