[ovs-dev] [PATCH] documentation: man vswitchd.conf.db(5) updated flow-restore-wait

2018-11-02 Thread Zak Whittington
Commit 7ed73428a changed the behavior of flow-restore-wait to
also prevent the switch from connecting to controllers in the
controller table, but failed to update the man page documentation
generated by vswitchd/vswitch.xml to reflect this.

This commit adds that documentation.

Signed-off-by: Zak Whittington 
---
 vswitchd/vswitch.xml | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 6d1fc1c..efa1ef8 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -122,6 +122,16 @@
   start receiving packets from the datapath and re-setup the flows.
 
 
+  Additionally, ovs-vswitchd is prevented from connecting
+  to controllers when this value is set to true. This
+  prevents controllers from making changes to the flow table in the
+  middle of flow restoration, which could result in undesirable
+  intermediate states. Once this value has been set to
+  false and the desired flow state has been
+  restored, ovs-vswitchd will be able to reconnect to
+  controllers and process any new flow table modifications.
+
+
   Thus, with this option, the procedure for a hot-upgrade of
   ovs-vswitchd becomes roughly the following:
 
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofp-msgs: Added ONF_ and NXT_REQUESTFORWARD for OF1.0-1.3

2018-10-26 Thread Zak Whittington
Backported OFPT14_REQUESTFORWARD to OF1.0-1.3.
OF 1.0-1.2 use an NXT Nicira extension while OF 1.3
uses an ONF extension (ONF version is specified in a
previously published ONF spec sheet).

Includes ofp-print tests for multiple inner message
types, and multiple OF versions including the NXT and ONF.
Also includes more end-to-end ofproto tests for both
NXT OF1.0 and also ONF OF1.3.

VMware-BZ: 2136594
Signed-off-by: Zak Whittington 
---
 include/openvswitch/ofp-monitor.h |   1 +
 include/openvswitch/ofp-msgs.h|   8 +-
 lib/ofp-monitor.c |  22 +++--
 ofproto/connmgr.c |   7 +-
 tests/ofp-print.at|  76 +++
 tests/ofproto.at  | 199 ++
 6 files changed, 305 insertions(+), 8 deletions(-)

