On Sun, Dec 2, 2018 at 12:56 AM Tariq Toukan <tar...@mellanox.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.

Reply via email to