Paolo Abeni <[email protected]> wrote:
> When the extension to be added is already present, the only
> skb field we may need to update is 'extensions': we can reorder
> the code and avoid a branch.
>
> Signed-off-by: Paolo Abeni <[email protected]>
> ---
> net/core/skbuff.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index e1d88762f659..38afa3ff2b44 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5666,11 +5666,8 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id
> id)
> if (!new)
> return NULL;
>
> - if (__skb_ext_exist(new, id)) {
> - if (old != new)
> - skb->extensions = new;
Yes, the old != new check can be avoided, we would
replace "extensions" with the same content.
> + if (__skb_ext_exist(new, id))
> goto set_active;
> - }
>
> newoff = new->chunks;
> } else {
> @@ -5684,9 +5681,9 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id
> id)
> newlen = newoff + skb_ext_type_len[id];
> new->chunks = newlen;
> new->offset[id] = newoff;
> - skb->extensions = new;
> -set_active:
> skb->active_extensions |= 1 << id;
> +set_active:
> + skb->extensions = new;
Why are you moving the label?
I don't think thats correct.
We must make sure the id is flagged as active in
active_extensions.