Skip to content

Commit

Permalink
odp-execute: Fix broken build with Clang as compiler.
Browse files Browse the repository at this point in the history
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 1620b7e ("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>
  • Loading branch information
blp committed Oct 16, 2018
1 parent f7158fa commit ea74b10
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/odp-util.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions lib/packets.h
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ofproto/ofproto-dpif-sflow.c
Expand Up @@ -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);

Expand Down

0 comments on commit ea74b10

Please sign in to comment.