[ovs-dev] [patch v2] datapath: Fix builds on older kernels.

Yifeng Sun pkusunyifeng at gmail.com
Wed Aug 29 18:36:57 UTC 2018


Thanks for the fix.

Tested-by: Yifeng Sun <pkusunyifeng at gmail.com>

Reviewed-by: Yifeng Sun <pkusunyifeng at gmail.com>

On Tue, Aug 28, 2018 at 7:54 PM Darrell Ball <dlu998 at gmail.com> wrote:

> On older kernels, for example 3.19, the function rt6_get_cookie() is
> not available and used with ipv6 config enabled;  it was introduced in
> 4.2.  Put back the replacement function if it does not exist.
> Add a 3.19 version to travis.
>
> CC: Yifeng Sun <pkusunyifeng at gmail.com>
> Fixes: bf61b8b1c1db ("datapath: Add support for kernel 4.16.x & 4.17.x.")
> Signed-off-by: Darrell Ball <dlu998 at gmail.com>
> ---
>
> v1->v2: add 3.19 to travis per Yifeng's suggestion.
>
>  .travis.yml                                 |  1 +
>  acinclude.m4                                |  5 ++++
>  datapath/linux/Modules.mk                   |  1 +
>  datapath/linux/compat/include/net/ip6_fib.h | 43
> +++++++++++++++++++++++++++++
>  4 files changed, 50 insertions(+)
>  create mode 100644 datapath/linux/compat/include/net/ip6_fib.h
>
> diff --git a/.travis.yml b/.travis.yml
> index 21447b5..a2ef8bd 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -41,6 +41,7 @@ env:
>    - KERNEL=4.14.63
>    - KERNEL=4.9.120
>    - KERNEL=4.4.148
> +  - KERNEL=3.19.8
>    - KERNEL=3.16.57
>    - TESTSUITE=1 LIBS=-ljemalloc
>
> diff --git a/acinclude.m4 b/acinclude.m4
> index ab141bd..0690bae 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -459,6 +459,9 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
>    OVS_GREP_IFELSE([$KSRC/arch/x86/include/asm/checksum_32.h], [src_err,],
>                    [OVS_DEFINE([HAVE_CSUM_COPY_DBG])])
>
> +  OVS_GREP_IFELSE([$KSRC/include/net/ip6_fib.h], [rt6_get_cookie],
> +                  [OVS_DEFINE([HAVE_RT6_GET_COOKIE])])
> +
>    OVS_GREP_IFELSE([$KSRC/include/net/addrconf.h], [ipv6_dst_lookup.*net],
>                    [OVS_DEFINE([HAVE_IPV6_DST_LOOKUP_NET])])
>    OVS_GREP_IFELSE([$KSRC/include/net/addrconf.h], [ipv6_stub])
> @@ -803,6 +806,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
>                    [OVS_DEFINE(HAVE_NF_CONNTRACK_HELPER_PUT)])
>
>  OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],[[[[:space:]]]SKB_GSO_UDP[[[:space:]]]],
>                    [OVS_DEFINE([HAVE_SKB_GSO_UDP])])
> +  OVS_GREP_IFELSE([$KSRC/include/net/dst.h],[DST_NOCACHE],
> +                  [OVS_DEFINE([HAVE_DST_NOCACHE])])
>    OVS_FIND_FIELD_IFELSE([$KSRC/include/net/rtnetlink.h], [rtnl_link_ops],
>                          [extack],
>                    [OVS_DEFINE([HAVE_EXT_ACK_IN_RTNL_LINKOPS])])
> diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
> index b06ca15..e31d784 100644
> --- a/datapath/linux/Modules.mk
> +++ b/datapath/linux/Modules.mk
> @@ -82,6 +82,7 @@ openvswitch_headers += \
>         linux/compat/include/net/inetpeer.h \
>         linux/compat/include/net/ip.h \
>         linux/compat/include/net/ip_tunnels.h \
> +        linux/compat/include/net/ip6_fib.h \
>         linux/compat/include/net/ip6_route.h \
>         linux/compat/include/net/ip6_tunnel.h \
>         linux/compat/include/net/ipv6.h \
> diff --git a/datapath/linux/compat/include/net/ip6_fib.h
> b/datapath/linux/compat/include/net/ip6_fib.h
> new file mode 100644
> index 0000000..0cc4358
> --- /dev/null
> +++ b/datapath/linux/compat/include/net/ip6_fib.h
> @@ -0,0 +1,43 @@
> +/*
> + *      Linux INET6 implementation
> + *
> + *      Authors:
> + *      Pedro Roque             <roque at di.fc.ul.pt>
> + *
> + *      This program is free software; you can redistribute it and/or
> + *      modify it under the terms of the GNU General Public License
> + *      as published by the Free Software Foundation; either version
> + *      2 of the License, or (at your option) any later version.
> + */
> +
> +#ifndef _IP6_FIB_WRAPPER_H
> +#define _IP6_FIB_WRAPPER_H
> +
> +#include_next <net/ip6_fib.h>
> +
> +#ifndef HAVE_RT6_GET_COOKIE
> +
> +#ifndef RTF_PCPU
> +#define RTF_PCPU        0x40000000
> +#endif
> +
> +#ifndef RTF_LOCAL
> +#define RTF_LOCAL       0x80000000
> +#endif
> +
> +#define rt6_get_cookie rpl_rt6_get_cookie
> +static inline u32 rt6_get_cookie(const struct rt6_info *rt)
> +{
> +       if (rt->rt6i_flags & RTF_PCPU ||
> +#ifdef HAVE_DST_NOCACHE
> +           (unlikely(rt->dst.flags & DST_NOCACHE) && rt->dst.from))
> +#else
> +           (unlikely(!list_empty(&rt->rt6i_uncached)) && rt->dst.from))
> +#endif
> +               rt = (struct rt6_info *)(rt->dst.from);
> +
> +       return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
> +}
> +#endif
> +
> +#endif
> --
> 1.9.1
>
>


More information about the dev mailing list