Patchwork [03/10,net-next] include:linux:inetdevice: Add struct ipv4_devstat and func __in_dev_get_rcu_safely

login
register
mail settings
Submitter Igor Maravić
Date Dec. 16, 2011, 3:25 p.m.
Message ID <1324049163-11207-4-git-send-email-igorm@etf.rs>
Download mbox | patch
Permalink /patch/131834/
State Rejected
Delegated to: David Miller
Headers show

Comments

Igor Maravić - Dec. 16, 2011, 3:25 p.m.
From: Igor Maravic <igorm@etf.rs>

Added struct ipv4_devstat for holding per device ipv4 stats.

Added function __in_dev_get_rcu_safely.
Did that so I would have cleaner code in IP_*_STATS and ICMP_*_STATS macros.

Signed-off-by: Igor Maravic <igorm@etf.rs>
---
 include/linux/inetdevice.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

Patch

diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 5f81466..a4bffa7 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -49,6 +49,13 @@  struct ipv4_devconf {
 	DECLARE_BITMAP(state, IPV4_DEVCONF_MAX);
 };
 
+struct ipv4_devstat {
+	struct proc_dir_entry   *proc_dir_entry;
+	DEFINE_SNMP_STAT(struct ipstats_mib, ip);
+	DEFINE_SNMP_STAT_ATOMIC(struct icmp_mib_dev, icmpdev);
+	DEFINE_SNMP_STAT_ATOMIC(struct icmpmsg_mib_dev, icmpmsgdev);
+};
+
 struct in_device {
 	struct net_device	*dev;
 	atomic_t		refcnt;
@@ -69,6 +76,7 @@  struct in_device {
 
 	struct neigh_parms	*arp_parms;
 	struct ipv4_devconf	cnf;
+	struct ipv4_devstat	stats;
 	struct rcu_head		rcu_head;
 };
 
@@ -209,6 +217,14 @@  static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev)
 	return rcu_dereference(dev->ip_ptr);
 }
 
+static inline struct in_device *__in_dev_get_rcu_safely(const struct net_device *dev)
+{
+	if (likely(dev))
+		return rcu_dereference(dev->ip_ptr);
+	else
+		return NULL;
+}
+
 static inline struct in_device *in_dev_get(const struct net_device *dev)
 {
 	struct in_device *in_dev;