% (version1_name, version2_name,
version2_name, version1_name))
- if vendor == vendor_map['NX']:
+ if vendor == vendor_map['OF']:
+ # All standard OpenFlow errors have a type and a code.
+ if code is None:
+ fatal("%s: %s domain requires code" % (dst, vendor_name))
+ elif vendor == vendor_map['NX']:
+ # Before OpenFlow 1.2, OVS used a Nicira extension to
+ # define errors that included a type and a code.
+ #
+ # In OpenFlow 1.2 and later, Nicira extension errors
+ # are defined using the OpenFlow experimenter error
+ # mechanism that includes a type but not a code.
+ if v1 < version_map['1.2'] or v2 < version_map['1.2']:
+ if code is None:
+ fatal("%s: NX1.0 and NX1.1 domains require code"
+ % (dst, vendor_name))
if v1 >= version_map['1.2'] or v2 >= version_map['1.2']:
if code is not None:
fatal("%s: NX1.2+ domains do not have codes" % dst)
- code = 0
- elif vendor != vendor_map['OF']:
+ else:
+ # Experimenter extension error for OF1.2+ only.
+ if v1 < version_map['1.2']:
+ fatal("%s: %s domain not supported before OF1.2"
+ % (dst, vendor_name))
if code is not None:
- fatal("%s: %s domains do not have codes" % vendor_name)
+ fatal("%s: %s domains do not have codes"
+ % (dst, vendor_name))
+ if code is None:
+ code = 0
for version in range(v1, v2 + 1):
domain[version].setdefault(vendor, {})
if enum not in map:
continue
vendor, type_, code = map[enum]
- if code is None:
- continue
value = (vendor << 32) | (type_ << 16) | code
if value in found:
continue
OFPT_ERROR (OF1.2) (xid=0x55555555): NXBRC_MUST_BE_ZERO
OFPT_ECHO_REQUEST (xid=0x11111111): 0 bytes of payload
])
+
+AT_CHECK([ovs-ofctl ofp-print '0301001812345678 ffff0a28 4f4e4600 0300000812345678'], [0], [dnl
+OFPT_ERROR (OF1.2) (xid=0x12345678): OFPBIC_DUP_INST
+OFPT_HELLO (OF1.2) (xid=0x12345678):
+ version bitmap: 0x01, 0x02, 0x03
+])
+AT_CHECK([ovs-ofctl ofp-print '0401001812345678 ffff0a28 4f4e4600 0400000812345678'], [0], [dnl
+OFPT_ERROR (OF1.3) (xid=0x12345678): OFPBIC_DUP_INST
+OFPT_HELLO (OF1.3) (xid=0x12345678):
+ version bitmap: 0x01, 0x02, 0x03, 0x04
+])
+AT_CHECK([ovs-ofctl ofp-print '0501001412345678 00030009 0500000812345678'], [0], [dnl
+OFPT_ERROR (OF1.4) (xid=0x12345678): OFPBIC_DUP_INST
+OFPT_HELLO (OF1.4) (xid=0x12345678):
+ version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05
+])
AT_CLEANUP
AT_SETUP([encoding experimenter errors])
AT_KEYWORDS([ofp-print ofp-errors])
+# Demonstrate that a Nicira extension error gets encoded correctly
+# using the Nicira error extension format in OF1.0 and OF1.1, and
+# correctly using the standard experimenter format in OF1.2.
AT_CHECK(
[ovs-ofctl encode-error-reply NXBRC_MUST_BE_ZERO 0100000812345678], [0], [dnl
00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@
00000000 03 01 00 18 12 34 56 78-ff ff 00 04 00 00 23 20 @&t@
00000010 03 00 00 08 12 34 56 78-
])
+
+# Check that OFPERR_OFPBIC_DUP_INST is:
+# - not encodable in OF1.0 (OF1.0 doesn't have instructions, after all).
+# - encoded as a Nicira extension in OF1.1.
+# - encoded as an ONF extension in OF1.2 and OF1.3.
+# - encoded in the standard form in OF1.4.
+AT_CHECK(
+ [ovs-ofctl '-vPATTERN:console:%c|%p|%m' encode-error-reply OFPBIC_DUP_INST 0100000812345678], [0], [dnl
+00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@
+00000010 00 01 02 09 01 00 00 08-12 34 56 78 @&t@
+], [ofp_errors|ERR|cannot encode OFPBIC_DUP_INST for OpenFlow 1.0
+])
+AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0200000812345678], [0],
+[00000000 02 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@
+00000010 00 03 01 00 02 00 00 08-12 34 56 78 @&t@
+])
+AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0300000812345678], [0],
+[00000000 03 01 00 18 12 34 56 78-ff ff 0a 28 4f 4e 46 00 @&t@
+00000010 03 00 00 08 12 34 56 78-
+])
+AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0400000812345678], [0],
+[00000000 04 01 00 18 12 34 56 78-ff ff 0a 28 4f 4e 46 00 @&t@
+00000010 04 00 00 08 12 34 56 78-
+])
+AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0500000812345678], [0],
+[00000000 05 01 00 14 12 34 56 78-00 03 00 09 05 00 00 08 @&t@
+00000010 12 34 56 78 @&t@
+])
AT_CLEANUP