[ovs-dev] [PATCH 3/3] ofproto-dpif-xlate: Fix an additional misaligned reference to ovs_u128.

Ben Pfaff blp at ovn.org
Wed Jun 14 16:24:57 UTC 2017


nl_msg_put_unspec_uninit() can return a pointer that is only 4-byte
aligned.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/odp-util.c               | 11 +++++++----
 ofproto/ofproto-dpif-xlate.c | 11 +++++------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index bfd3a1afc5dd..a0923c14f93e 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -85,8 +85,8 @@ static void format_geneve_opts(const struct geneve_opt *opt,
 static struct nlattr *generate_all_wildcard_mask(const struct attr_len_tbl tbl[],
                                                  int max, struct ofpbuf *,
                                                  const struct nlattr *key);
-static void format_u128(struct ds *ds, const ovs_u128 *value,
-                        const ovs_u128 *mask, bool verbose);
+static void format_u128(struct ds *d, const ovs_32aligned_u128 *key,
+                        const ovs_32aligned_u128 *mask, bool verbose);
 static int scan_u128(const char *s, ovs_u128 *value, ovs_u128 *mask);
 
 static int parse_odp_action(const char *s, const struct simap *port_names,
@@ -742,7 +742,10 @@ static void
 format_odp_conntrack_action(struct ds *ds, const struct nlattr *attr)
 {
     struct nlattr *a[ARRAY_SIZE(ovs_conntrack_policy)];
-    const ovs_u128 *label;
+    const struct {
+        ovs_32aligned_u128 value;
+        ovs_32aligned_u128 mask;
+    } *label;
     const uint32_t *mark;
     const char *helper;
     uint16_t zone;
@@ -780,7 +783,7 @@ format_odp_conntrack_action(struct ds *ds, const struct nlattr *attr)
         }
         if (label) {
             ds_put_format(ds, "label=");
-            format_u128(ds, label, label + 1, true);
+            format_u128(ds, &label->value, &label->mask, true);
             ds_put_char(ds, ',');
         }
         if (helper) {
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index dabdcffc2a89..e15e3dec3f1c 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -5281,13 +5281,12 @@ put_ct_label(const struct flow *flow, struct ofpbuf *odp_actions,
         struct {
             ovs_u128 key;
             ovs_u128 mask;
-        } *odp_ct_label;
+        } odp_ct_label;
 
-        odp_ct_label = nl_msg_put_unspec_uninit(odp_actions,
-                                                OVS_CT_ATTR_LABELS,
-                                                sizeof(*odp_ct_label));
-        odp_ct_label->key = ovs_u128_and(flow->ct_label, wc->masks.ct_label);
-        odp_ct_label->mask = wc->masks.ct_label;
+        odp_ct_label.key = ovs_u128_and(flow->ct_label, wc->masks.ct_label);
+        odp_ct_label.mask = wc->masks.ct_label;
+        nl_msg_put_unspec(odp_actions, OVS_CT_ATTR_LABELS,
+                          &odp_ct_label, sizeof odp_ct_label);
     }
 }
 
-- 
2.10.2



More information about the dev mailing list