[ovs-dev] [PATCH 7/7] flow: Fix misaligned access.

Ben Pfaff blp at nicira.com
Fri May 7 21:01:52 UTC 2010


The testsuite for the flow extractor triggered this.

With this commit, "make check" passes on SPARC.
---
 lib/flow.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 700e7f8..2667295 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -27,6 +27,7 @@
 #include "openflow/openflow.h"
 #include "openvswitch/datapath-protocol.h"
 #include "packets.h"
+#include "unaligned.h"
 #include "xtoxll.h"
 
 #include "vlog.h"
@@ -154,8 +155,8 @@ flow_extract(struct ofpbuf *packet, uint32_t tun_id, uint16_t in_port,
         if (flow->dl_type == htons(ETH_TYPE_IP)) {
             const struct ip_header *nh = pull_ip(&b);
             if (nh) {
-                flow->nw_src = nh->ip_src;
-                flow->nw_dst = nh->ip_dst;
+                flow->nw_src = get_unaligned_u32(&nh->ip_src);
+                flow->nw_dst = get_unaligned_u32(&nh->ip_dst);
                 flow->nw_tos = nh->ip_tos & IP_DSCP_MASK;
                 flow->nw_proto = nh->ip_proto;
                 packet->l4 = b.data;
-- 
1.6.5





More information about the dev mailing list