summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/tap/tap.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2019-06-10 11:20:15 +0200
committerDamjan Marion <dmarion@me.com>2019-06-20 03:39:31 +0000
commit97d54ed43eb69f6ea731c02305ebe0ca0b1a5cc4 (patch)
tree1247bbd99b64313aa7dc9aa9fd51d822a42e31d8 /src/vnet/devices/tap/tap.c
parent3a9f11e6d93c9839c7bb0aaa62662299165123d8 (diff)
tap: add support to configure tap interface host MTU size
This patch adds support to configure host mtu size using api, cli or startup.conf. Type: feature Change-Id: I8ab087d82dbe7dedc498825c1a3ea3fcb2cce030 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices/tap/tap.c')
-rw-r--r--src/vnet/devices/tap/tap.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index 35f1f2a3451..8dc798a3cb3 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -361,6 +361,29 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
}
}
+ if (args->host_mtu_set)
+ {
+ args->error =
+ vnet_netlink_set_link_mtu (vif->ifindex, args->host_mtu_size);
+ if (args->error)
+ {
+ args->rv = VNET_API_ERROR_NETLINK_ERROR;
+ goto error;
+ }
+ }
+ else if (tm->host_mtu_size != 0)
+ {
+ args->error =
+ vnet_netlink_set_link_mtu (vif->ifindex, tm->host_mtu_size);
+ if (args->error)
+ {
+ args->rv = VNET_API_ERROR_NETLINK_ERROR;
+ goto error;
+ }
+ args->host_mtu_set = 1;
+ args->host_mtu_size = tm->host_mtu_size;
+ }
+
/* Set vhost memory table */
i = sizeof (struct vhost_memory) + sizeof (struct vhost_memory_region);
vhost_mem = clib_mem_alloc (i);
@@ -396,6 +419,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
args->host_namespace = 0;
vif->host_bridge = args->host_bridge;
args->host_bridge = 0;
+ vif->host_mtu_size = args->host_mtu_size;
clib_memcpy (vif->host_mac_addr, args->host_mac_addr, 6);
vif->host_ip4_prefix_len = args->host_ip4_prefix_len;
vif->host_ip6_prefix_len = args->host_ip6_prefix_len;
@@ -627,6 +651,7 @@ tap_dump_ifs (tap_interface_details_t ** out_tapids)
if (vif->host_ip6_prefix_len)
clib_memcpy(tapid->host_ip6_addr, &vif->host_ip6_addr, 16);
tapid->host_ip6_prefix_len = vif->host_ip6_prefix_len;
+ tapid->host_mtu_size = vif->host_mtu_size;
);
/* *INDENT-ON* */
@@ -636,6 +661,26 @@ tap_dump_ifs (tap_interface_details_t ** out_tapids)
}
static clib_error_t *
+tap_mtu_config (vlib_main_t * vm, unformat_input_t * input)
+{
+ tap_main_t *tm = &tap_main;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "host-mtu %d", &tm->host_mtu_size))
+ ;
+ else
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+
+ return 0;
+}
+
+/* tap { host-mtu <size> } configuration. */
+VLIB_CONFIG_FUNCTION (tap_mtu_config, "tap");
+
+static clib_error_t *
tap_init (vlib_main_t * vm)
{
tap_main_t *tm = &tap_main;
@@ -644,6 +689,8 @@ tap_init (vlib_main_t * vm)
tm->log_default = vlib_log_register_class ("tap", 0);
vlib_log_debug (tm->log_default, "initialized");
+ tm->host_mtu_size = 0;
+
return error;
}