aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h52
1 files changed, 33 insertions, 19 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6f0b3e0adc73..0f665cb26b50 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2847,6 +2847,18 @@ static inline int skb_linearize_cow(struct sk_buff *skb)
2847 __skb_linearize(skb) : 0; 2847 __skb_linearize(skb) : 0;
2848} 2848}
2849 2849
2850static __always_inline void
2851__skb_postpull_rcsum(struct sk_buff *skb, const void *start, unsigned int len,
2852 unsigned int off)
2853{
2854 if (skb->ip_summed == CHECKSUM_COMPLETE)
2855 skb->csum = csum_block_sub(skb->csum,
2856 csum_partial(start, len, 0), off);
2857 else if (skb->ip_summed == CHECKSUM_PARTIAL &&
2858 skb_checksum_start_offset(skb) < 0)
2859 skb->ip_summed = CHECKSUM_NONE;
2860}
2861
2850/** 2862/**
2851 * skb_postpull_rcsum - update checksum for received skb after pull 2863 * skb_postpull_rcsum - update checksum for received skb after pull
2852 * @skb: buffer to update 2864 * @skb: buffer to update
@@ -2857,36 +2869,38 @@ static inline int skb_linearize_cow(struct sk_buff *skb)
2857 * update the CHECKSUM_COMPLETE checksum, or set ip_summed to 2869 * update the CHECKSUM_COMPLETE checksum, or set ip_summed to
2858 * CHECKSUM_NONE so that it can be recomputed from scratch. 2870 * CHECKSUM_NONE so that it can be recomputed from scratch.
2859 */ 2871 */
2860
2861static inline void skb_postpull_rcsum(struct sk_buff *skb, 2872static inline void skb_postpull_rcsum(struct sk_buff *skb,
2862 const void *start, unsigned int len) 2873 const void *start, unsigned int len)
2863{ 2874{
2864 if (skb->ip_summed == CHECKSUM_COMPLETE) 2875 __skb_postpull_rcsum(skb, start, len, 0);
2865 skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0));
2866 else if (skb->ip_summed == CHECKSUM_PARTIAL &&
2867 skb_checksum_start_offset(skb) < 0)
2868 skb->ip_summed = CHECKSUM_NONE;
2869} 2876}
2870 2877
2871unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len); 2878static __always_inline void
2879__skb_postpush_rcsum(struct sk_buff *skb, const void *start, unsigned int len,
2880 unsigned int off)
2881{
2882 if (skb->ip_summed == CHECKSUM_COMPLETE)
2883 skb->csum = csum_block_add(skb->csum,
2884 csum_partial(start, len, 0), off);
2885}
2872 2886
2887/**
2888 * skb_postpush_rcsum - update checksum for received skb after push
2889 * @skb: buffer to update
2890 * @start: start of data after push
2891 * @len: length of data pushed
2892 *
2893 * After doing a push on a received packet, you need to call this to
2894 * update the CHECKSUM_COMPLETE checksum.
2895 */
2873static inline void skb_postpush_rcsum(struct sk_buff *skb, 2896static inline void skb_postpush_rcsum(struct sk_buff *skb,
2874 const void *start, unsigned int len) 2897 const void *start, unsigned int len)
2875{ 2898{
2876 /* For performing the reverse operation to skb_postpull_rcsum(), 2899 __skb_postpush_rcsum(skb, start, len, 0);
2877 * we can instead of ...
2878 *
2879 * skb->csum = csum_add(skb->csum, csum_partial(start, len, 0));
2880 *
2881 * ... just use this equivalent version here to save a few
2882 * instructions. Feeding csum of 0 in csum_partial() and later
2883 * on adding skb->csum is equivalent to feed skb->csum in the
2884 * first place.
2885 */
2886 if (skb->ip_summed == CHECKSUM_COMPLETE)
2887 skb->csum = csum_partial(start, len, skb->csum);
2888} 2900}
2889 2901
2902unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
2903
2890/** 2904/**
2891 * skb_push_rcsum - push skb and update receive checksum 2905 * skb_push_rcsum - push skb and update receive checksum
2892 * @skb: buffer to update 2906 * @skb: buffer to update