diff options
Diffstat (limited to 'src/vnet/ethernet')
-rw-r--r-- | src/vnet/ethernet/ethernet.h | 7 | ||||
-rw-r--r-- | src/vnet/ethernet/interface.c | 19 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/vnet/ethernet/ethernet.h b/src/vnet/ethernet/ethernet.h index 9621429e4ee..b6adeb6f44d 100644 --- a/src/vnet/ethernet/ethernet.h +++ b/src/vnet/ethernet/ethernet.h @@ -130,7 +130,11 @@ typedef u32 (ethernet_flag_change_function_t) typedef struct { + /* ethernet interface flags change */ ethernet_flag_change_function_t *flag_change; + + /* set MTU callback */ + vnet_interface_set_mtu_function_t *set_mtu; } vnet_eth_if_callbacks_t; #define ETHERNET_MIN_PACKET_BYTES 64 @@ -166,9 +170,6 @@ typedef struct ethernet_interface /* Set interface to accept all packets (promiscuous mode). */ #define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL 1 - /* Change MTU on interface from hw interface structure */ -#define ETHERNET_INTERFACE_FLAG_MTU 2 - /* Callback, e.g. to turn on/off promiscuous mode */ vnet_eth_if_callbacks_t cb; diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c index b1513a79774..bac882228cb 100644 --- a/src/vnet/ethernet/interface.c +++ b/src/vnet/ethernet/interface.c @@ -310,6 +310,18 @@ ethernet_mac_change (vnet_hw_interface_t * hi, return (NULL); } +static clib_error_t * +ethernet_set_mtu (vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 mtu) +{ + ethernet_interface_t *ei = + pool_elt_at_index (ethernet_main.interfaces, hi->hw_instance); + + if (ei->cb.set_mtu) + return ei->cb.set_mtu (vnm, hi, mtu); + + return 0; +} + /* *INDENT-OFF* */ VNET_HW_INTERFACE_CLASS (ethernet_hw_interface_class) = { .name = "Ethernet", @@ -321,6 +333,7 @@ VNET_HW_INTERFACE_CLASS (ethernet_hw_interface_class) = { .build_rewrite = ethernet_build_rewrite, .update_adjacency = ethernet_update_adjacency, .mac_addr_change_function = ethernet_mac_change, + .set_mtu = ethernet_set_mtu, }; /* *INDENT-ON* */ @@ -367,8 +380,8 @@ vnet_eth_register_interface (vnet_main_t *vnm, hi->min_packet_bytes = hi->min_supported_packet_bytes = ETHERNET_MIN_PACKET_BYTES; - hi->max_packet_bytes = hi->max_supported_packet_bytes = - ETHERNET_MAX_PACKET_BYTES; + hi->max_supported_packet_bytes = ETHERNET_MAX_PACKET_BYTES; + hi->max_packet_bytes = em->default_mtu; /* Default ethernet MTU, 9000 unless set by ethernet_config see below */ vnet_sw_interface_set_mtu (vnm, hi->sw_if_index, em->default_mtu); @@ -460,8 +473,6 @@ ethernet_set_flags (vnet_main_t * vnm, u32 hw_if_index, u32 flags) /* fall through */ case ETHERNET_INTERFACE_FLAG_ACCEPT_ALL: ei->flags &= ~ETHERNET_INTERFACE_FLAG_STATUS_L3; - /* fall through */ - case ETHERNET_INTERFACE_FLAG_MTU: return ei->cb.flag_change (vnm, hi, opn_flags); default: return ~0; |