[ovs-dev] [PATCH] lib: Add zero padding field to flow_wildcards.

Ethan Jackson ethan at nicira.com
Fri Dec 3 23:53:58 UTC 2010


Before this commit, the compiler would add two bytes of padding to
the 'flow_wildcards' structure to achieve 32bit alignment.  These
two bytes had inconsistent values which caused 'flow_wildcards_hash'
to behave inconsistently.  This commit explicitly 32bit aligns
'flow_wildcards' with zero padding.

This commit also fixes an issue where in-band rules were not
getting deleted when in-band control was disabled.
---
 lib/flow.c |    2 ++
 lib/flow.h |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 7198f7d..ebbd927 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -306,6 +306,7 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc)
     wc->nw_dst_mask = htonl(0);
     memset(wc->reg_masks, 0, sizeof wc->reg_masks);
     wc->vlan_tci_mask = htons(0);
+    wc->zero = 0;
 }
 
 /* Initializes 'wc' as an exact-match set of wildcards; that is, 'wc' does not
@@ -318,6 +319,7 @@ flow_wildcards_init_exact(struct flow_wildcards *wc)
     wc->nw_dst_mask = htonl(UINT32_MAX);
     memset(wc->reg_masks, 0xff, sizeof wc->reg_masks);
     wc->vlan_tci_mask = htons(UINT16_MAX);
+    wc->zero = 0;
 }
 
 /* Returns true if 'wc' is exact-match, false if 'wc' wildcards any bits or
diff --git a/lib/flow.h b/lib/flow.h
index fd3246b..1509a7d 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -124,6 +124,7 @@ struct flow_wildcards {
     ovs_be32 nw_src_mask;       /* 1-bit in each significant nw_src bit. */
     ovs_be32 nw_dst_mask;       /* 1-bit in each significant nw_dst bit. */
     ovs_be16 vlan_tci_mask;     /* 1-bit in each significant vlan_tci bit. */
+    uint16_t zero;              /* Padding field set to zero. */
 };
 
 void flow_wildcards_init_catchall(struct flow_wildcards *);
-- 
1.7.2.3





More information about the dev mailing list