[ovs-dev] [rtnl_link_stats64 v2 2/4] datapath: Add clean compat layer for dev_get_stats().

Jesse Gross jesse at nicira.com
Mon Nov 8 23:23:59 UTC 2010


On Thu, Nov 4, 2010 at 2:37 PM, Ben Pfaff <blp at nicira.com> wrote:
> diff --git a/acinclude.m4 b/acinclude.m4
> index 565ca6d..c0c0b94 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -166,7 +166,17 @@ AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
>   OVS_GREP_IFELSE([$KSRC26/include/linux/in.h], [ipv4_is_multicast])
>
>   OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h], [dev_disable_lro])
> +
> +  # Linux 2.6.28 introduced dev_get_stats():
> +  #     extern const struct net_device_stats *dev_get_stats(struct net_device *dev);
> +  #
> +  # Linux 2.6.36 changed dev_get_stats() to:
> +  #     extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
> +  #                                                    struct rtnl_link_stats64 *storage);
>   OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h], [dev_get_stats])
> +  OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h],
> +                   [rtnl_link_stats64.*dev_get_stats],
> +                   [OVS_DEFINE([HAVE_DEV_GET_STATS64])])
>
>   # Check for the proto_data_valid member in struct sk_buff.  The [^@]
>   # is necessary because some versions of this header remove the
> @@ -200,6 +210,8 @@ AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
>   OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [NLA_NUL_STRING])
>   OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [nla_get_be16])
>
> +  OVS_GREP_IFELSE([$KSRC26/include/linux/if_link.h], [rtnl_link_stats64])
> +

Are these functions backported in distributions that you know about?
Generally, I've been doing compatibility code based on kernel version
and adding tests as problems arise.

> diff --git a/datapath/linux-2.6/compat-2.6/include/linux/if_link.h b/datapath/linux-2.6/compat-2.6/include/linux/if_link.h
> new file mode 100644
> index 0000000..8bc88cc
> --- /dev/null
> +++ b/datapath/linux-2.6/compat-2.6/include/linux/if_link.h
> @@ -0,0 +1,42 @@
> +#ifndef __LINUX_IF_LINK_WRAPPER_H
> +#define __LINUX_IF_LINK_WRAPPER_H 1
> +
> +#include_next <linux/if_link.h>
> +
> +#ifndef HAVE_RTNL_LINK_STATS64
> +#define HAVE_RTNL_LINK_STATS64

The kernel code should pick up headers in include/linux/, so if it is
the same as the one in compat-2.6 (which I think it is), we shouldn't
need both.

> diff --git a/include/linux/if_link.h b/include/linux/if_link.h
> new file mode 100644
> index 0000000..02d4eb4
> --- /dev/null
> +++ b/include/linux/if_link.h
> @@ -0,0 +1,42 @@
> +#ifndef __IF_LINK_WRAPPER_H
> +#define __IF_LINK_WRAPPER_H
> +
> +#include_next <linux/if_link.h>
> +
> +#ifndef HAVE_RTNL_LINK_STATS64
> +#define HAVE_RTNL_LINK_STATS64

HAVE_RTNL_LINK_STATS64 is defined as a symbol in kcompat.h, so I don't
think userspace will pick it up.




More information about the dev mailing list