[ovs-dev] [PATCH] datapath: Support for kernel 3.15
Pravin Shelar
pshelar at nicira.com
Wed Jul 2 22:35:42 UTC 2014
On Wed, Jul 2, 2014 at 11:08 AM, Pritesh Kothari
<pritesh.kothari at cisco.com> wrote:
> Signed-off-by: Pritesh Kothari <pritesh.kothari at cisco.com>
> ---
> v1: make check passes for 3.2/3.13/3.14/3.15
> ---
> FAQ | 1 +
> NEWS | 2 +-
> acinclude.m4 | 17 ++++++++-
> datapath/linux/Modules.mk | 1 -
> datapath/linux/compat/include/linux/if.h | 18 ---------
> datapath/linux/compat/include/linux/netdevice.h | 12 ++++++
> datapath/linux/compat/include/net/ip_tunnels.h | 8 +++-
> datapath/linux/compat/ip_tunnels_core.c | 51 +++++++++++++++++++++++--
> datapath/linux/compat/vxlan.c | 3 +-
> datapath/vport-geneve.c | 2 +-
> datapath/vport-gre.c | 2 +-
> datapath/vport-lisp.c | 2 +-
> datapath/vport-netdev.c | 2 +-
> debian/changelog | 3 +-
> 14 files changed, 91 insertions(+), 33 deletions(-)
> delete mode 100644 datapath/linux/compat/include/linux/if.h
>
> diff --git a/FAQ b/FAQ
> index 3470983..c6d2126 100644
> --- a/FAQ
> +++ b/FAQ
> @@ -150,6 +150,7 @@ A: The following table lists the Linux kernel versions against which the
> 2.0.x 2.6.32 to 3.10
> 2.1.x 2.6.32 to 3.11
> 2.2.x 2.6.32 to 3.14
> + 2.3.x 2.6.32 to 3.15
>
> Open vSwitch userspace should also work with the Linux kernel module
> built into Linux 3.3 and later.
> diff --git a/NEWS b/NEWS
> index 2504f5c..534432a 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -42,7 +42,7 @@ v2.2.0 - Internal Release
> - Upon the receipt of a SIGHUP signal, ovs-vswitchd no longer reopens its
> log file (it will terminate instead). Please use 'ovs-appctl vlog/reopen'
> instead.
> - - Support for Linux kernels up to 3.14. From Kernel 3.12 onwards OVS uses
> + - Support for Linux kernels up to 3.15. From Kernel 3.12 onwards OVS uses
> tunnel API for GRE and VXLAN.
> - Added DPDK support.
> - Added support for custom vlog patterns in Python
> diff --git a/acinclude.m4 b/acinclude.m4
> index aa9ffcd..a133b38 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -134,10 +134,10 @@ AC_DEFUN([OVS_CHECK_LINUX], [
> AC_MSG_RESULT([$kversion])
>
> if test "$version" -ge 3; then
> - if test "$version" = 3 && test "$patchlevel" -le 14; then
> + if test "$version" = 3 && test "$patchlevel" -le 15; then
> : # Linux 3.x
> else
> - AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version newer than 3.14.x is not supported (please refer to the FAQ for advice)])
> + AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version newer than 3.15.x is not supported (please refer to the FAQ for advice)])
> fi
> else
> if test "$version" -le 1 || test "$patchlevel" -le 5 || test "$sublevel" -le 31; then
> @@ -270,6 +270,10 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
> OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
> OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
>
> + OVS_GREP_IFELSE([$KSRC/include/linux/if.h], [IFF_OVS_DATAPATH])
> + OVS_GREP_IFELSE([$KSRC/include/linux/if.h], [IFF_TX_SKB_SHARING])
> + OVS_GREP_IFELSE([$KSRC/include/linux/if.h], [IFF_LIVE_ADDR_CHANGE])
> +
> OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [vlan_set_encap_proto])
>
Why are you changing existing compat code in this patch? Even if you
have a reason for such change please send separate patch with the
explanation.
> OVS_GREP_IFELSE([$KSRC/include/linux/in.h], [ipv4_is_multicast])
> @@ -281,6 +285,9 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
> OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [can_checksum_protocol])
> OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [netdev_features_t])
> OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [pcpu_sw_netstats])
> + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [IFF_OVS_DATAPATH])
> + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [IFF_TX_SKB_SHARING])
> + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [IFF_LIVE_ADDR_CHANGE])
>
> OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32])
>
> @@ -322,11 +329,17 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
> OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_get_hash])
> OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_clear_hash])
> OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [l4_rxhash])
> + OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [encapsulation])
>
I think better way to search for encap is searching for GRE offload
feature, I done same check in patch that I posted "datapath: Enable
tunnel GSO features."
> OVS_GREP_IFELSE([$KSRC/include/linux/types.h], [bool],
> [OVS_DEFINE([HAVE_BOOL_TYPE])])
> OVS_GREP_IFELSE([$KSRC/include/linux/types.h], [__wsum],
> [OVS_DEFINE([HAVE_CSUM_TYPES])])
> +
> + OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if.h], [IFF_OVS_DATAPATH])
> + OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if.h], [IFF_TX_SKB_SHARING])
> + OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if.h], [IFF_LIVE_ADDR_CHANGE])
> +
> OVS_GREP_IFELSE([$KSRC/include/uapi/linux/types.h], [__wsum],
> [OVS_DEFINE([HAVE_CSUM_TYPES])])
>
> diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
> index 46aa1f6..9ba8126 100644
> --- a/datapath/linux/Modules.mk
> +++ b/datapath/linux/Modules.mk
> @@ -29,7 +29,6 @@ openvswitch_headers += \
> linux/compat/include/linux/hash.h \
> linux/compat/include/linux/icmp.h \
> linux/compat/include/linux/icmpv6.h \
> - linux/compat/include/linux/if.h \
> linux/compat/include/linux/if_arp.h \
> linux/compat/include/linux/if_ether.h \
> linux/compat/include/linux/if_vlan.h \
> diff --git a/datapath/linux/compat/include/linux/if.h b/datapath/linux/compat/include/linux/if.h
> deleted file mode 100644
> index c4c656c..0000000
> --- a/datapath/linux/compat/include/linux/if.h
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -#ifndef __LINUX_IF_WRAPPER_H
> -#define __LINUX_IF_WRAPPER_H 1
> -
> -#include_next <linux/if.h>
> -
> -#ifndef IFF_TX_SKB_SHARING
> -#define IFF_TX_SKB_SHARING 0
> -#endif
> -
> -#ifndef IFF_OVS_DATAPATH
> -#define IFF_OVS_DATAPATH 0
> -#endif
> -
> -#ifndef IFF_LIVE_ADDR_CHANGE
> -#define IFF_LIVE_ADDR_CHANGE 0
> -#endif
> -
> -#endif
> diff --git a/datapath/linux/compat/include/linux/netdevice.h b/datapath/linux/compat/include/linux/netdevice.h
> index 886c2f8..e2c5ed8 100644
> --- a/datapath/linux/compat/include/linux/netdevice.h
> +++ b/datapath/linux/compat/include/linux/netdevice.h
> @@ -140,4 +140,16 @@ struct pcpu_sw_netstats {
> };
> #endif
>
> +#ifndef HAVE_IFF_OVS_DATAPATH
> +#define IFF_OVS_DATAPATH 0
> +#endif
> +
> +#ifndef HAVE_IFF_TX_SKB_SHARING
> +#define IFF_TX_SKB_SHARING 0
> +#endif
> +
> +#ifndef HAVE_IFF_LIVE_ADDR_CHANGE
> +#define IFF_LIVE_ADDR_CHANGE 0
> +#endif
> +
> #endif
> diff --git a/datapath/linux/compat/include/net/ip_tunnels.h b/datapath/linux/compat/include/net/ip_tunnels.h
> index c7a14ef..075e597 100644
> --- a/datapath/linux/compat/include/net/ip_tunnels.h
> +++ b/datapath/linux/compat/include/net/ip_tunnels.h
> @@ -2,7 +2,7 @@
> #define __NET_IP_TUNNELS_WRAPPER_H 1
>
> #include <linux/version.h>
> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
> +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,15,0)
> #include_next <net/ip_tunnels.h>
> #else
>
> @@ -36,11 +36,15 @@ struct tnl_ptk_info {
> #define PACKET_RCVD 0
> #define PACKET_REJECT 1
>
> -int iptunnel_xmit(struct rtable *rt,
> +int iptunnel_xmit(struct sock *sk, struct rtable *rt,
> struct sk_buff *skb,
> __be32 src, __be32 dst, __u8 proto,
> __u8 tos, __u8 ttl, __be16 df, bool xnet);
>
> +struct sk_buff *iptunnel_handle_offloads(struct sk_buff *skb,
> + bool csum_help,
> + int gso_type_mask);
> +
> int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
>
> #endif
> diff --git a/datapath/linux/compat/ip_tunnels_core.c b/datapath/linux/compat/ip_tunnels_core.c
> index d650be2..5146b3a 100644
> --- a/datapath/linux/compat/ip_tunnels_core.c
> +++ b/datapath/linux/compat/ip_tunnels_core.c
> @@ -17,7 +17,7 @@
> */
>
> #include <linux/version.h>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> @@ -36,8 +36,9 @@
>
> #include "compat.h"
> #include "gso.h"
> +#include "vlan.h"
>
> -int iptunnel_xmit(struct rtable *rt,
> +int iptunnel_xmit(struct sock *sk, struct rtable *rt,
> struct sk_buff *skb,
> __be32 src, __be32 dst, __u8 proto,
> __u8 tos, __u8 ttl, __be16 df, bool xnet)
> @@ -112,4 +113,48 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
> return 0;
> }
>
> -#endif /* 3.12 */
> +struct sk_buff *iptunnel_handle_offloads(struct sk_buff *skb,
> + bool csum_help,
> + int gso_type_mask)
> +{
> + int err;
> +
This function is not called from any other function in OVS. why do you
want to add it to ovs compat layer?
> +#ifdef HAVE_ENCAPSULATION
> + if (likely(!skb->encapsulation)) {
> + skb_reset_inner_headers(skb);
> + skb->encapsulation = 1;
> + }
> +#endif
> +
> + if (skb_is_gso(skb)) {
> + err = skb_unclone(skb, GFP_ATOMIC);
> + if (unlikely(err))
> + goto error;
> + skb_shinfo(skb)->gso_type |= gso_type_mask;
> + return skb;
> + }
> +
> + /* If packet is not gso and we are resolving any partial checksum,
> + * clear encapsulation flag. This allows setting CHECKSUM_PARTIAL
> + * on the outer header without confusing devices that implement
> + * NETIF_F_IP_CSUM with encapsulation.
> + */
> +#ifdef HAVE_ENCAPSULATION
> + if (csum_help)
> + skb->encapsulation = 0;
> +#endif
> +
> + if (skb->ip_summed == CHECKSUM_PARTIAL && csum_help) {
> + err = skb_checksum_help(skb);
> + if (unlikely(err))
> + goto error;
> + } else if (skb->ip_summed != CHECKSUM_PARTIAL)
> + skb->ip_summed = CHECKSUM_NONE;
> +
> + return skb;
> +error:
> + kfree_skb(skb);
> + return ERR_PTR(err);
> +}
> +
> +#endif /* 3.15 */
> diff --git a/datapath/linux/compat/vxlan.c b/datapath/linux/compat/vxlan.c
> index b8b8fa7..f7db205 100644
> --- a/datapath/linux/compat/vxlan.c
> +++ b/datapath/linux/compat/vxlan.c
> @@ -226,7 +226,8 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
> if (err)
> return err;
>
> - return iptunnel_xmit(rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, false);
> + return iptunnel_xmit(skb->sk, rt, skb, src, dst,
> + IPPROTO_UDP, tos, ttl, df, false);
> }
>
> static void rcu_free_vs(struct rcu_head *rcu)
> diff --git a/datapath/vport-geneve.c b/datapath/vport-geneve.c
> index 33047f2..bed759f 100644
> --- a/datapath/vport-geneve.c
> +++ b/datapath/vport-geneve.c
> @@ -414,7 +414,7 @@ static int geneve_send(struct vport *vport, struct sk_buff *skb)
>
> df = tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
>
> - sent_len = iptunnel_xmit(rt, skb,
> + sent_len = iptunnel_xmit(skb->sk, rt, skb,
> saddr, tun_key->ipv4_dst,
> IPPROTO_UDP, tun_key->ipv4_tos,
> tun_key->ipv4_ttl,
> diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
> index d2a2602..46f8b0f 100644
> --- a/datapath/vport-gre.c
> +++ b/datapath/vport-gre.c
> @@ -192,7 +192,7 @@ static int __send(struct vport *vport, struct sk_buff *skb,
> df = tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
> skb->local_df = 1;
>
> - return iptunnel_xmit(rt, skb, saddr,
> + return iptunnel_xmit(skb->sk, rt, skb, saddr,
> tun_key->ipv4_dst, IPPROTO_GRE,
> tun_key->ipv4_tos,
> tun_key->ipv4_ttl, df, false);
> diff --git a/datapath/vport-lisp.c b/datapath/vport-lisp.c
> index c41e09e..e515776 100644
> --- a/datapath/vport-lisp.c
> +++ b/datapath/vport-lisp.c
> @@ -490,7 +490,7 @@ static int lisp_send(struct vport *vport, struct sk_buff *skb)
> skb->local_df = 1;
>
> df = tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
> - sent_len = iptunnel_xmit(rt, skb,
> + sent_len = iptunnel_xmit(skb->sk, rt, skb,
> saddr, tun_key->ipv4_dst,
> IPPROTO_UDP, tun_key->ipv4_tos,
> tun_key->ipv4_ttl, df, false);
> diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c
> index c15923b..c60a6ef 100644
> --- a/datapath/vport-netdev.c
> +++ b/datapath/vport-netdev.c
> @@ -255,7 +255,7 @@ struct vport *ovs_netdev_get_vport(struct net_device *dev)
> {
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) || \
> defined HAVE_RHEL_OVS_HOOK
> -#if IFF_OVS_DATAPATH != 0
> +#if HAVE_IFF_OVS_DATAPATH
> if (likely(dev->priv_flags & IFF_OVS_DATAPATH))
> #else
> if (likely(rcu_access_pointer(dev->rx_handler) == netdev_frame_hook))
> diff --git a/debian/changelog b/debian/changelog
> index 4658a3d..f43e9ad 100644
> --- a/debian/changelog
> +++ b/debian/changelog
> @@ -1,7 +1,8 @@
> openvswitch (2.3.90-1) unstable; urgency=low
> [ Open vSwitch team ]
> * New upstream version
> - - Nothing yet! Try NEWS...
> + - Support for Linux kernels up to 3.15. From Kernel 3.12 onwards OVS uses
> + tunnel API for GRE and VXLAN.
>
> -- Open vSwitch team <dev at openvswitch.org> Thu, 15 May 2014 17:08:39 -0700
>
> --
> 1.9.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list