Skip to content

Commit 1269f7a

Browse files
committed
datapath: Tolerate backporting of rtnl_link_stats64 (as in RHEL 6).
Red Hat Enterprise Linux 6 has a 2.6.32 kernel but it backports the rtnl_link_stats64 structure that was introduced in 2.6.35, so we need to check whether it was defined instead of just guessing based on the kernel version number. Build-tested only, on 2.6.32-71.14.1.el6 (RHEL 6), linux-2.6.18-128.1.6.el5.xs5.5.0.496.101 (XenServer 5.5.0), 2.6.18-128.1.6.el5.xs5.5.0.505.1024xen (XenServer 5.5.0 update 1), and upstream 2.6.18, 2.6.26, 2.6.29, 2.6.33, 2.6.34, 2.6.36, all for i386, plus 2.6.36 for x86-64. My machine's userspace headers have <linux/if_link.h> but not rtnl_link_stats64. Jesse Gross tested the case where <linux/if_link.h> has rtnl_link_stats64, on Ubuntu 10.10. Reported-by: Geoff White <gwhite@nicira.com> Tested-by: Jesse Gross <jesse@nicira.com>
1 parent 5e5ce07 commit 1269f7a

4 files changed

Lines changed: 30 additions & 5 deletions

File tree

acinclude.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
204204
OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [nla_get_be16])
205205
OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [nla_find_nested])
206206
207+
OVS_GREP_IFELSE([$KSRC26/include/linux/if_link.h], [rtnl_link_stats64])
208+
207209
OVS_CHECK_LOG2_H
208210
209211
if cmp -s datapath/linux-2.6/kcompat.h.new \

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2008, 2009, 2010 Nicira Networks
1+
# Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@ OVS_CHECK_NDEBUG
4747
OVS_CHECK_NETLINK
4848
OVS_CHECK_OPENSSL
4949
OVS_CHECK_LOGDIR
50+
OVS_CHECK_RTNL_LINK_STATS64
5051
OVS_CHECK_PYTHON
5152
OVS_CHECK_PYUIC4
5253
OVS_CHECK_OVSDBMONITOR

include/linux/if_link.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include <linux/version.h>
55

6+
#ifdef HAVE_RTNL_LINK_STATS64
7+
#include_next <linux/if_link.h>
8+
#else /* !HAVE_RTNL_LINK_STATS64 */
9+
610
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
711
#include_next <linux/if_link.h>
812
#else
@@ -13,9 +17,8 @@
1317
* turn only really needs __u64. */
1418
#include <linux/types.h>
1519
#include <linux/netlink.h>
16-
#endif
20+
#endif /* kernel < 2.6.19 */
1721

18-
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
1922
/* The main device statistics structure */
2023
struct rtnl_link_stats64 {
2124
__u64 rx_packets; /* total packets received */
@@ -48,6 +51,6 @@ struct rtnl_link_stats64 {
4851
__u64 rx_compressed;
4952
__u64 tx_compressed;
5053
};
51-
#endif /* linux kernel < 2.6.35 */
54+
#endif /* !HAVE_RTNL_LINK_STATS64 */
5255

5356
#endif

m4/openvswitch.m4

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- autoconf -*-
22

3-
# Copyright (c) 2008, 2009, 2010 Nicira Networks.
3+
# Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -46,6 +46,25 @@ AC_DEFUN([OVS_CHECK_NDEBUG],
4646
[ndebug=false])
4747
AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
4848

49+
dnl Checks for struct rtnl_link_stats64.
50+
dnl
51+
dnl (OVS checks for this structure in both kernel and userspace headers. This
52+
dnl is not redundant, because the kernel and userspace builds have completely
53+
dnl different include paths. It is possible for the kernel to have this
54+
dnl structure but not userspace, and vice versa.)
55+
AC_DEFUN([OVS_CHECK_RTNL_LINK_STATS64],
56+
[AC_REQUIRE([OVS_CHECK_NETLINK])
57+
if test $HAVE_NETLINK = yes; then
58+
AC_CHECK_MEMBER(
59+
[struct rtnl_link_stats64.tx_packets],
60+
[AC_DEFINE([HAVE_RTNL_LINK_STATS64], [1],
61+
[Define to 1 if <linux/if_link.h> defines
62+
struct rtnl_link_stats64.])],
63+
[], [#include <sys/socket.h> /* Provides sa_family_t. */
64+
#include <linux/if_link.h>
65+
])
66+
fi])
67+
4968
dnl Checks for Netlink support.
5069
AC_DEFUN([OVS_CHECK_NETLINK],
5170
[AC_CHECK_HEADER([linux/netlink.h],

0 commit comments

Comments
 (0)