aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/dev/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/dev/handlers.c')
-rw-r--r--src/vnet/dev/handlers.c82
1 files changed, 58 insertions, 24 deletions
diff --git a/src/vnet/dev/handlers.c b/src/vnet/dev/handlers.c
index 2a55affe3e3..bfacbe27c99 100644
--- a/src/vnet/dev/handlers.c
+++ b/src/vnet/dev/handlers.c
@@ -19,7 +19,8 @@ vnet_dev_port_set_max_frame_size (vnet_main_t *vnm, vnet_hw_interface_t *hw,
u32 frame_size)
{
vlib_main_t *vm = vlib_get_main ();
- vnet_dev_port_t *p = vnet_dev_get_port_from_dev_instance (hw->dev_instance);
+ vnet_dev_instance_t *di = vnet_dev_get_dev_instance (hw->dev_instance);
+ vnet_dev_port_t *p;
vnet_dev_rv_t rv;
vnet_dev_port_cfg_change_req_t req = {
@@ -27,6 +28,11 @@ vnet_dev_port_set_max_frame_size (vnet_main_t *vnm, vnet_hw_interface_t *hw,
.max_rx_frame_size = frame_size,
};
+ p = di->port;
+
+ if (!di->is_primary_if)
+ return vnet_dev_port_err (vm, p, VNET_DEV_ERR_NOT_PRIMARY_INTERFACE, "");
+
log_debug (p->dev, "size %u", frame_size);
rv = vnet_dev_port_cfg_change_req_validate (vm, p, &req);
@@ -49,13 +55,17 @@ vnet_dev_port_eth_flag_change (vnet_main_t *vnm, vnet_hw_interface_t *hw,
u32 flags)
{
vlib_main_t *vm = vlib_get_main ();
- vnet_dev_port_t *p = vnet_dev_get_port_from_dev_instance (hw->dev_instance);
+ vnet_dev_instance_t *di = vnet_dev_get_dev_instance (hw->dev_instance);
+ vnet_dev_port_t *p = di->port;
vnet_dev_rv_t rv;
vnet_dev_port_cfg_change_req_t req = {
.type = VNET_DEV_PORT_CFG_PROMISC_MODE,
};
+ if (!di->is_primary_if)
+ return ~0;
+
switch (flags)
{
case ETHERNET_INTERFACE_FLAG_DEFAULT_L3:
@@ -87,13 +97,17 @@ vnet_dev_port_mac_change (vnet_hw_interface_t *hi, const u8 *old,
const u8 *new)
{
vlib_main_t *vm = vlib_get_main ();
- vnet_dev_port_t *p = vnet_dev_get_port_from_dev_instance (hi->dev_instance);
+ vnet_dev_instance_t *di = vnet_dev_get_dev_instance (hi->dev_instance);
+ vnet_dev_port_t *p = di->port;
vnet_dev_rv_t rv;
vnet_dev_port_cfg_change_req_t req = {
.type = VNET_DEV_PORT_CFG_CHANGE_PRIMARY_HW_ADDR,
};
+ if (!di->is_primary_if)
+ return vnet_dev_port_err (vm, p, VNET_DEV_ERR_NOT_PRIMARY_INTERFACE, "");
+
vnet_dev_set_hw_addr_eth_mac (&req.addr, new);
log_debug (p->dev, "new mac %U", format_vnet_dev_hw_addr, &req.addr);
@@ -116,7 +130,8 @@ vnet_dev_add_del_mac_address (vnet_hw_interface_t *hi, const u8 *address,
u8 is_add)
{
vlib_main_t *vm = vlib_get_main ();
- vnet_dev_port_t *p = vnet_dev_get_port_from_dev_instance (hi->dev_instance);
+ vnet_dev_instance_t *di = vnet_dev_get_dev_instance (hi->dev_instance);
+ vnet_dev_port_t *p = di->port;
vnet_dev_rv_t rv;
vnet_dev_port_cfg_change_req_t req = {
@@ -124,6 +139,9 @@ vnet_dev_add_del_mac_address (vnet_hw_interface_t *hi, const u8 *address,
VNET_DEV_PORT_CFG_REMOVE_SECONDARY_HW_ADDR,
};
+ if (!di->is_primary_if)
+ return vnet_dev_port_err (vm, p, VNET_DEV_ERR_NOT_PRIMARY_INTERFACE, "");
+
vnet_dev_set_hw_addr_eth_mac (&req.addr, address);
log_debug (p->dev, "received (addr %U is_add %u", format_vnet_dev_hw_addr,
@@ -147,10 +165,19 @@ vnet_dev_flow_ops_fn (vnet_main_t *vnm, vnet_flow_dev_op_t op,
u32 dev_instance, u32 flow_index, uword *private_data)
{
vlib_main_t *vm = vlib_get_main ();
- vnet_dev_port_t *p = vnet_dev_get_port_from_dev_instance (dev_instance);
+ vnet_dev_instance_t *di = vnet_dev_get_dev_instance (dev_instance);
+ vnet_dev_port_t *p;
vnet_dev_port_cfg_change_req_t req;
vnet_dev_rv_t rv;
+ if (!di)
+ return VNET_FLOW_ERROR_NO_SUCH_INTERFACE;
+
+ if (di->is_primary_if)
+ return VNET_FLOW_ERROR_NOT_SUPPORTED;
+
+ p = di->port;
+
switch (op)
{
case VNET_FLOW_DEV_OP_ADD_FLOW:
@@ -201,10 +228,12 @@ vnet_dev_interface_set_rss_queues (vnet_main_t *vnm, vnet_hw_interface_t *hi,
void
vnet_dev_clear_hw_interface_counters (u32 instance)
{
- vnet_dev_port_t *port = vnet_dev_get_port_from_dev_instance (instance);
+ vnet_dev_instance_t *di = vnet_dev_get_dev_instance (instance);
vlib_main_t *vm = vlib_get_main ();
- vnet_dev_process_call_port_op_no_rv (vm, port, vnet_dev_port_clear_counters);
+ if (di->is_primary_if)
+ vnet_dev_process_call_port_op_no_rv (vm, di->port,
+ vnet_dev_port_clear_counters);
}
void
@@ -213,44 +242,49 @@ vnet_dev_set_interface_next_node (vnet_main_t *vnm, u32 hw_if_index,
{
vlib_main_t *vm = vlib_get_main ();
vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_dev_port_t *port =
- vnet_dev_get_port_from_dev_instance (hw->dev_instance);
+ vnet_dev_instance_t *di = vnet_dev_get_dev_instance (hw->dev_instance);
+ vnet_dev_port_interface_t *intf;
int runtime_update = 0;
+ if (di->is_primary_if)
+ intf = vnet_dev_port_get_primary_if (di->port);
+ else
+ intf = vnet_dev_port_get_sec_if_by_index (di->port, di->sec_if_index);
+
if (node_index == ~0)
{
- port->intf.redirect_to_node_next_index = 0;
- if (port->intf.feature_arc == 0)
+ intf->redirect_to_node_next_index = 0;
+ if (intf->feature_arc == 0)
{
- port->intf.rx_next_index =
- vnet_dev_default_next_index_by_port_type[port->attr.type];
+ intf->rx_next_index =
+ vnet_dev_default_next_index_by_port_type[di->port->attr.type];
runtime_update = 1;
}
- port->intf.redirect_to_node = 0;
+ intf->redirect_to_node = 0;
}
else
{
u16 next_index = vlib_node_add_next (vlib_get_main (),
port_rx_eth_node.index, node_index);
- port->intf.redirect_to_node_next_index = next_index;
- if (port->intf.feature_arc == 0)
+ intf->redirect_to_node_next_index = next_index;
+ if (intf->feature_arc == 0)
{
- port->intf.rx_next_index = next_index;
+ intf->rx_next_index = next_index;
runtime_update = 1;
}
- port->intf.redirect_to_node = 1;
+ intf->redirect_to_node = 1;
}
- port->intf.rx_next_index =
+ intf->rx_next_index =
node_index == ~0 ?
- vnet_dev_default_next_index_by_port_type[port->attr.type] :
- node_index;
+ vnet_dev_default_next_index_by_port_type[di->port->attr.type] :
+ node_index;
if (runtime_update)
{
- foreach_vnet_dev_port_rx_queue (rxq, port)
+ foreach_vnet_dev_port_rx_queue (rxq, di->port)
vnet_dev_rx_queue_rt_request (
vm, rxq, (vnet_dev_rx_queue_rt_req_t){ .update_next_index = 1 });
- log_debug (port->dev, "runtime update requested due to chgange in "
- "reditect-to-next configuration");
+ log_debug (di->port->dev, "runtime update requested due to chgange in "
+ "reditect-to-next configuration");
}
}