skbuff.c (989a4222c13a3e148772730d362fceb0727852f5) | skbuff.c (b5947e5d1e710c35ea281247bd27e6975250285c) |
---|---|
1/* 2 * Routines having to do with the 'struct sk_buff' memory handlers. 3 * 4 * Authors: Alan Cox <alan@lxorguk.ukuu.org.uk> 5 * Florian La Roche <rzsfl@rz.uni-sb.de> 6 * 7 * Fixes: 8 * Alan Cox : Fixed the worst of the load --- 1091 unchanged lines hidden (view full) --- 1100 sock_zerocopy_put(uarg); 1101 } 1102} 1103EXPORT_SYMBOL_GPL(sock_zerocopy_put_abort); 1104 1105extern int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb, 1106 struct iov_iter *from, size_t length); 1107 | 1/* 2 * Routines having to do with the 'struct sk_buff' memory handlers. 3 * 4 * Authors: Alan Cox <alan@lxorguk.ukuu.org.uk> 5 * Florian La Roche <rzsfl@rz.uni-sb.de> 6 * 7 * Fixes: 8 * Alan Cox : Fixed the worst of the load --- 1091 unchanged lines hidden (view full) --- 1100 sock_zerocopy_put(uarg); 1101 } 1102} 1103EXPORT_SYMBOL_GPL(sock_zerocopy_put_abort); 1104 1105extern int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb, 1106 struct iov_iter *from, size_t length); 1107 |
1108int skb_zerocopy_iter_dgram(struct sk_buff *skb, struct msghdr *msg, int len) 1109{ 1110 return __zerocopy_sg_from_iter(skb->sk, skb, &msg->msg_iter, len); 1111} 1112EXPORT_SYMBOL_GPL(skb_zerocopy_iter_dgram); 1113 |
|
1108int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb, 1109 struct msghdr *msg, int len, 1110 struct ubuf_info *uarg) 1111{ 1112 struct ubuf_info *orig_uarg = skb_zcopy(skb); 1113 struct iov_iter orig_iter = msg->msg_iter; 1114 int err, orig_len = skb->len; 1115 --- 804 unchanged lines hidden (view full) --- 1920 * Pure masohism, indeed. 8)8) 1921 */ 1922 if (eat) { 1923 struct sk_buff *list = skb_shinfo(skb)->frag_list; 1924 struct sk_buff *clone = NULL; 1925 struct sk_buff *insp = NULL; 1926 1927 do { | 1114int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb, 1115 struct msghdr *msg, int len, 1116 struct ubuf_info *uarg) 1117{ 1118 struct ubuf_info *orig_uarg = skb_zcopy(skb); 1119 struct iov_iter orig_iter = msg->msg_iter; 1120 int err, orig_len = skb->len; 1121 --- 804 unchanged lines hidden (view full) --- 1926 * Pure masohism, indeed. 8)8) 1927 */ 1928 if (eat) { 1929 struct sk_buff *list = skb_shinfo(skb)->frag_list; 1930 struct sk_buff *clone = NULL; 1931 struct sk_buff *insp = NULL; 1932 1933 do { |
1928 BUG_ON(!list); 1929 | |
1930 if (list->len <= eat) { 1931 /* Eaten as whole. */ 1932 eat -= list->len; 1933 list = list->next; 1934 insp = list; 1935 } else { 1936 /* Eaten partially. */ 1937 --- 423 unchanged lines hidden (view full) --- 2361out: 2362 return orig_len - len; 2363 2364error: 2365 return orig_len == len ? ret : orig_len - len; 2366} 2367EXPORT_SYMBOL_GPL(skb_send_sock_locked); 2368 | 1934 if (list->len <= eat) { 1935 /* Eaten as whole. */ 1936 eat -= list->len; 1937 list = list->next; 1938 insp = list; 1939 } else { 1940 /* Eaten partially. */ 1941 --- 423 unchanged lines hidden (view full) --- 2365out: 2366 return orig_len - len; 2367 2368error: 2369 return orig_len == len ? ret : orig_len - len; 2370} 2371EXPORT_SYMBOL_GPL(skb_send_sock_locked); 2372 |
2369/* Send skb data on a socket. */ 2370int skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int len) 2371{ 2372 int ret = 0; 2373 2374 lock_sock(sk); 2375 ret = skb_send_sock_locked(sk, skb, offset, len); 2376 release_sock(sk); 2377 2378 return ret; 2379} 2380EXPORT_SYMBOL_GPL(skb_send_sock); 2381 | |
2382/** 2383 * skb_store_bits - store bits from kernel buffer to skb 2384 * @skb: destination buffer 2385 * @offset: offset in destination 2386 * @from: source buffer 2387 * @len: number of bytes to copy 2388 * 2389 * Copy the specified number of bytes from the source buffer to the --- 250 unchanged lines hidden (view full) --- 2640 } 2641 start = end; 2642 } 2643 BUG_ON(len); 2644 return csum; 2645} 2646EXPORT_SYMBOL(skb_copy_and_csum_bits); 2647 | 2373/** 2374 * skb_store_bits - store bits from kernel buffer to skb 2375 * @skb: destination buffer 2376 * @offset: offset in destination 2377 * @from: source buffer 2378 * @len: number of bytes to copy 2379 * 2380 * Copy the specified number of bytes from the source buffer to the --- 250 unchanged lines hidden (view full) --- 2631 } 2632 start = end; 2633 } 2634 BUG_ON(len); 2635 return csum; 2636} 2637EXPORT_SYMBOL(skb_copy_and_csum_bits); 2638 |
2639__sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len) 2640{ 2641 __sum16 sum; 2642 2643 sum = csum_fold(skb_checksum(skb, 0, len, skb->csum)); 2644 /* See comments in __skb_checksum_complete(). */ 2645 if (likely(!sum)) { 2646 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) && 2647 !skb->csum_complete_sw) 2648 netdev_rx_csum_fault(skb->dev, skb); 2649 } 2650 if (!skb_shared(skb)) 2651 skb->csum_valid = !sum; 2652 return sum; 2653} 2654EXPORT_SYMBOL(__skb_checksum_complete_head); 2655 2656/* This function assumes skb->csum already holds pseudo header's checksum, 2657 * which has been changed from the hardware checksum, for example, by 2658 * __skb_checksum_validate_complete(). And, the original skb->csum must 2659 * have been validated unsuccessfully for CHECKSUM_COMPLETE case. 2660 * 2661 * It returns non-zero if the recomputed checksum is still invalid, otherwise 2662 * zero. The new checksum is stored back into skb->csum unless the skb is 2663 * shared. 2664 */ 2665__sum16 __skb_checksum_complete(struct sk_buff *skb) 2666{ 2667 __wsum csum; 2668 __sum16 sum; 2669 2670 csum = skb_checksum(skb, 0, skb->len, 0); 2671 2672 sum = csum_fold(csum_add(skb->csum, csum)); 2673 /* This check is inverted, because we already knew the hardware 2674 * checksum is invalid before calling this function. So, if the 2675 * re-computed checksum is valid instead, then we have a mismatch 2676 * between the original skb->csum and skb_checksum(). This means either 2677 * the original hardware checksum is incorrect or we screw up skb->csum 2678 * when moving skb->data around. 2679 */ 2680 if (likely(!sum)) { 2681 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) && 2682 !skb->csum_complete_sw) 2683 netdev_rx_csum_fault(skb->dev, skb); 2684 } 2685 2686 if (!skb_shared(skb)) { 2687 /* Save full packet checksum */ 2688 skb->csum = csum; 2689 skb->ip_summed = CHECKSUM_COMPLETE; 2690 skb->csum_complete_sw = 1; 2691 skb->csum_valid = !sum; 2692 } 2693 2694 return sum; 2695} 2696EXPORT_SYMBOL(__skb_checksum_complete); 2697 |
|
2648static __wsum warn_crc32c_csum_update(const void *buff, int len, __wsum sum) 2649{ 2650 net_warn_ratelimited( 2651 "%s: attempt to compute crc32c without libcrc32c.ko\n", 2652 __func__); 2653 return 0; 2654} 2655 --- 301 unchanged lines hidden (view full) --- 2957 unsigned long flags; 2958 2959 spin_lock_irqsave(&list->lock, flags); 2960 __skb_queue_after(list, old, newsk); 2961 spin_unlock_irqrestore(&list->lock, flags); 2962} 2963EXPORT_SYMBOL(skb_append); 2964 | 2698static __wsum warn_crc32c_csum_update(const void *buff, int len, __wsum sum) 2699{ 2700 net_warn_ratelimited( 2701 "%s: attempt to compute crc32c without libcrc32c.ko\n", 2702 __func__); 2703 return 0; 2704} 2705 --- 301 unchanged lines hidden (view full) --- 3007 unsigned long flags; 3008 3009 spin_lock_irqsave(&list->lock, flags); 3010 __skb_queue_after(list, old, newsk); 3011 spin_unlock_irqrestore(&list->lock, flags); 3012} 3013EXPORT_SYMBOL(skb_append); 3014 |
2965/** 2966 * skb_insert - insert a buffer 2967 * @old: buffer to insert before 2968 * @newsk: buffer to insert 2969 * @list: list to use 2970 * 2971 * Place a packet before a given packet in a list. The list locks are 2972 * taken and this function is atomic with respect to other list locked 2973 * calls. 2974 * 2975 * A buffer cannot be placed on two lists at the same time. 2976 */ 2977void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list) 2978{ 2979 unsigned long flags; 2980 2981 spin_lock_irqsave(&list->lock, flags); 2982 __skb_insert(newsk, old->prev, old, list); 2983 spin_unlock_irqrestore(&list->lock, flags); 2984} 2985EXPORT_SYMBOL(skb_insert); 2986 | |
2987static inline void skb_split_inside_header(struct sk_buff *skb, 2988 struct sk_buff* skb1, 2989 const u32 len, const int pos) 2990{ 2991 int i; 2992 2993 skb_copy_from_linear_data_offset(skb, len, skb_put(skb1, pos - len), 2994 pos - len); --- 2128 unchanged lines hidden (view full) --- 5123 */ 5124int skb_vlan_pop(struct sk_buff *skb) 5125{ 5126 u16 vlan_tci; 5127 __be16 vlan_proto; 5128 int err; 5129 5130 if (likely(skb_vlan_tag_present(skb))) { | 3015static inline void skb_split_inside_header(struct sk_buff *skb, 3016 struct sk_buff* skb1, 3017 const u32 len, const int pos) 3018{ 3019 int i; 3020 3021 skb_copy_from_linear_data_offset(skb, len, skb_put(skb1, pos - len), 3022 pos - len); --- 2128 unchanged lines hidden (view full) --- 5151 */ 5152int skb_vlan_pop(struct sk_buff *skb) 5153{ 5154 u16 vlan_tci; 5155 __be16 vlan_proto; 5156 int err; 5157 5158 if (likely(skb_vlan_tag_present(skb))) { |
5131 skb->vlan_tci = 0; | 5159 __vlan_hwaccel_clear_tag(skb); |
5132 } else { 5133 if (unlikely(!eth_type_vlan(skb->protocol))) 5134 return 0; 5135 5136 err = __skb_vlan_pop(skb, &vlan_tci); 5137 if (err) 5138 return err; 5139 } --- 388 unchanged lines hidden --- | 5160 } else { 5161 if (unlikely(!eth_type_vlan(skb->protocol))) 5162 return 0; 5163 5164 err = __skb_vlan_pop(skb, &vlan_tci); 5165 if (err) 5166 return err; 5167 } --- 388 unchanged lines hidden --- |