Skip to content
  • Ben Pfaff's avatar
    packets: Remove unnecessary "packed" annotations. · 1620b7ea
    Ben Pfaff authored
    
    
    I know of two reasons to mark a structure as "packed".  The first is
    because the structure must match some defined interface and therefore
    compiler-inserted padding between or after members would cause its layout
    to diverge from that interface.  This is not a problem in a structure that
    follows the general alignment rules that are seen in ABIs for all the
    architectures that OVS cares about: basically, that a struct member needs
    to be aligned on a boundary that is a multiple of the member's size.
    
    The second reason is because instances of the struct tend to be at
    misaligned addresses.
    
    struct eth_header and struct vlan_eth_header are normally aligned on
    16-bit boundaries (at least), and they contain only 16-bit members, so
    there's no need to pack them.  This commit removes the packed annotation.
    
    This commit also removes the packed annotation from struct llc_header.
    Since that struct only contains 8-bit members, I don't know of any benefit
    to packing it, period.
    
    This commit also removes a few more packed annotations that are much less
    important.
    
    When these packed annotations were removed, it caused a few warnings
    related to casts from 'uint8_t *' to more strictly aligned pointer types,
    related to struct ovs_action_push_tnl.  That's because that struct had a
    trailing member used to store packet headers, that was declared as
    a uint8_t[].  Before, when this was cast to 'struct eth_header *', there
    was no change in alignment since eth_header was packed; now that
    eth_header is not packed, the compiler considers it suspicious.  This
    commit avoids that problem by changing the member from uint8_t[] to
    uint32_t[], which assures the compiler that it is properly aligned.
    
    Signed-off-by: default avatarBen Pfaff <blp@ovn.org>
    Acked-by: default avatarJoe Stringer <joe@ovn.org>
    1620b7ea