Skip to contentSkip to conversation

ip_pipeline: Fix compile issue with strict-aliasing

PATCH In review Michael Qiu 1 participant 2 messages Dec 9, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip_pipeline: Fix compile issue with strict-aliasing

From: root <[email protected]>

strict-aliasing

---
 .../ip_pipeline/pipeline/pipeline_routing_be.c     |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
examples/ip_pipeline/pipeline/pipeline_routing_be.c +4 -7
index 4a95c7d..9baabd0 100644
@@ -1461,8 +1461,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg)
 		uint64_t macaddr_dst;
 		uint64_t ethertype = ETHER_TYPE_IPv4;
 
-		*((struct ether_addr *) &macaddr_dst) =
-			req->data.ethernet.macaddr;
+		macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
 		macaddr_dst = rte_bswap64(macaddr_dst << 16);
 
 		entry_arp0.slab[0] =
@@ -1503,8 +1502,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg)
 		uint64_t svlan = req->data.l2.qinq.svlan;
 		uint64_t cvlan = req->data.l2.qinq.cvlan;
 
-		*((struct ether_addr *) &macaddr_dst) =
-			req->data.ethernet.macaddr;
+		macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
 		macaddr_dst = rte_bswap64(macaddr_dst << 16);
 
 		entry_arp0.slab[0] = rte_bswap64((svlan << 48) |
@@ -1563,8 +1561,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg)
 		uint64_t label3 = req->data.l2.mpls.labels[3];
 		uint32_t n_labels = req->data.l2.mpls.n_labels;
 
-		*((struct ether_addr *) &macaddr_dst) =
-			req->data.ethernet.macaddr;
+		macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
 		macaddr_dst = rte_bswap64(macaddr_dst << 16);
 
 		switch (n_labels) {
@@ -1814,7 +1811,7 @@ pipeline_routing_msg_req_arp_add_handler(struct pipeline *p, void *msg)
 		return rsp;
 	}
 
-	*((struct ether_addr *) &entry.macaddr) = req->macaddr;
+	entry.macaddr = *((uint64_t *)&(req->macaddr));
 	entry.macaddr = entry.macaddr << 16;
 
 	rsp->status = rte_pipeline_table_entry_add(p->p,
Signature · 1 line
1.7.1
#1 lore raw

Sorry please ignore this :)

Thanks,
Michael

-----Original Message-----
From: Qiu, Michael
Sent: Wednesday, December 9, 2015 4:40 PM
To: [email protected]
Cc: Singh, Jasvinder; Dumitrescu, Cristian; root; Qiu, Michael
Subject: [PATCH] ip_pipeline: Fix compile issue with strict-aliasing

From: root <[email protected]>

strict-aliasing

---
 .../ip_pipeline/pipeline/pipeline_routing_be.c     |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
examples/ip_pipeline/pipeline/pipeline_routing_be.c +2 -4
index 4a95c7d..9baabd0 100644
@@ -1461,8 +1461,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg)
 		uint64_t macaddr_dst;
 		uint64_t ethertype = ETHER_TYPE_IPv4;
 
-		*((struct ether_addr *) &macaddr_dst) =
-			req->data.ethernet.macaddr;
+		macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
 		macaddr_dst = rte_bswap64(macaddr_dst << 16);
 
 		entry_arp0.slab[0] =
@@ -1503,8 +1502,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg)
 		uint64_t svlan = req->data.l2.qinq.svlan;
 		uint64_t cvlan = req->data.l2.qinq.cvlan;
 
-		*((struct ether_addr *) &macaddr_dst) =
-			req->data.ethernet.macaddr;
+		macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
 		macaddr_dst = rte_bswap64(macaddr_dst << 16);
 
 		entry_arp0.slab[0] = rte_bswap64((svlan << 48) | @@ -1563,8 +1561,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg)

uint64_t label3 = req->data.l2.mpls.labels[3]; uint32_t n_labels = req->data.l2.mpls.n_labels;

- *((struct ether_addr *) &macaddr_dst) =
- req->data.ethernet.macaddr;
+ macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
macaddr_dst = rte_bswap64(macaddr_dst << 16);

switch (n_labels) {
@@ -1814,7 +1811,7 @@ pipeline_routing_msg_req_arp_add_handler(struct pipeline *p, void *msg)
return rsp;
}

- *((struct ether_addr *) &entry.macaddr) = req->macaddr;
+ entry.macaddr = *((uint64_t *)&(req->macaddr));
entry.macaddr = entry.macaddr << 16;

rsp->status = rte_pipeline_table_entry_add(p->p,
--
1.7.1