aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Zhou <azhou@nicira.com>2013-07-29 13:26:08 -0700
committerJesse Gross <jesse@nicira.com>2013-07-29 13:39:18 -0700
commitded97873874ab357e939c00b326e5abd377fceec (patch)
tree0d219fcf0644e237c4bf758f53be7296024608f5
parent8ce28dc6a8b30a043a0a7c981f235c2dd4b84a7b (diff)
datapath: fix a bug in SF_FLOW_KEY_PUT macro
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@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
-rw-r--r--datapath/flow.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/datapath/flow.c b/datapath/flow.c
index d2c3d649e..883c953e6 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); \
} \