aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/netdevice.h26
-rw-r--r--net/core/dev.c24
-rw-r--r--net/ipv4/gre_offload.c7
-rw-r--r--net/ipv4/udp_offload.c5
4 files changed, 33 insertions, 29 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index dfc1d8b8bd0f..456eb1fe51e8 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1883,8 +1883,8 @@ struct napi_gro_cb {
1883 /* GRO checksum is valid */ 1883 /* GRO checksum is valid */
1884 u8 csum_valid:1; 1884 u8 csum_valid:1;
1885 1885
1886 /* Number encapsulation layers crossed */ 1886 /* Number of checksums via CHECKSUM_UNNECESSARY */
1887 u8 encapsulation; 1887 u8 csum_cnt:3;
1888 1888
1889 /* used to support CHECKSUM_COMPLETE for tunneling protocols */ 1889 /* used to support CHECKSUM_COMPLETE for tunneling protocols */
1890 __wsum csum; 1890 __wsum csum;
@@ -2179,8 +2179,7 @@ static inline bool __skb_gro_checksum_validate_needed(struct sk_buff *skb,
2179 __sum16 check) 2179 __sum16 check)
2180{ 2180{
2181 return (skb->ip_summed != CHECKSUM_PARTIAL && 2181 return (skb->ip_summed != CHECKSUM_PARTIAL &&
2182 (skb->ip_summed != CHECKSUM_UNNECESSARY || 2182 NAPI_GRO_CB(skb)->csum_cnt == 0 &&
2183 (NAPI_GRO_CB(skb)->encapsulation > skb->encapsulation)) &&
2184 (!zero_okay || check)); 2183 (!zero_okay || check));
2185} 2184}
2186 2185
@@ -2196,18 +2195,17 @@ static inline __sum16 __skb_gro_checksum_validate_complete(struct sk_buff *skb,
2196 return __skb_gro_checksum_complete(skb); 2195 return __skb_gro_checksum_complete(skb);
2197} 2196}
2198 2197
2199/* Update skb for CHECKSUM_UNNECESSARY when we verified a top level
2200 * checksum or an encapsulated one during GRO. This saves work
2201 * if we fallback to normal path with the packet.
2202 */
2203static inline void skb_gro_incr_csum_unnecessary(struct sk_buff *skb) 2198static inline void skb_gro_incr_csum_unnecessary(struct sk_buff *skb)
2204{ 2199{
2205 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 2200 if (NAPI_GRO_CB(skb)->csum_cnt > 0) {
2206 if (NAPI_GRO_CB(skb)->encapsulation) 2201 /* Consume a checksum from CHECKSUM_UNNECESSARY */
2207 skb->encapsulation = 1; 2202 NAPI_GRO_CB(skb)->csum_cnt--;
2208 } else if (skb->ip_summed != CHECKSUM_PARTIAL) { 2203 } else {
2209 skb->ip_summed = CHECKSUM_UNNECESSARY; 2204 /* Update skb for CHECKSUM_UNNECESSARY and csum_level when we
2210 skb->encapsulation = 0; 2205 * verified a new top level checksum or an encapsulated one
2206 * during GRO. This saves work if we fallback to normal path.
2207 */
2208 __skb_incr_checksum_unnecessary(skb);
2211 } 2209 }
2212} 2210}
2213 2211
diff --git a/net/core/dev.c b/net/core/dev.c
index 26d296c2447c..a6077ef56345 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3962,13 +3962,6 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
3962 3962
3963 gro_list_prepare(napi, skb); 3963 gro_list_prepare(napi, skb);
3964 3964
3965 if (skb->ip_summed == CHECKSUM_COMPLETE) {
3966 NAPI_GRO_CB(skb)->csum = skb->csum;
3967 NAPI_GRO_CB(skb)->csum_valid = 1;
3968 } else {
3969 NAPI_GRO_CB(skb)->csum_valid = 0;
3970 }
3971
3972 rcu_read_lock(); 3965 rcu_read_lock();
3973 list_for_each_entry_rcu(ptype, head, list) { 3966 list_for_each_entry_rcu(ptype, head, list) {
3974 if (ptype->type != type || !ptype->callbacks.gro_receive) 3967 if (ptype->type != type || !ptype->callbacks.gro_receive)
@@ -3980,7 +3973,22 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
3980 NAPI_GRO_CB(skb)->flush = 0; 3973 NAPI_GRO_CB(skb)->flush = 0;
3981 NAPI_GRO_CB(skb)->free = 0; 3974 NAPI_GRO_CB(skb)->free = 0;
3982 NAPI_GRO_CB(skb)->udp_mark = 0; 3975 NAPI_GRO_CB(skb)->udp_mark = 0;
3983 NAPI_GRO_CB(skb)->encapsulation = 0; 3976
3977 /* Setup for GRO checksum validation */
3978 switch (skb->ip_summed) {
3979 case CHECKSUM_COMPLETE:
3980 NAPI_GRO_CB(skb)->csum = skb->csum;
3981 NAPI_GRO_CB(skb)->csum_valid = 1;
3982 NAPI_GRO_CB(skb)->csum_cnt = 0;
3983 break;
3984 case CHECKSUM_UNNECESSARY:
3985 NAPI_GRO_CB(skb)->csum_cnt = skb->csum_level + 1;
3986 NAPI_GRO_CB(skb)->csum_valid = 0;
3987 break;
3988 default:
3989 NAPI_GRO_CB(skb)->csum_cnt = 0;
3990 NAPI_GRO_CB(skb)->csum_valid = 0;
3991 }
3984 3992
3985 pp = ptype->callbacks.gro_receive(&napi->gro_list, skb); 3993 pp = ptype->callbacks.gro_receive(&napi->gro_list, skb);
3986 break; 3994 break;
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index d1bd16937d93..a4d7965fb880 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -172,12 +172,9 @@ static struct sk_buff **gre_gro_receive(struct sk_buff **head,
172 } 172 }
173 173
174 /* Don't bother verifying checksum if we're going to flush anyway. */ 174 /* Don't bother verifying checksum if we're going to flush anyway. */
175 if (greh->flags & GRE_CSUM) { 175 if ((greh->flags & GRE_CSUM) && !NAPI_GRO_CB(skb)->flush &&
176 if (!NAPI_GRO_CB(skb)->flush && 176 skb_gro_checksum_simple_validate(skb))
177 skb_gro_checksum_simple_validate(skb))
178 goto out_unlock; 177 goto out_unlock;
179 NAPI_GRO_CB(skb)->encapsulation++;
180 }
181 178
182 flush = 0; 179 flush = 0;
183 180
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 8ed460e3753c..a6adff98382a 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -238,12 +238,13 @@ struct sk_buff **udp_gro_receive(struct sk_buff **head, struct sk_buff *skb,
238 int flush = 1; 238 int flush = 1;
239 239
240 if (NAPI_GRO_CB(skb)->udp_mark || 240 if (NAPI_GRO_CB(skb)->udp_mark ||
241 (!skb->encapsulation && !NAPI_GRO_CB(skb)->csum_valid)) 241 (skb->ip_summed != CHECKSUM_PARTIAL &&
242 NAPI_GRO_CB(skb)->csum_cnt == 0 &&
243 !NAPI_GRO_CB(skb)->csum_valid))
242 goto out; 244 goto out;
243 245
244 /* mark that this skb passed once through the udp gro layer */ 246 /* mark that this skb passed once through the udp gro layer */
245 NAPI_GRO_CB(skb)->udp_mark = 1; 247 NAPI_GRO_CB(skb)->udp_mark = 1;
246 NAPI_GRO_CB(skb)->encapsulation++;
247 248
248 rcu_read_lock(); 249 rcu_read_lock();
249 uo_priv = rcu_dereference(udp_offload_base); 250 uo_priv = rcu_dereference(udp_offload_base);