[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpUH+18SgwPZUd7PiAiGauEfgiFb0nozKsNnawQcrzZrmQ@mail.gmail.com>
Date: Sun, 2 Dec 2018 21:11:13 -0800
From: Cong Wang <xiyou.wangcong@...il.com>
To: Tariq Toukan <tariqt@...lanox.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
Saeed Mahameed <saeedm@...lanox.com>
Subject: Re: [Patch net] mlx5: check for malformed packets
On Sun, Dec 2, 2018 at 12:56 AM Tariq Toukan <tariqt@...lanox.com> wrote:
>
>
>
> On 01/12/2018 10:38 PM, Cong Wang wrote:
> > + if (*proto == htons(ETH_P_IP)) {
> > + if (unlikely(*network_depth > skb->len - sizeof(struct iphdr)))
> > + return false;
> > + return true;
>
> Or just do the following?
> return *network_depth <= skb->len - sizeof(struct iphdr));
>
> We'll lose the compiler hint though, so I'm not sure which is better.
It is very important to keep this unlikely(), as it is on a hot path.
>
> > + } else if (*proto == htons(ETH_P_IPV6)) {
>
> No need for an else here, the first if block always returns.
Yeah, but not sure if this makes a difference on the generated
asm code. I will give it a try anyway.
Thanks.
Powered by blists - more mailing lists