aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet/af_packet.c
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2021-02-01 17:13:59 +0100
committerDamjan Marion <dmarion@me.com>2021-02-05 19:02:38 +0000
commitffc6bdcd38b8209050671d3d86f943c37887a7b7 (patch)
tree4150c463c4b3bfbc91751d55ec272dc81d421289 /src/vnet/devices/af_packet/af_packet.c
parent5398dfb2592d525018997a991a4f7bfde515adc4 (diff)
devices: af-packet gso mtu
Type: fix Set the GSO flag when buffer length exceeds the linux mtu. Don't listen for mtu changes on linux side for now. This also fixes a TX issue, as we only search for valid frames on tx to the extent of n_left, we might stay stuck. Change-Id: Idf0bdd88990254a614962c2f7bc3e0292ccfd61a Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
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);