Commit 79fe0f4611b60 (meta-flow: Add 64-bit registers.) added support for the OpenFlow 1.5 (draft) standardized registers, but neglected to cause them to be serialized when Open vSwitch composes flow matches. This meant that they were always sent to a controller as pairs of Nicira extension registers. This commit fixes the problem.
Found by inspection. ONF-JIRA: EXT-244 Signed-off-by: Ben Pfaff <b...@nicira.com> --- lib/nx-match.c | 14 ++++++-- tests/ovs-ofctl.at | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/lib/nx-match.c b/lib/nx-match.c index 1d3205f..6eee551 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -723,9 +723,17 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match, flow->tunnel.ip_dst, match->wc.masks.tunnel.ip_dst); /* Registers. */ - for (i = 0; i < FLOW_N_REGS; i++) { - nxm_put_32m(b, mf_oxm_header(MFF_REG0 + i, oxm), - htonl(flow->regs[i]), htonl(match->wc.masks.regs[i])); + if (oxm < OFP15_VERSION) { + for (i = 0; i < FLOW_N_REGS; i++) { + nxm_put_32m(b, mf_oxm_header(MFF_REG0 + i, oxm), + htonl(flow->regs[i]), htonl(match->wc.masks.regs[i])); + } + } else { + for (i = 0; i < FLOW_N_XREGS; i++) { + nxm_put_64m(b, mf_oxm_header(MFF_XREG0 + i, oxm), + htonll(flow_get_xreg(flow, i)), + htonll(flow_get_xreg(&match->wc.masks, i))); + } } /* Mark. */ diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at index 6e82837..8eca295 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -1681,7 +1681,7 @@ NXM_OF_IN_PORT(0001), NXM_OF_ETH_TYPE(0800) ]) AT_CLEANUP -AT_SETUP([ovs-ofctl parse-oxm]) +AT_SETUP([ovs-ofctl parse-oxm (OpenFlow 1.5)]) AT_KEYWORDS([oxm]) AT_DATA([oxm.txt], [dnl <any> @@ -1895,6 +1895,27 @@ OXM_OF_ETH_TYPE(86dd) OXM_OF_IP_PROTO(3a) OXM_OF_ICMPV6_TYPE(87) OXM_OF_IPV6_ND_ OXM_OF_ETH_TYPE(86dd) OXM_OF_IP_PROTO(3b) OXM_OF_ICMPV6_TYPE(87) OXM_OF_IPV6_ND_TARGET(20010db83c4d00010002000300040005) OXM_OF_IPV6_ND_TLL(0002e30f80a4) OXM_OF_ETH_TYPE(0800) OXM_OF_IP_PROTO(3a) OXM_OF_ICMPV6_TYPE(88) OXM_OF_IPV6_ND_TARGET(20010db83c4d00010002000300040005) OXM_OF_IPV6_ND_TLL(0002e30f80a4) +# Registers 0, 1, and 2. +NXM_NX_REG0(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0(a0e0d050) +NXM_NX_REG1(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1(a0e0d050) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2_W(a0e0d050/f0f0f0f0) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2(a0e0d050) + +# Extended registers 0, 1, and 2. +# (For OpenFlow 1.2, OVS transforms these into its extension registers.) +OXM_OF_PKT_REG0_W(acebdf5600000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(00000000acebdf56/00000000ffffffff) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0f0f0f0f0) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0ffffffff) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/ffffffff00000000) + # Invalid field number. 01020304(1111/2222) ]) @@ -2111,6 +2132,27 @@ nx_pull_match() returned error OFPBMC_BAD_PREREQ nx_pull_match() returned error OFPBMC_BAD_PREREQ nx_pull_match() returned error OFPBMC_BAD_PREREQ +# Registers 0, 1, and 2. +NXM_NX_REG0(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0(a0e0d050) +NXM_NX_REG1(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1(a0e0d050) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2_W(a0e0d050/f0f0f0f0) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2(a0e0d050) + +# Extended registers 0, 1, and 2. +# (For OpenFlow 1.2, OVS transforms these into its extension registers.) +NXM_NX_REG0(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0(a0e0d050) +NXM_NX_REG1(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1(a0e0d050) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2_W(a0e0d050/f0f0f0f0) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2(a0e0d050) + # Invalid field number. nx_pull_match() returned error OFPBMC_BAD_FIELD ], [stderr]) @@ -2125,6 +2167,55 @@ nx_match|WARN|NXM/OXM entry OXM_OF_METADATA_W(1234567890abcdef/ffff0000ffff0000) AT_CHECK([grep -v 'has 1-bits in value' stderr], [1]) AT_CLEANUP +AT_SETUP([ovs-ofctl parse-oxm (OpenFlow 1.5)]) +AT_KEYWORDS([oxm]) +AT_DATA([oxm.txt], [dnl +# Extended registers 0 and 1. +OXM_OF_PKT_REG0_W(acebdf5600000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(00000000acebdf56/00000000ffffffff) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0f0f0f0f0) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0ffffffff) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/ffffffff00000000) + +# Registers 0, 1, and 2. +# (OpenFlow 1.5 transforms these into the standard "xregs".) +NXM_NX_REG0(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0(a0e0d050) +NXM_NX_REG1(acebdf56) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1_W(a0e0d050/f0f0f0f0) +NXM_NX_REG0_W(a0e0d050/f0f0f0f0), NXM_NX_REG1(a0e0d050) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2_W(a0e0d050/f0f0f0f0) +NXM_NX_REG1_W(a0e0d050/f0f0f0f0), NXM_NX_REG2(a0e0d050) +]) +AT_CHECK([ovs-ofctl '-vPATTERN:console:%c|%p|%m' --strict parse-oxm OpenFlow15 < oxm.txt], + [0], [dnl +# Extended registers 0 and 1. +OXM_OF_PKT_REG0_W(acebdf5600000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(00000000acebdf56/00000000ffffffff) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0f0f0f0f0) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0ffffffff) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/ffffffff00000000) + +# Registers 0, 1, and 2. +# (OpenFlow 1.5 transforms these into the standard "xregs".) +OXM_OF_PKT_REG0_W(acebdf5600000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(a0e0d05000000000/ffffffff00000000) +OXM_OF_PKT_REG0_W(00000000acebdf56/00000000ffffffff) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0f0f0f0f0) +OXM_OF_PKT_REG0_W(a0e0d050a0e0d050/f0f0f0f0ffffffff) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/f0f0f0f000000000) +OXM_OF_PKT_REG0_W(00000000a0e0d050/00000000f0f0f0f0), OXM_OF_PKT_REG1_W(a0e0d05000000000/ffffffff00000000) +], []) +AT_CLEANUP + AT_SETUP([ovs-ofctl parse-oxm loose]) AT_KEYWORDS([oxm]) AT_DATA([oxm.txt], [dnl -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev