mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Richard Gobert <richardbgobert@gmail.com>,
	 davem@davemloft.net,  edumazet@google.com,  kuba@kernel.org,
	 pabeni@redhat.com,  willemdebruijn.kernel@gmail.com,
	 dsahern@kernel.org,  xeb@mail.ru,  shuah@kernel.org,
	 idosch@nvidia.com,  razor@blackwall.org,  amcohen@nvidia.com,
	 petrm@nvidia.com,  jbenc@redhat.com,  bpoirier@nvidia.com,
	 b.galvani@gmail.com,  gavinl@nvidia.com,  liujian56@huawei.com,
	 horms@kernel.org,  linyunsheng@huawei.com,  therbert@google.com,
	 netdev@vger.kernel.org,  linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v3 4/4] net: gro: move L3 flush checks to tcp_gro_receive
Date: Sun, 10 Mar 2024 06:34:05 -0400	[thread overview]
Message-ID: <65ed8c9d8dc5a_193375294e6@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <88831c36-a589-429f-8e8b-2ecb66a30263@gmail.com>

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 <richardbgobert@gmail.com>
> ---
> +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);
> +}

  parent reply	other threads:[~2024-03-10 10:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09 15:26 [PATCH net-next v3 0/4] net: gro: encapsulation bug fix and flush checks improvements Richard Gobert
2024-03-09 15:29 ` [PATCH net-next v3 1/4] net: gro: add p_off param in *_gro_complete Richard Gobert
2024-03-09 15:30   ` [PATCH net-next v3 2/4] selftests/net: add local address bind in vxlan selftest Richard Gobert
2024-03-09 15:33 ` [PATCH net-next v3 3/4] net: gro: add {inner_}network_offset to napi_gro_cb Richard Gobert
2024-03-09 15:34 ` [PATCH net-next v3 4/4] net: gro: move L3 flush checks to tcp_gro_receive Richard Gobert
2024-03-09 15:41   ` Eric Dumazet
2024-03-11  9:18     ` Richard Gobert
2024-03-11 12:11       ` Willem de Bruijn
2024-03-11 13:08         ` Richard Gobert
2024-03-11 13:13           ` Willem de Bruijn
2024-03-10 10:34   ` Willem de Bruijn [this message]
2024-03-11  9:21     ` Richard Gobert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65ed8c9d8dc5a_193375294e6@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=amcohen@nvidia.com \
    --cc=b.galvani@gmail.com \
    --cc=bpoirier@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gavinl@nvidia.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jbenc@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linyunsheng@huawei.com \
    --cc=liujian56@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.org \
    --cc=richardbgobert@gmail.com \
    --cc=shuah@kernel.org \
    --cc=therbert@google.com \
    --cc=xeb@mail.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®