lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <470C2737.60403@goop.org>
Date:	Tue, 09 Oct 2007 18:13:27 -0700
From:	Jeremy Fitzhardinge <jeremy@...p.org>
To:	Jeff Garzik <jgarzik@...ox.com>
CC:	Stephen Hemminger <shemminger@...ux-foundation.org>,
	Rusty Russell <rusty@...tcorp.com.au>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH 1/3] xen-netfront: use net_device's stats structure

struct net_device has its own stats structure, so use that instead.
Also, we can use the default get_stats function.

Signed-off-by: Jeremy Fitzhardinge <jeremy@...source.com>
Cc: Stephen Hemminger <shemminger@...ux-foundation.org>
Cc: Rusty Russell <rusty@...tcorp.com.au>
---
 drivers/net/xen-netfront.c |   25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

===================================================================
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -72,8 +72,6 @@ struct netfront_info {
 	struct list_head list;
 	struct net_device *netdev;
 
-	struct net_device_stats stats;
-
 	struct xen_netif_tx_front_ring tx;
 	struct xen_netif_rx_front_ring rx;
 
@@ -339,8 +337,6 @@ static int xennet_open(struct net_device
 static int xennet_open(struct net_device *dev)
 {
 	struct netfront_info *np = netdev_priv(dev);
-
-	memset(&np->stats, 0, sizeof(np->stats));
 
 	spin_lock_bh(&np->rx_lock);
 	if (netif_carrier_ok(dev)) {
@@ -566,8 +562,8 @@ static int xennet_start_xmit(struct sk_b
 	if (notify)
 		notify_remote_via_irq(np->netdev->irq);
 
-	np->stats.tx_bytes += skb->len;
-	np->stats.tx_packets++;
+	np->netdev->stats.tx_bytes += skb->len;
+	np->netdev->stats.tx_packets++;
 
 	/* Note: It is not safe to access skb after xennet_tx_buf_gc()! */
 	xennet_tx_buf_gc(dev);
@@ -580,7 +576,7 @@ static int xennet_start_xmit(struct sk_b
 	return 0;
 
  drop:
-	np->stats.tx_dropped++;
+	np->netdev->stats.tx_dropped++;
 	dev_kfree_skb(skb);
 	return 0;
 }
@@ -590,12 +586,6 @@ static int xennet_close(struct net_devic
 	struct netfront_info *np = netdev_priv(dev);
 	netif_stop_queue(np->netdev);
 	return 0;
-}
-
-static struct net_device_stats *xennet_get_stats(struct net_device *dev)
-{
-	struct netfront_info *np = netdev_priv(dev);
-	return &np->stats;
 }
 
 static void xennet_move_rx_slot(struct netfront_info *np, struct sk_buff *skb,
@@ -856,13 +846,13 @@ static int handle_incoming_queue(struct 
 			if (skb_checksum_setup(skb)) {
 				kfree_skb(skb);
 				packets_dropped++;
-				np->stats.rx_errors++;
+				np->netdev->stats.rx_errors++;
 				continue;
 			}
 		}
 
-		np->stats.rx_packets++;
-		np->stats.rx_bytes += skb->len;
+		np->netdev->stats.rx_packets++;
+		np->netdev->stats.rx_bytes += skb->len;
 
 		/* Pass it up. */
 		netif_receive_skb(skb);
@@ -917,7 +907,7 @@ err:
 err:
 			while ((skb = __skb_dequeue(&tmpq)))
 				__skb_queue_tail(&errq, skb);
-			np->stats.rx_errors++;
+			np->netdev->stats.rx_errors++;
 			i = np->rx.rsp_cons;
 			continue;
 		}
@@ -1200,7 +1190,6 @@ static struct net_device * __devinit xen
 	netdev->open            = xennet_open;
 	netdev->hard_start_xmit = xennet_start_xmit;
 	netdev->stop            = xennet_close;
-	netdev->get_stats       = xennet_get_stats;
 	netdev->poll            = xennet_poll;
 	netdev->uninit          = xennet_uninit;
 	netdev->change_mtu	= xennet_change_mtu;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