From patchwork Thu Jul 8 23:00:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 341 Return-Path: Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by open-mesh.net (Postfix) with SMTP id 4E7541545AF for ; Fri, 9 Jul 2010 01:00:22 +0200 (CEST) Received: (qmail invoked by alias); 08 Jul 2010 23:00:21 -0000 Received: from unknown (EHLO sven-desktop.lazhur.ath.cx) [89.246.219.69] by mail.gmx.net (mp070) with SMTP; 09 Jul 2010 01:00:21 +0200 X-Authenticated: #15668376 X-Provags-ID: V01U2FsdGVkX19jQ6Zf6GljK5ZwBdu1AczuJQTfVU6LTNhohYmYvK vGtDZxucFfJYm+ From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 9 Jul 2010 01:00:18 +0200 Message-Id: <1278630018-18345-1-git-send-email-sven.eckelmann@gmx.de> X-Mailer: git-send-email 1.7.1 X-Y-GMX-Trusted: 0 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: fix 64 bit counters on 32 bit arches X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2010 23:00:22 -0000 From: Eric Dumazet There is a small possibility that a reader gets incorrect values on 32 bit arches. SNMP applications could catch incorrect counters when a 32bit high part is changed by another stats consumer/provider. One way to solve this is to add a rtnl_link_stats64 param to all ndo_get_stats64() methods, and also add such a parameter to dev_get_stats(). Rule is that we are not allowed to use dev->stats64 as a temporary storage for 64bit stats, but a caller provided area (usually on stack) Old drivers (only providing get_stats() method) need no changes. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller [sven.eckelmann@gmx.de: Added compat.h defines for pre-2.6.36 kernels] Signed-off-by: Sven Eckelmann --- This patch entered net-next-2.6 today. It is also part of maint and must be applied in trunk too. The original commit can be found using its SHA1 28172739f0a276eb8d6ca917b3974c2edb036da3. batman-adv/compat.h | 8 ++++++++ batman-adv/hard-interface.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/batman-adv/compat.h b/batman-adv/compat.h index 09016c8..103593d 100644 --- a/batman-adv/compat.h +++ b/batman-adv/compat.h @@ -249,4 +249,12 @@ static inline struct net_device_stats *dev_get_stats(struct net_device *dev) #endif /* < KERNEL_VERSION(2, 6, 29) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) + +#define dev_get_stats(x, y) dev_get_stats(x) + +#define rtnl_link_stats64 rtnl_link_stats __attribute__((unused)) + +#endif /* < KERNEL_VERSION(2, 6, 36) */ + #endif /* _NET_BATMAN_ADV_COMPAT_H_ */ diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c index 5ff9dcb..6a37c33 100644 --- a/batman-adv/hard-interface.c +++ b/batman-adv/hard-interface.c @@ -445,6 +445,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, struct batman_packet *batman_packet; struct batman_if *batman_if; struct net_device_stats *stats; + struct rtnl_link_stats64 temp; int ret; skb = skb_share_check(skb, GFP_ATOMIC); @@ -480,7 +481,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, if (batman_if->if_status != IF_ACTIVE) goto err_free; - stats = (struct net_device_stats *)dev_get_stats(skb->dev); + stats = (struct net_device_stats *)dev_get_stats(skb->dev, &temp); if (stats) { stats->rx_packets++; stats->rx_bytes += skb->len;