Skip to content

Commit 758f75d

Browse files
Tom Herbertdavem330
authored andcommitted
gre: call skb_gro_checksum_simple_validate
Signed-off-by: Tom Herbert <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1933a78 commit 758f75d

File tree

1 file changed

+7
-36
lines changed

1 file changed

+7
-36
lines changed

net/ipv4/gre_offload.c

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,6 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
119119
return segs;
120120
}
121121

122-
/* Compute the whole skb csum in s/w and store it, then verify GRO csum
123-
* starting from gro_offset.
124-
*/
125-
static __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-
144122
static struct sk_buff **gre_gro_receive(struct sk_buff **head,
145123
struct sk_buff *skb)
146124
{
@@ -192,22 +170,15 @@ static struct sk_buff **gre_gro_receive(struct sk_buff **head,
192170
if (unlikely(!greh))
193171
goto out_unlock;
194172
}
195-
if (greh->flags & GRE_CSUM) { /* Need to verify GRE csum first */
196-
__sum16 csum = 0;
197-
198-
if (skb->ip_summed == CHECKSUM_COMPLETE)
199-
csum = csum_fold(NAPI_GRO_CB(skb)->csum);
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)
173+
174+
/* Don't bother verifying checksum if we're going to flush anyway. */
175+
if (greh->flags & GRE_CSUM) {
176+
if (!NAPI_GRO_CB(skb)->flush &&
177+
skb_gro_checksum_simple_validate(skb))
209178
goto out_unlock;
179+
NAPI_GRO_CB(skb)->encapsulation++;
210180
}
181+
211182
flush = 0;
212183

213184
for (p = *head; p; p = p->next) {

0 commit comments

Comments
 (0)