Simplify code for constructing skb in recv_packet_out().
authorBen Pfaff <blp@nicira.com>
Thu, 13 Nov 2008 20:50:03 +0000 (12:50 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 13 Nov 2008 20:50:03 +0000 (12:50 -0800)
datapath/forward.c
datapath/linux-2.4/compat-2.4/include/linux/skbuff.h

index 550e25f4901eb7d9f84f18bc686d74b90201c295..ed092fea1bd963a881825866321a39027ff1e77f 100644 (file)
@@ -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)
index 2758520a968e18660f3d0b0355bdcf70381b4354..49b2cacf47b5dc6c786beca93bcffa0113d7dd9e 100644 (file)
@@ -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