aboutsummaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/ethernet/interface.c4
-rw-r--r--vnet/vnet/interface.h6
-rw-r--r--vnet/vnet/interface_cli.c11
-rw-r--r--vnet/vnet/unix/tapcli.c65
-rw-r--r--vnet/vnet/unix/tapcli.h4
5 files changed, 57 insertions, 33 deletions
diff --git a/vnet/vnet/ethernet/interface.c b/vnet/vnet/ethernet/interface.c
index 6bc9f281a15..833ee3008b1 100644
--- a/vnet/vnet/ethernet/interface.c
+++ b/vnet/vnet/ethernet/interface.c
@@ -181,8 +181,8 @@ ethernet_register_interface (vnet_main_t * vnm,
ethernet_setup_node (vnm->vlib_main, hi->output_node_index);
- hi->min_packet_bytes = ETHERNET_MIN_PACKET_BYTES;
- hi->max_packet_bytes = ETHERNET_MAX_PACKET_BYTES;
+ hi->min_packet_bytes = hi->min_supported_packet_bytes = ETHERNET_MIN_PACKET_BYTES;
+ hi->max_packet_bytes = hi->max_supported_packet_bytes = ETHERNET_MAX_PACKET_BYTES;
hi->per_packet_overhead_bytes =
/* preamble */ 8 + /* inter frame gap */ 12;
diff --git a/vnet/vnet/interface.h b/vnet/vnet/interface.h
index fdf23a6bd74..2829a0ccfb3 100644
--- a/vnet/vnet/interface.h
+++ b/vnet/vnet/interface.h
@@ -292,6 +292,12 @@ typedef struct vnet_hw_interface_t {
/* Maximum transmit rate for this interface in bits/sec. */
f64 max_rate_bits_per_sec;
+ /* Smallest packet size supported by this interface. */
+ u32 min_supported_packet_bytes;
+
+ /* Largest packet size supported by this interface. */
+ u32 max_supported_packet_bytes;
+
/* Smallest packet size for this interface. */
u32 min_packet_bytes;
diff --git a/vnet/vnet/interface_cli.c b/vnet/vnet/interface_cli.c
index 31fc9c31ba9..13a7d8cffd9 100644
--- a/vnet/vnet/interface_cli.c
+++ b/vnet/vnet/interface_cli.c
@@ -851,13 +851,14 @@ mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
if (!eif)
return clib_error_return (0, "not supported");
- if (mtu < ETHERNET_MIN_PACKET_BYTES)
+ if (mtu < hi->min_supported_packet_bytes)
return clib_error_return (0, "Invalid mtu (%d): "
"must be >= min pkt bytes (%d)", mtu,
- hi->min_packet_bytes);
+ hi->min_supported_packet_bytes);
- if (mtu > ETHERNET_MAX_PACKET_BYTES)
- return clib_error_return (0, "Invalid mtu (%d): must be <= 9216", mtu);
+ if (mtu > hi->max_supported_packet_bytes)
+ return clib_error_return (0, "Invalid mtu (%d): must be <= (%d)", mtu,
+ hi->max_supported_packet_bytes);
if (hi->max_packet_bytes != mtu)
{
@@ -873,7 +874,7 @@ mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
VLIB_CLI_COMMAND (set_interface_mtu_cmd, static) = {
.path = "set interface mtu",
- .short_help = "set interface mtu <64-9216> <intfc>",
+ .short_help = "set interface mtu <value> <intfc>",
.function = mtu_cmd,
};
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;
diff --git a/vnet/vnet/unix/tapcli.h b/vnet/vnet/unix/tapcli.h
index 00a96c6b7bf..76580bf85d5 100644
--- a/vnet/vnet/unix/tapcli.h
+++ b/vnet/vnet/unix/tapcli.h
@@ -38,4 +38,8 @@ typedef struct {
int vnet_tap_dump_ifs (tapcli_interface_details_t **out_tapids);
+#define TAP_MTU_MIN 68
+#define TAP_MTU_MAX 65535
+#define TAP_MTU_DEFAULT 1500
+
#endif /* __included_tapcli_h__ */