aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorRay Kinsella <ray.kinsella@intel.com>2017-05-15 11:52:43 +0100
committerNeale Ranns <nranns@cisco.com>2017-05-15 18:20:30 +0000
commit7bfa119ead548fcca869bac7e777ce7137dc933b (patch)
treeea03411694d5a4ca9b6b726df7964346da1234c8 /src/vnet/devices
parented76d5f2e383834d8c6aae8ab3b89cf7d2479d0c (diff)
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 <ray.kinsella@intel.com>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/af_packet/af_packet.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index cb52e6daa04..ea52878dbcf 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -20,6 +20,9 @@
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
@@ -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;
}