On Wed,  4 May 2016 16:36:30 +0900, Simon Horman wrote:
> +static int push_eth(struct sk_buff *skb, struct sw_flow_key *key,
> +                 const struct ovs_action_push_eth *ethh)
> +{
> +     int err;
> +
> +     /* De-accelerate any hardware accelerated VLAN tag added to a previous
> +      * Ethernet header */
> +     err = skb_vlan_deaccel(skb);
> +     if (unlikely(err))
> +             return err;
> +
> +     /* Add the new Ethernet header */
> +     if (skb_cow_head(skb, ETH_HLEN) < 0)
> +             return -ENOMEM;
> +
> +     skb_push(skb, ETH_HLEN);
> +     skb_reset_mac_header(skb);
> +     skb_reset_mac_len(skb);
> +
> +     ether_addr_copy(eth_hdr(skb)->h_source, ethh->addresses.eth_src);
> +     ether_addr_copy(eth_hdr(skb)->h_dest, ethh->addresses.eth_dst);
> +     eth_hdr(skb)->h_proto = ethh->eth_type;

This doesn't seem right. We know the packet type, it's skb->protocol.
We should fill in that.

In addition, we should check whether mac_len > 0 and in such case,
change skb->protocol to ETH_P_TEB first (and store that value in the
pushed eth header).

Similarly on pop_eth, we need to check skb->protocol and if it is
ETH_P_TEB, call eth_type_trans on the modified frame to set the new
skb->protocol correctly. It's probably not that simple, as we'd need a
version of eth_type_trans that doesn't need a net device.

 Jiri

Reply via email to