summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorElias Rudberg <elias.rudberg@bahnhof.net>2020-05-07 14:29:21 +0200
committerElias Rudberg <elias.rudberg@bahnhof.net>2020-05-07 14:29:21 +0200
commit92e1b83a39458f98ff649883334b153f03af603b (patch)
treefe7a6accac254a3151081b5fccc27c7933d9e273 /src
parenta1e03d4da71a2452c1e5da399d96c51f1b487cad (diff)
lacp: fix regarding vm arg for vlib_time_now calls
Use thread-specific vlib_main_t *vm pointers to avoid problems with different threads accessing the same vlib_main_t data structure. This avoids assertion failure when vlib_time_now() is called with a vm corresponding to a different thread. Type: fix Signed-off-by: Elias Rudberg <elias.rudberg@bahnhof.net> Change-Id: I359596ecff86e03d57aa8d2330f77bf9a913485f
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lacp/input.c15
-rw-r--r--src/plugins/lacp/lacp.c14
-rw-r--r--src/plugins/lacp/mux_machine.c13
-rw-r--r--src/plugins/lacp/ptx_machine.c11
-rw-r--r--src/plugins/lacp/rx_machine.c11
-rw-r--r--src/plugins/lacp/tx_machine.c5
6 files changed, 26 insertions, 43 deletions
diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c
index ccefc20e7b2..a75c3b2aa4c 100644
--- a/src/plugins/lacp/input.c
+++ b/src/plugins/lacp/input.c
@@ -62,7 +62,7 @@ marker_fill_request_pdu (marker_pdu_t * marker, slave_if_t * sif)
}
static void
-send_ethernet_marker_response_pdu (slave_if_t * sif)
+send_ethernet_marker_response_pdu (vlib_main_t * vm, slave_if_t * sif)
{
lacp_main_t *lm = &lacp_main;
u32 *to_next;
@@ -71,7 +71,6 @@ send_ethernet_marker_response_pdu (slave_if_t * sif)
u32 bi0;
vlib_buffer_t *b0;
vlib_frame_t *f;
- vlib_main_t *vm = lm->vlib_main;
vnet_main_t *vnm = lm->vnet_main;
/*
@@ -109,7 +108,7 @@ send_ethernet_marker_response_pdu (slave_if_t * sif)
f->n_vectors = 1;
vlib_put_frame_to_node (vm, hw->output_node_index, f);
- sif->last_marker_pdu_sent_time = vlib_time_now (lm->vlib_main);
+ sif->last_marker_pdu_sent_time = vlib_time_now (vm);
sif->marker_pdu_sent++;
}
@@ -126,7 +125,7 @@ handle_marker_protocol (vlib_main_t * vm, slave_if_t * sif)
(marker->terminator.tlv_length != 0))
return (LACP_ERROR_BAD_TLV);
- send_ethernet_marker_response_pdu (sif);
+ send_ethernet_marker_response_pdu (vm, sif);
return LACP_ERROR_NONE;
}
@@ -138,7 +137,6 @@ lacp_error_t
lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
{
bond_main_t *bm = &bond_main;
- lacp_main_t *lm = &lacp_main;
slave_if_t *sif;
uword nbytes;
lacp_error_t e;
@@ -157,7 +155,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
marker = (marker_pdu_t *) (b0->data + b0->current_data);
if (marker->subtype == MARKER_SUBTYPE)
{
- sif->last_marker_pdu_recd_time = vlib_time_now (lm->vlib_main);
+ sif->last_marker_pdu_recd_time = vlib_time_now (vm);
if (sif->last_marker_pkt)
_vec_len (sif->last_marker_pkt) = 0;
vec_validate (sif->last_marker_pkt,
@@ -195,7 +193,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
nbytes = vlib_buffer_contents (vm, bi0, sif->last_rx_pkt);
ASSERT (nbytes <= vec_len (sif->last_rx_pkt));
- sif->last_lacpdu_recd_time = vlib_time_now (lm->vlib_main);
+ sif->last_lacpdu_recd_time = vlib_time_now (vm);
if (nbytes < sizeof (lacp_pdu_t))
{
sif->bad_pdu_received++;
@@ -209,8 +207,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
(sif->last_packet_signature == last_packet_signature) &&
((sif->actor.state & LACP_STEADY_STATE) == LACP_STEADY_STATE))
{
- lacp_start_current_while_timer (lm->vlib_main, sif,
- sif->ttl_in_seconds);
+ lacp_start_current_while_timer (vm, sif, sif->ttl_in_seconds);
e = LACP_ERROR_CACHE_HIT;
}
else
diff --git a/src/plugins/lacp/lacp.c b/src/plugins/lacp/lacp.c
index e789de52911..01d8e7b25e0 100644
--- a/src/plugins/lacp/lacp.c
+++ b/src/plugins/lacp/lacp.c
@@ -42,7 +42,7 @@ lacp_fill_pdu (lacp_pdu_t * lacpdu, slave_if_t * sif)
* send a lacp pkt on an ethernet interface
*/
static void
-lacp_send_ethernet_lacp_pdu (slave_if_t * sif)
+lacp_send_ethernet_lacp_pdu (vlib_main_t * vm, slave_if_t * sif)
{
lacp_main_t *lm = &lacp_main;
u32 *to_next;
@@ -51,7 +51,6 @@ lacp_send_ethernet_lacp_pdu (slave_if_t * sif)
u32 bi0;
vlib_buffer_t *b0;
vlib_frame_t *f;
- vlib_main_t *vm = lm->vlib_main;
vnet_main_t *vnm = lm->vnet_main;
/*
@@ -90,7 +89,7 @@ lacp_send_ethernet_lacp_pdu (slave_if_t * sif)
vlib_put_frame_to_node (vm, hw->output_node_index, f);
- sif->last_lacpdu_sent_time = vlib_time_now (lm->vlib_main);
+ sif->last_lacpdu_sent_time = vlib_time_now (vm);
sif->pdu_sent++;
}
@@ -127,7 +126,7 @@ lacp_send_lacp_pdu (vlib_main_t * vm, slave_if_t * sif)
switch (sif->packet_template_index)
{
case LACP_PACKET_TEMPLATE_ETHERNET:
- lacp_send_ethernet_lacp_pdu (sif);
+ lacp_send_ethernet_lacp_pdu (vm, sif);
break;
default:
@@ -139,7 +138,6 @@ void
lacp_periodic (vlib_main_t * vm)
{
bond_main_t *bm = &bond_main;
- lacp_main_t *lm = &lacp_main;
slave_if_t *sif;
bond_if_t *bif;
u8 actor_state, partner_state;
@@ -153,20 +151,20 @@ lacp_periodic (vlib_main_t * vm)
actor_state = sif->actor.state;
partner_state = sif->partner.state;
if (lacp_timer_is_running (sif->current_while_timer) &&
- lacp_timer_is_expired (lm->vlib_main, sif->current_while_timer))
+ lacp_timer_is_expired (vm, sif->current_while_timer))
{
lacp_machine_dispatch (&lacp_rx_machine, vm, sif,
LACP_RX_EVENT_TIMER_EXPIRED, &sif->rx_state);
}
if (lacp_timer_is_running (sif->periodic_timer) &&
- lacp_timer_is_expired (lm->vlib_main, sif->periodic_timer))
+ lacp_timer_is_expired (vm, sif->periodic_timer))
{
lacp_machine_dispatch (&lacp_ptx_machine, vm, sif,
LACP_PTX_EVENT_TIMER_EXPIRED, &sif->ptx_state);
}
if (lacp_timer_is_running (sif->wait_while_timer) &&
- lacp_timer_is_expired (lm->vlib_main, sif->wait_while_timer))
+ lacp_timer_is_expired (vm, sif->wait_while_timer))
{
sif->ready_n = 1;
lacp_stop_timer (&sif->wait_while_timer);
diff --git a/src/plugins/lacp/mux_machine.c b/src/plugins/lacp/mux_machine.c
index bbe452da454..6a5549077a2 100644
--- a/src/plugins/lacp/mux_machine.c
+++ b/src/plugins/lacp/mux_machine.c
@@ -98,14 +98,13 @@ lacp_mux_action_detached (void *p1, void *p2)
{
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
- lacp_main_t *lm = &lacp_main;
lacp_detach_mux_from_aggregator (vm, sif);
sif->actor.state &= ~LACP_STATE_COLLECTING;
bond_disable_collecting_distributing (vm, sif);
sif->actor.state &= ~LACP_STATE_DISTRIBUTING;
sif->ntt = 1;
- lacp_start_periodic_timer (lm->vlib_main, sif, 0);
+ lacp_start_periodic_timer (vm, sif, 0);
if (sif->selected == LACP_PORT_SELECTED)
lacp_machine_dispatch (&lacp_mux_machine, vm, sif,
@@ -123,14 +122,13 @@ lacp_mux_action_attached (void *p1, void *p2)
{
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
- lacp_main_t *lm = &lacp_main;
lacp_attach_mux_to_aggregator (vm, sif);
sif->actor.state &= ~LACP_STATE_COLLECTING;
bond_disable_collecting_distributing (vm, sif);
sif->actor.state &= ~LACP_STATE_DISTRIBUTING;
sif->ntt = 1;
- lacp_start_periodic_timer (lm->vlib_main, sif, 0);
+ lacp_start_periodic_timer (vm, sif, 0);
if ((sif->selected == LACP_PORT_UNSELECTED) ||
(sif->selected == LACP_PORT_STANDBY))
@@ -149,11 +147,9 @@ lacp_mux_action_waiting (void *p1, void *p2)
{
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
- lacp_main_t *lm = &lacp_main;
if (!lacp_timer_is_running (sif->wait_while_timer))
- lacp_start_wait_while_timer (lm->vlib_main, sif,
- LACP_AGGREGATE_WAIT_TIME);
+ lacp_start_wait_while_timer (vm, sif, LACP_AGGREGATE_WAIT_TIME);
if ((sif->selected == LACP_PORT_SELECTED) && sif->ready)
lacp_machine_dispatch (&lacp_mux_machine, vm, sif,
@@ -171,13 +167,12 @@ lacp_mux_action_collecting_distributing (void *p1, void *p2)
{
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
- lacp_main_t *lm = &lacp_main;
sif->actor.state |= LACP_STATE_SYNCHRONIZATION | LACP_STATE_COLLECTING |
LACP_STATE_DISTRIBUTING;
bond_enable_collecting_distributing (vm, sif);
sif->ntt = 1;
- lacp_start_periodic_timer (lm->vlib_main, sif, 0);
+ lacp_start_periodic_timer (vm, sif, 0);
if ((sif->selected == LACP_PORT_UNSELECTED) ||
(sif->selected == LACP_PORT_STANDBY) ||
!(sif->partner.state & LACP_STATE_SYNCHRONIZATION))
diff --git a/src/plugins/lacp/ptx_machine.c b/src/plugins/lacp/ptx_machine.c
index bd4150fe39f..941fc58cbc4 100644
--- a/src/plugins/lacp/ptx_machine.c
+++ b/src/plugins/lacp/ptx_machine.c
@@ -88,7 +88,6 @@ lacp_ptx_action_slow_periodic (void *p1, void *p2)
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
u8 timer_expired;
- lacp_main_t *lm = &lacp_main;
if (!(sif->partner.state & LACP_STATE_LACP_ACTIVITY) &&
!(sif->actor.state & LACP_STATE_LACP_ACTIVITY))
@@ -97,12 +96,12 @@ lacp_ptx_action_slow_periodic (void *p1, void *p2)
else
{
if (lacp_timer_is_running (sif->periodic_timer) &&
- lacp_timer_is_expired (lm->vlib_main, sif->periodic_timer))
+ lacp_timer_is_expired (vm, sif->periodic_timer))
timer_expired = 1;
else
timer_expired = 0;
- lacp_schedule_periodic_timer (lm->vlib_main, sif);
+ lacp_schedule_periodic_timer (vm, sif);
if (timer_expired || (sif->partner.state & LACP_STATE_LACP_TIMEOUT))
lacp_machine_dispatch (&lacp_ptx_machine, vm, sif,
@@ -118,7 +117,6 @@ lacp_ptx_action_fast_periodic (void *p1, void *p2)
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
u8 timer_expired;
- lacp_main_t *lm = &lacp_main;
if (!(sif->partner.state & LACP_STATE_LACP_ACTIVITY) &&
!(sif->actor.state & LACP_STATE_LACP_ACTIVITY))
@@ -127,13 +125,12 @@ lacp_ptx_action_fast_periodic (void *p1, void *p2)
else
{
if (lacp_timer_is_running (sif->periodic_timer) &&
- lacp_timer_is_expired (lm->vlib_main, sif->periodic_timer))
+ lacp_timer_is_expired (vm, sif->periodic_timer))
timer_expired = 1;
else
timer_expired = 0;
- lacp_start_periodic_timer (lm->vlib_main, sif,
- LACP_FAST_PERIODIC_TIMER);
+ lacp_start_periodic_timer (vm, sif, LACP_FAST_PERIODIC_TIMER);
if (timer_expired)
lacp_machine_dispatch (&lacp_ptx_machine, vm, sif,
diff --git a/src/plugins/lacp/rx_machine.c b/src/plugins/lacp/rx_machine.c
index 0d9d703ff42..605cccba08c 100644
--- a/src/plugins/lacp/rx_machine.c
+++ b/src/plugins/lacp/rx_machine.c
@@ -174,7 +174,6 @@ lacp_update_ntt (vlib_main_t * vm, slave_if_t * sif)
lacp_pdu_t *lacpdu = (lacp_pdu_t *) sif->last_rx_pkt;
u8 states = LACP_STATE_LACP_ACTIVITY | LACP_STATE_LACP_TIMEOUT |
LACP_STATE_SYNCHRONIZATION | LACP_STATE_AGGREGATION;
- lacp_main_t *lm = &lacp_main;
if ((states & lacpdu->partner.port_info.state) !=
(states & sif->actor.state)
@@ -182,7 +181,7 @@ lacp_update_ntt (vlib_main_t * vm, slave_if_t * sif)
sizeof (sif->actor) - sizeof (sif->actor.state)))
{
sif->ntt = 1;
- lacp_start_periodic_timer (lm->vlib_main, sif, 0);
+ lacp_start_periodic_timer (vm, sif, 0);
}
}
@@ -285,17 +284,16 @@ lacp_rx_action_expired (void *p1, void *p2)
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
u8 timer_expired;
- lacp_main_t *lm = &lacp_main;
sif->partner.state &= ~LACP_STATE_SYNCHRONIZATION;
sif->partner.state |= LACP_STATE_LACP_TIMEOUT;
lacp_ptx_post_short_timeout_event (vm, sif);
if (lacp_timer_is_running (sif->current_while_timer) &&
- lacp_timer_is_expired (lm->vlib_main, sif->current_while_timer))
+ lacp_timer_is_expired (vm, sif->current_while_timer))
timer_expired = 1;
else
timer_expired = 0;
- lacp_start_current_while_timer (lm->vlib_main, sif, sif->ttl_in_seconds);
+ lacp_start_current_while_timer (vm, sif, sif->ttl_in_seconds);
sif->actor.state |= LACP_STATE_EXPIRED;
if (timer_expired)
lacp_machine_dispatch (&lacp_rx_machine, vm, sif,
@@ -365,12 +363,11 @@ lacp_rx_action_current (void *p1, void *p2)
{
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
- lacp_main_t *lm = &lacp_main;
lacp_update_selected (vm, sif);
lacp_update_ntt (vm, sif);
lacp_record_pdu (vm, sif);
- lacp_start_current_while_timer (lm->vlib_main, sif, sif->ttl_in_seconds);
+ lacp_start_current_while_timer (vm, sif, sif->ttl_in_seconds);
sif->actor.state &= ~LACP_STATE_EXPIRED;
if (lacp_port_is_moved (vm, sif))
lacp_set_port_moved (vm, sif, 1);
diff --git a/src/plugins/lacp/tx_machine.c b/src/plugins/lacp/tx_machine.c
index 73ca4862fe8..3377da86422 100644
--- a/src/plugins/lacp/tx_machine.c
+++ b/src/plugins/lacp/tx_machine.c
@@ -40,8 +40,7 @@ lacp_tx_action_transmit (void *p1, void *p2)
{
vlib_main_t *vm = p1;
slave_if_t *sif = p2;
- lacp_main_t *lm = &lacp_main;
- f64 now = vlib_time_now (lm->vlib_main);
+ f64 now = vlib_time_now (vm);
if (!lacp_timer_is_running (sif->periodic_timer))
return 0;
@@ -53,7 +52,7 @@ lacp_tx_action_transmit (void *p1, void *p2)
if (sif->ntt)
{
lacp_send_lacp_pdu (vm, sif);
- lacp_schedule_periodic_timer (lm->vlib_main, sif);
+ lacp_schedule_periodic_timer (vm, sif);
}
sif->ntt = 0;