From 388c13d860f34f6c1cf7aa799eaf61e9bcfc253b Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Mon, 29 Jul 2013 13:26:08 -0700 Subject: [PATCH] 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 Signed-off-by: Jesse Gross --- datapath/flow.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/datapath/flow.c b/datapath/flow.c index 2c114083f..7f69538e2 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); \ } \ -- 2.43.0