Skip to content

Commit 80e85fb

Browse files
nbd168Paolo Abeni
authored andcommitted
net: create tcp_gro_lookup helper function
This pulls the flow port matching out of tcp_gro_receive, so that it can be reused for the next change, which adds the TCP fraglist GRO heuristic. Acked-by: Paolo Abeni <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Felix Fietkau <[email protected]> Reviewed-by: David Ahern <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 8d95dc4 commit 80e85fb

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

include/net/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,7 @@ void tcp_v4_destroy_sock(struct sock *sk);
21912191

21922192
struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
21932193
netdev_features_t features);
2194+
struct sk_buff *tcp_gro_lookup(struct list_head *head, struct tcphdr *th);
21942195
struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb);
21952196
INDIRECT_CALLABLE_DECLARE(int tcp4_gro_complete(struct sk_buff *skb, int thoff));
21962197
INDIRECT_CALLABLE_DECLARE(struct sk_buff *tcp4_gro_receive(struct list_head *head, struct sk_buff *skb));

net/ipv4/tcp_offload.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,27 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
245245
return segs;
246246
}
247247

248+
struct sk_buff *tcp_gro_lookup(struct list_head *head, struct tcphdr *th)
249+
{
250+
struct tcphdr *th2;
251+
struct sk_buff *p;
252+
253+
list_for_each_entry(p, head, list) {
254+
if (!NAPI_GRO_CB(p)->same_flow)
255+
continue;
256+
257+
th2 = tcp_hdr(p);
258+
if (*(u32 *)&th->source ^ *(u32 *)&th2->source) {
259+
NAPI_GRO_CB(p)->same_flow = 0;
260+
continue;
261+
}
262+
263+
return p;
264+
}
265+
266+
return NULL;
267+
}
268+
248269
struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)
249270
{
250271
struct sk_buff *pp = NULL;
@@ -282,24 +303,12 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)
282303
len = skb_gro_len(skb);
283304
flags = tcp_flag_word(th);
284305

285-
list_for_each_entry(p, head, list) {
286-
if (!NAPI_GRO_CB(p)->same_flow)
287-
continue;
288-
289-
th2 = tcp_hdr(p);
290-
291-
if (*(u32 *)&th->source ^ *(u32 *)&th2->source) {
292-
NAPI_GRO_CB(p)->same_flow = 0;
293-
continue;
294-
}
295-
296-
goto found;
297-
}
298-
p = NULL;
299-
goto out_check_final;
306+
p = tcp_gro_lookup(head, th);
307+
if (!p)
308+
goto out_check_final;
300309

301-
found:
302310
/* Include the IP ID check below from the inner most IP hdr */
311+
th2 = tcp_hdr(p);
303312
flush = NAPI_GRO_CB(p)->flush;
304313
flush |= (__force int)(flags & TCP_FLAG_CWR);
305314
flush |= (__force int)((flags ^ tcp_flag_word(th2)) &

0 commit comments

Comments
 (0)