summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-10-15 15:52:18 -0700
committerBen Pfaff <blp@ovn.org>2018-10-16 15:12:16 -0700
commitea74b10c0838f156a98bac8c43ee79628b8fc0ce (patch)
treec1cfde902bb9e74b1f035d4b443077695cc77973
parentf7158faf655266e4ab2ac20c158a826df56d5011 (diff)
downloadopenvswitch-ea74b10c0838f156a98bac8c43ee79628b8fc0ce.tar.gz
odp-execute: Fix broken build with Clang as compiler.
Builds of branch-2.7 have been failing on Travis when Clang is used as compiler due to: ../ofproto/ofproto-dpif.c:2057:46: warning: taking address of packed member 'eth_src' of class or structure 'eth_header' may result in an unaligned pointer value [-Waddress-of-packed-member] netdev_get_etheraddr(ofport->up.netdev, &eth->eth_src); ^~~~~~~~~~~~ ../ofproto/ofproto-dpif.c:2082:50: warning: taking address of packed member 'eth_src' of class or structure 'eth_header' may result in an unaligned pointer value [-Waddress-of-packed-member] netdev_get_etheraddr(ofport->up.netdev, &eth->eth_src); ^~~~~~~~~~~~ On master these don't come up because of commit 1620b7ea68c2 ("packets: Remove unnecessary "packed" annotations."), which removed the packed annotation that causes the warning. This commit applies enough of that commit to make the build pass. Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/odp-util.c4
-rw-r--r--lib/packets.h3
-rw-r--r--ofproto/ofproto-dpif-sflow.c3
3 files changed, 5 insertions, 5 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 4ced1dde5..c71b0e4df 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -453,7 +453,7 @@ format_odp_tnl_push_header(struct ds *ds, struct ovs_action_push_tnl *data)
const void *l4;
const struct udp_header *udp;
- eth = (const struct eth_header *)data->header;
+ eth = ALIGNED_CAST(const struct eth_header *, data->header);
l3 = eth + 1;
@@ -894,7 +894,7 @@ ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data)
if (!ovs_scan_len(s, &n, "tnl_push(tnl_port(%"SCNi32"),", &data->tnl_port)) {
return -EINVAL;
}
- eth = (struct eth_header *) data->header;
+ eth = ALIGNED_CAST(struct eth_header *, data->header);
l3 = (data->header + sizeof *eth);
ip = (struct ip_header *) l3;
ip6 = (struct ovs_16aligned_ip6_hdr *) l3;
diff --git a/lib/packets.h b/lib/packets.h
index 84daca1e1..6b94ab61b 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -389,12 +389,11 @@ static inline bool eth_type_vlan(ovs_be16 eth_type)
#define ETH_TOTAL_MIN (ETH_HEADER_LEN + ETH_PAYLOAD_MIN)
#define ETH_TOTAL_MAX (ETH_HEADER_LEN + ETH_PAYLOAD_MAX)
#define ETH_VLAN_TOTAL_MAX (ETH_HEADER_LEN + VLAN_HEADER_LEN + ETH_PAYLOAD_MAX)
-OVS_PACKED(
struct eth_header {
struct eth_addr eth_dst;
struct eth_addr eth_src;
ovs_be16 eth_type;
-});
+};
BUILD_ASSERT_DECL(ETH_HEADER_LEN == sizeof(struct eth_header));
#define LLC_DSAP_SNAP 0xaa
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index 0d2dc1f10..4557abdc6 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -884,7 +884,8 @@ sflow_read_tnl_push_action(const struct nlattr *attr,
{
/* Modeled on lib/odp-util.c: format_odp_tnl_push_header */
const struct ovs_action_push_tnl *data = nl_attr_get(attr);
- const struct eth_header *eth = (const struct eth_header *) data->header;
+ const struct eth_header *eth = ALIGNED_CAST(const struct eth_header *,
+ data->header);
const struct ip_header *ip
= ALIGNED_CAST(const struct ip_header *, eth + 1);