On Thu, Apr 9, 2015 at 11:15 AM, Jesse Gross <[email protected]> wrote:
> skb protocol offsets are relative to the beginning of the
> buffer and therefore must be updated if the buffer size is
> expanded. Kernel functions do this automatically for existing
> fields but obviously not for anything that we backport. This
> introduces a wrapper for pskb_expand_head() to update the
> inner protocol fields that we have backported.
>
> Without this, a kernel crash can be triggered with tunnel
> packets that do not have enough headroom and need to be
> segmented. pskb_expand_head() is called in directly through
> skb_cow_head() at the beginning of each of the tunnel transmit
> routines.
>
> Reported-by: Yinpeijun <[email protected]>
> Signed-off-by: Jesse Gross <[email protected]>
> ---
> v2: Use existing backported skb offset APIs to avoid introducing
> additional version checks.
> v3: Move macro into skbuff.h to ensure that it rewrites all calls
> of pskb_expand_head().
> v4: Rebase and add EXPORT_SYMBOL for vport module use.
>     Offsets can be negative and should be signed.
> ---
>  datapath/linux/compat/gso.h                  | 17 +++++++++++++++++
>  datapath/linux/compat/include/linux/skbuff.h | 14 +++++++++++++-
>  datapath/linux/compat/skbuff-openvswitch.c   | 27 +++++++++++++++++++++++++++
>  3 files changed, 57 insertions(+), 1 deletion(-)
>
> diff --git a/datapath/linux/compat/gso.h b/datapath/linux/compat/gso.h
> index 337d13a..dce4c67 100644
> --- a/datapath/linux/compat/gso.h
> +++ b/datapath/linux/compat/gso.h
> @@ -52,6 +52,15 @@ static inline int skb_inner_network_offset(const struct 
> sk_buff *skb)
>         return skb_inner_network_header(skb) - skb->data;
>  }
>
> +/* We don't actually store the transport offset on backports because
> + * we don't use it anywhere. Slightly rename this version to avoid
> + * future users from picking it up accidentially.
> + */
Can we add WARN_ON() to catch this case?

> +static inline int ovs_skb_inner_transport_offset(const struct sk_buff *skb)
> +{
> +       return 0;
> +}
> +
>  static inline void skb_set_inner_network_header(const struct sk_buff *skb,
>                                                 int offset)
>  {
> @@ -62,6 +71,14 @@ static inline void skb_set_inner_network_header(const

Otherwise looks good.
Acked-by: Pravin B Shelar <[email protected]>
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to