Signed-off-by: Simon Horman <ho...@verge.net.au> --- v2 As suggested by Ben Pfaff * Where Open Flow 1.2 breaks apart error codes defined in previous versions, provide all new definitions to previous versions and map the numeric error code to the first first definition supplied in ofp-errors.h. The case handled so far is: OFPERR_OFPBIC_BAD_EXP_TYPE -> { OFPERR_OFPBIC_BAD_EXPERIMENTER, OFPERR_OFPBIC_BAD_EXP_TYPE } * Correct name of OFPERR_OFPERR_BAD_ROLE, it should be OFPERR_OFPRRFC_BAD_ROLE. * Where Open Flow 1.2 adds error codes that were previously defined as Nicira extension errors define the later in terms of the new codes.
Add some missing common openflow definitions Signed-off-by: Simon Horman <ho...@verge.net.au> --- build-aux/extract-ofp-errors | 30 +++++++---- lib/nx-match.c | 10 ++-- lib/ofp-errors.h | 117 +++++++++++++++++++++++++++++++++++------- ofproto/ofproto.c | 2 +- 4 files changed, 125 insertions(+), 34 deletions(-) diff --git a/build-aux/extract-ofp-errors b/build-aux/extract-ofp-errors index 5c3cd26..9c84283 100755 --- a/build-aux/extract-ofp-errors +++ b/build-aux/extract-ofp-errors @@ -145,7 +145,7 @@ def extract_ofp_errors(filenames): names = [] domain = {} reverse = {} - for domain_name in ("OF1.0", "OF1.1", "NX1.0", "NX1.1"): + for domain_name in ("OF1.0", "OF1.1", "OF1.2", "NX1.0", "NX1.1"): domain[domain_name] = {} reverse[domain_name] = {} @@ -194,29 +194,33 @@ def extract_ofp_errors(filenames): names.append(enum) for dst in dsts.split(', '): - m = re.match(r'([A-Z0-9.]+)\((\d+)(?:,(\d+))?\)$', dst) + m = re.match(r'([A-Z0-9.]+(?:only)?)\((\d+|(0x)[0-9a-fA-F]+)(?:,(\d+))?\)$', dst) if not m: fatal("%s: syntax error in destination" % dst) targets = m.group(1) - type_ = int(m.group(2)) if m.group(3): - code = int(m.group(3)) + base = 16 + else: + base = 10 + type_ = int(m.group(2), base) + if m.group(4): + code = int(m.group(4)) else: code = None - target_map = {"OF": ("OF1.0", "OF1.1"), + target_map = {"OF": ("OF1.0", "OF1.1", "OF1.2"), "OF1.0": ("OF1.0",), - "OF1.1": ("OF1.1",), - "NX": ("OF1.0", "OF1.1"), + "OF1.1only": ("OF1.1",), + "OF1.1": ("OF1.1", "OF1.2"), + "NX": ("OF1.0", "OF1.1", "OF1.2"), "NX1.0": ("OF1.0",), - "NX1.1": ("OF1.1",)} + "NX1.1": ("OF1.1",), + "OF1.2": ("OF1.2",)}; if targets not in target_map: fatal("%s: unknown error domain" % target) for target in target_map[targets]: if type_ not in domain[target]: domain[target][type_] = {} - if code in domain[target][type_]: - fatal("%s: duplicate assignment in domain" % dst) domain[target][type_][code] = enum reverse[target][enum] = (type_, code) @@ -253,12 +257,17 @@ static enum ofperr %s_decode(uint16_t type, uint16_t code) { switch ((type << 16) | code) {""" % name + found = [] for enum in names: if enum not in map: continue type_, code = map[enum] if code is None: continue + value = type_ << 16 | code + if value in found: + continue + found.append(value) print " case (%d << 16) | %d:" % (type_, code) print " return OFPERR_%s;" % enum print """\ @@ -306,6 +315,7 @@ const struct ofperr_domain %s = { output_domain(reverse["OF1.0"], "ofperr_of10", "OpenFlow 1.0", 0x01) output_domain(reverse["OF1.1"], "ofperr_of11", "OpenFlow 1.1", 0x02) + output_domain(reverse["OF1.2"], "ofperr_of12", "OpenFlow 1.2", 0x03) if __name__ == '__main__': if '--help' in sys.argv: diff --git a/lib/nx-match.c b/lib/nx-match.c index 3ead9b6..47784b0 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -124,16 +124,16 @@ nx_pull_match__(struct ofpbuf *b, unsigned int match_len, bool strict, continue; } } else if (!mf_are_prereqs_ok(mf, &rule->flow)) { - error = OFPERR_NXBRC_NXM_BAD_PREREQ; + error = OFPERR_OFPBMC_BAD_PREREQ; } else if (!mf_is_all_wild(mf, &rule->wc)) { - error = OFPERR_NXBRC_NXM_DUP_TYPE; + error = OFPERR_OFPBMC_DUP_FIELD; } else { unsigned int width = mf->n_bytes; union mf_value value; memcpy(&value, p + 4, width); if (!mf_is_value_valid(mf, &value)) { - error = OFPERR_NXBRC_NXM_BAD_VALUE; + error = OFPERR_OFPBMC_BAD_VALUE; } else if (!NXM_HASMASK(header)) { error = 0; mf_set_value(mf, &value, rule); @@ -142,7 +142,7 @@ nx_pull_match__(struct ofpbuf *b, unsigned int match_len, bool strict, memcpy(&mask, p + 4 + width, width); if (!mf_is_mask_valid(mf, &mask)) { - error = OFPERR_NXBRC_NXM_BAD_MASK; + error = OFPERR_OFPBMC_BAD_MASK; } else { error = 0; mf_set(mf, &value, &mask, rule); @@ -153,7 +153,7 @@ nx_pull_match__(struct ofpbuf *b, unsigned int match_len, bool strict, /* Check if the match is for a cookie rather than a classifier rule. */ if ((header == NXM_NX_COOKIE || header == NXM_NX_COOKIE_W) && cookie) { if (*cookie_mask) { - error = OFPERR_NXBRC_NXM_DUP_TYPE; + error = OFPERR_OFPBMC_DUP_FIELD; } else { unsigned int width = sizeof *cookie; diff --git a/lib/ofp-errors.h b/lib/ofp-errors.h index cef32f2..2d434cf 100644 --- a/lib/ofp-errors.h +++ b/lib/ofp-errors.h @@ -95,6 +95,15 @@ enum ofperr { /* OF1.1(1,9). Specified table-id invalid or does not exist. */ OFPERR_OFPBRC_BAD_TABLE_ID, + /* OF1.2(1,10). Denied because controller is slave. */ + OFPERR_OFPBRC_IS_SLAVE, + + /* OF1.2(1,11). Invalid port. */ + OFPERR_OFPBRC_BAD_PORT, + + /* OF1.2(1,12). Invalid packet in packet-out. */ + OFPERR_OFPBRC_BAD_PACKET, + /* NX(1,256). Invalid NXM flow match. */ OFPERR_NXBRC_NXM_INVALID, @@ -102,24 +111,9 @@ enum ofperr { * nxm_hasmask or nxm_length or both, is invalid or not implemented. */ OFPERR_NXBRC_NXM_BAD_TYPE, - /* NX(1,258). Invalid nxm_value. */ - OFPERR_NXBRC_NXM_BAD_VALUE, - - /* NX(1,259). Invalid nxm_mask. */ - OFPERR_NXBRC_NXM_BAD_MASK, - - /* NX(1,260). A prerequisite was not met. */ - OFPERR_NXBRC_NXM_BAD_PREREQ, - - /* NX(1,261). A given nxm_type was specified more than once. */ - OFPERR_NXBRC_NXM_DUP_TYPE, - /* NX(1,512). A request specified a nonexistent table ID. */ OFPERR_NXBRC_BAD_TABLE_ID, - /* NX(1,513). NXT_ROLE_REQUEST specified an invalid role. */ - OFPERR_NXBRC_BAD_ROLE, - /* NX(1,514). The in_port in an ofp_packet_out request is invalid. */ OFPERR_NXBRC_BAD_IN_PORT, @@ -176,6 +170,15 @@ enum ofperr { /* OF1.1(2,12). Actions uses an unsupported tag/encap. */ OFPERR_OFPBAC_BAD_TAG, + /* OF1.2(2,13). Unsupported type in SET_FIELD action. */ + OFPERR_OFPBAC_SET_TYPE, + + /* OF1.2(2,14). Length problem in SET_FIELD action. */ + OFPERR_OFPBAC_SET_LEN, + + /* OF1.2(2,15). Bad argument in SET_FIELD action. */ + OFPERR_OFPBAC_ARGUMENT, + /* NX(2,256). Must-be-zero action argument had nonzero value. */ OFPERR_NXBAC_MUST_BE_ZERO, @@ -201,8 +204,17 @@ enum ofperr { /* OF1.1(3,4). Metadata mask value unsupported by datapath. */ OFPERR_OFPBIC_UNSUP_METADATA_MASK, - /* OF1.1(3,5). Specific experimenter instruction unsupported. */ - OFPERR_OFPBIC_UNSUP_EXP_INST, + /* OF1.1only(3,5), OF1.2(3,5). Unknown experimenter id specified. */ + OFPERR_OFPBIC_BAD_EXPERIMENTER, + + /* OF1.1only(3,5), OF1.2(3,6). Unknown instruction for experimenter id. */ + OFPERR_OFPBIC_BAD_EXP_TYPE, + + /* OF1.2(3,7). Length problem in instructions. */ + OFPERR_OFPBIC_BAD_LEN, + + /* OF1.2(3,8). Permissions error. */ + OFPERR_OFPBIC_EPERM, /* ## --------------- ## */ /* ## OFPET_BAD_MATCH ## */ @@ -234,9 +246,22 @@ enum ofperr { /* OF1.1(4,6). Unsupported field in the match. */ OFPERR_OFPBMC_BAD_FIELD, - /* OF1.1(4,7). Unsupported value in a match field. */ + /* NX1.0(1,258), NX1.1(1,258), OF1.1(4,7). Unsupported value in a match field. */ OFPERR_OFPBMC_BAD_VALUE, + /* NX1.0(1,259), NX1.1(1,259), OF1.2(4,8). Unsupported mask specified in the match, + field is not dl-address or nw-address. */ + OFPERR_OFPBMC_BAD_MASK, + + /* NX1.0(1,260), NX1.1(1,260), OF1.2(4,9). A prerequisite was not met. */ + OFPERR_OFPBMC_BAD_PREREQ, + + /* NX1.0(1,261), NX1.1(1,261), OF1.2(4,10). A field type was duplicated. */ + OFPERR_OFPBMC_DUP_FIELD, + + /* OF1.2(4,11). Permissions error. */ + OFPERR_OFPBMC_EPERM, + /* ## --------------------- ## */ /* ## OFPET_FLOW_MOD_FAILED ## */ /* ## --------------------- ## */ @@ -272,6 +297,9 @@ enum ofperr { /* OF1.0(3,4), OF1.1(5,6). Unsupported or unknown command. */ OFPERR_OFPFMFC_BAD_COMMAND, + /* OF1.2(5,7). Unsupported or unknown flags. */ + OFPERR_OFPFMFC_BAD_FLAGS, + /* OF1.0(3,5). Unsupported action list - cannot process in the order * specified. */ OFPERR_OFPFMFC_UNSUPPORTED, @@ -323,6 +351,25 @@ enum ofperr { * modify a non-existent group. */ OFPERR_OFPGMFC_UNKNOWN_GROUP, + /* OF1.2(6,9). Group not deleted because another + group is forwarding to it. */ + OFPERR_OFPGMFC_CHAINED_GROUP, + + /* OF1.2(6,10). Unsupported or unknown group type. */ + OFPERR_OFPGMFC_BAD_TYPE, + + /* OF1.2(6,11). Unsupported or unknown command. */ + OFPERR_OFPGMFC_BAD_COMMAND, + + /* OF1.2(6,12). Error in bucket. */ + OFPERR_OFPGMFC_OFPGMFC_BAD_BUCKET, + + /* OF1.2(6,13). Error in watch port/group. */ + OFPERR_OFPGMFC_OFPGMFC_BAD_WATCH, + + /* OF1.2(6,14). Permissions error. */ + OFPERR_OFPGMFC_OFPGMFC_EPERM, + /* ## --------------------- ## */ /* ## OFPET_PORT_MOD_FAILED ## */ /* ## --------------------- ## */ @@ -343,6 +390,9 @@ enum ofperr { /* OF1.1(7,3). Specified advertise is invalid. */ OFPERR_OFPPMFC_BAD_ADVERTISE, + /* OF1.2(7,4). Permissions error. */ + OFPERR_OFPPMFC_EPERM, + /* ## ---------------------- ## */ /* ## OFPET_TABLE_MOD_FAILED ## */ /* ## ---------------------- ## */ @@ -356,6 +406,9 @@ enum ofperr { /* OF1.1(8,1). Specified config is invalid. */ OFPERR_OFPTMFC_BAD_CONFIG, + /* OF1.2(8,2). Permissions error. */ + OFPERR_OFPTMFC_EPERM, + /* ## --------------------- ## */ /* ## OFPET_QUEUE_OP_FAILED ## */ /* ## --------------------- ## */ @@ -384,10 +437,38 @@ enum ofperr { /* OF1.1(10,1). Specified len is invalid. */ OFPERR_OFPSCFC_BAD_LEN, + + /* OF1.2(10,2). Permissions error. */ + OFPERR_OFPSCFC_EPERM, + +/* ## ------------------------- ## */ +/* ## OFPET_ROLE_REQUEST_FAILED ## */ +/* ## ------------------------- ## */ + + /* OF1.2(11). Controller Role request failed. */ + OFPERR_OFPET_ROLE_REQUEST_FAILED, + + /* OF1.2(11,0). Stale Message: old generation_id. */ + OFPERR_OFPRRFC_STALE, + + /* OF1.2(11,1). Controller role change unsupported. */ + OFPERR_OFPRRFC_UNSUP, + + /* NX1.0(1,513), NX1.1(1,513), OF1.2(11,2). Invalid role. */ + OFPERR_OFPRRFC_BAD_ROLE, + + +/* ## ------------------ ## */ +/* ## OFPET_EXPERIMENTER ## */ +/* ## ------------------ ## */ + + /* OF1.2(0xffff). Experimenter error messages. */ + OFPERR_OFPET_EXPERIMENTER, }; extern const struct ofperr_domain ofperr_of10; extern const struct ofperr_domain ofperr_of11; +extern const struct ofperr_domain ofperr_of12; const struct ofperr_domain *ofperr_domain_from_version(uint8_t version); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index aa97124..e7e0401 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3064,7 +3064,7 @@ handle_role_request(struct ofconn *ofconn, const struct ofp_header *oh) role = ntohl(nrr->role); if (role != NX_ROLE_OTHER && role != NX_ROLE_MASTER && role != NX_ROLE_SLAVE) { - return OFPERR_NXBRC_BAD_ROLE; + return OFPERR_OFPRRFC_BAD_ROLE; } if (ofconn_get_role(ofconn) != role -- 1.7.6.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev