On Fri, May 06, 2016 at 11:35:04AM +0200, Jiri Benc wrote: > 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.
I think that makes sense. Possibly the eth_type field can be removed from ovs_action_push_eth. > 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. I'm not sure I understand the interaction with ETH_P_TEB here. In my mind skb->protocol == ETH_P_TEB may be used early on in OvS's receive processing to find the inner protocol from the packet and at that point skb->protocol is set to that value. And that for further packet processing the fact the packet was received as TEB is transparent. Conversely, skb->protocol may be set as necessary on transmit as a packet exits OvS. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev