[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1324049163-11207-7-git-send-email-igorm@etf.rs>
Date: Fri, 16 Dec 2011 16:25:59 +0100
From: igorm@....rs
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, Igor Maravic <igorm@....rs>
Subject: [PATCH 06/10 net-next] include:net:icmp: Tuned up ICMP_*_STATS macros for per device statistics and changed prototype for icmp_out_count
From: Igor Maravic <igorm@....rs>
Changed ICMP_*_STATS so now they call _DEV* macros.
They call _DEV* macros under rcu_read_lock,
so we could get in_device from net_device with function
__in_dev_get_rcu_safely. This function is safe if dev==NULL.
Changed prototype for icmp_out_count so we can have per device statistics.
Signed-off-by: Igor Maravic <igorm@....rs>
---
include/net/icmp.h | 37 ++++++++++++++++++++++++++++++++-----
1 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/include/net/icmp.h b/include/net/icmp.h
index 75d6156..aa71b9a 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -29,10 +29,37 @@ struct icmp_err {
};
extern const struct icmp_err icmp_err_convert[];
-#define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field)
-#define ICMP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field)
-#define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field+256)
-#define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field)
+#define ICMP_INC_STATS(net, dev, field) \
+ ({ \
+ rcu_read_lock(); \
+ _DEVINCATOMIC(net, icmp, , struct in_device, \
+ __in_dev_get_rcu_safely(dev), field); \
+ rcu_read_unlock(); \
+ })
+
+#define ICMP_INC_STATS_BH(net, dev, field) \
+ ({ \
+ rcu_read_lock(); \
+ _DEVINCATOMIC(net, icmp, _BH, struct in_device, \
+ __in_dev_get_rcu_safely(dev), field); \
+ rcu_read_unlock(); \
+ })
+
+#define ICMPMSGOUT_INC_STATS(net, dev, field) \
+ ({ \
+ rcu_read_lock(); \
+ _DEVINC_ATOMIC_ATOMIC(net, icmpmsg, struct in_device, \
+ __in_dev_get_rcu_safely(dev), field +256); \
+ rcu_read_unlock(); \
+ })
+
+#define ICMPMSGIN_INC_STATS_BH(net, dev, field) \
+ ({ \
+ rcu_read_lock(); \
+ _DEVINC_ATOMIC_ATOMIC(net, icmpmsg, struct in_device, \
+ __in_dev_get_rcu_safely(dev), field); \
+ rcu_read_unlock(); \
+ })
struct dst_entry;
struct net_proto_family;
@@ -43,6 +70,6 @@ extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info);
extern int icmp_rcv(struct sk_buff *skb);
extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg);
extern int icmp_init(void);
-extern void icmp_out_count(struct net *net, unsigned char type);
+extern void icmp_out_count(struct net_device *dev, unsigned char type);
#endif /* _ICMP_H */
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists