[ovs-dev] [Missing vlan V3 1/2] datapath: fix a bug in SF_FLOW_KEY_PUT macro

Andy Zhou azhou at nicira.com
Mon Jul 29 21:05:22 UTC 2013


This bug will cause mask values to corrupt the flow key value. So far
the bug has not showed up because we don't write mask value when
there is no mask Netlink attributes.  However, it needs to be fixed for
the next and future commits where we will start to set default
values for key and mask for missing Netlink attributes.

Signed-off-by: Andy Zhou <azhou at nicira.com>

---
V1->v2: Apply the same fix for the memcpy version
V2->v3: no change
---
 datapath/flow.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/datapath/flow.c b/datapath/flow.c
index 2c11408..7f69538 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -82,8 +82,9 @@ static void update_range__(struct sw_flow_match *match,
 	do { \
 		update_range__(match, offsetof(struct sw_flow_key, field),  \
 				     sizeof((match)->key->field), is_mask); \
-		if (is_mask && match->mask != NULL) {                       \
-			(match)->mask->key.field = value;		    \
+		if (is_mask) {						    \
+			if ((match)->mask)				    \
+				(match)->mask->key.field = value;	    \
 		} else {                                                    \
 			(match)->key->field = value;		            \
 		}                                                           \
@@ -93,8 +94,9 @@ static void update_range__(struct sw_flow_match *match,
 	do { \
 		update_range__(match, offsetof(struct sw_flow_key, field),  \
 				len, is_mask);                              \
-		if (is_mask && match->mask != NULL) {                       \
-			memcpy(&(match)->mask->key.field, value_p, len);    \
+		if (is_mask) {						    \
+			if ((match)->mask)				    \
+				memcpy(&(match)->mask->key.field, value_p, len);\
 		} else {                                                    \
 			memcpy(&(match)->key->field, value_p, len);         \
 		}                                                           \
-- 
1.7.9.5




More information about the dev mailing list