summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/api_errno.h3
-rw-r--r--src/vnet/devices/devices.c8
-rw-r--r--src/vnet/interface_cli.c9
3 files changed, 17 insertions, 3 deletions
diff --git a/src/vnet/api_errno.h b/src/vnet/api_errno.h
index 22522f34be9..c0deb1d0087 100644
--- a/src/vnet/api_errno.h
+++ b/src/vnet/api_errno.h
@@ -114,7 +114,8 @@ _(BD_NOT_MODIFIABLE, -121, "Bridge domain 0 can't be deleted/modified") \
_(BD_ID_EXCEED_MAX, -122, "Bridge domain ID exceed 16M limit") \
_(SUBIF_DOESNT_EXIST, -123, "Subinterface doesn't exist") \
_(L2_MACS_EVENT_CLINET_PRESENT, -124, "Client already exist for L2 MACs events") \
-_(UNSUPPORTED, -125, "Unsupported")
+_(INVALID_QUEUE, -125, "Invalid queue") \
+_(UNSUPPORTED, -126, "Unsupported")
typedef enum
{
diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c
index 2eb8e30e076..a38ecd2d1bb 100644
--- a/src/vnet/devices/devices.c
+++ b/src/vnet/devices/devices.c
@@ -264,6 +264,10 @@ vnet_hw_interface_set_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
(hw->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE) == 0)
return VNET_API_ERROR_UNSUPPORTED;
+ if ((vec_len (hw->input_node_thread_index_by_queue) < queue_id + 1) ||
+ (vec_len (hw->rx_mode_by_queue) < queue_id + 1))
+ return VNET_API_ERROR_INVALID_QUEUE;
+
hw->rx_mode_by_queue[queue_id] = mode;
thread_index = hw->input_node_thread_index_by_queue[queue_id];
vm = vlib_mains[thread_index];
@@ -307,6 +311,10 @@ vnet_hw_interface_get_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
if (hw->input_node_thread_index_by_queue == 0)
return VNET_API_ERROR_INVALID_INTERFACE;
+ if ((vec_len (hw->input_node_thread_index_by_queue) < queue_id + 1) ||
+ (vec_len (hw->rx_mode_by_queue) < queue_id + 1))
+ return VNET_API_ERROR_INVALID_QUEUE;
+
thread_index = hw->input_node_thread_index_by_queue[queue_id];
vm = vlib_mains[thread_index];
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index f37f139b48a..a6680c5b5f2 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -1313,6 +1313,8 @@ set_hw_interface_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
break;
case VNET_API_ERROR_INVALID_INTERFACE:
return clib_error_return (0, "invalid interface");
+ case VNET_API_ERROR_INVALID_QUEUE:
+ return clib_error_return (0, "invalid queue");
default:
return clib_error_return (0, "unknown error");
}
@@ -1334,6 +1336,8 @@ set_hw_interface_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
return clib_error_return (0, "unsupported");
case VNET_API_ERROR_INVALID_INTERFACE:
return clib_error_return (0, "invalid interface");
+ case VNET_API_ERROR_INVALID_QUEUE:
+ return clib_error_return (0, "invalid queue");
default:
return clib_error_return (0, "unknown error");
}
@@ -1353,6 +1357,7 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
u32 queue_id = (u32) ~ 0;
vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
int i;
+ u8 input_queue_id = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -1363,7 +1368,7 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
(line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
;
else if (unformat (line_input, "queue %d", &queue_id))
- ;
+ input_queue_id = 1;
else if (unformat (line_input, "polling"))
mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
else if (unformat (line_input, "interrupt"))
@@ -1389,7 +1394,7 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
hw = vnet_get_hw_interface (vnm, hw_if_index);
- if (queue_id == ~0)
+ if (input_queue_id == 0)
{
for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++)
{