From: Eric Dumazet <eric.dumazet@gmail.com>
To: Oliver Herms <oliver.peter.herms@gmail.com>,
davem@davemloft.net, kuznet@ms2.inr.ac.ru,
yoshfuji@linux-ipv6.org
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] net: ip/tnl: Set iph->id only when don't fragment is not set
Date: Sat, 23 Nov 2019 09:53:33 -0800 [thread overview]
Message-ID: <fa37491f-3604-bd3b-7518-dab654b641b6@gmail.com> (raw)
In-Reply-To: <20191123145817.GA22321@fuckup>
On 11/23/19 6:58 AM, Oliver Herms wrote:
> In IPv4 the identification field ensures that fragments of different datagrams
> are not mixed by the receiver. Packets with Don't Fragment (DF) flag set are not
> to be fragmented in transit and thus don't need an identification.
Official sources for this assertion please, so that we can double check if you
implemented the proper avoidance ?
> Calculating the identification takes significant CPU time.
> This patch will increase IP tunneling performance by ~10% unless DF is not set.
> However, DF is set by default which is best practice.
>
> Signed-off-by: Oliver Herms <oliver.peter.herms@gmail.com>
> ---
> net/ipv4/ip_tunnel_core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
> index 1452a97914a0..8636c1e0e7b7 100644
> --- a/net/ipv4/ip_tunnel_core.c
> +++ b/net/ipv4/ip_tunnel_core.c
> @@ -73,7 +73,9 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
> iph->daddr = dst;
> iph->saddr = src;
> iph->ttl = ttl;
> - __ip_select_ident(net, iph, skb_shinfo(skb)->gso_segs ?: 1);
> +
> + if (unlikely((iph->frag_off & htons(IP_DF)) == false))
This unlikely() seems wrong to me.
You do not know what are the odds of IP_DF being set or not.
> + __ip_select_ident(net, iph, skb_shinfo(skb)->gso_segs ?: 1);
>
> err = ip_local_out(net, sk, skb);
>
>
So we are going to send 2 bytes with garbage if we do not call __ip_select_ident()
This would cause various security threats, since the garbage might reveal a secret.
next prev parent reply other threads:[~2019-11-23 17:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-23 14:58 [PATCH] net: ip/tnl: Set iph->id only when don't fragment is not set Oliver Herms
2019-11-23 17:53 ` Eric Dumazet [this message]
2019-11-23 18:29 ` Joe Perches
2019-11-24 13:02 ` Oliver Herms
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=fa37491f-3604-bd3b-7518-dab654b641b6@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=oliver.peter.herms@gmail.com \
--cc=yoshfuji@linux-ipv6.org \
/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;
as well as URLs for NNTP newsgroup(s).