From 7bfa119ead548fcca869bac7e777ce7137dc933b Mon Sep 17 00:00:00 2001 From: Ray Kinsella Date: Mon, 15 May 2017 11:52:43 +0100 Subject: af_packet: support changing the mtu size Added support to the af_packet device to change the MTU size. Change-Id: I9c9e1e17323721f3efccf70a10b753e12eef94d5 Signed-off-by: Ray Kinsella --- src/vnet/devices/af_packet/af_packet.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c index cb52e6da..ea52878d 100644 --- a/src/vnet/devices/af_packet/af_packet.c +++ b/src/vnet/devices/af_packet/af_packet.c @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include #include #include @@ -61,7 +64,26 @@ static u32 af_packet_eth_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags) { - /* nothing for now */ + clib_error_t *error; + u8 *s; + af_packet_main_t *apm = &af_packet_main; + af_packet_if_t *apif = + pool_elt_at_index (apm->interfaces, hi->dev_instance); + + if (ETHERNET_INTERFACE_FLAG_MTU == (flags & ETHERNET_INTERFACE_FLAG_MTU)) + { + s = format (0, "/sys/class/net/%s/mtu%c", apif->host_if_name, 0); + + error = vlib_sysfs_write ((char *) s, "%d", hi->max_packet_bytes); + vec_free (s); + + if (error) + { + clib_error_report (error); + return VNET_API_ERROR_SYSCALL_ERROR_1; + } + } + return 0; } -- cgit 1.2.3-korg