From: Ben Pfaff Date: Thu, 2 Dec 2010 22:15:33 +0000 (-0800) Subject: nicira-ext: Clarify and fix macros to check for NXM metadata registers. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19e7439c61970cc5066aae601492a2e9b55ffcb7;p=openvswitch nicira-ext: Clarify and fix macros to check for NXM metadata registers. 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 --- diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h index 8140edfc..97f54788 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)