diff options
Diffstat (limited to 'include/linux/skbuff.h')
| -rw-r--r-- | include/linux/skbuff.h | 123 |
1 files changed, 86 insertions, 37 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 5d4a990d5577..42edce6abe23 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
| @@ -155,16 +155,29 @@ struct skb_shared_info { | |||
| 155 | #define SKB_DATAREF_SHIFT 16 | 155 | #define SKB_DATAREF_SHIFT 16 |
| 156 | #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) | 156 | #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) |
| 157 | 157 | ||
| 158 | extern struct timeval skb_tv_base; | ||
| 159 | |||
| 160 | struct skb_timeval { | ||
| 161 | u32 off_sec; | ||
| 162 | u32 off_usec; | ||
| 163 | }; | ||
| 164 | |||
| 165 | |||
| 166 | enum { | ||
| 167 | SKB_FCLONE_UNAVAILABLE, | ||
| 168 | SKB_FCLONE_ORIG, | ||
| 169 | SKB_FCLONE_CLONE, | ||
| 170 | }; | ||
| 171 | |||
| 158 | /** | 172 | /** |
| 159 | * struct sk_buff - socket buffer | 173 | * struct sk_buff - socket buffer |
| 160 | * @next: Next buffer in list | 174 | * @next: Next buffer in list |
| 161 | * @prev: Previous buffer in list | 175 | * @prev: Previous buffer in list |
| 162 | * @list: List we are on | 176 | * @list: List we are on |
| 163 | * @sk: Socket we are owned by | 177 | * @sk: Socket we are owned by |
| 164 | * @stamp: Time we arrived | 178 | * @tstamp: Time we arrived stored as offset to skb_tv_base |
| 165 | * @dev: Device we arrived on/are leaving by | 179 | * @dev: Device we arrived on/are leaving by |
| 166 | * @input_dev: Device we arrived on | 180 | * @input_dev: Device we arrived on |
| 167 | * @real_dev: The real device we are using | ||
| 168 | * @h: Transport layer header | 181 | * @h: Transport layer header |
| 169 | * @nh: Network layer header | 182 | * @nh: Network layer header |
| 170 | * @mac: Link layer header | 183 | * @mac: Link layer header |
| @@ -190,14 +203,11 @@ struct skb_shared_info { | |||
| 190 | * @end: End pointer | 203 | * @end: End pointer |
| 191 | * @destructor: Destruct function | 204 | * @destructor: Destruct function |
| 192 | * @nfmark: Can be used for communication between hooks | 205 | * @nfmark: Can be used for communication between hooks |
| 193 | * @nfcache: Cache info | ||
| 194 | * @nfct: Associated connection, if any | 206 | * @nfct: Associated connection, if any |
| 195 | * @nfctinfo: Relationship of this skb to the connection | 207 | * @nfctinfo: Relationship of this skb to the connection |
| 196 | * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c | 208 | * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c |
| 197 | * @private: Data which is private to the HIPPI implementation | ||
| 198 | * @tc_index: Traffic control index | 209 | * @tc_index: Traffic control index |
| 199 | * @tc_verd: traffic control verdict | 210 | * @tc_verd: traffic control verdict |
| 200 | * @tc_classid: traffic control classid | ||
| 201 | */ | 211 | */ |
| 202 | 212 | ||
| 203 | struct sk_buff { | 213 | struct sk_buff { |
| @@ -205,12 +215,10 @@ struct sk_buff { | |||
| 205 | struct sk_buff *next; | 215 | struct sk_buff *next; |
| 206 | struct sk_buff *prev; | 216 | struct sk_buff *prev; |
| 207 | 217 | ||
| 208 | struct sk_buff_head *list; | ||
| 209 | struct sock *sk; | 218 | struct sock *sk; |
| 210 | struct timeval stamp; | 219 | struct skb_timeval tstamp; |
| 211 | struct net_device *dev; | 220 | struct net_device *dev; |
| 212 | struct net_device *input_dev; | 221 | struct net_device *input_dev; |
| 213 | struct net_device *real_dev; | ||
| 214 | 222 | ||
| 215 | union { | 223 | union { |
| 216 | struct tcphdr *th; | 224 | struct tcphdr *th; |
| @@ -252,33 +260,28 @@ struct sk_buff { | |||
| 252 | __u8 local_df:1, | 260 | __u8 local_df:1, |
| 253 | cloned:1, | 261 | cloned:1, |
| 254 | ip_summed:2, | 262 | ip_summed:2, |
| 255 | nohdr:1; | 263 | nohdr:1, |
| 256 | /* 3 bits spare */ | 264 | nfctinfo:3; |
| 257 | __u8 pkt_type; | 265 | __u8 pkt_type:3, |
| 258 | __u16 protocol; | 266 | fclone:2; |
| 267 | __be16 protocol; | ||
| 259 | 268 | ||
| 260 | void (*destructor)(struct sk_buff *skb); | 269 | void (*destructor)(struct sk_buff *skb); |
| 261 | #ifdef CONFIG_NETFILTER | 270 | #ifdef CONFIG_NETFILTER |
| 262 | unsigned long nfmark; | 271 | __u32 nfmark; |
| 263 | __u32 nfcache; | ||
| 264 | __u32 nfctinfo; | ||
| 265 | struct nf_conntrack *nfct; | 272 | struct nf_conntrack *nfct; |
| 273 | #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) | ||
| 274 | __u8 ipvs_property:1; | ||
| 275 | #endif | ||
| 266 | #ifdef CONFIG_BRIDGE_NETFILTER | 276 | #ifdef CONFIG_BRIDGE_NETFILTER |
| 267 | struct nf_bridge_info *nf_bridge; | 277 | struct nf_bridge_info *nf_bridge; |
| 268 | #endif | 278 | #endif |
| 269 | #endif /* CONFIG_NETFILTER */ | 279 | #endif /* CONFIG_NETFILTER */ |
| 270 | #if defined(CONFIG_HIPPI) | ||
| 271 | union { | ||
| 272 | __u32 ifield; | ||
| 273 | } private; | ||
| 274 | #endif | ||
| 275 | #ifdef CONFIG_NET_SCHED | 280 | #ifdef CONFIG_NET_SCHED |
| 276 | __u32 tc_index; /* traffic control index */ | 281 | __u16 tc_index; /* traffic control index */ |
| 277 | #ifdef CONFIG_NET_CLS_ACT | 282 | #ifdef CONFIG_NET_CLS_ACT |
| 278 | __u32 tc_verd; /* traffic control verdict */ | 283 | __u16 tc_verd; /* traffic control verdict */ |
| 279 | __u32 tc_classid; /* traffic control classid */ | ||
| 280 | #endif | 284 | #endif |
| 281 | |||
| 282 | #endif | 285 | #endif |
| 283 | 286 | ||
| 284 | 287 | ||
| @@ -300,8 +303,20 @@ struct sk_buff { | |||
| 300 | #include <asm/system.h> | 303 | #include <asm/system.h> |
| 301 | 304 | ||
| 302 | extern void __kfree_skb(struct sk_buff *skb); | 305 | extern void __kfree_skb(struct sk_buff *skb); |
| 303 | extern struct sk_buff *alloc_skb(unsigned int size, | 306 | extern struct sk_buff *__alloc_skb(unsigned int size, |
| 304 | unsigned int __nocast priority); | 307 | unsigned int __nocast priority, int fclone); |
| 308 | static inline struct sk_buff *alloc_skb(unsigned int size, | ||
| 309 | unsigned int __nocast priority) | ||
| 310 | { | ||
| 311 | return __alloc_skb(size, priority, 0); | ||
| 312 | } | ||
| 313 | |||
| 314 | static inline struct sk_buff *alloc_skb_fclone(unsigned int size, | ||
| 315 | unsigned int __nocast priority) | ||
| 316 | { | ||
| 317 | return __alloc_skb(size, priority, 1); | ||
| 318 | } | ||
| 319 | |||
| 305 | extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, | 320 | extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, |
| 306 | unsigned int size, | 321 | unsigned int size, |
| 307 | unsigned int __nocast priority); | 322 | unsigned int __nocast priority); |
| @@ -502,7 +517,8 @@ static inline struct sk_buff *skb_share_check(struct sk_buff *skb, | |||
| 502 | * | 517 | * |
| 503 | * %NULL is returned on a memory allocation failure. | 518 | * %NULL is returned on a memory allocation failure. |
| 504 | */ | 519 | */ |
| 505 | static inline struct sk_buff *skb_unshare(struct sk_buff *skb, int pri) | 520 | static inline struct sk_buff *skb_unshare(struct sk_buff *skb, |
| 521 | unsigned int __nocast pri) | ||
| 506 | { | 522 | { |
| 507 | might_sleep_if(pri & __GFP_WAIT); | 523 | might_sleep_if(pri & __GFP_WAIT); |
| 508 | if (skb_cloned(skb)) { | 524 | if (skb_cloned(skb)) { |
| @@ -596,7 +612,6 @@ static inline void __skb_queue_head(struct sk_buff_head *list, | |||
| 596 | { | 612 | { |
| 597 | struct sk_buff *prev, *next; | 613 | struct sk_buff *prev, *next; |
| 598 | 614 | ||
| 599 | newsk->list = list; | ||
| 600 | list->qlen++; | 615 | list->qlen++; |
| 601 | prev = (struct sk_buff *)list; | 616 | prev = (struct sk_buff *)list; |
| 602 | next = prev->next; | 617 | next = prev->next; |
| @@ -621,7 +636,6 @@ static inline void __skb_queue_tail(struct sk_buff_head *list, | |||
| 621 | { | 636 | { |
| 622 | struct sk_buff *prev, *next; | 637 | struct sk_buff *prev, *next; |
| 623 | 638 | ||
| 624 | newsk->list = list; | ||
| 625 | list->qlen++; | 639 | list->qlen++; |
| 626 | next = (struct sk_buff *)list; | 640 | next = (struct sk_buff *)list; |
| 627 | prev = next->prev; | 641 | prev = next->prev; |
| @@ -654,7 +668,6 @@ static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list) | |||
| 654 | next->prev = prev; | 668 | next->prev = prev; |
| 655 | prev->next = next; | 669 | prev->next = next; |
| 656 | result->next = result->prev = NULL; | 670 | result->next = result->prev = NULL; |
| 657 | result->list = NULL; | ||
| 658 | } | 671 | } |
| 659 | return result; | 672 | return result; |
| 660 | } | 673 | } |
| @@ -663,7 +676,7 @@ static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list) | |||
| 663 | /* | 676 | /* |
| 664 | * Insert a packet on a list. | 677 | * Insert a packet on a list. |
| 665 | */ | 678 | */ |
| 666 | extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk); | 679 | extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list); |
| 667 | static inline void __skb_insert(struct sk_buff *newsk, | 680 | static inline void __skb_insert(struct sk_buff *newsk, |
| 668 | struct sk_buff *prev, struct sk_buff *next, | 681 | struct sk_buff *prev, struct sk_buff *next, |
| 669 | struct sk_buff_head *list) | 682 | struct sk_buff_head *list) |
| @@ -671,24 +684,23 @@ static inline void __skb_insert(struct sk_buff *newsk, | |||
| 671 | newsk->next = next; | 684 | newsk->next = next; |
| 672 | newsk->prev = prev; | 685 | newsk->prev = prev; |
| 673 | next->prev = prev->next = newsk; | 686 | next->prev = prev->next = newsk; |
| 674 | newsk->list = list; | ||
| 675 | list->qlen++; | 687 | list->qlen++; |
| 676 | } | 688 | } |
| 677 | 689 | ||
| 678 | /* | 690 | /* |
| 679 | * Place a packet after a given packet in a list. | 691 | * Place a packet after a given packet in a list. |
| 680 | */ | 692 | */ |
| 681 | extern void skb_append(struct sk_buff *old, struct sk_buff *newsk); | 693 | extern void skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list); |
| 682 | static inline void __skb_append(struct sk_buff *old, struct sk_buff *newsk) | 694 | static inline void __skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list) |
| 683 | { | 695 | { |
| 684 | __skb_insert(newsk, old, old->next, old->list); | 696 | __skb_insert(newsk, old, old->next, list); |
| 685 | } | 697 | } |
| 686 | 698 | ||
| 687 | /* | 699 | /* |
| 688 | * remove sk_buff from list. _Must_ be called atomically, and with | 700 | * remove sk_buff from list. _Must_ be called atomically, and with |
| 689 | * the list known.. | 701 | * the list known.. |
| 690 | */ | 702 | */ |
| 691 | extern void skb_unlink(struct sk_buff *skb); | 703 | extern void skb_unlink(struct sk_buff *skb, struct sk_buff_head *list); |
| 692 | static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) | 704 | static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) |
| 693 | { | 705 | { |
| 694 | struct sk_buff *next, *prev; | 706 | struct sk_buff *next, *prev; |
| @@ -697,7 +709,6 @@ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) | |||
| 697 | next = skb->next; | 709 | next = skb->next; |
| 698 | prev = skb->prev; | 710 | prev = skb->prev; |
| 699 | skb->next = skb->prev = NULL; | 711 | skb->next = skb->prev = NULL; |
| 700 | skb->list = NULL; | ||
| 701 | next->prev = prev; | 712 | next->prev = prev; |
| 702 | prev->next = next; | 713 | prev->next = next; |
| 703 | } | 714 | } |
| @@ -1212,6 +1223,8 @@ extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); | |||
| 1212 | extern void skb_split(struct sk_buff *skb, | 1223 | extern void skb_split(struct sk_buff *skb, |
| 1213 | struct sk_buff *skb1, const u32 len); | 1224 | struct sk_buff *skb1, const u32 len); |
| 1214 | 1225 | ||
| 1226 | extern void skb_release_data(struct sk_buff *skb); | ||
| 1227 | |||
| 1215 | static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, | 1228 | static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, |
| 1216 | int len, void *buffer) | 1229 | int len, void *buffer) |
| 1217 | { | 1230 | { |
| @@ -1229,6 +1242,42 @@ static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, | |||
| 1229 | extern void skb_init(void); | 1242 | extern void skb_init(void); |
| 1230 | extern void skb_add_mtu(int mtu); | 1243 | extern void skb_add_mtu(int mtu); |
| 1231 | 1244 | ||
| 1245 | /** | ||
| 1246 | * skb_get_timestamp - get timestamp from a skb | ||
| 1247 | * @skb: skb to get stamp from | ||
| 1248 | * @stamp: pointer to struct timeval to store stamp in | ||
| 1249 | * | ||
| 1250 | * Timestamps are stored in the skb as offsets to a base timestamp. | ||
| 1251 | * This function converts the offset back to a struct timeval and stores | ||
| 1252 | * it in stamp. | ||
| 1253 | */ | ||
| 1254 | static inline void skb_get_timestamp(struct sk_buff *skb, struct timeval *stamp) | ||
| 1255 | { | ||
| 1256 | stamp->tv_sec = skb->tstamp.off_sec; | ||
| 1257 | stamp->tv_usec = skb->tstamp.off_usec; | ||
| 1258 | if (skb->tstamp.off_sec) { | ||
| 1259 | stamp->tv_sec += skb_tv_base.tv_sec; | ||
| 1260 | stamp->tv_usec += skb_tv_base.tv_usec; | ||
| 1261 | } | ||
| 1262 | } | ||
| 1263 | |||
| 1264 | /** | ||
| 1265 | * skb_set_timestamp - set timestamp of a skb | ||
| 1266 | * @skb: skb to set stamp of | ||
| 1267 | * @stamp: pointer to struct timeval to get stamp from | ||
| 1268 | * | ||
| 1269 | * Timestamps are stored in the skb as offsets to a base timestamp. | ||
| 1270 | * This function converts a struct timeval to an offset and stores | ||
| 1271 | * it in the skb. | ||
| 1272 | */ | ||
| 1273 | static inline void skb_set_timestamp(struct sk_buff *skb, struct timeval *stamp) | ||
| 1274 | { | ||
| 1275 | skb->tstamp.off_sec = stamp->tv_sec - skb_tv_base.tv_sec; | ||
| 1276 | skb->tstamp.off_usec = stamp->tv_usec - skb_tv_base.tv_usec; | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | extern void __net_timestamp(struct sk_buff *skb); | ||
| 1280 | |||
| 1232 | #ifdef CONFIG_NETFILTER | 1281 | #ifdef CONFIG_NETFILTER |
| 1233 | static inline void nf_conntrack_put(struct nf_conntrack *nfct) | 1282 | static inline void nf_conntrack_put(struct nf_conntrack *nfct) |
| 1234 | { | 1283 | { |
