/* True if the monitor thread is running. */
static bool monitor_running;
-static struct seq *monitor_seq;
static struct latch monitor_exit_latch;
static struct ovs_rwlock monitor_rwlock = OVS_RWLOCK_INITIALIZER;
memcpy(mport->hw_addr, hw_addr, ETH_ADDR_LEN);
}
/* If bfd/cfm is added or reconfigured, move the mport on top of the heap
- * and wakes up the monitor thread. */
+ * so that the monitor thread can run the mport next time it wakes up. */
if (mport->bfd || mport->cfm) {
heap_change(&monitor_heap, &mport->heap_node, LLONG_MAX);
- seq_change(monitor_seq);
}
}
\f
if (ovsthread_once_start(&once)) {
hmap_init(&monitor_hmap);
- monitor_seq = seq_create();
ovsthread_once_done(&once);
}
}
set_subprogram_name("monitor");
VLOG_INFO("monitor thread created");
while (!latch_is_set(&monitor_exit_latch)) {
- uint64_t seq = seq_read(monitor_seq);
-
monitor_run();
latch_wait(&monitor_exit_latch);
- seq_wait(monitor_seq, seq);
poll_block();
}
VLOG_INFO("monitor thread terminated");
return NULL;
}
+/* The monitor thread should wake up this often to ensure that newly added or
+ * reconfigured monitoring ports are run in a timely manner. */
+#define MONITOR_INTERVAL_MSEC 100
+
/* Checks the sending of control packets on mports that have timed out.
* Sends the control packets if needed. Executes bfd and cfm periodic
* functions (run, wait) on those mports. */
/* Waits on the earliest next wakeup time. */
if (!heap_is_empty(&monitor_heap)) {
- poll_timer_wait_until(PRIO_TO_MSEC(heap_max(&monitor_heap)->priority));
+ long long int next_timeout, next_mport_wakeup;
+
+ next_timeout = time_msec() + MONITOR_INTERVAL_MSEC;
+ next_mport_wakeup = PRIO_TO_MSEC(heap_max(&monitor_heap)->priority);
+ poll_timer_wait_until(MIN(next_timeout, next_mport_wakeup));
}
ovs_rwlock_unlock(&monitor_rwlock);
ofpbuf_uninit(&packet);
# for decay_min_rx < 2000ms, the decay detection time is set to 2000ms.
# this should reset the min_rx.
AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000])
+ovs-appctl time/warp 100
BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
# Test-4 BFD decay: set min_rx to 800ms.
# this should firstly reset the min_rx and then re-decay to 1000ms.
AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=800])
-BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
-BFD_CHECK_RX([p0], [800ms], [800ms], [500ms])
+ovs-appctl time/warp 100
# for the following 1600ms, there should be no decay,
# since the decay detection time is set to 2000ms.
# Test-5 BFD decay: set min_rx to 300ms and decay_min_rx to 5000ms together.
AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=300 bfd:decay_min_rx=5000])
-BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
-BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
+ovs-appctl time/warp 100
# for decay_min_rx > 2000ms, the decay detection time is set to
# decay_min_rx (5000ms).
# Test-6 BFD decay: set decay_min_rx to 0 to disable bfd decay.
AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0])
-# min_rx is reset.
-BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
-BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
+ovs-appctl time/warp 100
+
for i in `seq 0 20`
do
ovs-appctl time/warp 500
done
# reset the p1's min_tx to 500ms.
AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500])
+ovs-appctl time/warp 100
+
# since p0 has been in decay, now the RX will show 3000ms.
BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
# reconfigure the decay_min_rx to 1000ms.
AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000])
-BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
-BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
# wait for 5000ms to decay.
for i in `seq 0 9`; do ovs-appctl time/warp 500; done
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
-# turn cfm on p1 off, should increment the cfm_flap_count on p1.
+# turn cfm on p1 off, should increment the cfm_flap_count on p0.
AT_CHECK([ovs-vsctl remove interface p1 cfm_mpid 2])
for i in `seq 0 10`; do ovs-appctl time/warp 100; done
CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 1])
CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : [[]]])
-# turn cfm on p1 on again, should increment the cfm_flap_count on p1.
+# turn cfm on p1 on again, should increment the cfm_flap_count on p0.
AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
for i in `seq 0 10`; do ovs-appctl time/warp 100; done
CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 2])
-CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : 0])
OVS_VSWITCHD_STOP
AT_CLEANUP
\ No newline at end of file