[ovs-dev] [nxm-fixes 1/3] nicira-ext: Clarify and fix macros to check for NXM metadata registers.

Justin Pettit jpettit at nicira.com
Tue Dec 7 02:57:38 UTC 2010


Looks good.

--Justin


On Dec 2, 2010, at 2:22 PM, Ben Pfaff wrote:

> The NXM_IS_NX_REG macro didn't check the "hasmask" bit, which meant that it
> looked like it was supposed to match both exact and wildcarded NXM headers,
> e.g. both NXM_NX_REG0 and NXM_NX_REG0_W.  But exact and wildcarded NXM
> headers differ not just in the "hasmask" bit but in the "length" value
> also (the wildcarded version's length is twice the exact version's length),
> so this was not what it actually did.
> 
> The only current users of NXM_IS_NX_REG actually only want to match exact
> versions, so this commit makes it only match those.  It also adds a new
> NXM_IS_NX_REG_W macro that matches only wildcarded versions.  This new
> macro has no users yet, but its existence should help to make it clear that
> NXM_IS_NX_REG only matches exact NXM headers.
> 
> Reported-by: Natasha Gude <natasha at nicira.com>
> ---
> include/openflow/nicira-ext.h |    3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h
> index 1a59d3b..56a3195 100644
> --- a/include/openflow/nicira-ext.h
> +++ b/include/openflow/nicira-ext.h
> @@ -864,7 +864,8 @@ OFP_ASSERT(sizeof(struct nx_action_note) == 16);
> #define NXM_NX_REG(IDX)   NXM_HEADER  (0x0001, IDX, 4)
> #define NXM_NX_REG_W(IDX) NXM_HEADER_W(0x0001, IDX, 4)
> #define NXM_NX_REG_IDX(HEADER) NXM_FIELD(HEADER)
> -#define NXM_IS_NX_REG(HEADER) (!((((HEADER) ^ NXM_NX_REG(0))) & 0xffffe0ff))
> +#define NXM_IS_NX_REG(HEADER) (!((((HEADER) ^ NXM_NX_REG0)) & 0xffffe1ff))
> +#define NXM_IS_NX_REG_W(HEADER) (!((((HEADER) ^ NXM_NX_REG0_W)) & 0xffffe1ff))
> #define NXM_NX_REG0       NXM_HEADER  (0x0001, 0, 4)
> #define NXM_NX_REG0_W     NXM_HEADER_W(0x0001, 0, 4)
> #define NXM_NX_REG1       NXM_HEADER  (0x0001, 1, 4)
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list