Richard Gobert wrote:
> {inet,ipv6}_gro_receive functions perform flush checks (ttl, flags,
> iph->id, ...) against all packets in a loop. These flush checks are
> relevant only to tcp flows, and as such they're used to determine whether
> the packets can be merged later in tcp_gro_receive.
> 
> These checks are not relevant to UDP packets.

These are network protocol coalescing invariants. Why would they be
limited to certain transport protocols only?

> Furthermore, they need to be
> done only once in tcp_gro_receive and only against the found p skb, since
> they only affect flush and not same_flow.
> 
> Levaraging the previous commit in the series, in which correct network
> header offsets are saved for both outer and inner network headers -
> allowing these checks to be done only once, in tcp_gro_receive. As a
> result, NAPI_GRO_CB(p)->flush is not used at all. In addition - flush_id
> checks are more declerative and contained in inet_gro_flush, thus removing

declarative

> the need for flush_id in napi_gro_cb.
> 
> Signed-off-by: Richard Gobert <[email protected]>
> ---
> +static int inet_gro_flush(const struct iphdr *iph, const struct iphdr *iph2,
> +                       struct sk_buff *p, u32 outer)
> +{
> +     const u32 id = ntohl(*(__be32 *)&iph->id);
> +     const u32 id2 = ntohl(*(__be32 *)&iph2->id);
> +     const int flush_id = ntohs(id >> 16) - ntohs(id2 >> 16);
> +     const u16 count = NAPI_GRO_CB(p)->count;
> +     const u32 df = id & IP_DF;
> +     u32 is_atomic;
> +     int flush;
> +
> +     /* All fields must match except length and checksum. */
> +     flush = (iph->ttl ^ iph2->ttl) | (iph->tos ^ iph2->tos) | (df ^ (id2 & 
> IP_DF));
> +
> +     /* When we receive our second frame we can make a decision on if we
> +      * continue this flow as an atomic flow with a fixed ID or if we use
> +      * an incremdfenting ID.
> +      */

Comment became garbled on move: incrementing

> +     if (count == 1) {
> +             is_atomic = df && flush_id == 0;
> +             NAPI_GRO_CB(p)->is_atomic = is_atomic;
> +     } else {
> +             is_atomic = df && NAPI_GRO_CB(p)->is_atomic;
> +     }
> +
> +     /* Ignore outer IP ID value if based on atomic datagram. */
> +     outer = (outer && df) - 1;
> +     is_atomic--;
> +
> +     return flush | ((flush_id ^ (count & is_atomic)) & outer);
> +}

Reply via email to