1 #ifndef __LINUX_SKBUFF_WRAPPER_H
2 #define __LINUX_SKBUFF_WRAPPER_H 1
4 #include_next <linux/skbuff.h>
7 #define mac_header mac.raw
8 #define network_header nh.raw
10 /* Emulate Linux 2.6 behavior, in which kfree_skb silently ignores null pointer
12 #define kfree_skb(skb) kfree_skb_maybe_null(skb)
13 static inline void kfree_skb_maybe_null(struct sk_buff *skb)
15 if (likely(skb != NULL))
19 /* Note that CHECKSUM_PARTIAL is not implemented, but this allows us to at
20 * least test against it: see update_csum() in forward.c. */
21 #define CHECKSUM_PARTIAL 3
22 #define CHECKSUM_COMPLETE CHECKSUM_HW
24 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
29 static inline void skb_reset_transport_header(struct sk_buff *skb)
31 skb->h.raw = skb->data;
34 static inline void skb_set_transport_header(struct sk_buff *skb,
37 skb->h.raw = skb->data + offset;
40 static inline unsigned char *skb_network_header(const struct sk_buff *skb)
45 static inline void skb_reset_network_header(struct sk_buff *skb)
47 skb->nh.raw = skb->data;
50 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
52 skb->nh.raw = skb->data + offset;
55 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
60 static inline int skb_mac_header_was_set(const struct sk_buff *skb)
62 return skb->mac.raw != NULL;
65 static inline void skb_reset_mac_header(struct sk_buff *skb)
67 skb->mac.raw = skb->data;
70 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
72 skb->mac.raw = skb->data + offset;
74 static inline int skb_transport_offset(const struct sk_buff *skb)
76 return skb_transport_header(skb) - skb->data;
79 static inline u32 skb_network_header_len(const struct sk_buff *skb)
81 return skb->h.raw - skb->nh.raw;
84 static inline int skb_network_offset(const struct sk_buff *skb)
86 return skb_network_header(skb) - skb->data;
89 static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
94 static inline void skb_reset_tail_pointer(struct sk_buff *skb)
96 skb->tail = skb->data;
99 static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
101 skb->tail = skb->data + offset;
105 * CPUs often take a performance hit when accessing unaligned memory
106 * locations. The actual performance hit varies, it can be small if the
107 * hardware handles it or large if we have to take an exception and fix it
110 * Since an ethernet header is 14 bytes network drivers often end up with
111 * the IP header at an unaligned offset. The IP header can be aligned by
112 * shifting the start of the packet by 2 bytes. Drivers should do this
115 * skb_reserve(NET_IP_ALIGN);
117 * The downside to this alignment of the IP header is that the DMA is now
118 * unaligned. On some architectures the cost of an unaligned DMA is high
119 * and this cost outweighs the gains made by aligning the IP header.
121 * Since this trade off varies between architectures, we allow NET_IP_ALIGN
125 #define NET_IP_ALIGN 2