aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/gre_offload.c
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2014-08-22 16:34:22 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-24 21:09:23 -0400
commit758f75d1ffa9ef482ae095f40087cf217e1f41b0 (patch)
tree2bea6c4ff48759fb86e95926d9c87d38fb3399c5 /net/ipv4/gre_offload.c
parent1933a7852ce6a81349855431b25122d7666bbfca (diff)
gre: call skb_gro_checksum_simple_validate
Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/gre_offload.c')
-rw-r--r--net/ipv4/gre_offload.c43
1 files changed, 7 insertions, 36 deletions
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index 6556263c8fa5..d1bd16937d93 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -119,28 +119,6 @@ out:
119 return segs; 119 return segs;
120} 120}
121 121
122/* Compute the whole skb csum in s/w and store it, then verify GRO csum
123 * starting from gro_offset.
124 */
125static __sum16 gro_skb_checksum(struct sk_buff *skb)
126{
127 __sum16 sum;
128
129 skb->csum = skb_checksum(skb, 0, skb->len, 0);
130 NAPI_GRO_CB(skb)->csum = csum_sub(skb->csum,
131 csum_partial(skb->data, skb_gro_offset(skb), 0));
132 sum = csum_fold(NAPI_GRO_CB(skb)->csum);
133 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) {
134 if (unlikely(!sum) && !skb->csum_complete_sw)
135 netdev_rx_csum_fault(skb->dev);
136 } else {
137 skb->ip_summed = CHECKSUM_COMPLETE;
138 skb->csum_complete_sw = 1;
139 }
140
141 return sum;
142}
143
144static struct sk_buff **gre_gro_receive(struct sk_buff **head, 122static struct sk_buff **gre_gro_receive(struct sk_buff **head,
145 struct sk_buff *skb) 123 struct sk_buff *skb)
146{ 124{
@@ -192,22 +170,15 @@ static struct sk_buff **gre_gro_receive(struct sk_buff **head,
192 if (unlikely(!greh)) 170 if (unlikely(!greh))
193 goto out_unlock; 171 goto out_unlock;
194 } 172 }
195 if (greh->flags & GRE_CSUM) { /* Need to verify GRE csum first */ 173
196 __sum16 csum = 0; 174 /* Don't bother verifying checksum if we're going to flush anyway. */
197 175 if (greh->flags & GRE_CSUM) {
198 if (skb->ip_summed == CHECKSUM_COMPLETE) 176 if (!NAPI_GRO_CB(skb)->flush &&
199 csum = csum_fold(NAPI_GRO_CB(skb)->csum); 177 skb_gro_checksum_simple_validate(skb))
200 /* Don't trust csum error calculated/reported by h/w */
201 if (skb->ip_summed == CHECKSUM_NONE || csum != 0)
202 csum = gro_skb_checksum(skb);
203
204 /* GRE CSUM is the 1's complement of the 1's complement sum
205 * of the GRE hdr plus payload so it should add up to 0xffff
206 * (and 0 after csum_fold()) just like the IPv4 hdr csum.
207 */
208 if (csum)
209 goto out_unlock; 178 goto out_unlock;
179 NAPI_GRO_CB(skb)->encapsulation++;
210 } 180 }
181
211 flush = 0; 182 flush = 0;
212 183
213 for (p = *head; p; p = p->next) { 184 for (p = *head; p; p = p->next) {