diff options
author | Dave Barach <dave@barachs.net> | 2020-02-26 10:27:08 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-02-26 18:50:35 +0000 |
commit | 5fa4525543b212dd04b4f687722bf7feb1eeb6f9 (patch) | |
tree | acbfb597680d6c2b1102f570b92d28e39afb5e30 /src/vnet/ethernet/interface.c | |
parent | 2fcd265d383a17e74b7d51f26e81bd27f830bf6b (diff) |
ethernet: configure system default ethernet MTU
Type: feature
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I9c2081c56cfbf61df7e5170002f5f65902f49942
Diffstat (limited to 'src/vnet/ethernet/interface.c')
-rw-r--r-- | src/vnet/ethernet/interface.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c index 39e5cfb3cf8..3b9093c6031 100644 --- a/src/vnet/ethernet/interface.c +++ b/src/vnet/ethernet/interface.c @@ -359,8 +359,8 @@ ethernet_register_interface (vnet_main_t * vnm, hi->max_packet_bytes = hi->max_supported_packet_bytes = ETHERNET_MAX_PACKET_BYTES; - /* Standard default ethernet MTU. */ - vnet_sw_interface_set_mtu (vnm, hi->sw_if_index, 9000); + /* Default ethernet MTU, 9000 unless set by ethernet_config see below */ + vnet_sw_interface_set_mtu (vnm, hi->sw_if_index, em->default_mtu); clib_memcpy (ei->address, address, sizeof (ei->address)); vec_add (hi->hw_address, address, sizeof (ei->address)); @@ -1192,6 +1192,29 @@ VLIB_CLI_COMMAND (delete_sub_interface_command, static) = { }; /* *INDENT-ON* */ +static clib_error_t * +ethernet_config (vlib_main_t * vm, unformat_input_t * input) +{ + ethernet_main_t *em = ðernet_main; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "default-mtu %u", &em->default_mtu)) + { + if (em->default_mtu < 64 || em->default_mtu > 9000) + return clib_error_return (0, "default MTU must be >=64, <=9000"); + } + else + { + return clib_error_return (0, "unknown input '%U'", + format_unformat_error, input); + } + } + return 0; +} + +VLIB_CONFIG_FUNCTION (ethernet_config, "ethernet"); + /* * fd.io coding-style-patch-verification: ON * |