diff --git a/include/openvswitch/ofp-monitor.h 
b/include/openvswitch/ofp-monitor.h
index 1bfcf92..5951260 100644
--- a/include/openvswitch/ofp-monitor.h
+++ b/include/openvswitch/ofp-monitor.h
@@ -116,6 +116,7 @@ struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t 
id);
 
 struct ofputil_requestforward {
 ovs_be32 xid;
+/* Also used for OF 1.0-1.3 when using Nicira Extension: */
 enum ofp14_requestforward_reason reason;
 union {
 /* reason == OFPRFR_METER_MOD. */
diff --git a/include/openvswitch/ofp-msgs.h b/include/openvswitch/ofp-msgs.h
index 8a32a3d..cacba41 100644
--- a/include/openvswitch/ofp-msgs.h
+++ b/include/openvswitch/ofp-msgs.h
@@ -274,6 +274,10 @@ enum ofpraw {
 /* OFPT 1.4+ (31): struct ofp14_table_status, uint8_t[8][]. */
 OFPRAW_OFPT14_TABLE_STATUS,
 
+/* NXT 1.0-1.2 (132): struct ofp14_requestforward, uint8_t[8][]. */
+OFPRAW_NXT_REQUESTFORWARD,
+/* ONFT 1.3 (2350): struct ofp14_requestforward, uint8_t[8][]. */
+OFPRAW_ONFT13_REQUESTFORWARD,
 /* OFPT 1.4+ (32): struct ofp14_requestforward, uint8_t[8][]. */
 OFPRAW_OFPT14_REQUESTFORWARD,
 
@@ -645,7 +649,9 @@ enum ofptype {
* OFPRAW_OFPT14_ROLE_STATUS. */
 
 /* Request forwarding by the switch. */
-OFPTYPE_REQUESTFORWARD,   /* OFPRAW_OFPT14_REQUESTFORWARD. */
+OFPTYPE_REQUESTFORWARD,   /* OFPRAW_NXT_REQUESTFORWARD.
+   * OFPRAW_ONFT13_REQUESTFORWARD.
+   * OFPRAW_OFPT14_REQUESTFORWARD. */
 
 /* Asynchronous messages. */
 OFPTYPE_TABLE_STATUS,  /* OFPRAW_OFPT14_TABLE_STATUS. */
diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c
index d1853d9..9e0983c 100644
--- a/lib/ofp-monitor.c
+++ b/lib/ofp-monitor.c
@@ -785,13 +785,13 @@ ofputil_flow_update_format(struct ds *s,
 }
 }
 
-/* Encodes 'rf' according to 'protocol', and returns the encoded message.
- * 'protocol' must be for OpenFlow 1.4 or later. */
+/* Encodes 'rf' according to 'protocol', and returns the encoded message. */
 struct ofpbuf *
 ofputil_encode_requestforward(const struct ofputil_requestforward *rf,
   enum ofputil_protocol protocol)
 {
 enum ofp_version ofp_version = ofputil_protocol_to_ofp_version(protocol);
+enum ofptype raw_msg_type;
 struct ofpbuf *inner;
 
 switch (rf->reason) {
@@ -813,9 +813,16 @@ ofputil_encode_requestforward(const struct 
ofputil_requestforward *rf,
 inner_oh->xid = rf->xid;
 inner_oh->length = htons(inner->size);
 
-struct ofpbuf *outer = ofpraw_alloc_xid(OFPRAW_OFPT14_REQUESTFORWARD,
-ofp_version, htonl(0),
-inner->size);
+if (ofp_version < OFP13_VERSION) {
+raw_msg_type = OFPRAW_NXT_REQUESTFORWARD;
+} else if (ofp_version == OFP13_VERSION) {
+raw_msg_type = OFPRAW_ONFT13_REQUESTFORWARD;
+} else {
+raw_msg_type = OFPRAW_OFPT14_REQUESTFORWARD;
+}
+
+struct ofpbuf *outer = ofpraw_alloc_xid(raw_msg_type, ofp_version,
+htonl(0), inner->size);
 ofpbuf_put(outer, inner->data, inner->size);
 ofpbuf_delete(inner);
 
@@ -836,7 +843,10 @@ ofputil_decode_requestforward(const struct ofp_header 
*outer,
 struct ofpbuf b = ofpbuf_const_initializer(outer, ntohs(outer->length));
 
 /* Skip past outer message. */
-ovs_assert(ofpraw_pull_assert() == OFPRAW_OFPT14_REQUESTFORWARD);
+enum ofpraw raw_msg_type = ofpraw_pull_assert();
+ovs_assert(raw_msg_type == OFPRAW_OFPT14_REQUESTFORWARD ||
+   raw_msg_type == OFPRAW_ONFT13_REQUESTFORWARD ||
+   raw_msg_type == OFPRAW_NXT_REQUESTFORWARD);
 
 /* Validate inner message. */
 if (b.size < sizeof(struct ofp_header)) {
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 9431200..db9f6ba 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1691,8 +1691,13 @@ connmgr_send_requestforward(struct connmgr *mgr, const 
struct ofconn *source,
 struct ofconn *ofconn;
 
 LIST_FOR_EACH (ofconn, node,

[ovs-dev] [PATCH] ofp-msgs: Added NXT_REQUESTFORWARD for OF1.0-1.3

2018-10-25 Thread Zak Whittington
Backported OFPT14_REQUESTFORWARD to OF1.0-1.3 as a Nicira
extension. Includes ofp-print tests for multiple OF
verions and multiple payload types, as well as more
comprehensive end-to-end tests using OF1.0 and OF1.3.

VMware-BZ: 2136594
Signed-off-by: Zak Whittington 
---
 include/openvswitch/ofp-monitor.h |   1 +
 include/openvswitch/ofp-msgs.h|   5 +-
 lib/ofp-monitor.c |  11 ++-
 ofproto/connmgr.c |   7 +-
 tests/ofp-print.at|  76 +++
 tests/ofproto.at  | 199 ++
 6 files changed, 293 insertions(+), 6 deletions(-)

diff --git a/include/openvswitch/ofp-monitor.h 
b/include/openvswitch/ofp-monitor.h
index 1bfcf92..5951260 100644
--- a/include/openvswitch/ofp-monitor.h
+++ b/include/openvswitch/ofp-monitor.h
@@ -116,6 +116,7 @@ struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t 
id);
 
 struct ofputil_requestforward {
 ovs_be32 xid;
+/* Also used for OF 1.0-1.3 when using Nicira Extension: */
 enum ofp14_requestforward_reason reason;
 union {
 /* reason == OFPRFR_METER_MOD. */
diff --git a/include/openvswitch/ofp-msgs.h b/include/openvswitch/ofp-msgs.h
index 8a32a3d..012aa06 100644
--- a/include/openvswitch/ofp-msgs.h
+++ b/include/openvswitch/ofp-msgs.h
@@ -274,6 +274,8 @@ enum ofpraw {
 /* OFPT 1.4+ (31): struct ofp14_table_status, uint8_t[8][]. */
 OFPRAW_OFPT14_TABLE_STATUS,
 
+/* NXT 1.0-1.3 (132): struct ofp14_requestforward, uint8_t[8][]. */
+OFPRAW_NXT_REQUESTFORWARD,
 /* OFPT 1.4+ (32): struct ofp14_requestforward, uint8_t[8][]. */
 OFPRAW_OFPT14_REQUESTFORWARD,
 
@@ -645,7 +647,8 @@ enum ofptype {
* OFPRAW_OFPT14_ROLE_STATUS. */
 
 /* Request forwarding by the switch. */
-OFPTYPE_REQUESTFORWARD,   /* OFPRAW_OFPT14_REQUESTFORWARD. */
+OFPTYPE_REQUESTFORWARD,   /* OFPRAW_NXT_REQUESTFORWARD.
+   * OFPRAW_OFPT14_REQUESTFORWARD. */
 
 /* Asynchronous messages. */
 OFPTYPE_TABLE_STATUS,  /* OFPRAW_OFPT14_TABLE_STATUS. */
diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c
index d1853d9..2661a5a 100644
--- a/lib/ofp-monitor.c
+++ b/lib/ofp-monitor.c
@@ -785,8 +785,7 @@ ofputil_flow_update_format(struct ds *s,
 }
 }
 
-/* Encodes 'rf' according to 'protocol', and returns the encoded message.
- * 'protocol' must be for OpenFlow 1.4 or later. */
+/* Encodes 'rf' according to 'protocol', and returns the encoded message. */
 struct ofpbuf *
 ofputil_encode_requestforward(const struct ofputil_requestforward *rf,
   enum ofputil_protocol protocol)
@@ -813,7 +812,9 @@ ofputil_encode_requestforward(const struct 
ofputil_requestforward *rf,
 inner_oh->xid = rf->xid;
 inner_oh->length = htons(inner->size);
 
-struct ofpbuf *outer = ofpraw_alloc_xid(OFPRAW_OFPT14_REQUESTFORWARD,
+struct ofpbuf *outer = ofpraw_alloc_xid(ofp_version < OFP14_VERSION
+? OFPRAW_NXT_REQUESTFORWARD
+: OFPRAW_OFPT14_REQUESTFORWARD,
 ofp_version, htonl(0),
 inner->size);
 ofpbuf_put(outer, inner->data, inner->size);
@@ -836,7 +837,9 @@ ofputil_decode_requestforward(const struct ofp_header 
*outer,
 struct ofpbuf b = ofpbuf_const_initializer(outer, ntohs(outer->length));
 
 /* Skip past outer message. */
-ovs_assert(ofpraw_pull_assert() == OFPRAW_OFPT14_REQUESTFORWARD);
+enum ofpraw raw_msg_type = ofpraw_pull_assert();
+ovs_assert(raw_msg_type == OFPRAW_OFPT14_REQUESTFORWARD ||
+   raw_msg_type == OFPRAW_NXT_REQUESTFORWARD);
 
 /* Validate inner message. */
 if (b.size < sizeof(struct ofp_header)) {
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 9431200..db9f6ba 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1691,8 +1691,13 @@ connmgr_send_requestforward(struct connmgr *mgr, const 
struct ofconn *source,
 struct ofconn *ofconn;
 
 LIST_FOR_EACH (ofconn, node, >all_conns) {
+/* METER_MOD only supported in OF13 and up. */
+if (rf->reason == OFPRFR_METER_MOD
+&& rconn_get_version(ofconn->rconn) < OFP13_VERSION) {
+continue;
+}
+
 if (ofconn_receives_async_msg(ofconn, OAM_REQUESTFORWARD, rf->reason)
-&& rconn_get_version(ofconn->rconn) >= OFP14_VERSION
 && ofconn != source) {
 enum ofputil_protocol protocol = ofconn_get_protocol(ofconn);
 ofconn_send(ofconn, ofputil_encode_requestforward(rf, protocol),
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index e38ca4a..966061a 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -3138,6 +3138,82 @@ OFPT_REQUESTFORWARD (OF1.4) (xid=0x2): reason=meter_m

[ovs-dev] [PATCH] bridge.c: prevent controller connects while flow-restore-wait

2018-10-25 Thread Zak Whittington
When force-reload-kmod is used, it shows an error when reinstalling
tlvs during "Restoring saved flows" step:
OFPT_ERROR (xid=0x4): NXTTMFC_ALREADY_MAPPED

This is caused by a race condition between the restore script,
which calls ofctl, and the connected controllers both adding back
the same TLVs.

The restore script already sets flow-restore-wait to true while
doing flow restoration, and sets it back to false after it is
done, and this patch utilizes that fact to prevent the TLV race.
It does this by preventing vswitchd from connecting to
controllers in the controller table while it is in a
flow-restore-wait state.

With this patch, when bridge_configure_remotes() calls
bridge_get_controllers(), it first checks if flow-restore-wait
has been set, and if so, it ignores any controllers in the
controller database and sets n_controllers to 0.

This solution does preserve the management service controller
which is added via bridge_ofproto_controller_for_mgmt() after
checking whether we should call bridge_get_controllers()
(and thus n_controllers is properly set to 1, etc)

VMware-BZ: 2195377
Signed-off-by: Zak Whittington 
---
 vswitchd/bridge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 706a07c..9d230b2 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -3608,7 +3608,8 @@ bridge_configure_remotes(struct bridge *br,
 ofproto_set_extra_in_band_remotes(br->ofproto, managers, n_managers);
 }
 
-n_controllers = bridge_get_controllers(br, );
+n_controllers = (ofproto_get_flow_restore_wait() ? 0
+ : bridge_get_controllers(br, ));
 
 ocs = xmalloc((n_controllers + 1) * sizeof *ocs);
 n_ocs = 0;
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] bridge.c: prevent controller connects while flow-restore-wait

2018-10-24 Thread Zak Whittington
When force-reload-kmod is used, it shows an error when reinstalling
tlvs during "Restoring saved flows" step:
OFPT_ERROR (xid=0x4): NXTTMFC_ALREADY_MAPPED

This is caused by a race condition between the restore script,
which calls ofctl, and the connected controllers both adding back
the same TLVs.

The restore script already sets flow-restore-wait to true while
doing flow restoration, and sets it back to false after it is
done, and this patch utilizes that fact to prevent the TLV race.
It does this by preventing vswitchd from connecting to
controllers in the controller table while it is in a
flow-restore-wait state.

With this patch, when bridge_configure_remotes() calls
bridge_get_controllers(), it first checks if flow-restore-wait
has been set, and if so, it ignores any controllers in the
controller database and sets n_controllers to 0.

This solution does preserve the management service controller
which is added via bridge_ofproto_controller_for_mgmt() after
checking whether we should call bridge_get_controllers()
(and thus n_controllers is properly set to 1, etc)

VMware-BZ: 2195377
Signed-off-by: Zak Whittington 
---
 vswitchd/bridge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 706a07c..de43302 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -3608,7 +3608,8 @@ bridge_configure_remotes(struct bridge *br,
 ofproto_set_extra_in_band_remotes(br->ofproto, managers, n_managers);
 }
 
-n_controllers = bridge_get_controllers(br, );
+n_controllers = ofproto_get_flow_restore_wait()? 0 :
+bridge_get_controllers(br, );
 
 ocs = xmalloc((n_controllers + 1) * sizeof *ocs);
 n_ocs = 0;
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofp-msgs: Added NXT_REQUESTFORWARD for OF1.0-1.3

2018-10-23 Thread Zak Whittington
Backported OFPT14_REQUESTFORWARD to OF1.0-1.3 as a Nicira
extension.

VMware-BZ: 2136594
Signed-off-by: Zak Whittington 
---
 include/openvswitch/ofp-monitor.h |  1 +
 include/openvswitch/ofp-msgs.h|  5 +-
 lib/ofp-monitor.c | 11 +++--
 ofproto/connmgr.c |  6 ++-
 tests/ofp-print.at| 76 ++
 tests/ofproto.at  | 98 +++
 6 files changed, 191 insertions(+), 6 deletions(-)

diff --git a/include/openvswitch/ofp-monitor.h 
b/include/openvswitch/ofp-monitor.h
index 1bfcf92..7015200 100644
--- a/include/openvswitch/ofp-monitor.h
+++ b/include/openvswitch/ofp-monitor.h
@@ -116,6 +116,7 @@ struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t 
id);
 
 struct ofputil_requestforward {
 ovs_be32 xid;
+/* Also used for OF 1.0-1.3 when using Nicera Extension: */
 enum ofp14_requestforward_reason reason;
 union {
 /* reason == OFPRFR_METER_MOD. */
diff --git a/include/openvswitch/ofp-msgs.h b/include/openvswitch/ofp-msgs.h
index 8a32a3d..012aa06 100644
--- a/include/openvswitch/ofp-msgs.h
+++ b/include/openvswitch/ofp-msgs.h
@@ -274,6 +274,8 @@ enum ofpraw {
 /* OFPT 1.4+ (31): struct ofp14_table_status, uint8_t[8][]. */
 OFPRAW_OFPT14_TABLE_STATUS,
 
+/* NXT 1.0-1.3 (132): struct ofp14_requestforward, uint8_t[8][]. */
+OFPRAW_NXT_REQUESTFORWARD,
 /* OFPT 1.4+ (32): struct ofp14_requestforward, uint8_t[8][]. */
 OFPRAW_OFPT14_REQUESTFORWARD,
 
@@ -645,7 +647,8 @@ enum ofptype {
* OFPRAW_OFPT14_ROLE_STATUS. */
 
 /* Request forwarding by the switch. */
-OFPTYPE_REQUESTFORWARD,   /* OFPRAW_OFPT14_REQUESTFORWARD. */
+OFPTYPE_REQUESTFORWARD,   /* OFPRAW_NXT_REQUESTFORWARD.
+   * OFPRAW_OFPT14_REQUESTFORWARD. */
 
 /* Asynchronous messages. */
 OFPTYPE_TABLE_STATUS,  /* OFPRAW_OFPT14_TABLE_STATUS. */
diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c
index d1853d9..4a9a650 100644
--- a/lib/ofp-monitor.c
+++ b/lib/ofp-monitor.c
@@ -785,8 +785,7 @@ ofputil_flow_update_format(struct ds *s,
 }
 }
 
-/* Encodes 'rf' according to 'protocol', and returns the encoded message.
- * 'protocol' must be for OpenFlow 1.4 or later. */
+/* Encodes 'rf' according to 'protocol', and returns the encoded message. */
 struct ofpbuf *
 ofputil_encode_requestforward(const struct ofputil_requestforward *rf,
   enum ofputil_protocol protocol)
@@ -813,7 +812,9 @@ ofputil_encode_requestforward(const struct 
ofputil_requestforward *rf,
 inner_oh->xid = rf->xid;
 inner_oh->length = htons(inner->size);
 
-struct ofpbuf *outer = ofpraw_alloc_xid(OFPRAW_OFPT14_REQUESTFORWARD,
+struct ofpbuf *outer = ofpraw_alloc_xid((ofp_version < OFP14_VERSION) ?
+OFPRAW_NXT_REQUESTFORWARD :
+OFPRAW_OFPT14_REQUESTFORWARD,
 ofp_version, htonl(0),
 inner->size);
 ofpbuf_put(outer, inner->data, inner->size);
@@ -836,7 +837,9 @@ ofputil_decode_requestforward(const struct ofp_header 
*outer,
 struct ofpbuf b = ofpbuf_const_initializer(outer, ntohs(outer->length));
 
 /* Skip past outer message. */
-ovs_assert(ofpraw_pull_assert() == OFPRAW_OFPT14_REQUESTFORWARD);
+enum ofpraw raw_msg_type = ofpraw_pull_assert();
+ovs_assert(raw_msg_type == OFPRAW_OFPT14_REQUESTFORWARD ||
+   raw_msg_type == OFPRAW_NXT_REQUESTFORWARD);
 
 /* Validate inner message. */
 if (b.size < sizeof(struct ofp_header)) {
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 9431200..a9b52f9 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1691,8 +1691,12 @@ connmgr_send_requestforward(struct connmgr *mgr, const 
struct ofconn *source,
 struct ofconn *ofconn;
 
 LIST_FOR_EACH (ofconn, node, >all_conns) {
+/* METER_MOD only supported in OF13 and up. */
+if (rf->reason == OFPRFR_METER_MOD &&
+rconn_get_version(ofconn->rconn) < OFP13_VERSION)
+continue;
+
 if (ofconn_receives_async_msg(ofconn, OAM_REQUESTFORWARD, rf->reason)
-&& rconn_get_version(ofconn->rconn) >= OFP14_VERSION
 && ofconn != source) {
 enum ofputil_protocol protocol = ofconn_get_protocol(ofconn);
 ofconn_send(ofconn, ofputil_encode_requestforward(rf, protocol),
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index e38ca4a..966061a 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -3138,6 +3138,82 @@ OFPT_REQUESTFORWARD (OF1.4) (xid=0x2): reason=meter_mod 
MOD meter=1 flags:0x100
 ])
 AT_CLEANUP
 
+AT_SETUP([NXT_REQUESTFORWARD - inner NXT_GROUP_MOD])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs

[ovs-dev] [PATCH] ofp-msgs: Added NXT_REQUESTFORWARD for OF1.0-1.3

2018-10-23 Thread Zak Whittington
Backported OFPT14_REQUESTFORWARD to OF1.0-1.3 as a Nicira
extension. Will only forward GROUP_MOD messages in OF
1.0 through 1.2, since METER_MOD was only added in 1.3.

VMware-BZ: 2136594
Signed-off-by: Zak Whittington 
---
 include/openvswitch/ofp-monitor.h |  1 +
 include/openvswitch/ofp-msgs.h|  5 ++-
 lib/ofp-monitor.c | 11 --
 ofproto/connmgr.c |  6 +++-
 tests/ofp-print.at| 76 +++
 5 files changed, 94 insertions(+), 5 deletions(-)

diff --git a/include/openvswitch/ofp-monitor.h 
b/include/openvswitch/ofp-monitor.h
index 1bfcf92..7015200 100644
--- a/include/openvswitch/ofp-monitor.h
+++ b/include/openvswitch/ofp-monitor.h
@@ -116,6 +116,7 @@ struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t 
id);
 
 struct ofputil_requestforward {
 ovs_be32 xid;
+/* Also used for OF 1.0-1.3 when using Nicera Extension: */
 enum ofp14_requestforward_reason reason;
 union {
 /* reason == OFPRFR_METER_MOD. */
diff --git a/include/openvswitch/ofp-msgs.h b/include/openvswitch/ofp-msgs.h
index 8a32a3d..012aa06 100644
--- a/include/openvswitch/ofp-msgs.h
+++ b/include/openvswitch/ofp-msgs.h
@@ -274,6 +274,8 @@ enum ofpraw {
 /* OFPT 1.4+ (31): struct ofp14_table_status, uint8_t[8][]. */
 OFPRAW_OFPT14_TABLE_STATUS,
 
+/* NXT 1.0-1.3 (132): struct ofp14_requestforward, uint8_t[8][]. */
+OFPRAW_NXT_REQUESTFORWARD,
 /* OFPT 1.4+ (32): struct ofp14_requestforward, uint8_t[8][]. */
 OFPRAW_OFPT14_REQUESTFORWARD,
 
@@ -645,7 +647,8 @@ enum ofptype {
* OFPRAW_OFPT14_ROLE_STATUS. */
 
 /* Request forwarding by the switch. */
-OFPTYPE_REQUESTFORWARD,   /* OFPRAW_OFPT14_REQUESTFORWARD. */
+OFPTYPE_REQUESTFORWARD,   /* OFPRAW_NXT_REQUESTFORWARD.
+   * OFPRAW_OFPT14_REQUESTFORWARD. */
 
 /* Asynchronous messages. */
 OFPTYPE_TABLE_STATUS,  /* OFPRAW_OFPT14_TABLE_STATUS. */
diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c
index d1853d9..5ae7308 100644
--- a/lib/ofp-monitor.c
+++ b/lib/ofp-monitor.c
@@ -786,7 +786,9 @@ ofputil_flow_update_format(struct ds *s,
 }
 
 /* Encodes 'rf' according to 'protocol', and returns the encoded message.
- * 'protocol' must be for OpenFlow 1.4 or later. */
+ * Version checking should be done before calling this.
+ * (Only OF1.3+ has METER_MOD capabilities)
+ */
 struct ofpbuf *
 ofputil_encode_requestforward(const struct ofputil_requestforward *rf,
   enum ofputil_protocol protocol)
@@ -812,7 +814,8 @@ ofputil_encode_requestforward(const struct 
ofputil_requestforward *rf,
 struct ofp_header *inner_oh = inner->data;
 inner_oh->xid = rf->xid;
 inner_oh->length = htons(inner->size);
-
+/* OFPRAW_OFPT14_REQUESTFORWARD is the same size as
+   OFPRAW_NXT_REQUESTFORWARD:*/
 struct ofpbuf *outer = ofpraw_alloc_xid(OFPRAW_OFPT14_REQUESTFORWARD,
 ofp_version, htonl(0),
 inner->size);
@@ -836,7 +839,9 @@ ofputil_decode_requestforward(const struct ofp_header 
*outer,
 struct ofpbuf b = ofpbuf_const_initializer(outer, ntohs(outer->length));
 
 /* Skip past outer message. */
-ovs_assert(ofpraw_pull_assert() == OFPRAW_OFPT14_REQUESTFORWARD);
+enum ofpraw raw_msg_type = ofpraw_pull_assert();
+ovs_assert(raw_msg_type == OFPRAW_OFPT14_REQUESTFORWARD ||
+   raw_msg_type == OFPRAW_NXT_REQUESTFORWARD);
 
 /* Validate inner message. */
 if (b.size < sizeof(struct ofp_header)) {
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 50e0b8f..d8b7603 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1687,8 +1687,12 @@ connmgr_send_requestforward(struct connmgr *mgr, const 
struct ofconn *source,
 struct ofconn *ofconn;
 
 LIST_FOR_EACH (ofconn, node, >all_conns) {
+/* METER_MOD only supported in OF13 and up. */
+if (rf->reason == OFPRFR_METER_MOD &&
+rconn_get_version(ofconn->rconn) < OFP13_VERSION)
+continue;
+
 if (ofconn_receives_async_msg(ofconn, OAM_REQUESTFORWARD, rf->reason)
-&& rconn_get_version(ofconn->rconn) >= OFP14_VERSION
 && ofconn != source) {
 enum ofputil_protocol protocol = ofconn_get_protocol(ofconn);
 ofconn_send(ofconn, ofputil_encode_requestforward(rf, protocol),
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index e38ca4a..966061a 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -3138,6 +3138,82 @@ OFPT_REQUESTFORWARD (OF1.4) (xid=0x2): reason=meter_mod 
MOD meter=1 flags:0x100
 ])
 AT_CLEANUP
 
+AT_SETUP([NXT_REQUESTFORWARD - inner NXT_GROUP_MOD])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+dnl OF version 1.0; type=extension:
+01 04 \
+dnl size in bytes:

[ovs-dev] [PATCH] ovs-save: save and restore groups on restart

2018-09-24 Thread Zak Whittington
VMware-BZ: 2192560
Signed-off-by: Zak Whittington 
---
 utilities/ovs-save | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/utilities/ovs-save b/utilities/ovs-save
index 2294583..5c046bb 100755
--- a/utilities/ovs-save
+++ b/utilities/ovs-save
@@ -121,11 +121,19 @@ save_flows () {
  cnt++;printf "{class="$1",type="$2",len="$3"}->"$4}'
 echo "'"
 
-printf "%s" "ovs-ofctl -O $ofp_version replace-flows ${bridge} " \
-"\"$workdir/$bridge.flows.dump\""
+# If possible use OpenFlow 1.4 atomic bundle txn for flows and groups
+[ ${ofp_version#OpenFlow} -ge 14 ] && bundle=" --bundle" || bundle=""
 
-# If possible, use OpenFlow 1.4 atomic bundle transaction to add flows
-[ ${ofp_version#OpenFlow} -ge 14 ] && echo " --bundle" || echo
+echo "ovs-ofctl -O $ofp_version add-groups ${bridge} \
+  \"$workdir/$bridge.groups.dump\" ${bundle}"
+
+echo "ovs-ofctl -O $ofp_version replace-flows ${bridge} \
+  \"$workdir/$bridge.flows.dump\" ${bundle}"
+
+ovs-ofctl -O $ofp_version dump-groups "$bridge" | \
+sed -e '/^OFPST_GROUP_DESC/d' \
+-e '/^NXST_GROUP_DESC/d' > \
+"$workdir/$bridge.groups.dump"
 
 ovs-ofctl -O $ofp_version dump-flows --no-names --no-stats "$bridge" | 
\
 sed -e '/NXST_FLOW/d' \
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ovs-save: save and restore groups on restart

2018-09-21 Thread Zak Whittington
VMware-BZ: 2192560
Signed-off-by: Zak Whittington 
---
 utilities/ovs-save | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/utilities/ovs-save b/utilities/ovs-save
index 2294583..902d331 100755
--- a/utilities/ovs-save
+++ b/utilities/ovs-save
@@ -121,11 +121,23 @@ save_flows () {
  cnt++;printf "{class="$1",type="$2",len="$3"}->"$4}'
 echo "'"
 
+printf "%s" "ovs-ofctl -O $ofp_version add-groups ${bridge} " \
+"\"$workdir/$bridge.groups.dump\""
+
+# If possible use OpenFlow 1.4 atomic bundle transaction to add groups
+[ ${ofp_version#OpenFlow} -ge 14 ] && bundle=" --bundle" || bundle=""
+echo "${bundle}"
+
 printf "%s" "ovs-ofctl -O $ofp_version replace-flows ${bridge} " \
 "\"$workdir/$bridge.flows.dump\""
 
 # If possible, use OpenFlow 1.4 atomic bundle transaction to add flows
-[ ${ofp_version#OpenFlow} -ge 14 ] && echo " --bundle" || echo
+echo "${bundle}"
+
+ovs-ofctl -O $ofp_version dump-groups "$bridge" | \
+sed -e '/^OFPST_GROUP_DESC/d' \
+-e '/^NXST_GROUP_DESC/d' > \
+"$workdir/$bridge.groups.dump"
 
 ovs-ofctl -O $ofp_version dump-flows --no-names --no-stats "$bridge" | 
\
 sed -e '/NXST_FLOW/d' \
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofproto-dpif-xlate: use new info-level logging helper when sending out an in_port

2018-08-07 Thread Zak Whittington
Added new helper function similar to xlate_report_error called
xlate_report_info that logs info-level messages, and used that
function to add an extra log message when attempting to send
out an in-port.

VMware-BZ: 2158607
Signed-off-by: Zak Whittington 
---
 ofproto/ofproto-dpif-xlate.c | 32 ++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 01f1faf..aa169bf 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -674,6 +674,34 @@ xlate_report_error(const struct xlate_ctx *ctx, const char 
*format, ...)
 ds_destroy();
 }
 
+/* This is like xlate_report() for messages that should be logged
+   at the info level (even when not tracing). */
+static void OVS_PRINTF_FORMAT(2, 3)
+xlate_report_info(const struct xlate_ctx *ctx, const char *format, ...)
+{
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+if (!OVS_UNLIKELY(ctx->xin->trace)
+&& (!ctx->xin->packet || VLOG_DROP_INFO())) {
+return;
+}
+
+struct ds s = DS_EMPTY_INITIALIZER;
+va_list args;
+va_start(args, format);
+ds_put_format_valist(, format, args);
+va_end(args);
+
+if (ctx->xin->trace) {
+oftrace_report(ctx->xin->trace, OFT_WARN, ds_cstr());
+} else {
+ds_put_format(, " on bridge %s while processing ",
+  ctx->xbridge->name);
+flow_format(, >base_flow, NULL);
+VLOG_INFO("%s", ds_cstr());
+}
+ds_destroy();
+}
+
 /* This is like xlate_report() for messages that should be logged at debug
  * level (even if we are not tracing) because they can be valuable for
  * debugging. */
@@ -5007,7 +5035,7 @@ xlate_output_action(struct xlate_ctx *ctx, ofp_port_t 
port,
 if (port != ctx->xin->flow.in_port.ofp_port) {
 compose_output_action(ctx, port, NULL, is_last_action, truncate);
 } else {
-xlate_report(ctx, OFT_WARN, "skipping output to input port");
+xlate_report_info(ctx, "skipping output to input port");
 }
 break;
 }
@@ -5092,7 +5120,7 @@ xlate_output_trunc_action(struct xlate_ctx *ctx,
 ctx->xout->slow |= SLOW_ACTION;
 }
 } else {
-xlate_report(ctx, OFT_WARN, "skipping output to input port");
+xlate_report_info(ctx, "skipping output to input port");
 }
 break;
 }
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofproto-dpif-xlate: Added logging for when sending out an in port

2018-08-07 Thread Zak Whittington
VMware-BZ: 2158607
Signed-off-by: Zak Whittington 
---
 ofproto/ofproto-dpif-xlate.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 01f1faf..9b36536 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -5007,6 +5007,18 @@ xlate_output_action(struct xlate_ctx *ctx, ofp_port_t 
port,
 if (port != ctx->xin->flow.in_port.ofp_port) {
 compose_output_action(ctx, port, NULL, is_last_action, truncate);
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+if (!VLOG_DROP_INFO()) {
+struct ds s = DS_EMPTY_INITIALIZER;
+ds_put_cstr(,
+"Skipping output to input port while processing: ");
+flow_format(, >base_flow, NULL);
+ds_put_format(, " on bridge %s", ctx->xbridge->name);
+VLOG_INFO("%s", ds_cstr());
+ds_destroy();
+}
+
+/* For when tracing only: */
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
@@ -5092,6 +5104,18 @@ xlate_output_trunc_action(struct xlate_ctx *ctx,
 ctx->xout->slow |= SLOW_ACTION;
 }
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+if (!VLOG_DROP_INFO()) {
+struct ds s = DS_EMPTY_INITIALIZER;
+ds_put_cstr(,
+"Skipping output to input port while processing:");
+flow_format(, >base_flow, NULL);
+ds_put_format(, " on bridge %s", ctx->xbridge->name);
+VLOG_INFO("%s", ds_cstr());
+ds_destroy();
+}
+
+/* For when tracing only: */
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofproto-dpif-xlate: Added logging when attempting to send out an in_port

2018-08-03 Thread Zak Whittington
VMware-BZ: 2158607
Signed-off-by: Zak Whittington 
---
 ofproto/ofproto-dpif-xlate.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 01f1faf..93fbee5 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -5007,6 +5007,8 @@ xlate_output_action(struct xlate_ctx *ctx, ofp_port_t 
port,
 if (port != ctx->xin->flow.in_port.ofp_port) {
 compose_output_action(ctx, port, NULL, is_last_action, truncate);
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+VLOG_INFO_RL(, "skipping output to input port");
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
@@ -5092,6 +5094,8 @@ xlate_output_trunc_action(struct xlate_ctx *ctx,
 ctx->xout->slow |= SLOW_ACTION;
 }
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+VLOG_INFO_RL(, "skipping output to input port");
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofproto-dpif-xlate: Added logging when attempting to send out an in_port

2018-08-03 Thread Zak Whittington
VMware-BZ: 2158607
---
 ofproto/ofproto-dpif-xlate.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 01f1faf..93fbee5 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -5007,6 +5007,8 @@ xlate_output_action(struct xlate_ctx *ctx, ofp_port_t 
port,
 if (port != ctx->xin->flow.in_port.ofp_port) {
 compose_output_action(ctx, port, NULL, is_last_action, truncate);
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+VLOG_INFO_RL(, "skipping output to input port");
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
@@ -5092,6 +5094,8 @@ xlate_output_trunc_action(struct xlate_ctx *ctx,
 ctx->xout->slow |= SLOW_ACTION;
 }
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+VLOG_INFO_RL(, "skipping output to input port");
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofproto-dpif: Add logging when sending out an in_port

2018-08-02 Thread Zak Whittington
This patch adds a log message to warn when sending out an in_port.

VMware-BZ: #2158607
Signed-off-by: Zak Whittington 
---
 ofproto/ofproto-dpif-xlate.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 01f1faf..93fbee5 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -5007,6 +5007,8 @@ xlate_output_action(struct xlate_ctx *ctx, ofp_port_t
port,
 if (port != ctx->xin->flow.in_port.ofp_port) {
 compose_output_action(ctx, port, NULL, is_last_action,
truncate);
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+VLOG_INFO_RL(, "skipping output to input port");
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
@@ -5092,6 +5094,8 @@ xlate_output_trunc_action(struct xlate_ctx *ctx,
 ctx->xout->slow |= SLOW_ACTION;
 }
 } else {
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+VLOG_INFO_RL(, "skipping output to input port");
 xlate_report(ctx, OFT_WARN, "skipping output to input port");
 }
 break;
-- 
2.7.4
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev