From: Simon Horman Date: Mon, 30 Jul 2012 02:03:00 +0000 (+0900) Subject: ofproto: As of Open Flow 1.1 switch_features has no capabilities field X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=210d8d9cc1f46d874b9d3a8dc08f8d7dee8ce41d;p=openvswitch ofproto: As of Open Flow 1.1 switch_features has no capabilities field In Open Flow 1.0 switch_features has a capabilities field. However, in Open Flow 1.1, 1.2 and 1.3 this field is reserved. Thus it should not be read on decode and it seems most appropriate to set as zero on encode. This patch takes the approach of setting the features field to all available features for Open Flow 1.1+. I am unsure if it would be sufficient to just set it to zero. Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/lib/ofp-print.c b/lib/ofp-print.c index dc9fb6de..832e008e 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -507,10 +507,19 @@ ofp_print_switch_features(struct ds *string, const struct ofp_header *oh) ofputil_capabilities_to_name, ' '); ds_put_char(string, '\n'); - ds_put_cstr(string, "actions: "); - ofp_print_bit_names(string, features.actions, - ofputil_action_bitmap_to_name, ' '); - ds_put_char(string, '\n'); + switch ((enum ofp_version)oh->version) { + case OFP10_VERSION: + ds_put_cstr(string, "actions: "); + ofp_print_bit_names(string, features.actions, + ofputil_action_bitmap_to_name, ' '); + ds_put_char(string, '\n'); + break; + case OFP11_VERSION: + case OFP12_VERSION: + break; + default: + NOT_REACHED(); + } ofp_print_phy_ports(string, oh->version, &b); } diff --git a/lib/ofp-util.c b/lib/ofp-util.c index a943b4ec..3c3513c4 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -2418,7 +2418,16 @@ ofputil_decode_switch_features(const struct ofp_header *oh, if (osf->capabilities & htonl(OFPC11_GROUP_STATS)) { features->capabilities |= OFPUTIL_C_GROUP_STATS; } - features->actions = decode_action_bits(osf->actions, of11_action_bits); + switch ((enum ofp_version)oh->version) { + case OFP11_VERSION: + case OFP12_VERSION: + features->actions = decode_action_bits(htonl(UINT32_MAX), + of11_action_bits); + break; + case OFP10_VERSION: + default: + NOT_REACHED(); + } } else { return OFPERR_OFPBRC_BAD_VERSION; } @@ -2517,7 +2526,6 @@ ofputil_encode_switch_features(const struct ofputil_switch_features *features, if (features->capabilities & OFPUTIL_C_GROUP_STATS) { osf->capabilities |= htonl(OFPC11_GROUP_STATS); } - osf->actions = encode_action_bits(features->actions, of11_action_bits); break; default: NOT_REACHED(); diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 35faaff9..21466247 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -202,7 +202,6 @@ ff ff ff fe 00 00 00 00 50 54 00 00 00 01 00 00 \ OFPT_FEATURES_REPLY (OF1.1) (xid=0x1): dpid:0000505400000001 n_tables:2, n_buffers:256 capabilities: FLOW_STATS TABLE_STATS PORT_STATS ARP_MATCH_IP -actions: OUTPUT SET_VLAN_VID SET_VLAN_PCP SET_DL_SRC SET_DL_DST SET_NW_SRC SET_NW_DST SET_NW_ECN SET_NW_TOS SET_TP_SRC SET_TP_DST COPY_TTL_OUT COPY_TTL_IN SET_MPLS_LABEL SET_MPLS_TC SET_MPLS_TTL 3(eth0): addr:50:54:00:00:00:01 config: 0 state: 0