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:
parent
d1b50d546c
commit
8cb5117cb2
37 changed files with 518 additions and 24 deletions
|
|
@ -31,6 +31,7 @@ func GenerateConfig(c Config) (string, error) {
|
|||
fmt.Fprintf(&sb, "dhcp-option=3\n")
|
||||
}
|
||||
fmt.Fprintf(&sb, "dhcp-option=6,1.1.1.1,8.8.8.8\n")
|
||||
fmt.Fprintf(&sb, "dhcp-option=26,%d\n", c.interfaceMTU())
|
||||
fmt.Fprintf(&sb, "dhcp-hostsdir=%s\n", HostsDir(c.ConfDir, c.Name))
|
||||
fmt.Fprintf(&sb, "dhcp-optsdir=%s\n", OptsDir(c.ConfDir, c.Name))
|
||||
|
||||
|
|
@ -44,6 +45,13 @@ func GenerateConfig(c Config) (string, error) {
|
|||
return outPath, os.WriteFile(outPath, []byte(sb.String()), 0644)
|
||||
}
|
||||
|
||||
func (c Config) interfaceMTU() int {
|
||||
if c.MTU == 0 {
|
||||
return 1500
|
||||
}
|
||||
return c.MTU
|
||||
}
|
||||
|
||||
func classlessRoutes(c Config) []string {
|
||||
nextHop := c.InterfaceIP.String()
|
||||
|
||||
|
|
|
|||
20
internal/dhcp/mtu_test.go
Normal file
20
internal/dhcp/mtu_test.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package dhcp
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenerateConfig_CarriesTheInterfaceMTU(t *testing.T) {
|
||||
c := newConf(t, "192.168.1.0/29")
|
||||
c.MTU = 1450
|
||||
if content := confLines(t, c); !strings.Contains(content, "dhcp-option=26,1450\n") {
|
||||
t.Errorf("option 26 absente :\n%s", content)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateConfig_InterfaceMTUIs1500WhenUnset(t *testing.T) {
|
||||
if content := confLines(t, newConf(t, "192.168.1.0/29")); !strings.Contains(content, "dhcp-option=26,1500\n") {
|
||||
t.Errorf("option 26 absente :\n%s", content)
|
||||
}
|
||||
}
|
||||
|
|
@ -15,4 +15,5 @@ type Config struct {
|
|||
ConfDir string
|
||||
Listen string
|
||||
Except string
|
||||
MTU int
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue