summaryrefslogtreecommitdiff
path: root/lib/ofp-print.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2015-12-21 15:39:10 -0800
committerBen Pfaff <blp@ovn.org>2016-01-07 09:04:26 -0800
commitad99e2ed492607397e33ee921133ff6ad64f4614 (patch)
tree4aa81d0b77a47dcaf3c97d4e794dad713885a303 /lib/ofp-print.c
parent56085be5fed24dbc44e01b6c72adcafe2328846f (diff)
downloadopenvswitch-ad99e2ed492607397e33ee921133ff6ad64f4614.tar.gz
Better abstract OFPT_SET_CONFIG and OFPT_GET_CONFIG_REPLY, make stricter.
The OFPT_SET_CONFIG and OFPT_GET_CONFIG_REPLY messages, which have the same format, have a 'flags' field in which OpenFlow defines some bits, which change somewhat from one version to another, and does not define others. Until now, Open vSwitch has not abstracted these messages at all and has ignored the bits that OpenFlow leaves undefined. This commit abstracts the messages in the same way as other OpenFlow messages and validates in OFPT_SET_CONFIG messages that the undefined bits are set to zero. OpenFlow 1.1 and 1.2, but not OpenFlow 1.0, define a flag named OFPC_INVALID_TTL_TO_CONTROLLER. Open vSwitch has until now also implemented this as an extension to OpenFlow 1.0, and this commit retains that extension. Reported-by: Manpreet Singh <er.manpreet25@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
Diffstat (limited to 'lib/ofp-print.c')
-rw-r--r--lib/ofp-print.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 02bcd7ae5..5525aee4e 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -496,25 +496,39 @@ ofp_print_switch_features(struct ds *string, const struct ofp_header *oh)
}
static void
-ofp_print_switch_config(struct ds *string, const struct ofp_switch_config *osc)
+ofp_print_switch_config(struct ds *string,
+ const struct ofputil_switch_config *config)
{
- enum ofp_config_flags flags;
+ ds_put_format(string, " frags=%s",
+ ofputil_frag_handling_to_string(config->frag));
- flags = ntohs(osc->flags);
-
- ds_put_format(string, " frags=%s", ofputil_frag_handling_to_string(flags));
- flags &= ~OFPC_FRAG_MASK;
-
- if (flags & OFPC_INVALID_TTL_TO_CONTROLLER) {
+ if (config->invalid_ttl_to_controller > 0) {
ds_put_format(string, " invalid_ttl_to_controller");
- flags &= ~OFPC_INVALID_TTL_TO_CONTROLLER;
}
- if (flags) {
- ds_put_format(string, " ***unknown flags 0x%04"PRIx16"***", flags);
+ ds_put_format(string, " miss_send_len=%"PRIu16"\n", config->miss_send_len);
+}
+
+static void
+ofp_print_set_config(struct ds *string, const struct ofp_header *oh)
+{
+ struct ofputil_switch_config config;
+ enum ofperr error;
+
+ error = ofputil_decode_set_config(oh, &config);
+ if (error) {
+ ofp_print_error(string, error);
+ return;
}
+ ofp_print_switch_config(string, &config);
+}
- ds_put_format(string, " miss_send_len=%"PRIu16"\n", ntohs(osc->miss_send_len));
+static void
+ofp_print_get_config_reply(struct ds *string, const struct ofp_header *oh)
+{
+ struct ofputil_switch_config config;
+ ofputil_decode_get_config_reply(oh, &config);
+ ofp_print_switch_config(string, &config);
}
static void print_wild(struct ds *string, const char *leader, int is_wild,
@@ -3212,8 +3226,11 @@ ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw,
break;
case OFPTYPE_GET_CONFIG_REPLY:
+ ofp_print_get_config_reply(string, oh);
+ break;
+
case OFPTYPE_SET_CONFIG:
- ofp_print_switch_config(string, ofpmsg_body(oh));
+ ofp_print_set_config(string, oh);
break;
case OFPTYPE_PACKET_IN: