Signed-off-by: Simon Horman <ho...@verge.net.au> --- v2 * Do not use OF1.4 paused and resumed messages for OF1.1 - OF1.3 --- ofproto/connmgr.c | 12 +++++++---- ofproto/connmgr.h | 8 +++++--- ofproto/ofproto.c | 60 ++++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 55 insertions(+), 25 deletions(-)
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index 2cc0bd4..7fc42b1 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -126,7 +126,8 @@ struct ofconn { /* State of monitors for a single ongoing flow_mod. * * 'updates' is a list of "struct ofpbuf"s that contain - * NXST_FLOW_MONITOR_REPLY messages representing the changes made by the + * OFPST14_FLOW_MONITOR_REPLY/NXST_FLOW_MONITOR_REPLY messages + * representing the changes made by the * current flow_mod. * * When 'updates' is nonempty, 'sent_abbrev_update' is true if 'updates' @@ -2139,7 +2140,8 @@ ofmonitor_report(struct connmgr *mgr, struct rule *rule, if (flags) { if (list_is_empty(&ofconn->updates)) { - ofputil_start_flow_update(OFP10_VERSION, &ofconn->updates); + ofputil_start_flow_update(rconn_get_version(ofconn->rconn), + &ofconn->updates); ofconn->sent_abbrev_update = false; } @@ -2190,6 +2192,7 @@ ofmonitor_flush(struct connmgr *mgr) struct ofconn *ofconn; LIST_FOR_EACH (ofconn, node, &mgr->all_conns) { + enum ofp_version ofp_version = rconn_get_version(ofconn->rconn); struct ofpbuf *msg, *next; struct list msgs; @@ -2203,7 +2206,7 @@ ofmonitor_flush(struct connmgr *mgr) if (!ofconn->monitor_paused && n_bytes > 128 * 1024) { COVERAGE_INC(ofmonitor_pause); ofconn->monitor_paused = monitor_seqno++; - ofmonitor_compose_paused(&msgs); + ofmonitor_compose_paused(ofp_version, &msgs); } } ofconn_send_replies(ofconn, &msgs); @@ -2214,6 +2217,7 @@ static void ofmonitor_resume(struct ofconn *ofconn) OVS_REQUIRES(ofproto_mutex) { + enum ofp_version ofp_version = rconn_get_version(ofconn->rconn); struct rule_collection rules; struct ofmonitor *m; struct list msgs; @@ -2224,7 +2228,7 @@ ofmonitor_resume(struct ofconn *ofconn) } list_init(&msgs); - ofmonitor_compose_resumed(&rules, &msgs); + ofmonitor_compose_resumed(ofp_version, &rules, &msgs); ofconn_send_replies(ofconn, &msgs); ofconn->monitor_paused = 0; diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h index f3b9448..c2212ef 100644 --- a/ofproto/connmgr.h +++ b/ofproto/connmgr.h @@ -234,12 +234,14 @@ struct rule_collection; void ofmonitor_collect_resume_rules(struct ofmonitor *, uint64_t seqno, struct rule_collection *) OVS_REQUIRES(ofproto_mutex); -void ofmonitor_compose_refresh_updates(struct rule_collection *rules, +void ofmonitor_compose_refresh_updates(enum ofp_version ofp_version, + struct rule_collection *rules, struct list *msgs) OVS_REQUIRES(ofproto_mutex); -void ofmonitor_compose_paused(struct list *msgs); -void ofmonitor_compose_resumed(struct rule_collection *rules, +void ofmonitor_compose_paused(enum ofp_version ofp_version, struct list *msgs); +void ofmonitor_compose_resumed(enum ofp_version ofp_version, + struct rule_collection *rules, struct list *msgs) OVS_REQUIRES(ofproto_mutex); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 6bbf53a..88ac5b5 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -4698,7 +4698,8 @@ handle_barrier_request(struct ofconn *ofconn, const struct ofp_header *oh) } static void -ofproto_compose_flow_refresh_update(const struct rule *rule, +ofproto_compose_flow_refresh_update(enum ofp_version ofp_version, + const struct rule *rule, enum ofp14_flow_monitor_flags flags, struct list *msgs) OVS_REQUIRES(ofproto_mutex) @@ -4730,13 +4731,14 @@ ofproto_compose_flow_refresh_update(const struct rule *rule, fu.ofpacts_len = actions ? actions->ofpacts_len : 0; if (list_is_empty(msgs)) { - ofputil_start_flow_update(OFP10_VERSION, msgs); + ofputil_start_flow_update(ofp_version, msgs); } ofputil_append_flow_update(&fu, msgs); } void -ofmonitor_compose_refresh_updates(struct rule_collection *rules, +ofmonitor_compose_refresh_updates(enum ofp_version ofp_version, + struct rule_collection *rules, struct list *msgs) OVS_REQUIRES(ofproto_mutex) { @@ -4747,33 +4749,55 @@ ofmonitor_compose_refresh_updates(struct rule_collection *rules, enum ofp14_flow_monitor_flags flags = rule->monitor_flags; rule->monitor_flags = 0; - ofproto_compose_flow_refresh_update(rule, flags, msgs); + ofproto_compose_flow_refresh_update(ofp_version, rule, flags, msgs); } } static void -ofproto_compose_paused_or_resumed(struct list *msgs, bool paused) -{ - struct ofpbuf *msg; - enum ofpraw raw; - raw = paused ? OFPRAW_NXT_FLOW_MONITOR_PAUSED - : OFPRAW_NXT_FLOW_MONITOR_RESUMED; - msg = ofpraw_alloc_xid(raw, OFP10_VERSION, htonl(0), 0); - list_push_back(msgs, &msg->list_node); +ofproto_compose_paused_or_resumed(enum ofp_version ofp_version, + struct list *msgs, bool paused) +{ + switch (ofp_version) { + case OFP10_VERSION: { + struct ofpbuf *msg; + enum ofpraw raw; + raw = paused ? OFPRAW_NXT_FLOW_MONITOR_PAUSED + : OFPRAW_NXT_FLOW_MONITOR_RESUMED; + msg = ofpraw_alloc_xid(raw, ofp_version, htonl(0), 0); + list_push_back(msgs, &msg->list_node); + break; + } + case OFP14_VERSION: + case OFP15_VERSION: { + struct ofputil_flow_update fu; + fu.event = paused ? OFPFME14_PAUSED : OFPFME14_RESUMED; + if (list_is_empty(msgs)) { + ofputil_start_flow_update(ofp_version, msgs); + } + ofputil_append_flow_update(&fu, msgs); + break; + } + case OFP11_VERSION: + case OFP12_VERSION: + case OFP13_VERSION: /* XXX: Use ONF extension */ + default: + OVS_NOT_REACHED(); + } } void -ofmonitor_compose_paused(struct list *msgs) +ofmonitor_compose_paused(enum ofp_version ofp_version, struct list *msgs) { - ofproto_compose_paused_or_resumed(msgs, true); + ofproto_compose_paused_or_resumed(ofp_version, msgs, true); } void -ofmonitor_compose_resumed(struct rule_collection *rules, struct list *msgs) +ofmonitor_compose_resumed(enum ofp_version ofp_version, + struct rule_collection *rules, struct list *msgs) OVS_REQUIRES(ofproto_mutex) { - ofmonitor_compose_refresh_updates(rules, msgs); - ofproto_compose_paused_or_resumed(msgs, false); + ofmonitor_compose_refresh_updates(ofp_version, rules, msgs); + ofproto_compose_paused_or_resumed(ofp_version, msgs, false); } static void @@ -4938,7 +4962,7 @@ handle_flow_monitor_request(struct ofconn *ofconn, const struct ofp_header *oh) } ofpmp_init(&replies, oh); - ofmonitor_compose_refresh_updates(&rules, &replies); + ofmonitor_compose_refresh_updates(oh->version, &rules, &replies); ovs_mutex_unlock(&ofproto_mutex); rule_collection_destroy(&rules); -- 2.0.0.rc2 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev