On Tue, 2016-09-06 at 08:08 -0400, Jamal Hadi Salim wrote:
> ng
> On 16-08-30 08:44 AM, Eric Dumazet wrote:
> > On Tue, 2016-08-30 at 07:57 -0400, Jamal Hadi Salim wrote:
> >>         if (flags & SKBMOD_F_SWAPMAC) {
> >>                 u8 tmpaddr[ETH_ALEN];
> >>                 /*XXX: I am sure we can come up with something more 
> >> efficient */
> >>                 ether_addr_copy(tmpaddr, eth_hdr(skb)->h_dest);
> >>                 ether_addr_copy(eth_hdr(skb)->h_dest, 
> >> eth_hdr(skb)->h_source);
> >>                 ether_addr_copy(eth_hdr(skb)->h_source, tmpaddr);
> >>         }
> >
> > While ether_addr_copy() is accepting u8 pointers, data must be aligned to 
> > u16 at least.
> >
> > (See comments in include/linux/etherdevice.h)
> >
> > Some arches/compilers might do things here that would generate a trap
> > if tmpaddr is not aligned.
> >
> 
> Hrm. How do you suggest dealing with this?

Just use u16 in the array ?

u16 tmpaddr[ETH_ALEN / 2]; /* ether_addr_copy() requirement */

ether_addr_copy((u8 *)tmpaddr, eth_hdr(skb)->h_dest);
...




Reply via email to