Skip to content

Commit 76c4290

Browse files
yew011ejj
authored andcommitted
cfm: Add ovsdb column "cfm_flap_count".
This commit adds a new ovsdb column "cfm_flap_count". It counts the number of cfm fault flaps since boot. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
1 parent 36d29fc commit 76c4290

8 files changed

Lines changed: 82 additions & 2 deletions

File tree

lib/cfm.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ struct cfm {
129129
atomic_bool check_tnl_key; /* Verify the tunnel key of inbound packets? */
130130
atomic_bool extended; /* Extended mode. */
131131
atomic_int ref_cnt;
132+
133+
uint64_t flap_count; /* Count the flaps since boot. */
132134
};
133135

134136
/* Remote MPs represent foreign network entities that are configured to have
@@ -330,6 +332,7 @@ cfm_create(const struct netdev *netdev) OVS_EXCLUDED(mutex)
330332
cfm->fault_override = -1;
331333
cfm->health = -1;
332334
cfm->last_tx = 0;
335+
cfm->flap_count = 0;
333336
atomic_init(&cfm->extended, false);
334337
atomic_init(&cfm->check_tnl_key, false);
335338
atomic_init(&cfm->ref_cnt, 1);
@@ -487,6 +490,11 @@ cfm_run(struct cfm *cfm) OVS_EXCLUDED(mutex)
487490
ds_put_char(&ds, ']');
488491
VLOG_INFO("%s: CFM faults changed %s.", cfm->name, ds_cstr(&ds));
489492
ds_destroy(&ds);
493+
494+
/* If there is a flap, increments the counter. */
495+
if (old_cfm_fault == false || cfm->fault == false) {
496+
cfm->flap_count++;
497+
}
490498
}
491499

492500
cfm->booted = true;
@@ -834,6 +842,17 @@ cfm_get_fault(const struct cfm *cfm) OVS_EXCLUDED(mutex)
834842
return fault;
835843
}
836844

845+
/* Gets the number of cfm fault flapping since start. */
846+
uint64_t
847+
cfm_get_flap_count(const struct cfm *cfm) OVS_EXCLUDED(mutex)
848+
{
849+
uint64_t flap_count;
850+
ovs_mutex_lock(&mutex);
851+
flap_count = cfm->flap_count;
852+
ovs_mutex_unlock(&mutex);
853+
return flap_count;
854+
}
855+
837856
/* Gets the health of 'cfm'. Returns an integer between 0 and 100 indicating
838857
* the health of the link as a percentage of ccm frames received in
839858
* CFM_HEALTH_INTERVAL * 'fault_interval' if there is only 1 remote_mpid,

lib/cfm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *,
7777
struct flow_wildcards *);
7878
void cfm_process_heartbeat(struct cfm *, const struct ofpbuf *packet);
7979
int cfm_get_fault(const struct cfm *);
80+
uint64_t cfm_get_flap_count(const struct cfm *);
8081
int cfm_get_health(const struct cfm *);
8182
int cfm_get_opup(const struct cfm *);
8283
void cfm_get_remote_mpids(const struct cfm *, uint64_t **rmps, size_t *n_rmps);

ofproto/ofproto-dpif.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,7 @@ get_cfm_status(const struct ofport *ofport_,
19531953

19541954
if (ofport->cfm) {
19551955
status->faults = cfm_get_fault(ofport->cfm);
1956+
status->flap_count = cfm_get_flap_count(ofport->cfm);
19561957
status->remote_opstate = cfm_get_opup(ofport->cfm);
19571958
status->health = cfm_get_health(ofport->cfm);
19581959
cfm_get_remote_mpids(ofport->cfm, &status->rmps, &status->n_rmps);

ofproto/ofproto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ struct ofproto_cfm_status {
408408
* mode. */
409409
int remote_opstate;
410410

411+
uint64_t flap_count;
412+
411413
/* Ordinarily a "health status" in the range 0...100 inclusive, with 0
412414
* being worst and 100 being best, or -1 if the health status is not
413415
* well-defined. */

tests/cfm.at

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ Remote MPID $7
1414
])
1515
])
1616

