Skip to content

Commit

Permalink
nx-match: Serialize standard xregs instead of Nicira registers, in OF…
Browse files Browse the repository at this point in the history
…1.5.

Commit 79fe0f4 (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 <[email protected]>
Acked-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
blp committed Sep 4, 2014
1 parent 6524e99 commit a678b23
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 4 deletions.
14 changes: 11 additions & 3 deletions lib/nx-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,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. */
Expand Down
93 changes: 92 additions & 1 deletion tests/ovs-ofctl.at
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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)
])
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand Down

0 comments on commit a678b23

Please sign in to comment.