diff --git a/integration/netconfig/netconfig_test.go b/integration/netconfig/netconfig_test.go index 92284c9..540c8ad 100644 --- a/integration/netconfig/netconfig_test.go +++ b/integration/netconfig/netconfig_test.go @@ -46,7 +46,8 @@ const goldenInterfaces = ` "hardware_addr": "02:73:53:00:b0:0c", "spoof_hardware_addr": "02:73:53:00:b0:aa", "name": "lan0", - "addr": "192.168.42.1/24" + "addr": "192.168.42.1/24", + "mtu": 1492 }, { "name": "wg0", @@ -393,6 +394,9 @@ func TestNetconfig(t *testing.T) { if !strings.Contains(string(link), "link/ether 02:73:53:00:b0:aa") { t.Errorf("lan0 MAC address is not 02:73:53:00:b0:aa") } + if !strings.Contains(string(link), " mtu 1492 ") { + t.Errorf("lan0 MTU is not 1492 (link: %q)", string(link)) + } addrs, err := exec.Command("ip", "-netns", ns, "address", "show", "dev", "uplink0").Output() if err != nil { diff --git a/internal/netconfig/netconfig.go b/internal/netconfig/netconfig.go index 597355a..14e5c03 100644 --- a/internal/netconfig/netconfig.go +++ b/internal/netconfig/netconfig.go @@ -268,6 +268,7 @@ type InterfaceDetails struct { Addr string `json:"addr"` // e.g. 192.168.42.1/24 ExtraAddrs []string `json:"extra_addrs"` // e.g. ["192.168.23.1/24"] ExtraRoutes []Route `json:"extra_routes"` + MTU int `json:"mtu"` // e.g. 1492 for PPPoE connections } type BridgeDetails struct { @@ -422,6 +423,12 @@ func applyInterfaces(dir, root string, cfg InterfaceConfig) error { attr.Name = details.Name } + if details.MTU != 0 { + if err := netlink.LinkSetMTU(l, details.MTU); err != nil { + return fmt.Errorf("LinkSetMTU(%d): %v", details.MTU, err) + } + } + if spoof := details.SpoofHardwareAddr; spoof != "" { hwaddr, err := net.ParseMAC(spoof) if err != nil {