17+
m4_define([CFM_VSCTL_LIST_IFACE], [
18+
AT_CHECK([ovs-vsctl list interface $1 | sed -n '/$2/p'],[0],
19+
[dnl
20+
$3
21+
])
22+
])
23+
1724
# test cfm under demand mode.
1825
AT_SETUP([cfm - demand mode])
19-
#Create 2 bridges connected by patch ports and enable BFD
26+
#Create 2 bridges connected by patch ports and enable cfm
2027
OVS_VSWITCHD_START([add-br br1 -- \
2128
set bridge br1 datapath-type=dummy \
2229
other-config:hwaddr=aa:55:aa:56:00:00 -- \
@@ -55,3 +62,38 @@ done
5562

5663
OVS_VSWITCHD_STOP
5764
AT_CLEANUP
65+
66+
# test cfm_flap_count.
67+
AT_SETUP([cfm - flap_count])
68+
#Create 2 bridges connected by patch ports and enable cfm
69+
OVS_VSWITCHD_START([add-br br1 -- \
70+
set bridge br1 datapath-type=dummy \
71+
other-config:hwaddr=aa:55:aa:56:00:00 -- \
72+
add-port br1 p1 -- set Interface p1 type=patch \
73+
options:peer=p0 -- \
74+
add-port br0 p0 -- set Interface p0 type=patch \
75+
options:peer=p1 -- \
76+
set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
77+
set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
78+
79+
ovs-appctl time/stop
80+
81+
# wait for a while to stablize cfm.
82+
for i in `seq 0 100`; do ovs-appctl time/warp 100; done
83+
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
84+
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
85+
86+
# turn cfm on p1 off, should increment the cfm_flap_count on p1.
87+
AT_CHECK([ovs-vsctl remove interface p1 cfm_mpid 2])
88+
for i in `seq 0 10`; do ovs-appctl time/warp 100; done
89+
CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 1])
90+
CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : [[]]])
91+
92+
# turn cfm on p1 on again, should increment the cfm_flap_count on p1.
93+
AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
94+
for i in `seq 0 10`; do ovs-appctl time/warp 100; done
95+
CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 2])
96+
CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : 0])
97+
98+
OVS_VSWITCHD_STOP
99+
AT_CLEANUP

vswitchd/bridge.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ bridge_init(const char *remote)
376376
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_cfm_fault);
377377
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_cfm_fault_status);
378378
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_cfm_remote_mpids);
379+
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_cfm_flap_count);
379380
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_cfm_health);
380381
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_cfm_remote_opstate);
381382
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_bfd_status);
@@ -1890,11 +1891,13 @@ iface_refresh_cfm_stats(struct iface *iface)
18901891
ovsrec_interface_set_cfm_fault(cfg, NULL, 0);
18911892
ovsrec_interface_set_cfm_fault_status(cfg, NULL, 0);
18921893
ovsrec_interface_set_cfm_remote_opstate(cfg, NULL);
1894+
ovsrec_interface_set_cfm_flap_count(cfg, NULL, 0);
18931895
ovsrec_interface_set_cfm_health(cfg, NULL, 0);
18941896
ovsrec_interface_set_cfm_remote_mpids(cfg, NULL, 0);
18951897
} else {
18961898
const char *reasons[CFM_FAULT_N_REASONS];
18971899
int64_t cfm_health = status.health;
1900+
int64_t cfm_flap_count = status.flap_count;
18981901
bool faulted = status.faults != 0;
18991902
size_t i, j;
19001903

@@ -1909,6 +1912,8 @@ iface_refresh_cfm_stats(struct iface *iface)
19091912
}
19101913
ovsrec_interface_set_cfm_fault_status(cfg, (char **) reasons, j);
19111914

1915+
ovsrec_interface_set_cfm_flap_count(cfg, &cfm_flap_count, 1);
1916+
19121917
if (status.remote_opstate >= 0) {
19131918
const char *remote_opstate = status.remote_opstate ? "up" : "down";
19141919
ovsrec_interface_set_cfm_remote_opstate(cfg, remote_opstate);

vswitchd/vswitch.ovsschema

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{"name": "Open_vSwitch",
22
"version": "7.3.0",
3-
"cksum": "2483452374 20182",
3+
"cksum": "2811681289 20311",
44
"tables": {
55
"Open_vSwitch": {
66
"columns": {
@@ -224,6 +224,11 @@
224224
"min": 0,
225225
"max": "unlimited"},
226226
"ephemeral": true},
227+
"cfm_flap_count": {
228+
"type": {
229+
"key": {"type": "integer"},
230+
"min": 0,
231+
"max": 1}},
227232
"cfm_fault": {
228233
"type": {
229234
"key": { "type": "boolean"},

vswitchd/vswitch.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,11 @@
20092009
CFM on this <ref table="Interface"/>.
20102010
</column>
20112011

2012+
<column name="cfm_flap_count">
2013+
Counts the number of cfm fault flapps since boot. A flap is
2014+
considered to be a change of the <ref column="cfm_fault"/> value.
2015+
</column>
2016+
20122017
<column name="cfm_fault">
20132018
<p>
20142019
Indicates a connectivity fault triggered by an inability to receive

0 commit comments

Comments
 (0)