aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet
diff options
context:
space:
mode:
authorAloys Augustin <aloaugus@cisco.com>2021-03-29 22:08:09 +0200
committerDamjan Marion <dmarion@me.com>2021-04-08 21:43:25 +0000
commite39376e4d5aa66a5f8973f4f5470c736afeab4ed (patch)
treec5f9e9698abd2c74f0579fdc3c382c702d1ec3d0 /src/vnet/devices/af_packet
parent7fbc5f9b1d613ba9c2b3ba2211f5de2e7bf43db3 (diff)
devices: af_packet - use netlink to get/set mtu
The /sys filesystem is not always accurate when switching network namespaces. Using netlink should work in more situations. Type: improvement Change-Id: I71611f14319820469ea7794eec5b7c6c70e2be6d Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
Diffstat (limited to 'src/vnet/devices/af_packet')
-rw-r--r--src/vnet/devices/af_packet/af_packet.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index 60a3ccc081f..76677a43092 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -30,6 +30,7 @@
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vnet/ip/ip.h>
+#include <vnet/devices/netlink.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/interface/rx_queue_funcs.h>
@@ -63,22 +64,18 @@ af_packet_eth_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi,
u32 flags)
{
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 (flags == ETHERNET_INTERFACE_FLAG_MTU)
{
- s = format (0, "/sys/class/net/%s/mtu%c", apif->host_if_name, 0);
-
- error = clib_sysfs_write ((char *) s, "%d", hi->max_packet_bytes);
- vec_free (s);
+ error =
+ vnet_netlink_set_link_mtu (apif->host_if_index, hi->max_packet_bytes);
if (error)
{
- vlib_log_err (apm->log_class,
- "sysfs write failed to change MTU: %U",
+ vlib_log_err (apm->log_class, "netlink failed to change MTU: %U",
format_clib_error, error);
clib_error_free (error);
return VNET_API_ERROR_SYSCALL_ERROR_1;
@@ -95,13 +92,10 @@ 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);
+ error = vnet_netlink_get_link_mtu (apif->host_if_index, &apif->host_mtu);
if (error)
{
- vlib_log_err (apm->log_class, "sysfs read failed to get MTU: %U",
+ vlib_log_err (apm->log_class, "netlink failed to get MTU: %U",
format_clib_error, error);
clib_error_free (error);
return VNET_API_ERROR_SYSCALL_ERROR_1;