summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet/af_packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/devices/af_packet/af_packet.c')
-rw-r--r--src/vnet/devices/af_packet/af_packet.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index ba6bf3d5a46..2cc0cc70bca 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -83,11 +83,32 @@ af_packet_eth_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi,
clib_error_free (error);
return VNET_API_ERROR_SYSCALL_ERROR_1;
}
+ else
+ apif->host_mtu = hi->max_packet_bytes;
}
return 0;
}
+static int
+af_packet_read_mtu (af_packet_if_t *apif)
+{
+ af_packet_main_t *apm = &af_packet_main;
+ clib_error_t *error;
+ u8 *s;
+ s = format (0, "/sys/class/net/%s/mtu%c", apif->host_if_name, 0);
+ error = clib_sysfs_read ((char *) s, "%d", &apif->host_mtu);
+ vec_free (s);
+ if (error)
+ {
+ vlib_log_err (apm->log_class, "sysfs read failed to get MTU: %U",
+ format_clib_error, error);
+ clib_error_free (error);
+ return VNET_API_ERROR_SYSCALL_ERROR_1;
+ }
+ return 0;
+}
+
static clib_error_t *
af_packet_fd_read_ready (clib_file_t * uf)
{
@@ -338,6 +359,10 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
apif->next_tx_frame = 0;
apif->next_rx_frame = 0;
+ ret = af_packet_read_mtu (apif);
+ if (ret != 0)
+ goto error;
+
if (tm->n_vlib_mains > 1)
clib_spinlock_init (&apif->lockp);