aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJohn Lo <loj@cisco.com>2017-09-23 08:59:58 -0400
committerDave Barach <openvpp@barachs.net>2017-09-25 16:07:37 +0000
commit7e9743aef924093c9c25bdf445637434c190d31a (patch)
tree74367e3929a946465d9644ede6a21bd32ee197e5 /src/plugins
parent905c14af2b1464840cea201daed005cb30513683 (diff)
Fix sending GARP/NA on Bonded Interface Active/Backup Link Up/Down
For bonded interface in Active/Backup mode (mode 1), we need to send a GARP/NA packet, if IP address is present, on slave link state change to up or down to help with route convergence. The callback from DPDK happens in a separate thread so we need to make sure RPC call is used to signal the send_garp_na process in the main thread. Also need to fix DPDK polling so the slave links are not polled. Change-Id: If5fd8ea2d28c54dd28726ac403ad366386ce9651 Signed-off-by: John Lo <loj@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dpdk/device/common.c94
-rw-r--r--src/plugins/dpdk/device/node.c2
2 files changed, 72 insertions, 24 deletions
diff --git a/src/plugins/dpdk/device/common.c b/src/plugins/dpdk/device/common.c
index 2707b4d889c..aedc3f5227d 100644
--- a/src/plugins/dpdk/device/common.c
+++ b/src/plugins/dpdk/device/common.c
@@ -181,12 +181,69 @@ dpdk_device_stop (dpdk_device_t * xd)
}
}
+/* Even type for send_garp_na_process */
+enum
+{
+ SEND_GARP_NA = 1,
+} dpdk_send_garp_na_process_event_t;
+
+static vlib_node_registration_t send_garp_na_proc_node;
+
+static uword
+send_garp_na_process (vlib_main_t * vm,
+ vlib_node_runtime_t * rt, vlib_frame_t * f)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ uword event_type, *event_data = 0;
+
+ while (1)
+ {
+ u32 i;
+ uword dpdk_port;
+ vlib_process_wait_for_event (vm);
+ event_type = vlib_process_get_events (vm, &event_data);
+ ASSERT (event_type == SEND_GARP_NA);
+ for (i = 0; i < vec_len (event_data); i++)
+ {
+ dpdk_port = event_data[i];
+ if (i < 5) /* wait 0.2 sec for link to settle, max total 1 sec */
+ vlib_process_suspend (vm, 0.2);
+ dpdk_device_t *xd = &dpdk_main.devices[dpdk_port];
+ u32 hw_if_index = xd->hw_if_index;
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ dpdk_update_link_state (xd, vlib_time_now (vm));
+ send_ip4_garp (vm, hi);
+ send_ip6_na (vm, hi);
+ }
+ vec_reset_length (event_data);
+ }
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (send_garp_na_proc_node, static) = {
+ .function = send_garp_na_process,
+ .type = VLIB_NODE_TYPE_PROCESS,
+ .name = "send-garp-na-process",
+};
+/* *INDENT-ON* */
+
+void vl_api_force_rpc_call_main_thread (void *fp, u8 * data, u32 data_length);
+
+static void
+garp_na_proc_callback (uword * dpdk_port)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ ASSERT (vlib_get_thread_index () == 0);
+ vlib_process_signal_event
+ (vm, send_garp_na_proc_node.index, SEND_GARP_NA, *dpdk_port);
+}
+
always_inline int
dpdk_port_state_callback_inline (uint8_t port_id,
enum rte_eth_event_type type, void *param)
{
struct rte_eth_link link;
- vlib_main_t *vm = vlib_get_main ();
dpdk_device_t *xd = &dpdk_main.devices[port_id];
RTE_SET_USED (param);
@@ -201,32 +258,21 @@ dpdk_port_state_callback_inline (uint8_t port_id,
if (xd->flags & DPDK_DEVICE_FLAG_BOND_SLAVE)
{
- u8 bd_port = xd->bond_port;
+ uword bd_port = xd->bond_port;
int bd_mode = rte_eth_bond_mode_get (bd_port);
-
- if ((link_up && !(xd->flags & DPDK_DEVICE_FLAG_BOND_SLAVE_UP)) ||
- (!link_up && (xd->flags & DPDK_DEVICE_FLAG_BOND_SLAVE_UP)))
+#if 0
+ clib_warning ("Port %d state to %s, "
+ "slave of port %d BondEthernet%d in mode %d",
+ port_id, (link_up) ? "UP" : "DOWN",
+ bd_port, xd->port_id, bd_mode);
+#endif
+ if (bd_mode == BONDING_MODE_ACTIVE_BACKUP)
{
- clib_warning ("Port %d state to %s, "
- "slave of port %d BondEthernet%d in mode %d",
- port_id, (link_up) ? "UP" : "DOWN",
- bd_port, xd->port_id, bd_mode);
- if (bd_mode == BONDING_MODE_ACTIVE_BACKUP)
- {
- rte_eth_link_get_nowait (bd_port, &link);
- if (link.link_status) /* bonded interface up */
- {
- u32 hw_if_index = dpdk_main.devices[bd_port].hw_if_index;
- vlib_process_signal_event
- (vm, send_garp_na_process_node_index, SEND_GARP_NA,
- hw_if_index);
- }
- }
+ vl_api_force_rpc_call_main_thread
+ (garp_na_proc_callback, (u8 *) & bd_port, sizeof (uword));
}
- if (link_up) /* Update slave link status */
- xd->flags |= DPDK_DEVICE_FLAG_BOND_SLAVE_UP;
- else
- xd->flags &= ~DPDK_DEVICE_FLAG_BOND_SLAVE_UP;
+ xd->flags |= link_up ?
+ DPDK_DEVICE_FLAG_BOND_SLAVE_UP : ~DPDK_DEVICE_FLAG_BOND_SLAVE_UP;
}
else /* Should not happen as callback not setup for "normal" links */
{
diff --git a/src/plugins/dpdk/device/node.c b/src/plugins/dpdk/device/node.c
index 74fb8da1f2e..cf8b9699206 100644
--- a/src/plugins/dpdk/device/node.c
+++ b/src/plugins/dpdk/device/node.c
@@ -661,6 +661,8 @@ dpdk_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * f)
foreach_device_and_queue (dq, rt->devices_and_queues)
{
xd = vec_elt_at_index(dm->devices, dq->dev_instance);
+ if (PREDICT_FALSE (xd->flags & DPDK_DEVICE_FLAG_BOND_SLAVE))
+ continue; /* Do not poll slave to a bonded interface */
if (xd->flags & DPDK_DEVICE_FLAG_MAYBE_MULTISEG)
n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 1);
else