All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shirley Ma <mashirle@us.ibm.com>
To: kuznet@ms2.inr.ac.ru
Cc: netdev@oss.sgi.com, xma@us.ibm.com
Subject: [PATCH]snmp6 64-bit counter support in proc.c
Date: Fri, 5 Dec 2003 12:14:47 -0800	[thread overview]
Message-ID: <200312051214.48076.mashirle@us.ibm.com> (raw)
In-Reply-To: <200312021240.PAA01536@yakov.inr.ac.ru>

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

I add this because there are some 64-bit counters in the new IPv6 MIBs. 
This patch has been tested agaist linux-2.6.0-test9, and cleanly applied to 
linux-2.6.0-test11.

Thanks
Shirley Ma
IBM Linux Technology Center

[-- Attachment #2: linux-2.6.0-test11-ipv6mib2-64.patch --]
[-- Type: text/x-diff, Size: 3156 bytes --]

diff -urN linux-2.6.0-test11/net/ipv6/proc.c linux-2.6.0-test11-ipv6mib2-64/net/ipv6/proc.c
--- linux-2.6.0-test11/net/ipv6/proc.c	2003-11-26 12:43:38.000000000 -0800
+++ linux-2.6.0-test11-ipv6mib2-64/net/ipv6/proc.c	2003-12-05 12:04:19.000000000 -0800
@@ -60,13 +60,14 @@
 struct snmp6_item
 {
 	char *name;
+	int   size;
 	int   offset;
 };
-#define SNMP6_SENTINEL	{ .name = NULL, .offset = 0 }
+#define SNMP6_SENTINEL	{ .name = NULL, .size = 0, .offset = 0 }
 
 static struct snmp6_item snmp6_ipv6_list[] = {
 /* ipv6 mib according to RFC 2465 */
-#define SNMP6_GEN(x) { .name = #x , .offset = offsetof(struct ipv6_mib, x) }
+#define SNMP6_GEN(x) { .name = #x , .size = sizeof(((struct ipv6_mib *)0)->x), .offset = offsetof(struct ipv6_mib, x) }
 	SNMP6_GEN(Ip6InReceives),
 	SNMP6_GEN(Ip6InHdrErrors),
 	SNMP6_GEN(Ip6InTooBigErrors),
@@ -104,7 +105,7 @@
 		OutRouterAdvertisements too.
 		OutGroupMembQueries too.
  */
-#define SNMP6_GEN(x) { .name = #x , .offset = offsetof(struct icmpv6_mib, x) }
+#define SNMP6_GEN(x) { .name = #x , .size = sizeof(((struct icmpv6_mib *)0)->x), .offset = offsetof(struct icmpv6_mib, x) }
 	SNMP6_GEN(Icmp6InMsgs),
 	SNMP6_GEN(Icmp6InErrors),
 	SNMP6_GEN(Icmp6InDestUnreachs),
@@ -138,7 +139,7 @@
 };
 
 static struct snmp6_item snmp6_udp6_list[] = {
-#define SNMP6_GEN(x) { .name = "Udp6" #x , .offset = offsetof(struct udp_mib, Udp##x) }
+#define SNMP6_GEN(x) { .name = "Udp6" #x , .size = sizeof(((struct udp_mib *)0)->Udp##x), .offset = offsetof(struct udp_mib, Udp##x) }
 	SNMP6_GEN(InDatagrams),
 	SNMP6_GEN(NoPorts),
 	SNMP6_GEN(InErrors),
@@ -147,22 +148,27 @@
 	SNMP6_SENTINEL
 };
 
-static unsigned long
-fold_field(void *mib[], int offt)
+static unsigned long long
+fold_field(void *mib[], int size, int offt)
 {
-        unsigned long res = 0;
+        unsigned long long res = 0;
         int i;
  
         for (i = 0; i < NR_CPUS; i++) {
                 if (!cpu_possible(i))
                         continue;
-                res +=
-                    *((unsigned long *) (((void *)per_cpu_ptr(mib[0], i)) +
-                                         offt));
-                res +=
-                    *((unsigned long *) (((void *)per_cpu_ptr(mib[1], i)) +
-                                         offt));
-        }
+		if (size == 4) {
+			res += *((unsigned long *) 
+				(((void *)per_cpu_ptr(mib[0], i)) + offt));
+			res += *((unsigned long *)
+				(((void *)per_cpu_ptr(mib[1], i)) + offt));
+		} else if (size == 8) {
+			res += *((unsigned long long *) 
+				(((void *)per_cpu_ptr(mib[0], i)) + offt));
+			res += *((unsigned long long *)
+				(((void *)per_cpu_ptr(mib[1], i)) + offt));
+		}
+	}
         return res;
 }
 
