From: Ben Pfaff Date: Thu, 13 Nov 2008 20:50:03 +0000 (-0800) Subject: Simplify code for constructing skb in recv_packet_out(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61c2760e8f14529637489d9a3ad8384182f00c8f;p=openvswitch Simplify code for constructing skb in recv_packet_out(). --- diff --git a/datapath/forward.c b/datapath/forward.c index 550e25f4..ed092fea 100644 --- a/datapath/forward.c +++ b/datapath/forward.c @@ -122,8 +122,6 @@ recv_packet_out(struct sw_chain *chain, const struct sender *sender, { const struct ofp_packet_out *opo = msg; struct sk_buff *skb; - struct vlan_ethhdr *mac; - int nh_ofs; uint16_t v_code; struct sw_flow_key key; size_t actions_len = ntohs(opo->actions_len); @@ -145,16 +143,11 @@ recv_packet_out(struct sw_chain *chain, const struct sender *sender, /* FIXME? We don't reserve NET_IP_ALIGN or NET_SKB_PAD since * we're just transmitting this raw without examining anything * at those layers. */ - memcpy(skb_put(skb, data_len), (uint8_t *)opo->actions + actions_len, - data_len); - - skb_set_mac_header(skb, 0); - mac = vlan_eth_hdr(skb); - if (likely(mac->h_vlan_proto != htons(ETH_P_8021Q))) - nh_ofs = sizeof(struct ethhdr); - else - nh_ofs = sizeof(struct vlan_ethhdr); - skb_set_network_header(skb, nh_ofs); + skb_put(skb, data_len); + skb_copy_to_linear_data(skb, + (uint8_t *)opo->actions + actions_len, + data_len); + skb_reset_mac_header(skb); } else { skb = retrieve_skb(ntohl(opo->buffer_id)); if (!skb) diff --git a/datapath/linux-2.4/compat-2.4/include/linux/skbuff.h b/datapath/linux-2.4/compat-2.4/include/linux/skbuff.h index 2758520a..49b2cacf 100644 --- a/datapath/linux-2.4/compat-2.4/include/linux/skbuff.h +++ b/datapath/linux-2.4/compat-2.4/include/linux/skbuff.h @@ -125,6 +125,11 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset) #define NET_IP_ALIGN 2 #endif - +static inline void skb_copy_to_linear_data(struct sk_buff *skb, + const void *from, + const unsigned int len) +{ + memcpy(skb->data, from, len); +} #endif