f-56: agent: MTU unique network.mtu_vm, underlay à 9000 contrôlé à la création, option DHCP 26 et host_mtu #56

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-23 12:10:01 +02:00
commit 8639c4727f
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
37 changed files with 518 additions and 24 deletions

View file

@ -0,0 +1,52 @@
package configuration
import "fmt"
const (
MTUVM = 1500
MinMTUVM = 1280
MTUUnderlay = 9000
VXLANOverhead = 50
)
type Network struct {
MTUVM int `mapstructure:"mtu_vm"`
AllowMTUVMBelow1500 bool `mapstructure:"allow_mtu_vm_below_1500"`
AllowMTUUnderlayBelow9000 bool `mapstructure:"allow_mtu_underlay_below_9000"`
}
func (n Network) VM() int {
if n.MTUVM == 0 {
return MTUVM
}
return n.MTUVM
}
func (n Network) Validate() error {
switch {
case n.MTUVM > MTUVM:
return fmt.Errorf("network.mtu_vm %d is above %d", n.MTUVM, MTUVM)
case n.MTUVM < MinMTUVM:
return fmt.Errorf("network.mtu_vm %d is below the minimum %d", n.MTUVM, MinMTUVM)
case n.MTUVM < MTUVM && !n.AllowMTUVMBelow1500:
return fmt.Errorf("network.mtu_vm %d is below %d: set network.allow_mtu_vm_below_1500 to allow it", n.MTUVM, MTUVM)
}
return nil
}
func (n Network) CheckUnderlay(iface string, mtu int) error {
if mtu != MTUUnderlay && !n.AllowMTUUnderlayBelow9000 {
return fmt.Errorf("underlay %s has mtu %d, %d expected: set network.allow_mtu_underlay_below_9000 to allow another value", iface, mtu, MTUUnderlay)
}
if mtu < n.VM()+VXLANOverhead {
return fmt.Errorf("underlay %s has mtu %d, below network.mtu_vm %d plus %d bytes of vxlan header", iface, mtu, n.VM(), VXLANOverhead)
}
return nil
}
func (n Network) CheckBridge(iface string, mtu int) error {
if mtu < n.VM() {
return fmt.Errorf("bridge %s has mtu %d, below network.mtu_vm %d", iface, mtu, n.VM())
}
return nil
}