lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALnjE+oX2JJELJNVdO1V2T9jobsgP-+oU-Z7T93Pt6gkhE_cPw@mail.gmail.com>
Date:	Wed, 19 Nov 2014 00:05:53 -0800
From:	Pravin Shelar <pshelar@...ira.com>
To:	Jiri Pirko <jiri@...nulli.us>
Cc:	netdev <netdev@...r.kernel.org>,
	David Miller <davem@...emloft.net>,
	Jamal Hadi Salim <jhs@...atatu.com>,
	Tom Herbert <therbert@...gle.com>,
	Eric Dumazet <edumazet@...gle.com>,
	Willem de Bruijn <willemb@...gle.com>,
	Daniel Borkmann <dborkman@...hat.com>, mst@...hat.com,
	fw@...len.de, Paul.Durrant@...rix.com, Thomas Graf <tgraf@...g.ch>,
	Cong Wang <cwang@...pensource.com>
Subject: Re: [patch net-next v3 6/9] vlan: introduce __vlan_insert_tag helper
 which does not free skb

On Tue, Nov 18, 2014 at 1:37 PM, Jiri Pirko <jiri@...nulli.us> wrote:
> There's a need for helper which inserts vlan tag but does not free the
> skb in case of an error.
>
> Suggested-by: Pravin Shelar <pshelar@...ira.com>
> Signed-off-by: Jiri Pirko <jiri@...nulli.us>
Acked-by: Pravin B Shelar <pshelar@...ira.com>

> ---
>  include/linux/if_vlan.h | 45 ++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 34 insertions(+), 11 deletions(-)
>
> diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
> index 291e670..515a35e 100644
> --- a/include/linux/if_vlan.h
> +++ b/include/linux/if_vlan.h
> @@ -282,28 +282,24 @@ static inline bool vlan_hw_offload_capable(netdev_features_t features,
>  }
>
>  /**
> - * vlan_insert_tag - regular VLAN tag inserting
> + * __vlan_insert_tag - regular VLAN tag inserting
>   * @skb: skbuff to tag
>   * @vlan_proto: VLAN encapsulation protocol
>   * @vlan_tci: VLAN TCI to insert
>   *
>   * Inserts the VLAN tag into @skb as part of the payload
> - * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
> - *
> - * Following the skb_unshare() example, in case of error, the calling function
> - * doesn't have to worry about freeing the original skb.
> + * Returns error if skb_cow_head failes.
>   *
>   * Does not change skb->protocol so this function can be used during receive.
>   */
> -static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb,
> -                                             __be16 vlan_proto, u16 vlan_tci)
> +static inline int __vlan_insert_tag(struct sk_buff *skb,
> +                                   __be16 vlan_proto, u16 vlan_tci)
>  {
>         struct vlan_ethhdr *veth;
>
> -       if (skb_cow_head(skb, VLAN_HLEN) < 0) {
> -               dev_kfree_skb_any(skb);
> -               return NULL;
> -       }
> +       if (skb_cow_head(skb, VLAN_HLEN) < 0)
> +               return -ENOMEM;
> +
>         veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
>
>         /* Move the mac addresses to the beginning of the new header. */
> @@ -316,6 +312,33 @@ static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb,
>         /* now, the TCI */
>         veth->h_vlan_TCI = htons(vlan_tci);
>
> +       return 0;
> +}
> +
> +/**
> + * vlan_insert_tag - regular VLAN tag inserting
> + * @skb: skbuff to tag
> + * @vlan_proto: VLAN encapsulation protocol
> + * @vlan_tci: VLAN TCI to insert
> + *
> + * Inserts the VLAN tag into @skb as part of the payload
> + * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
> + *
> + * Following the skb_unshare() example, in case of error, the calling function
> + * doesn't have to worry about freeing the original skb.
> + *
> + * Does not change skb->protocol so this function can be used during receive.
> + */
> +static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb,
> +                                             __be16 vlan_proto, u16 vlan_tci)
> +{
> +       int err;
> +
> +       err = __vlan_insert_tag(skb, vlan_proto, vlan_tci);
> +       if (err) {
> +               dev_kfree_skb_any(skb);
> +               return NULL;
> +       }
>         return skb;
>  }
>
> --
> 1.9.3
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