@@ -170,9 +176,9 @@
 snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp6_item *itemlist)
 {
 	int i;
-	for (i=0; itemlist[i].name; i++)
-		seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name, 
-				fold_field(mib, itemlist[i].offset));
+	for (i=0; itemlist[i].name; i++) 
+		seq_printf(seq, "%-32s\t%llu\n", itemlist[i].name, 
+			fold_field(mib, itemlist[i].size, itemlist[i].offset));
 }
 
 static int snmp6_seq_show(struct seq_file *seq, void *v)

  reply	other threads:[~2003-12-05 20:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-20  0:21 IPv6 MIB:ipv6PrefixTable implementation Shirley Ma
2003-12-02 12:40 ` kuznet
2003-12-05 20:14   ` Shirley Ma [this message]
2003-12-05 20:31     ` [PATCH]snmp6 64-bit counter support in proc.c David S. Miller
2004-01-14 22:52       ` Shirley Ma
2004-01-15  8:57         ` David S. Miller
2003-12-05 21:51 ` [PATCH] IPv6 MIB:ipv6Prefix netlink notification Shirley Ma
2003-12-05 22:57   ` David S. Miller
2004-01-14 22:54     ` Shirley Ma
2004-01-15  8:58       ` David S. Miller
2004-01-14 23:52     ` [PATCH] IPv6 MIB:ipv6RouterAdvert " Shirley Ma
2004-01-15  8:52       ` David S. Miller
2004-01-15  9:10         ` YOSHIFUJI Hideaki / 吉藤英明
2004-01-15  0:21     ` [PATCH] IPv6 MIB:ipv6inetNetToMediaTable Shirley Ma
2004-01-15  8:48       ` David S. Miller
2004-01-15  9:04       ` YOSHIFUJI Hideaki / 吉藤英明
2004-01-15  0:22     ` [PATCH] IPv6 MIB:ipv6DefaultRouterTable Shirley Ma
2004-01-15  9:03       ` YOSHIFUJI Hideaki / 吉藤英明
  -- strict thread matches above, loose matches on Subject: below --
2003-12-05 21:55 [PATCH]snmp6 64-bit counter support in proc.c Shirley Ma
2004-01-21 19:45 Shirley Ma
2004-01-21 20:27 ` YOSHIFUJI Hideaki / 吉藤英明
2004-01-21 22:05 ` David S. Miller
2004-01-22 18:26 ` kuznet
2004-01-21 23:44 Shirley Ma
2004-01-22 21:18 Krishna Kumar
2004-01-22 22:10 ` David S. Miller
2004-01-22 22:50 Krishna Kumar
2004-01-23  0:35 ` David S. Miller
2004-01-23  1:08 Shirley Ma
2004-01-23  1:43 ` David S. Miller
2004-01-23  2:45 Krishna Kumar
2004-01-28 19:09 ` David S. Miller
2004-01-23  2:57 Krishna Kumar
2004-01-23 18:06 Shirley Ma
2004-01-28 19:19 Krishna Kumar
2004-01-28 19:33 ` David S. Miller
2004-01-28 20:09 Shirley Ma
2004-01-28 20:15 Shirley Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200312051214.48076.mashirle@us.ibm.com \
    --to=mashirle@us.ibm.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@oss.sgi.com \
    --cc=xma@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.