aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/unix/tapcli.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2016-04-24 18:53:42 +0200
committerDamjan Marion <damarion@cisco.com>2016-04-26 16:43:30 +0000
commitf2ba9aadbb627dfdf99c0a13e9dbf9fc0b15cb20 (patch)
treec2d77937e672acca7f8d0e6fab2fe249b1eacfc8 /vnet/vnet/unix/tapcli.c
parente39a7b8347b1055cca6e9cfadcfeca23f8236eb9 (diff)
MTU: set interface mtu tap
This patch introduces standard command line 'set interface mtu' for setting the MTU for tap devices. It allows user to set the mtu in between 68 to 65535 bytes aligned to what linux kernel supports for tun/tap devices. Right now tapcli set the same MTU size for each tap interface. But it should be set and configure to per interface rather than per tap instance. Change-Id: I81b7f3ad95ca56d585907ff8f51d9935a428e01b Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'vnet/vnet/unix/tapcli.c')
-rw-r--r--vnet/vnet/unix/tapcli.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c
index d17d09dcbdb..596f8d184ab 100644
--- a/vnet/vnet/unix/tapcli.c
+++ b/vnet/vnet/unix/tapcli.c
@@ -515,39 +515,48 @@ static u32 tapcli_flag_change (vnet_main_t * vnm,
{
tapcli_main_t *tm = &tapcli_main;
tapcli_interface_t *ti;
- struct ifreq ifr;
- u32 want_promisc;
-
- ti = vec_elt_at_index (tm->tapcli_interfaces, hw->dev_instance);
- clib_memcpy (&ifr, &ti->ifr, sizeof (ifr));
+ ti = vec_elt_at_index (tm->tapcli_interfaces, hw->dev_instance);
- /* get flags, modify to bring up interface... */
- if (ioctl (ti->provision_fd, SIOCGIFFLAGS, &ifr) < 0)
+ if (flags & ETHERNET_INTERFACE_FLAG_MTU)
{
- clib_unix_warning ("Couldn't get interface flags for %s", hw->name);
- return 0;
+ const uword buffer_size = VLIB_BUFFER_DATA_SIZE;
+ tm->mtu_bytes = hw->max_packet_bytes;
+ tm->mtu_buffers = (tm->mtu_bytes + (buffer_size - 1)) / buffer_size;
}
+ else
+ {
+ struct ifreq ifr;
+ u32 want_promisc;
- want_promisc = (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) != 0;
+ memcpy (&ifr, &ti->ifr, sizeof (ifr));
- if (want_promisc == ti->is_promisc)
- return 0;
+ /* get flags, modify to bring up interface... */
+ if (ioctl (ti->provision_fd, SIOCGIFFLAGS, &ifr) < 0)
+ {
+ clib_unix_warning ("Couldn't get interface flags for %s", hw->name);
+ return 0;
+ }
+ want_promisc = (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) != 0;
- if (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL)
- ifr.ifr_flags |= IFF_PROMISC;
- else
- ifr.ifr_flags &= ~(IFF_PROMISC);
+ if (want_promisc == ti->is_promisc)
+ return 0;
- /* get flags, modify to bring up interface... */
- if (ioctl (ti->provision_fd, SIOCSIFFLAGS, &ifr) < 0)
- {
- clib_unix_warning ("Couldn't set interface flags for %s", hw->name);
- return 0;
- }
+ if (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL)
+ ifr.ifr_flags |= IFF_PROMISC;
+ else
+ ifr.ifr_flags &= ~(IFF_PROMISC);
- ti->is_promisc = want_promisc;
+ /* get flags, modify to bring up interface... */
+ if (ioctl (ti->provision_fd, SIOCSIFFLAGS, &ifr) < 0)
+ {
+ clib_unix_warning ("Couldn't set interface flags for %s", hw->name);
+ return 0;
+ }
+
+ ti->is_promisc = want_promisc;
+ }
return 0;
}
@@ -788,7 +797,9 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg,
{
vnet_hw_interface_t * hw;
hw = vnet_get_hw_interface (tm->vnet_main, ti->hw_if_index);
- hw->max_l3_packet_bytes[VLIB_RX] = hw->max_l3_packet_bytes[VLIB_TX] = tm->mtu_bytes - sizeof(ethernet_header_t);
+ hw->min_supported_packet_bytes = TAP_MTU_MIN;
+ hw->max_supported_packet_bytes = TAP_MTU_MAX;
+ hw->max_l3_packet_bytes[VLIB_RX] = hw->max_l3_packet_bytes[VLIB_TX] = hw->max_supported_packet_bytes - sizeof(ethernet_header_t);
ti->sw_if_index = hw->sw_if_index;
if (sw_if_indexp)
*sw_if_indexp = hw->sw_if_index;
@@ -1149,7 +1160,9 @@ tap_connect_command_fn (vlib_main_t * vm,
vnet_hw_interface_t * hw;
hw = vnet_get_hw_interface (tm->vnet_main, ti->hw_if_index);
ti->sw_if_index = hw->sw_if_index;
- hw->max_l3_packet_bytes[VLIB_RX] = hw->max_l3_packet_bytes[VLIB_TX] = tm->mtu_bytes - sizeof(ethernet_header_t);
+ hw->min_supported_packet_bytes = TAP_MTU_MIN;
+ hw->max_supported_packet_bytes = TAP_MTU_MAX;
+ hw->max_l3_packet_bytes[VLIB_RX] = hw->max_l3_packet_bytes[VLIB_TX] = hw->max_supported_packet_bytes - sizeof(ethernet_header_t);
}
ti->active = 1;
@@ -1187,7 +1200,7 @@ tapcli_init (vlib_main_t * vm)
tm->vlib_main = vm;
tm->vnet_main = vnet_get_main();
tm->unix_main = &unix_main;
- tm->mtu_bytes = 4096 + 256;
+ tm->mtu_bytes = TAP_MTU_DEFAULT;
tm->tapcli_interface_index_by_sw_if_index = hash_create (0, sizeof(uword));
tm->tapcli_interface_index_by_unix_fd = hash_create (0, sizeof (uword));
tm->rx_buffers = 0;